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.

135 lines
5.1 KiB

  1. //***************************************************************************
  2. //
  3. // Copyright � Microsoft Corporation. All rights reserved.
  4. //
  5. // FRQueryEx.h
  6. //
  7. // Purpose: Extended and non-published query support classes
  8. //
  9. //***************************************************************************
  10. #pragma once
  11. #define SetBit( p, offset ) \
  12. *((BYTE*)p + ((unsigned int)offset / 8)) |= (1 << ((unsigned int)offset % 8) )
  13. #define IsBitSet( p, offset ) \
  14. *((BYTE*)p + ((unsigned int)offset / 8)) & (1 << ((unsigned int)offset % 8) )
  15. #define SetAllBits( p, maxBits ) \
  16. memset( p , 0xff, ((unsigned int)maxBits / 8) + 1 )
  17. #define ZeroAllBits( p, maxBits ) \
  18. memset( p , 0x00, ((unsigned int)maxBits / 8) + 1 )
  19. class POLARITY CFrameworkQueryEx : public CFrameworkQuery
  20. {
  21. protected:
  22. CHString m_sQueryEx;
  23. public:
  24. CFrameworkQueryEx();
  25. ~CFrameworkQueryEx();
  26. // Note: call VariantInit on the variants before calling this function.
  27. // This method is a quick and dirty implementation. It is needed to allow for optimization of
  28. // a specific type of query that is generated by cimon during a specific type of assocation queries.
  29. // If the association is between two instances of the same class (like Directory To SubDirectory),
  30. // cimom generates a query of the form WHERE (Antecedent = 'D:\foo' or Dependent = 'D:\foo'). The normal
  31. // GetValuesForProp can't handle this.
  32. //
  33. // First this routine checks the query to see if it is an OR query between
  34. // exactly two expressions. The expressions must be = operators (ie not >, <=, etc).
  35. // If so, then it checks the property names of the two expressions against the two passed in property names.
  36. // If they both match, it sends back the values in the variants, and returns TRUE;
  37. //
  38. // So, these queries all return FALSE for a call like this (L"x", L"y", vVar1, vVar2):
  39. // "Select * from foo"
  40. // "Select * from foo where x=5",
  41. // "Select * from foo where x=5 and y = 7"
  42. // "Select * from foo where x = 5 or x = 6 or x = 7"
  43. // "Select * from foo where x = 5 or y < 8"
  44. // "Select * from foo where x = 5 or z = 9"
  45. // These will return TRUE for the same call
  46. // "Select * from foo where x = 5 or y = 6
  47. // "Select * from foo where y = 6 or x = 5"
  48. // "Select * from foo where (y = 6 or x = 5)"
  49. BOOL Is3TokenOR(LPCWSTR wszProp1, LPCWSTR wszProp2, VARIANT &vVar1, VARIANT &vVar2);
  50. /*****************************************************************************
  51. *
  52. * FUNCTION : IsNTokenAnd
  53. *
  54. * DESCRIPTION : Checks to see if the query is of the form:
  55. * propname1 = value1 [and propname2 = value2 [and etc]]]
  56. *
  57. * INPUTS :
  58. *
  59. * OUTPUTS : CHStringArray - Outputs the propnames
  60. * CHPtrArray - Outputs array of variant_t*
  61. *
  62. * RETURNS : TRUE if the query is of the correct form, else FALSE
  63. *
  64. * COMMENTS :
  65. *
  66. * The only joining operator recognized is AND. 'OR' and 'NOT' will both
  67. * cause the function to return FALSE. Because of the operation of the
  68. * parsing class, parenthesis will get simplified out if all joining operators
  69. * are AND, so ((propname1 = value1) and propname2 = value2) should also work.
  70. *
  71. * The properties must be doing equality comparisons (=) to their values (ie not
  72. * >, < >=, etc). If they are not, this function returns FALSE.
  73. *
  74. * Lastly, property names cannot repeat, or else this function returns FALSE.
  75. *
  76. * Both the CHStringArray and the CHPtrArray must be empty before calling this
  77. * function. Further, the elements CHPtrArray MUST BE FREED BY THE CALLER.
  78. *
  79. * As a note, the property names returned in sarr will all be uppercase.
  80. *
  81. * Also note, queries of the form propname1 = value1 will return true.
  82. *
  83. *****************************************************************************/
  84. BOOL IsNTokenAnd(CHStringArray &sarr, CHPtrArray &sPtrArr);
  85. // Like CFrameworkQuery::GetValuesForProp except uses variant_t's.
  86. HRESULT GetValuesForProp(LPCWSTR wszPropName, std::vector<_variant_t>& vectorValues);
  87. // Like CFrameworkQuery::GetValuesForProp except uses ints
  88. HRESULT GetValuesForProp(LPCWSTR wszPropName, std::vector<int>& vectorValues);
  89. /*****************************************************************************
  90. *
  91. * FUNCTION : GetPropertyBitMask
  92. *
  93. * DESCRIPTION : Checks an array of property names, and sets a bitmask to
  94. * show which properties are required.
  95. *
  96. * INPUTS : Array to scan
  97. *
  98. * OUTPUTS : Array of bits.
  99. *
  100. * RETURNS :
  101. *
  102. * COMMENTS : We must populate the elements in the where clause, otherwise
  103. * winmgmt will postprocess away all our instances.
  104. *
  105. *****************************************************************************/
  106. void GetPropertyBitMask(const CHPtrArray &Properties, LPVOID pBits);
  107. virtual HRESULT InitEx(
  108. const BSTR bstrQueryFormat,
  109. const BSTR bstrQuery,
  110. long lFlags,
  111. CHString &sNamespace
  112. );
  113. virtual bool IsExtended();
  114. };