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.

127 lines
2.8 KiB

  1. // QueryHelp.cpp
  2. #include "precomp.h"
  3. // Becase someone is using _ASSERT in WMI!
  4. #ifdef _ASSERT
  5. #undef _ASSERT
  6. #endif
  7. //#include <analyser.h>
  8. #include <ql.h>
  9. #include "QueryHelp.h"
  10. CQueryParser::CQueryParser() :
  11. m_pLexSource(NULL),
  12. m_pParser(NULL),
  13. m_pExpr(NULL)
  14. {
  15. }
  16. CQueryParser::~CQueryParser()
  17. {
  18. if (m_pLexSource)
  19. delete m_pLexSource;
  20. if (m_pParser)
  21. delete m_pParser;
  22. if (m_pExpr)
  23. delete m_pExpr;
  24. }
  25. HRESULT CQueryParser::Init(LPCWSTR szQuery)
  26. {
  27. HRESULT hr = WBEM_E_OUT_OF_MEMORY;
  28. m_pLexSource = new CTextLexSource(szQuery);
  29. if (m_pLexSource)
  30. {
  31. m_pParser = new QL1_Parser(m_pLexSource);
  32. if (m_pParser)
  33. {
  34. if (m_pParser->Parse(&m_pExpr) == 0)
  35. hr = S_OK;
  36. else
  37. hr = WBEM_E_INVALID_QUERY;
  38. }
  39. }
  40. return hr;
  41. }
  42. HRESULT CQueryParser::GetClassName(_bstr_t &strClass)
  43. {
  44. HRESULT hr;
  45. if (m_pExpr)
  46. {
  47. strClass = m_pExpr->bsClassName;
  48. hr = S_OK;
  49. }
  50. else
  51. hr = WBEM_E_FAILED;
  52. return hr;
  53. }
  54. /*
  55. HRESULT CQueryParser::GetValuesForProp(LPCWSTR szProperty, CBstrList &listValues)
  56. {
  57. CPropertyName prop;
  58. prop.AddElement(szProperty);
  59. // Get the necessary query
  60. QL_LEVEL_1_RPN_EXPRESSION *pPropExpr;
  61. HRESULT hres =
  62. CQueryAnalyser::GetNecessaryQueryForProperty(
  63. m_pExpr,
  64. prop,
  65. pPropExpr);
  66. if (FAILED(hres))
  67. return hres;
  68. // See if there are any tokens
  69. if (pPropExpr->nNumTokens > 0)
  70. {
  71. // Combine them all
  72. for (int i = 0; i < pPropExpr->nNumTokens && SUCCEEDED(hres); i++)
  73. {
  74. QL_LEVEL_1_TOKEN &token = pPropExpr->pArrayOfTokens[i];
  75. if (token.nTokenType == QL1_NOT)
  76. hres = WBEMESS_E_REGISTRATION_TOO_BROAD;
  77. else if (token.nTokenType == QL1_AND || token.nTokenType == QL1_OR)
  78. {
  79. // We treat them all as ORs
  80. // ========================
  81. }
  82. else
  83. {
  84. // This is a token
  85. if (token.nOperator != QL1_OPERATOR_EQUALS)
  86. hres = WBEMESS_E_REGISTRATION_TOO_BROAD;
  87. else if (V_VT(&token.vConstValue) != VT_BSTR)
  88. hres = WBEM_E_INVALID_QUERY;
  89. else
  90. {
  91. // This token is a string equality.
  92. listValues.push_back(V_BSTR(&token.vConstValue));
  93. }
  94. }
  95. }
  96. }
  97. else
  98. hres = WBEMESS_E_REGISTRATION_TOO_BROAD;
  99. delete pPropExpr;
  100. return hres;
  101. }
  102. */