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.

176 lines
3.4 KiB

  1. #ifndef __provider_sql_eval_lib__
  2. #define __provider_sql_eval_lib__
  3. #if _MSC_VER > 1000
  4. #pragma once
  5. #endif
  6. #include <wbemprov.h>
  7. #include <objbase.h>
  8. #include <list>
  9. using namespace std;
  10. struct SQL_LEVEL_1_RPN_EXPRESSION;
  11. // object to be evaluated by sql eval
  12. // a CSqlEvalee is provided based on IWbemClassObject
  13. // To Evaluate different object, provide your class inherit from
  14. // CSqlEvalee
  15. class CSqlEvalee
  16. {
  17. public:
  18. virtual const VARIANT* Get(WCHAR*)=0;
  19. };
  20. class CSqlWmiEvalee : public CSqlEvalee
  21. {
  22. protected:
  23. IWbemClassObject* m_pInstance;
  24. VARIANT m_v;
  25. public:
  26. CSqlWmiEvalee(
  27. IWbemClassObject*);
  28. ~CSqlWmiEvalee();
  29. const VARIANT* Get(WCHAR*);
  30. };
  31. // sql eval
  32. class CQueryEnumerator;
  33. class CSqlEval
  34. {
  35. public:
  36. virtual BOOL Evaluate(CSqlEvalee*);
  37. virtual ~CSqlEval(){};
  38. virtual void GenerateQueryEnum(CQueryEnumerator&){};
  39. static CSqlEval* CreateClass(
  40. SQL_LEVEL_1_RPN_EXPRESSION*,
  41. int* );
  42. };
  43. class CSqlEvalAnd : public CSqlEval
  44. {
  45. public:
  46. BOOL Evaluate(CSqlEvalee*);
  47. CSqlEvalAnd(
  48. SQL_LEVEL_1_RPN_EXPRESSION*,
  49. int* );
  50. void GenerateQueryEnum(CQueryEnumerator&);
  51. virtual ~CSqlEvalAnd();
  52. protected:
  53. CSqlEval* m_left;
  54. CSqlEval* m_right;
  55. };
  56. class CSqlEvalOr: public CSqlEval
  57. {
  58. public:
  59. BOOL Evaluate(CSqlEvalee*);
  60. CSqlEvalOr(
  61. SQL_LEVEL_1_RPN_EXPRESSION*,
  62. int* );
  63. void GenerateQueryEnum(CQueryEnumerator&);
  64. virtual ~CSqlEvalOr();
  65. protected:
  66. CSqlEval* m_left;
  67. CSqlEval* m_right;
  68. };
  69. class CSqlEvalNot: public CSqlEval
  70. {
  71. public:
  72. BOOL Evaluate(CSqlEvalee*);
  73. CSqlEvalNot(
  74. SQL_LEVEL_1_RPN_EXPRESSION*,
  75. int* );
  76. virtual ~CSqlEvalNot();
  77. void GenerateQueryEnum(CQueryEnumerator&);
  78. protected:
  79. CSqlEval* m_exp;
  80. };
  81. class CSqlEvalExp: public CSqlEval
  82. {
  83. enum DATATYPE{IntergerType, StringType};
  84. public:
  85. BOOL Evaluate(CSqlEvalee*);
  86. CSqlEvalExp(
  87. SQL_LEVEL_1_RPN_EXPRESSION*,
  88. int* );
  89. ~CSqlEvalExp();
  90. protected:
  91. virtual void GenerateQueryEnum(CQueryEnumerator&);
  92. BSTR m_BstrName;
  93. VARIANT m_v;
  94. int m_op;
  95. DWORD m_dw;
  96. BSTR m_bstr;
  97. int m_DataType;
  98. };
  99. class CQueryEnumerator
  100. {
  101. friend CSqlEvalExp;
  102. friend CSqlEvalAnd;
  103. friend CSqlEvalOr;
  104. friend CSqlEvalNot;
  105. enum{INITIAL_SIZE = 10};
  106. class CStringArray
  107. {
  108. protected:
  109. WCHAR** m_ppWstr;
  110. int m_cNumString;
  111. BOOL m_bIsNull;
  112. BOOL StringArrayCopy(
  113. WCHAR***,
  114. WCHAR**,
  115. int cArgs);
  116. public:
  117. CStringArray();
  118. ~CStringArray();
  119. CStringArray(CStringArray&);
  120. CStringArray(
  121. WCHAR**,
  122. int cNumString);
  123. CStringArray& operator=(CStringArray&);
  124. int Size();
  125. BOOL IsNULL(){return m_bIsNull;};
  126. void Merge(CStringArray&);
  127. const WCHAR** Data();
  128. };
  129. protected:
  130. void ArrayMerge(
  131. CStringArray&);
  132. void ArrayDelete();
  133. void ArrayAdd(CStringArray&);
  134. CStringArray m_QueryFields;
  135. CStringArray* m_QuerySet;
  136. int m_cNumOfRecordInSet;
  137. int m_index;
  138. int m_MaxSize;
  139. public:
  140. CQueryEnumerator(
  141. WCHAR**, //array of string identifying the name fields to
  142. //be queried
  143. int cArg // number of argument
  144. );
  145. CQueryEnumerator(CQueryEnumerator&);
  146. void And(CQueryEnumerator&);
  147. void Or(CQueryEnumerator&);
  148. virtual ~CQueryEnumerator();
  149. // DWORD InitEnumerator(
  150. // WCHAR**, //array of string identifying the name fields to
  151. // //be queried
  152. // int cArg, // number of argument
  153. // CSqlEval*);
  154. const WCHAR** GetNext(int&);
  155. void Reset(void);
  156. };
  157. #endif