Source code of Windows XP (NT5)
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.

543 lines
14 KiB

  1. /****************************************************************************
  2. Copyright information : Copyright (c) 1998-1999 Microsoft Corporation
  3. File Name : CommandSwitches.h
  4. Project Name : WMI Command Line
  5. Author Name : Ch.Sriramachandramurthy
  6. Date of Creation (dd/mm/yy) : 27th-September-2000
  7. Version Number : 1.0
  8. Brief Description : This file consist of class declaration of
  9. class CommandSwitches
  10. Revision History :
  11. Last Modified By : Ch. Sriramachandramurthy
  12. Last Modified Date : 20th-March-2001
  13. ****************************************************************************/
  14. // CommandSwitches.h : header file
  15. //
  16. /*-------------------------------------------------------------------
  17. Class Name : CCommandSwitches
  18. Class Type : Concrete
  19. Brief Description : This class encapsulates the functionality needed
  20. for accessing and storing the command switches
  21. information, which will be used by Parsing,
  22. Execution and Format Engines depending upon the
  23. applicability.
  24. Super Classes : None
  25. Sub Classes : None
  26. Classes Used : None
  27. Interfaces Used : None
  28. --------------------------------------------------------------------*/
  29. #pragma once
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CCommandSwitches
  32. class CCommandSwitches
  33. {
  34. public:
  35. // Construction
  36. CCommandSwitches();
  37. // Destruction
  38. ~CCommandSwitches();
  39. // Restrict Assignment
  40. CCommandSwitches& operator=(CCommandSwitches& rCmdSwitches);
  41. // Attributes
  42. private:
  43. //command string
  44. _TCHAR *m_pszCommandInput;
  45. //alias name
  46. _TCHAR *m_pszAliasName;
  47. //alias description
  48. _TCHAR *m_pszAliasDesc;
  49. //class path
  50. _TCHAR *m_pszClassPath;
  51. //path expression
  52. _TCHAR *m_pszPathExpr;
  53. //where expression
  54. _TCHAR *m_pszWhereExpr;
  55. //verb name - standard|userdefined verb
  56. _TCHAR *m_pszVerb;
  57. //method name
  58. _TCHAR *m_pszMethodName;
  59. //XSLT details vector.
  60. XSLTDETVECTOR m_xdvXSLTDetVec;
  61. //alias target class
  62. _TCHAR *m_pszAliasTarget;
  63. //XML stream
  64. BSTR m_bstrXML;
  65. //session success - flag.
  66. BOOL m_bSuccess;
  67. //HRESULT
  68. HRESULT m_hResult;
  69. //friendly names|trasnlate tables - map
  70. BSTRMAP m_bmAlsFrnNmsDesOrTrnsTblEntrs;
  71. //property(s) details - map
  72. PROPDETMAP m_pdmPropDet;
  73. //method(s) details - map
  74. METHDETMAP m_mdmMethDet;
  75. //input property(s) - vector
  76. CHARVECTOR m_cvProperties;
  77. //PWhere param(s) - vector
  78. CHARVECTOR m_cvPWhereParams;
  79. //Translate table entry(s) - vector
  80. CHARVECTOR m_cvTrnsTablesList;
  81. //input method param(s) - map
  82. BSTRMAP m_bmParameters;
  83. //verb interactive mode
  84. WMICLIINT m_nInteractiveMode;
  85. ///EVERY interval value
  86. ULONG m_ulInterval;
  87. ///tablename - TRANSLATE:<tablename>
  88. _TCHAR *m_pszTransTableName;
  89. //listformat - LISTFORMAT type
  90. _TCHAR *m_pszListFormat;
  91. // Errata code
  92. UINT m_uErrataCode;
  93. // Message code
  94. UINT m_uInformationCode;
  95. // Credentials flag
  96. BOOL m_bCredFlag;
  97. // parameterized string with '#' as place holder(s) for input value(s)
  98. _TCHAR *m_pszPWhereExpr;
  99. // COM error object
  100. _com_error *m_pComError;
  101. // IWbemClassObject, to store output parameters of method execution.
  102. IWbemClassObject *m_pIMethOutParam;
  103. // alias connection information
  104. // alias user name
  105. _TCHAR *m_pszUser;
  106. // alias user password
  107. _TCHAR *m_pszPassword;
  108. // alias node
  109. _TCHAR *m_pszNode;
  110. // alias locale
  111. _TCHAR *m_pszLocale;
  112. // alias namespace
  113. _TCHAR *m_pszNamespace;
  114. // Type of the verb ( CLASSMETHOD/STDVERB/CMDLINE ).
  115. VERBTYPE m_vtVerbType;
  116. // Verb derivation string
  117. _TCHAR *m_pszVerbDerivation;
  118. // flag to check that WHERE is specified explicitly
  119. BOOL m_bExplicitWhereExpr;
  120. ALSFMTDETMAP m_afdAlsFmtDet;
  121. BOOL m_bTranslateFirst;
  122. // /RESULTCLASS switch value of ASSOC verb
  123. _TCHAR *m_pszResultClassName;
  124. // /RESULTROLE switch value of ASSOC verb
  125. _TCHAR *m_pszResultRoleName;
  126. // /ASSOCCLASS switch value of ASSOC verb
  127. _TCHAR *m_pszAssocClassName;
  128. // count for /REPEAT:N
  129. ULONG m_ulRepeatCount;
  130. // Flag for availibility of methods.
  131. BOOL m_bMethAvail;
  132. // Flag for availibility of writable properties.
  133. BOOL m_bWritePropsAvail;
  134. // Flag for availibility list formats.
  135. BOOL m_bLISTFrmsAvail;
  136. //input property(s) - vector
  137. CHARVECTOR m_cvInteractiveProperties;
  138. // Flag to specify Named Parameter List.
  139. BOOL m_bNamedParamList;
  140. // Flag to check if every switch is specified.
  141. BOOL m_bEverySwitch ;
  142. // Flag to check if output switch is specified.
  143. BOOL m_bOutputSwitch ;
  144. //the query formed of the given command .
  145. BSTR m_bstrFormedQuery;
  146. BOOL m_bSysProp;
  147. // Operations
  148. public:
  149. //Assigns the parameter passed to m_pszCommandInput
  150. BOOL SetCommandInput(const _TCHAR* pszCommandInput);
  151. //Assigns the parameter passed to m_pszAliasName that represents
  152. //Alias object.
  153. BOOL SetAliasName(const _TCHAR* pszAliasName);
  154. // Sets the alias description
  155. BOOL SetAliasDesc(const _TCHAR* pszAliasDesc);
  156. // Sets the alias credentials information
  157. BOOL SetAliasUser(const _TCHAR* pszUserName);
  158. BOOL SetAliasNode(const _TCHAR* pszNode);
  159. BOOL SetAliasPassword(const _TCHAR* pszPassword);
  160. BOOL SetAliasLocale(const _TCHAR* pszLocale);
  161. BOOL SetAliasNamespace(const _TCHAR* pszNamespace);
  162. //Assigns the parameter passed to m_pszClassPath.
  163. BOOL SetClassPath(const _TCHAR* pszClassPath);
  164. //Assigns the parameter passed to m_pszPathExpr.
  165. BOOL SetPathExpression(const _TCHAR* pszPathExpr);
  166. //Assigns the parameter passed to m_pszWhereExpr
  167. BOOL SetWhereExpression(const _TCHAR* pszWhereExpr);
  168. //Assigns the parameter passed to m_pszMathodName.
  169. BOOL SetMethodName(const _TCHAR* pszMethodName);
  170. //Adds to vector held by m_xdvXSLDetVec.
  171. void AddToXSLTDetailsVector(XSLTDET xdXSLTDet);
  172. //Assigns the parameter passed to m_pszVerbName.
  173. BOOL SetVerbName(const _TCHAR* pszVerbName);
  174. //Assigns the parameter passed to m_pszSesionFilePath
  175. BOOL SetSessionFilePath(const _TCHAR* pszSessionFilePath);
  176. //Assigns the parameter passed to m_bstrXML, is used to store XML file
  177. //Name that contains result set.
  178. BOOL SetXMLResultSet(const BSTR bstrXMLResultSet);
  179. //Assigns the parameter passed to m_pszAliasTarget, is used in Parsing
  180. //Engine to avail the alias object informations.
  181. BOOL SetAliasTarget(const _TCHAR* pszAliasTarget);
  182. //Adds string that passed through parameter to m_bmParameters, which is
  183. //a data member of type BSTRMAP
  184. BOOL AddToPropertyList(_TCHAR* const pszProperty);
  185. BOOL AddToTrnsTablesList(_TCHAR* const pszTableName);
  186. //Adds bstrKey and bstrValue passed as parameters to m_bmParameters,which
  187. //is type of BSTRMAP data structure
  188. BOOL AddToParameterMap(_bstr_t bstrKey, _bstr_t bstrValue);
  189. //Adds bstrKey and bstrValue passed as parameters to m_bmParameters,which
  190. //is type of ALSFMTDETMAP data structure
  191. BOOL AddToAliasFormatDetMap(_bstr_t bstrKey, BSTRVECTOR bvProps);
  192. //Adds bstrKey and bstrValue passed as parameters to
  193. //m_bmAlsFrnNmsDesOrTrnsTblEntrs,
  194. //which is type of BSTRMAP
  195. BOOL AddToAlsFrnNmsOrTrnsTblMap(_bstr_t bstrKey, _bstr_t bstrValue);
  196. //Adds bstrKey and mdMethDet passed as parameters to m_mdmMethDet,
  197. //which is type of METHDETMAP.
  198. BOOL AddToMethDetMap(_bstr_t bstrKey, METHODDETAILS mdMethDet);
  199. //Adds bstrKey and pdPropDet passed as parameters to m_pdmPropDet,
  200. //which is type of PROPERTYDETALS
  201. BOOL AddToPropDetMap(_bstr_t bstrKey, PROPERTYDETAILS pdPropDet);
  202. //Assigns the Boolean variable to m_bSuccess
  203. void SetSuccessFlag(BOOL bSuccess);
  204. //Assigns the string variable to m_pszTransTableName.
  205. BOOL SetTranslateTableName(const _TCHAR* pszTransTableName);
  206. //Assigns the integer value to m_nInterval
  207. BOOL SetRetrievalInterval(const ULONG lInterval);
  208. //Assigns the parameter value to m_ListFormat
  209. BOOL SetListFormat(const _TCHAR *pszListFormat);
  210. //Set|Reset the verb interactive mode
  211. void SetInteractiveMode(WMICLIINT nInteractiveMode);
  212. //Stores the parameter in map array
  213. BOOL AddToPWhereParamsList(_TCHAR* const pszParameter);
  214. //Assigns the value to m_uErrataCode
  215. void SetErrataCode(const UINT uErrataCode);
  216. //Assigns the value to m_uInformationCode
  217. void SetInformationCode(const UINT uInformationCode);
  218. // Assigns the string to m_pszPWhereExpr
  219. BOOL SetPWhereExpr(const _TCHAR* pszPWhereExpr);
  220. // Assigns the parameter passed to m_pComError that consist of
  221. // error info
  222. void SetCOMError(_com_error& rComError);
  223. // Set m_pIMethExecOutParam.
  224. BOOL SetMethExecOutParam(IWbemClassObject* pIMethOutParam);
  225. // Set m_vtVerbType to passed flag.
  226. void SetVerbType( VERBTYPE vtVerbType);
  227. // Set m_pszVerbDerivation.
  228. BOOL SetVerbDerivation( const _TCHAR* pszVerbDerivation );
  229. //Set the credential flag status
  230. void SetCredentialsFlag(BOOL bCredFlag);
  231. // Set the explicit where flag
  232. void SetExplicitWhereExprFlag(BOOL bWhere);
  233. //Assigns the string variable to m_pszResultClassName.
  234. BOOL SetResultClassName(const _TCHAR* pszResultClassName);
  235. //Assigns the string variable to m_pszResultRoleName.
  236. BOOL SetResultRoleName(const _TCHAR* pszResultRoleName);
  237. //Assigns the string variable to m_pszAssocClassName.
  238. BOOL SetAssocClassName(const _TCHAR* pszAssocClassName);
  239. // Set repeat count.
  240. BOOL SetRepeatCount(const ULONG lRepCount);
  241. // Set methods available.
  242. void SetMethodsAvailable(BOOL bFlag);
  243. // Retruns the alias description
  244. _TCHAR* GetAliasDesc();
  245. //Returns the alias name held by the object
  246. _TCHAR* GetAliasName();
  247. //Returns the class path held by the object
  248. _TCHAR* GetClassPath();
  249. // Return the alias credentials information.
  250. _TCHAR* GetAliasUser();
  251. _TCHAR* GetAliasNode();
  252. _TCHAR* GetAliasPassword();
  253. _TCHAR* GetAliasLocale();
  254. _TCHAR* GetAliasNamespace();
  255. //Returns the path expression held by the object
  256. _TCHAR* GetPathExpression();
  257. //Returns the where expression held by the object
  258. _TCHAR* GetWhereExpression();
  259. //Returns the method name held by the object
  260. _TCHAR* GetMethodName();
  261. //Returns the XSLTDetVec held by the object.
  262. XSLTDETVECTOR& GetXSLTDetailsVector();
  263. //Returns the verb name held by the object
  264. _TCHAR* GetVerbName();
  265. //Returns the session file path held by the object
  266. _TCHAR* GetSessionFilePath();
  267. //Returns the alias target held by the object
  268. _TCHAR* GetAliasTarget();
  269. //Returns the command input held by the object
  270. _TCHAR* GetCommandInput();
  271. //Returns the XML result set held by the object.
  272. BSTR GetXMLResultSet();
  273. //Returns the property held by the object.
  274. CHARVECTOR& GetPropertyList();
  275. //Returns the tables held by the object.
  276. CHARVECTOR& GetTrnsTablesList();
  277. //Returns the parameter map containing both key and value
  278. BSTRMAP& GetParameterMap();
  279. //Returns the alias formats map
  280. ALSFMTDETMAP& GetAliasFormatDetMap();
  281. //Returns the alias friendly names map held by the object
  282. BSTRMAP& GetAlsFrnNmsOrTrnsTblMap();
  283. //Returns the method details map held by the object
  284. METHDETMAP& GetMethDetMap();
  285. //Returns the alias property details map held by the object
  286. PROPDETMAP& GetPropDetMap();
  287. //Returns the success flag held by the object
  288. BOOL GetSuccessFlag();
  289. //Returns the value of m_ulInterval.
  290. ULONG GetRetrievalInterval();
  291. //Returns the value of m_pszTransTableName.
  292. _TCHAR* GetTranslateTableName();
  293. //Returns the list format type m_ListFormat
  294. _TCHAR* GetListFormat();
  295. //Returns the name of XSL file used for specifying format for dumping.
  296. _TCHAR* GetDumpXSLFormat();
  297. //returns the verb interactive mode
  298. WMICLIINT GetInteractiveMode();
  299. //Returns the PWhereParameters list
  300. CHARVECTOR& GetPWhereParamsList();
  301. //This function gets the class of Alias
  302. void GetClassOfAliasTarget(_bstr_t& bstrClassName);
  303. //returns the error code
  304. UINT GetErrataCode();
  305. //returns the information code
  306. UINT GetInformationCode();
  307. // returns the PWhere expression - m_pszPWhereExpr
  308. _TCHAR* GetPWhereExpr();
  309. // Get m_pIMethExecOutParam.
  310. IWbemClassObject* GetMethExecOutParam();
  311. // Get m_vtVerbType.
  312. VERBTYPE GetVerbType();
  313. // Get m_pszVerbDerivation.
  314. _TCHAR* GetVerbDerivation();
  315. // Returns the credential flag status
  316. BOOL GetCredentialsFlagStatus();
  317. // Returns the explicit where flag status
  318. BOOL GetExplicitWhereExprFlag();
  319. // Get m_uRepeatCount count.
  320. ULONG GetRepeatCount();
  321. // This function returns the COMError object
  322. _com_error* CCommandSwitches::GetCOMError();
  323. // Update the parameter value
  324. BOOL UpdateParameterValue(_bstr_t bstrKey, _bstr_t bstrValue);
  325. // Free the COM error
  326. void FreeCOMError();
  327. // Clear cvPropertyList.
  328. void ClearPropertyList();
  329. // Initiliaze the necessary member variables
  330. void Initialize();
  331. // Free the member variables
  332. void Uninitialize();
  333. // This function sets the the order of the format and
  334. // translate switch flag
  335. void SetTranslateFirstFlag(BOOL bTranslateFirst);
  336. // This function returns the order of the format and
  337. // translate switch flag
  338. BOOL GetTranslateFirstFlag();
  339. //Returns the value of m_pszResultClassName.
  340. _TCHAR* GetResultClassName();
  341. //Returns the value of m_pszResultRoleName.
  342. _TCHAR* GetResultRoleName();
  343. //Returns the value of m_pszAssocClassName.
  344. _TCHAR* GetAssocClassName();
  345. // Get methods available.
  346. BOOL GetMethodsAvailable();
  347. // Set writable properties available flag.
  348. void SetWriteablePropsAvailable(BOOL bFlag);
  349. // Get writable properties available flag.
  350. BOOL GetWriteablePropsAvailable();
  351. // Set LIST Formats available flag.
  352. void SetLISTFormatsAvailable(BOOL bFlag);
  353. // Get LIST Formats Available flag.
  354. BOOL GetLISTFormatsAvailable();
  355. BOOL AddToInteractivePropertyList(_TCHAR* const pszProperty);
  356. CHARVECTOR& GetInteractivePropertyList();
  357. // Set m_bNamedParamList flag.
  358. void SetNamedParamListFlag(BOOL bFlag);
  359. // Get m_bNamedParamList flag.
  360. BOOL GetNamedParamListFlag();
  361. // Clear or nullify XSL Details vector.
  362. void ClearXSLTDetailsVector();
  363. //every
  364. // Set m_bEverySwitch flag.
  365. void SetEverySwitchFlag(BOOL bFlag);
  366. // Get m_bEverySwitch flag.
  367. BOOL GetEverySwitchFlag();
  368. // Set m_bOutputSwitch flag.
  369. void SetOutputSwitchFlag(BOOL bFlag);
  370. // Get m_bOutputSwitch flag.
  371. BOOL GetOutputSwitchFlag();
  372. //Sets the m_bstrFormedQuery
  373. BOOL SetFormedQuery(const BSTR bstrFormedQuery);
  374. //Returns the query formed for the given command.
  375. BSTR GetFormedQuery();
  376. // Get the status of sytem properties flag
  377. BOOL GetSysPropFlag();
  378. // Sets the status of system properties flag
  379. void SetSysPropFlag(BOOL bSysProp);
  380. };