home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / CL / CL.H < prev    next >
C/C++ Source or Header  |  1991-12-12  |  3KB  |  111 lines

  1. #ifndef _CL_H
  2. #define _CL_H
  3.  
  4. #include <dir.h>
  5. #include <stdio.h>
  6. #include <conio.h>
  7. #include <dos.h>
  8. #include <string.h>
  9. #include <array.h>
  10.  
  11. _CLASSDEF(oclass)
  12. _CLASSDEF(nclass)
  13.  
  14. #define oClass    __firstUserClass
  15. #define nClass (oClass+1)
  16. #define CL_ENDOFLIST -1
  17.  
  18. class _CLASSTYPE nclass : public Object
  19. {
  20. private :
  21.     char *name;
  22. public :
  23.     nclass () { name = NULL; }
  24.     nclass (char *Aname) { name = strdup (Aname); }
  25.     ~nclass () { if (name) delete [strlen (name) + 1] name; name = NULL; }
  26.     char *getName () { return name; }
  27.     virtual hashValueType   hashValue() const { return hashValueType(0); }
  28.     virtual int             isEqual( RCObject ) const { return 1; }
  29.     virtual void printOn( Rostream os) const
  30.     {
  31.         os << "Name " << name << endl;
  32.     }
  33.     char *nameOf () const { return "nClass"; }
  34.     classType isA() const { return nClass; }
  35. };
  36.  
  37. class _CLASSTYPE oclass : public Object
  38. {
  39. private :
  40.     char SwitchChar;
  41.     char *OptionArg;
  42. public :
  43.     oclass (char a) { SwitchChar = a; OptionArg = NULL; }
  44.     oclass () { SwitchChar = 0; OptionArg = NULL; }
  45.     ~oclass () { if (OptionArg) delete [strlen (OptionArg) + 1] OptionArg; OptionArg = NULL; }
  46.     void setOptionArg (char *a) { OptionArg = strdup (a); }
  47.     int getOption (char *&optarg ) { optarg = OptionArg; return SwitchChar; }
  48.     virtual hashValueType   hashValue() const { return hashValueType(0); }
  49.     virtual int             isEqual( RCObject ) const { return 1; }
  50.     virtual void printOn( Rostream os) const
  51.     {
  52.         os << "Option " << SwitchChar << ":" << OptionArg << endl;
  53.     }
  54.     char *nameOf () const { return "oClass"; }
  55.     classType isA() const { return oClass; }
  56. };
  57.  
  58. class _CLASSTYPE CmdLn
  59. {
  60. private :
  61.     Array *Options;
  62.     Array *Names;
  63.     Array *Errors;
  64.     oclass *coption;
  65.     char *options,*opt;
  66.     int nameindex,optionindex,errorindex;
  67.  
  68.     void pCluster ();
  69.     void pOption (char *lookup);
  70.     void expand ();
  71.     void pName ();
  72.     void clear (Array *);
  73.     char gOpt (Array *p,int no,char *&optarg);
  74. public:
  75.     CmdLn (char *);
  76.     ~CmdLn ();
  77.     void printContentsOn (Rostream);
  78.     int  numOptions () { return Options->getItemsInContainer (); }
  79.     char getOption (int,char *&);
  80.     char getFirstOption (char *&optarg) { return getOption (optionindex = 0,optarg); }
  81.     char getLastOption  (char *&optarg)
  82.         { return getOption (optionindex = Options->getItemsInContainer () - 1,optarg); }
  83.     char getNextOption  (char *&optarg) { return getOption (++optionindex,optarg); }
  84.     char getPrevOption  (char *&optarg) { return getOption (--optionindex,optarg); }
  85.  
  86.     int  numErrors () { return Errors->getItemsInContainer (); }
  87.     char getError (int no);
  88.     char getFirstError () { return getError (errorindex = 0); }
  89.     char getLastError  ()
  90.         { return getError (errorindex = Errors->getItemsInContainer () - 1); }
  91.     char getNextError  () { return getError (++errorindex); }
  92.     char getPrevError  () { return getError (--errorindex); }
  93.  
  94.     int  numNames () { return Names->getItemsInContainer (); }
  95.     char *getName (int);
  96.     char *getFirstName () { return getName (nameindex = 0); }
  97.     char *getLastName  ()
  98.         { return getName (nameindex = Names->getItemsInContainer () - 1); }
  99.     char *getNextName  () { return getName (++nameindex); }
  100.     char *getPrevName  () { return getName (--nameindex); }
  101.     void add (char *);
  102.     void clearNames ();
  103.     void clearOptions ();
  104.     void clearErrors ();
  105.     void clearAll ();
  106.     void reset ();
  107.     char *version () { return "1.1";}
  108. };
  109.  
  110. #endif
  111.