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.

131 lines
3.3 KiB

  1. //+------------------------------------------------------------------
  2. //
  3. // File: cmdarg.cxx
  4. //
  5. // Contents: implementation of CCmdlineArg class
  6. //
  7. // Synoposis: CCmdlineArg encapsulates an argv string.
  8. //
  9. // Classes: CCmdlineArg
  10. //
  11. // Functions:
  12. //
  13. // History: 12/30/91 Lizch Created
  14. // 04/17/92 Lizch Converted to NLS_STR
  15. // 09/18/92 Lizch Precompile headers
  16. //
  17. //-------------------------------------------------------------------
  18. #include <comtpch.hxx>
  19. #pragma hdrstop
  20. #include <cmdlinew.hxx> // public cmdlinew stuff
  21. #include "_clw.hxx" // private cmdlinew stuff
  22. #include <ctype.h> // is functions
  23. //+------------------------------------------------------------------
  24. //
  25. // Function: Constructor for CCmdlineArg
  26. //
  27. // Synoposis: Makes a copy of one argv string.
  28. //
  29. // Arguments: [nszArg] - an argv element
  30. //
  31. // Returns: nothing
  32. //
  33. // History: Created 12/30/91 Lizch
  34. // Converted to NLS_STR 04/17/92 Lizch
  35. //
  36. //-------------------------------------------------------------------
  37. CCmdlineArg::CCmdlineArg(LPCNSTR nszArg)
  38. {
  39. _fProcessed = FALSE;
  40. _pnszArgument = new NCHAR[_ncslen(nszArg)+1];
  41. if (NULL != _pnszArgument)
  42. {
  43. _ncscpy(_pnszArgument, nszArg);
  44. }
  45. else
  46. {
  47. SetError(CMDLINE_ERROR_OUT_OF_MEMORY);
  48. }
  49. }
  50. //+------------------------------------------------------------------
  51. //
  52. // Function: Destructor for CCmdlineArg
  53. //
  54. // Synoposis: Frees resources allocated in constructor.
  55. //
  56. // Arguments: None
  57. //
  58. // Returns: nothing
  59. //
  60. // History: Created 10/25/93 DeanE
  61. //
  62. //-------------------------------------------------------------------
  63. CCmdlineArg::~CCmdlineArg()
  64. {
  65. delete _pnszArgument;
  66. }
  67. //+------------------------------------------------------------------
  68. //
  69. // Function: IsProcessed
  70. //
  71. // Synoposis: Indicates whether this argument has been processed on
  72. // the command line. If FALSE, it probably indicates that
  73. // an unexpected switch was supplied.
  74. //
  75. // Arguments: none
  76. //
  77. // Returns: TRUE if processed, FALSE otherwise
  78. //
  79. // History: Created 05/30/92 Lizch
  80. //
  81. //-------------------------------------------------------------------
  82. const BOOL CCmdlineArg::IsProcessed()
  83. {
  84. return(_fProcessed);
  85. }
  86. //+------------------------------------------------------------------
  87. //
  88. // Function: SetProcessedFlag
  89. //
  90. // Synoposis: Sets whether this argument has been found on the command
  91. // line.
  92. //
  93. // Arguments: fProcessed - TRUE if found, FALSE otherwise
  94. //
  95. // Returns: nothing
  96. //
  97. // History: Created 05/30/92 Lizch
  98. //
  99. //-------------------------------------------------------------------
  100. void CCmdlineArg::SetProcessedFlag(BOOL fProcessed)
  101. {
  102. _fProcessed = fProcessed;
  103. }
  104. //+------------------------------------------------------------------
  105. //
  106. // Function: QueryArg
  107. //
  108. // Synoposis: Returns a pointer to this argument
  109. //
  110. // Arguments: none
  111. //
  112. // Returns: a NCHAR pointer to the argument
  113. //
  114. // History: Created 05/30/92 Lizch
  115. //
  116. //-------------------------------------------------------------------
  117. LPCNSTR CCmdlineArg::QueryArg()
  118. {
  119. return(_pnszArgument);
  120. }