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.

208 lines
4.6 KiB

  1. //***************************************************************************
  2. //
  3. // VPQUALS.H
  4. //
  5. // Module: WBEM VIEW PROVIDER
  6. //
  7. // Copyright (c) 1998-2001 Microsoft Corporation, All Rights Reserved
  8. //
  9. //***************************************************************************
  10. #ifndef _VIEW_PROV_VPQUALS_H
  11. #define _VIEW_PROV_VPQUALS_H
  12. //forward definition
  13. class CWbemServerWrap;
  14. CStringW GetStringFromRPN(SQL_LEVEL_1_RPN_EXPRESSION* pRPN, DWORD num_extra,
  15. SQL_LEVEL_1_TOKEN* pExtraTokens, BOOL bAllprops = FALSE);
  16. template <> inline BOOL AFXAPI CompareElements<CStringW, LPCWSTR>(const CStringW* pElement1, const LPCWSTR* pElement2)
  17. {
  18. //return TRUE if equal
  19. return (pElement1->CompareNoCase(*pElement2) == 0);
  20. }
  21. template <> inline UINT AFXAPI HashKey <LPCWSTR> (LPCWSTR key)
  22. {
  23. CStringW tmp(key);
  24. tmp.MakeUpper();
  25. return HashKeyLPCWSTR((const WCHAR*)tmp);
  26. }
  27. class CSourceQualifierItem : public CObject
  28. {
  29. private:
  30. CStringW m_QueryStr;
  31. SQL_LEVEL_1_RPN_EXPRESSION* m_RPNExpr;
  32. IWbemClassObject* m_pClassObj;
  33. BOOL m_isValid;
  34. public:
  35. //Constructor
  36. CSourceQualifierItem(wchar_t* qry, IWbemClassObject* obj = NULL);
  37. //set methods may be called after instance creation
  38. void SetClassObject(IWbemClassObject* pObj);
  39. //retrieval of stored members
  40. BOOL IsValid() { return m_isValid; }
  41. SQL_LEVEL_1_RPN_EXPRESSION* GetRPNExpression() { return m_RPNExpr; }
  42. IWbemClassObject* GetClassObject();
  43. CStringW GetQueryStr() { return m_QueryStr; }
  44. BSTR GetClassName();
  45. //Destructor
  46. ~CSourceQualifierItem();
  47. };
  48. class CNSpaceQualifierItem : public CObject
  49. {
  50. private:
  51. CWbemServerWrap** m_ServObjs;
  52. CStringW* m_NSPaths;
  53. UINT m_Count;
  54. BOOL m_Valid;
  55. HRESULT m_hrServError;
  56. void Parse(const wchar_t* ns_path);
  57. public:
  58. //Constructor
  59. CNSpaceQualifierItem(const wchar_t* ns_path);
  60. //set members
  61. void SetServerPtrs(CWbemServerWrap** pServs) { m_ServObjs = pServs; }
  62. //retrieval of members
  63. CWbemServerWrap** GetServerPtrs() { return m_ServObjs; }
  64. UINT GetCount() { return m_Count; }
  65. CStringW* GetNamespacePaths() { return m_NSPaths; }
  66. BOOL IsValid() { return m_Valid; }
  67. void SetServerCreationError ( HRESULT hr )
  68. {
  69. m_hrServError = hr;
  70. }
  71. HRESULT GetServerCreationError ()
  72. {
  73. HRESULT hr = WBEM_E_FAILED;
  74. if ( FAILED ( m_hrServError ) )
  75. {
  76. hr = m_hrServError;
  77. }
  78. return hr;
  79. }
  80. //Destructor
  81. ~CNSpaceQualifierItem();
  82. };
  83. class CPropertyQualifierItem
  84. {
  85. private:
  86. CStringW m_ViewPropertyName;
  87. BOOL m_HiddenDefault;
  88. BOOL m_bKey;
  89. CIMTYPE m_CimType;
  90. CStringW m_RefTo;
  91. BOOL m_bDirect;
  92. public:
  93. //public members
  94. CArray<CStringW, LPCWSTR> m_SrcPropertyNames;
  95. //Constructor
  96. CPropertyQualifierItem(const wchar_t* prop, BOOL bHD, BOOL bKy, CIMTYPE ct, CStringW rfto, BOOL bDt);
  97. //retrieval methods
  98. CStringW GetViewPropertyName() { return m_ViewPropertyName; }
  99. BOOL IsHiddenDefault() { return m_HiddenDefault; }
  100. BOOL IsKey() { return m_bKey; }
  101. BOOL IsDirect() { return m_bDirect; }
  102. CIMTYPE GetCimType() { return m_CimType; }
  103. CStringW GetReferenceClass() { return m_RefTo; }
  104. //Destructor
  105. ~CPropertyQualifierItem();
  106. };
  107. class CJoinOnQualifierArray
  108. {
  109. private:
  110. UINT m_Count;
  111. wchar_t* m_Buff;
  112. wchar_t** m_AClasses;
  113. wchar_t** m_AProps;
  114. wchar_t** m_BClasses;
  115. wchar_t** m_BProps;
  116. UINT* m_Ops;
  117. BOOL m_Valid;
  118. void Parse(const wchar_t* qualStr);
  119. wchar_t* SkipSpace(wchar_t*& src);
  120. wchar_t* SkipToSpecial(wchar_t*& src);
  121. wchar_t* GetClassStr(wchar_t*& src);
  122. wchar_t* GetPropertyStrAndOperator(wchar_t*& src, UINT& op);
  123. wchar_t* GetPropertyStr(wchar_t*& src);
  124. BOOL StripAnd(wchar_t*& src);
  125. public:
  126. //possible operators
  127. enum{NO_OPERATOR = 0, EQUALS_OPERATOR = 1, NOT_EQUALS_OPERATOR = 2};
  128. CMap<CStringW, LPCWSTR, int, int> m_AllClasses;
  129. BOOL* m_bDone;
  130. //Constructor
  131. CJoinOnQualifierArray();
  132. BOOL Set(const wchar_t* jStr);
  133. UINT GetCount() { return m_Count; }
  134. wchar_t** GetAClasses() { return m_AClasses; }
  135. wchar_t** GetAProperties() { return m_AProps; }
  136. wchar_t** GetBClasses() { return m_BClasses; }
  137. wchar_t** GetBProperties() { return m_BProps; }
  138. UINT* GetOperators() { return m_Ops; }
  139. BOOL IsValid() { return m_Valid; }
  140. BOOL ValidateJoin();
  141. //Destructor
  142. ~CJoinOnQualifierArray();
  143. };
  144. template <> inline void AFXAPI DestructElements<CPropertyQualifierItem*> (CPropertyQualifierItem** ptr_e, int x)
  145. {
  146. for (int i = 0; i < x; i++)
  147. {
  148. if (ptr_e[i] != NULL)
  149. {
  150. delete ((CPropertyQualifierItem*)(ptr_e[i]));
  151. }
  152. }
  153. }
  154. #endif //_VIEW_PROV_VPQUALS_H