home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / cmdproc.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  1.4 KB  |  48 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. // cmdproc.h
  3. // Copyright (C) 1996 - 1999 Microsoft Corp.
  4. //
  5. //  more flexible replacement for mfc CCommandLineInfo
  6.  
  7. /////////////////////////////////////////////////////////////////////////////
  8. // CCommandLineInfo
  9.  
  10. #ifndef CMDPROC_H
  11. #pragma option push -b -a8 -pc -A- /*P_O_Push*/
  12. #define CMDPROC_H
  13.  
  14.  
  15. class CCommandLineProc : public CObject 
  16. {
  17. public:
  18.     // process the command line for switch based arguments
  19.     BOOLEAN ProcessCommandLine(int iSC, int &argc, _TCHAR **argv);
  20. protected:
  21.     typedef void (CCommandLineProc::*PMFNCmdProc)(CString &csArg);
  22.     class CArgProcTable {
  23.     public:
  24.         int m_iIDS;  // string resource of command switch
  25.         PMFNCmdProc m_Cmd;    // argument processing function
  26.     };
  27.     friend CArgProcTable;
  28.     static CArgProcTable acapArgs[];
  29.     // remove any desired positional arguments
  30.     virtual BOOLEAN GetPositionalArgs(int &argc, _TCHAR **argv);
  31.     
  32.     // this function deletes the argument at iPos by copy the remaining
  33.     // elements of argv 1 to the left
  34.     inline void CCommandLineProc::DeleteArg(int iPos, int &argc, _TCHAR **argv)
  35.     {
  36.         for (int k = iPos + 1; k < argc; k++) {
  37.             argv[k - 1] = argv[k];
  38.         }
  39.         argc--;
  40.     }
  41.  
  42. };
  43.  
  44.  
  45. #pragma option pop /*P_O_Pop*/
  46. #endif
  47. // end of file - cmdproc.h
  48.