home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / cmdproc.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  1KB  |  46 lines

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