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.

109 lines
2.3 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. TREES.H
  5. Abstract:
  6. History:
  7. --*/
  8. #ifndef __HMM_TREES__H_
  9. #define __HMM_TREES__H_
  10. #include <windows.h>
  11. #include <stdio.h>
  12. #include <providl.h>
  13. #include <arrtempl.h>
  14. #include <wstring.h>
  15. #include <parmdefs.h>
  16. #include <metadata.h>
  17. #include <relation.h>
  18. class CHmmNode
  19. {
  20. public:
  21. long m_lRef;
  22. int m_lTokenType;
  23. public:
  24. CHmmNode() : m_lRef(0){}
  25. virtual ~CHmmNode(){}
  26. inline void AddRef() {m_lRef++;}
  27. inline void Release() {m_lRef--; if(m_lRef == 0) delete this;}
  28. virtual HRESULT Evaluate(IHmmPropertySource* pSource) = 0;
  29. virtual HRESULT Negate() = 0;
  30. virtual void Print(FILE* f, int nOffset) = 0;
  31. static HRESULT EvaluateNode(CHmmNode* pNode, IHmmPropertySource* pSource);
  32. static HMM_RELATIONSHIP RelateNodes(CHmmNode* pFirst, CHmmNode* pSecond,
  33. CMetaData* pMeta);
  34. protected:
  35. void PrintOffset(int nOffset);
  36. };
  37. class CNodeArray : public CUniquePointerArray<CHmmNode>
  38. {
  39. public:
  40. void AddRefElement(CHmmNode* pNode)
  41. {
  42. pNode->AddRef();
  43. }
  44. void ReleaseElement(CHmmNode* pNode)
  45. {
  46. pNode->Release();
  47. }
  48. };
  49. class CLogicalNode : public CHmmNode
  50. {
  51. public:
  52. CNodeArray m_apChildren;
  53. HRESULT Evaluate(IHmmPropertySource* pSource);
  54. HRESULT Negate();
  55. void Print(FILE* f, int nOffset);
  56. void Add(CHmmNode* pNode);
  57. };
  58. class CSql1Token : public CHmmNode
  59. {
  60. public:
  61. WString m_wsProperty;
  62. long m_lOperator;
  63. VARIANT m_vConstValue;
  64. long m_lPropertyFunction;
  65. long m_lConstFunction;
  66. public:
  67. CSql1Token();
  68. CSql1Token(const CSql1Token& Other);
  69. CSql1Token(const HMM_SQL1_TOKEN& Token);
  70. ~CSql1Token();
  71. void Load(const HMM_SQL1_TOKEN& Token);
  72. void Save(HMM_SQL1_TOKEN& Token);
  73. HRESULT Evaluate(IHmmPropertySource* pSource);
  74. HRESULT Negate();
  75. void Print(FILE* f, int nOffset);
  76. static HMM_RELATIONSHIP ComputeRelation(
  77. CSql1Token* pFirst, CSql1Token* pSecond, CMetaData* pMeta);
  78. protected:
  79. static int CompareVariants(VARIANT& v1, VARIANT& v2);
  80. static void ComputeSegment(long lOperator, int nRightHand,
  81. int& nStart, int& nEnd);
  82. static HRESULT EvaluateFunction(IN long lFunctionID,
  83. IN READ_ONLY VARIANT* pvArg,
  84. OUT INIT_AND_CLEAR_ME VARIANT* pvDest);
  85. };
  86. #endif