Source code of Windows XP (NT5)
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.

141 lines
3.9 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. SQL1FILT.H
  5. Abstract:
  6. History:
  7. --*/
  8. #include <windows.h>
  9. #include <objbase.h>
  10. #include <stdio.h>
  11. #include "providl.h"
  12. #include "unk.h"
  13. #include "arrtempl.h"
  14. #include "hmmstr.h"
  15. #include <wstring.h>
  16. #include <genlex.h>
  17. #include <sql_1.h>
  18. #include <parmdefs.h>
  19. #include <classinf.h>
  20. #include <stackt.h>
  21. #include <trees.h>
  22. #define TOKENTYPE_SPECIAL -1
  23. class CSql1Filter : public CUnk
  24. {
  25. protected:
  26. class XFilter : public CImpl<IHmmSql1Filter, CSql1Filter>
  27. {
  28. public:
  29. XFilter(CSql1Filter* pObj)
  30. : CImpl<IHmmSql1Filter, CSql1Filter>(pObj){}
  31. STDMETHOD(CheckObject)(IN IHmmPropertySource* pObject,
  32. OUT IHmmPropertyList** ppList,
  33. OUT IUnknown** ppHint);
  34. STDMETHOD(IsSpecial)();
  35. STDMETHOD(GetType)(OUT IID* piid);
  36. STDMETHOD(GetSelectedPropertyList)(
  37. IN long lFlags, // necessary, sufficient
  38. OUT IHmmPropertyList** ppList);
  39. STDMETHOD(GetTargetClass)(OUT HMM_CLASS_INFO* pTargetClass);
  40. STDMETHOD(GetTokens)(IN long lFirstIndex, IN long lNumTokens,
  41. OUT long* plTokensReturned, OUT HMM_SQL1_TOKEN* aTokens);
  42. } m_XFilter;
  43. friend XFilter;
  44. class XConfigure : public CImpl<IConfigureHmmSql1Filter, CSql1Filter>
  45. {
  46. public:
  47. XConfigure(CSql1Filter* pObj)
  48. : CImpl<IConfigureHmmSql1Filter, CSql1Filter>(pObj){}
  49. STDMETHOD(SetTargetClass)(IN HMM_CLASS_INFO* pTargetClass);
  50. STDMETHOD(AddTokens)(IN long lNumTokens, IN HMM_SQL1_TOKEN* aTokens);
  51. STDMETHOD(RemoveAllTokens)();
  52. STDMETHOD(AddProperties)(IN long lNumProps, IN HMM_WSTR* awszProps);
  53. STDMETHOD(RemoveAllProperties)();
  54. } m_XConfigure;
  55. friend XConfigure;
  56. class XParse : public CImpl<IHmmParse, CSql1Filter>, public CSql1ParseSink
  57. {
  58. protected:
  59. WString m_wsText;
  60. CAbstractSql1Parser* m_pParser;
  61. enum {not_parsing, at_0, at_where} m_nStatus;
  62. CHmmStack<long> m_InnerStack;
  63. public:
  64. XParse(CSql1Filter* pObj)
  65. : CImpl<IHmmParse, CSql1Filter>(pObj), m_nStatus(not_parsing),
  66. m_pParser(NULL), m_InnerStack(100)
  67. {}
  68. ~XParse();
  69. STDMETHOD(Parse)(IN HMM_WSTR wszText, IN long lFlags);
  70. public:
  71. HRESULT EnsureTarget();
  72. HRESULT EnsureWhere();
  73. HRESULT ParserError(int nError);
  74. void SetClassName(COPY LPCWSTR wszClass);
  75. void AddToken(COPY const HMM_SQL1_TOKEN& Token);
  76. void AddProperty(COPY LPCWSTR wszProperty);
  77. void AddAllProperties();
  78. void InOrder(long lOp);
  79. } m_XParse;
  80. friend XParse;
  81. protected:
  82. typedef CHmmStack<BOOL> CBooleanStack;
  83. HRESULT EvaluateExpression(READ_ONLY CSql1Token* pToken,
  84. READ_ONLY IHmmPropertySource* pPropSource,
  85. OUT BOOL& bResult);
  86. HRESULT EvaluateFunction(IN long lFunctionID,
  87. IN READ_ONLY VARIANT* pvArg,
  88. OUT INIT_AND_CLEAR_ME VARIANT* pvDest);
  89. CHmmNode* GetTree();
  90. protected:
  91. CUniquePointerArray<CSql1Token> m_apTokens;
  92. CContainerControl m_ContainerControl;
  93. CHmmClassInfo m_TargetClass;
  94. protected:
  95. CHmmNode* m_pTree;
  96. inline void InvalidateTree()
  97. {if(m_pTree) m_pTree->Release(); m_pTree = NULL;}
  98. public:
  99. CSql1Filter(CLifeControl* pControl, IUnknown* pOuter)
  100. : CUnk(pControl, pOuter), m_XFilter(this), m_XConfigure(this),
  101. m_XParse(this), m_ContainerControl(GetUnknown()),
  102. m_TargetClass(NULL), m_pTree(NULL)
  103. {}
  104. ~CSql1Filter(){}
  105. void* GetInterface(REFIID riid);
  106. BOOL OnInitialize()
  107. {
  108. m_TargetClass.SetControl(&m_ContainerControl);
  109. return TRUE;
  110. }
  111. HRESULT Evaluate(BOOL bSkipTarget,
  112. IN IHmmPropertySource* pPropSource, OUT IHmmPropertyList** ppList);
  113. };