Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
3.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1996 - 1997.
  5. //
  6. // File: cmdparse.hxx
  7. //
  8. // Contents: class for parsing the command line parameters
  9. //
  10. // Classes: CCmdLineParser CCmdLineParserA CCmdLineParserW
  11. // CCmdLineParserTemplate
  12. //
  13. // Functions:
  14. //
  15. // History: 11-08-94 SriniG Created
  16. // 11-22-96 Ericne Removed CString dependancy,
  17. // made template, improved efficiency
  18. //
  19. //----------------------------------------------------------------------------
  20. #ifndef __CMDPARSE_H__
  21. #define __CMDPARSE_H__
  22. //+---------------------------------------------------------------------------
  23. //
  24. // Class: CCmdLineParserTemplate ()
  25. //
  26. // Purpose: Template class for the command line parser class
  27. //
  28. // Interface: CCmdLineParserTemplate -- constructor
  29. // ~CCmdLineParserTemplate -- destructor
  30. // IsFlagExist -- returns true if the flag exists
  31. // EnumerateFlag -- returns TRUE if the flag exists
  32. // pParams is an array of parameters
  33. // cCount is the number of parameters
  34. // GetNextFlag -- returns FALSE if there are no more
  35. // flags. szFlag is the next flag that
  36. // has not been referenced yet
  37. // m_argc -- reference to the main argument argc
  38. // m_argv -- reference to the main argument argv
  39. // m_hyphen -- character constant for '-'
  40. // m_slash -- character constant for '/'
  41. //
  42. // History: 11-08-94 SriniG Created
  43. // 11-22-96 Ericne Removed CString dependancy,
  44. // made template, improved efficiency
  45. //
  46. // Notes:
  47. //
  48. //----------------------------------------------------------------------------
  49. template<class T>
  50. class CCmdLineParserTemplate
  51. {
  52. public:
  53. CCmdLineParserTemplate( int & argc, T **& argv );
  54. virtual ~CCmdLineParserTemplate();
  55. virtual BOOL IsFlagExist( const T * szFlag );
  56. virtual BOOL EnumerateFlag( const T * szFlag,
  57. /*out*/ T **& pParams,
  58. /*out*/ int & cCount );
  59. virtual BOOL GetNextFlag( /*out*/ T *& szFlag );
  60. protected:
  61. int & m_argc;
  62. T **& m_argv;
  63. static const T m_hyphen;
  64. static const T m_slash;
  65. };
  66. typedef CCmdLineParserTemplate<char> CCmdLineParserA;
  67. typedef CCmdLineParserTemplate<wchar_t> CCmdLineParserW;
  68. #if defined( UNICODE ) || defined( _UNICODE )
  69. typedef CCmdLineParserW CCmdLineParser;
  70. #else
  71. typedef CCmdLineParserA CCmdLineParser;
  72. #endif
  73. #endif // _CMDPARSE_H