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.

118 lines
4.1 KiB

  1. //***************************************************************************
  2. //
  3. // Copyright � Microsoft Corporation. All rights reserved.
  4. //
  5. // FRQuery.h
  6. //
  7. // Purpose: query support classes
  8. //
  9. //***************************************************************************
  10. #if _MSC_VER > 1000
  11. #pragma once
  12. #endif
  13. #ifndef _FRAMEWORK_QUERY_H_
  14. #define _FRAMEWORK_QUERY_H_
  15. #include <stdio.h>
  16. #include <sql_1.h>
  17. #include <comdef.h>
  18. #include <vector>
  19. class POLARITY CFrameworkQuery
  20. {
  21. public:
  22. CFrameworkQuery();
  23. ~CFrameworkQuery();
  24. // Finds out if a particular field was requested by the query in either
  25. // the Select statement, or the Where statement. Only meaningful if we
  26. // are in ExecQueryAsync and the query has been sucessfully parsed.
  27. bool IsPropertyRequired(LPCWSTR propName);
  28. // Gets the class name from the query. Only meaningful if we are
  29. // in ExecQueryAsync and the query has been sucessfully parsed. It
  30. // is the responsibility of the caller to SysFreeString the returned
  31. // string.
  32. BSTR GetQueryClassName(void) { return SysAllocString(m_bstrtClassName); }
  33. // Given a property name, it will return all the values
  34. // that the query requests in a CHStringArray.
  35. // Select * from win32_directory where drive = "C:" GetValuesForProp(L"Drive") -> C:
  36. // Where Drive = "C:" or Drive = "D:" GetValuesForProp(L"Drive") -> C:, D:
  37. // Where Path = "\DOS" GetValuesForProp(L"Drive") -> (empty)
  38. // Where Drive <> "C:" GetValuesForProp(L"Drive") -> (empty)
  39. // Where Drive = "C:" or (Drive = "D:" and Mounted = true) GetValuesForProp(L"Drive") -> C:, D:
  40. HRESULT GetValuesForProp(LPCWSTR wszPropName, CHStringArray& achNames);
  41. // Here's an overloaded version in case client wants to pass in a vector of _bstr_t's
  42. HRESULT GetValuesForProp(LPCWSTR wszPropName, std::vector<_bstr_t>& vectorNames);
  43. // Returns a list of all the properties specified in the Select clause, plus.
  44. // all the the properties from the Where clauses. If the returned array is empty, all
  45. // properties are required.
  46. void GetRequiredProperties(CHStringArray &saProperties);
  47. // Boolean indicating if all properties are being requested.
  48. bool AllPropertiesAreRequired(void) { return (m_csaPropertiesRequired.GetSize() == 0); }
  49. // Boolean indicating if only the key properties are required.
  50. bool KeysOnly(void) { return m_bKeysOnly; }
  51. // Accessor function to retrieve wql query
  52. const CHString &GetQuery() ;
  53. // Moves the values into the member variables. Should never be called by users.
  54. HRESULT Init(
  55. const BSTR bstrQueryFormat,
  56. const BSTR bstrQuery,
  57. long lFlags,
  58. CHString &sNamespace
  59. );
  60. // Moves the values into the member variables. Should never be called by users.
  61. HRESULT Init(
  62. ParsedObjectPath *pParsedObjectPath,
  63. IWbemContext *pCtx,
  64. LPCWSTR lpwszClassName,
  65. CHString &sNamespace
  66. );
  67. // Initializes the KeysOnly data member. Should never be called by users.
  68. void Init2(IWbemClassObject *IClass);
  69. protected:
  70. /*****************************************************************************/
  71. /* The rest of these data members and functions are intended for Microsoft */
  72. /* internal use only. Use by third parties is unsupported and unrecommended. */
  73. /*****************************************************************************/
  74. SQL_LEVEL_1_RPN_EXPRESSION *m_pLevel1RPNExpression;
  75. CHStringArray m_csaPropertiesRequired;
  76. enum QueryTypes{eUnknown, eWQLCommand, eContextObject} m_QueryType;
  77. DWORD IsInList(const CHStringArray &csaArray, LPCWSTR pwszValue);
  78. BOOL IsReference(LPCWSTR lpwszPropertyName);
  79. const CHString &GetNamespace();
  80. private:
  81. CHString m_sNamespace;
  82. long m_lFlags;
  83. IWbemClassObject *m_IClass;
  84. CHString m_sQueryFormat;
  85. void Reset(void);
  86. bool m_bKeysOnly;
  87. bool m_AddKeys;
  88. CHString m_sQuery;
  89. bstr_t m_bstrtClassName;
  90. };
  91. #endif