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.

189 lines
3.1 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. qryparse.hxx
  5. Abstract:
  6. Author:
  7. Felix Wong [t-FelixW] 05-Nov-1996
  8. ++*/
  9. #ifndef _QRYPARSE_HXX
  10. #define _QRYPARSE_HXX
  11. #define BAIL_ON_FAILURE(hr) \
  12. if (FAILED(hr)) { \
  13. goto error; \
  14. }\
  15. #define MAXVAL 1000
  16. #define QUERYNODE_INITIAL 2
  17. #define QUERYNODE_INC 5
  18. #define ATTRNODE_INITIAL 2
  19. #define ATTRNODE_INC 2
  20. enum snodetypes {
  21. SNODE_SZ,
  22. SNODE_NODE,
  23. SNODE_FILTER,
  24. SNODE_NULL
  25. };
  26. enum query_symbols {
  27. QUERY_EQUAL,
  28. QUERY_NOT,
  29. QUERY_APPROX,
  30. QUERY_OR,
  31. QUERY_AND,
  32. QUERY_PRESENT,
  33. QUERY_STRING,
  34. QUERY_LE,
  35. QUERY_GE,
  36. QUERY_UNKNOWN
  37. };
  38. enum search_scope {
  39. NDS_SCOPE_BASE,
  40. NDS_SCOPE_ONELEVEL,
  41. NDS_SCOPE_SUBTREE
  42. };
  43. typedef struct _AttrNode {
  44. LPWSTR szName;
  45. DWORD dwType;
  46. BOOL fBinary;
  47. } AttrNode;
  48. class CQueryNode;
  49. class CStack;
  50. class CSyntaxNode;
  51. class CAttrList;
  52. class CQueryNode
  53. {
  54. public:
  55. CQueryNode();
  56. ~CQueryNode();
  57. HRESULT AddToFilterBuf(
  58. pFilter_Cursor_T pCur,
  59. CAttrList *pAttrList
  60. );
  61. HRESULT SetToString(LPWSTR szValue);
  62. static HRESULT MapQueryToNDSType(
  63. DWORD dwType,
  64. nuint16 *pdwNDSType
  65. );
  66. HRESULT AddChild(CQueryNode *pChild);
  67. static void N_FAR N_CDECL FreeFilterTokens(
  68. nuint32 syntax,
  69. nptr pVal
  70. );
  71. DWORD _dwType;
  72. private:
  73. LPWSTR _szValue;
  74. CQueryNode **_rgQueryNode;
  75. DWORD _dwQueryNode;
  76. DWORD _dwQueryNodeMax;
  77. };
  78. class CStack
  79. {
  80. public:
  81. CStack();
  82. ~CStack();
  83. HRESULT Push(CSyntaxNode*);
  84. HRESULT Pop(CSyntaxNode**);
  85. HRESULT Pop();
  86. HRESULT Current(CSyntaxNode**);
  87. void Dump();
  88. private:
  89. DWORD _dwStackIndex;
  90. CSyntaxNode* _Stack[MAXVAL];
  91. };
  92. // Helper functions
  93. HRESULT MakeNode(
  94. DWORD dwType,
  95. CQueryNode *pLQueryNode,
  96. CQueryNode *pRQueryNode,
  97. CQueryNode **ppQueryNodeReturn
  98. );
  99. HRESULT MakeLeaf(
  100. LPWSTR szValue,
  101. CQueryNode **ppQuerynNodeReturn
  102. );
  103. HRESULT Parse(
  104. LPWSTR szQuery,
  105. CQueryNode **ppNode,
  106. CAttrList **ppAttrList
  107. );
  108. class CSyntaxNode
  109. {
  110. public:
  111. CSyntaxNode();
  112. ~CSyntaxNode();
  113. void SetNode(CQueryNode *pNode);
  114. void SetNode(LPWSTR szValue);
  115. void SetNode(DWORD dwFilterType);
  116. DWORD _dwToken;
  117. DWORD _dwState;
  118. DWORD _dwType;
  119. union {
  120. CQueryNode *_pNode; // Put in after reduction
  121. LPWSTR _szValue; // dwToken == ATTRTYPE|ATTRVAL
  122. DWORD _dwFilterType; // reduction of FT
  123. };
  124. };
  125. class CAttrList
  126. {
  127. public:
  128. CAttrList();
  129. ~CAttrList();
  130. HRESULT Add(LPWSTR szName);
  131. HRESULT CAttrList::SetupType(NDS_CONTEXT_HANDLE hADsContext);
  132. HRESULT GetType(LPWSTR szName, DWORD *pdwType);
  133. private:
  134. DWORD _dwAttrMax;
  135. DWORD _dwAttrCur;
  136. AttrNode* _rgAttr;
  137. };
  138. HRESULT
  139. AdsNdsGenerateFilterBuffer(
  140. NDS_CONTEXT_HANDLE hADsContext,
  141. LPWSTR szSearchFilter,
  142. NDS_BUFFER_HANDLE *phFilterBuf
  143. );
  144. #endif