home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / CLASSINC.PAK / CMDLINE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  1.6 KB  |  57 lines

  1. //----------------------------------------------------------------------------
  2. // Borland Class Library
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   5.4  $
  6. //
  7. // Command line parsing class
  8. //----------------------------------------------------------------------------
  9. #if !defined(CLASSLIB_CMDLINE_H)
  10. #define CLASSLIB_CMDLINE_H
  11.  
  12. #if !defined(CLASSLIB_DEFS_H)
  13. # include <classlib/defs.h>
  14. #endif
  15.  
  16. #if defined(BI_NAMESPACE)
  17. namespace ClassLib {
  18. #endif
  19.  
  20. //
  21. // class TCmdLine
  22. // ~~~~~ ~~~~~~~~
  23. // Command line argument processing class, processes in the form:
  24. //
  25. //  <Name> | {-/}<Option>[{:=}<Value>] ...
  26. //
  27. class _BIDSCLASS TCmdLine {
  28.   public:
  29.     enum TKind {
  30.       Start,   // No tokens have been parsed yet
  31.       Name,    // Name type token, has no leading / or -
  32.       Option,  // Option type token. Leading / or - skipped by Token
  33.       Value,   // Value for name or option. Leading : or = skipped by Token
  34.       Done     // No more tokens
  35.     };
  36.     TCmdLine(const _TCHAR far* cmdLine);
  37.    ~TCmdLine();
  38.  
  39.     TKind NextToken(bool removeCurrent=false);
  40.     const _TCHAR* GetLine() const {return Buffer;}
  41.     void Reset();
  42.  
  43.     TKind Kind;       // Kind of current token
  44.     _TCHAR* Token;      // Ptr to current token. (Not 0-terminated, use TokenLen)
  45.     int   TokenLen;   // Length of current token
  46.  
  47.   private:
  48.     _TCHAR* Buffer;     // Command line buffer
  49.     _TCHAR* TokenStart; // Actual start of current token
  50. };
  51.  
  52. #if defined(BI_NAMESPACE)
  53. }   // namespace ClassLib
  54. #endif
  55.  
  56. #endif  // CLASSLIB_CMDLINE_H
  57.