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.

78 lines
1.6 KiB

  1. //
  2. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  3. //
  4. #ifndef QUERY_H
  5. #define QUERY_H
  6. struct StackElement
  7. {
  8. int m_iOperator;
  9. int m_iNumOperandsLeft;
  10. };
  11. class Stack
  12. {
  13. StackElement m_stack[100];
  14. int m_iTop;
  15. static int s_iMax;
  16. public:
  17. Stack()
  18. {
  19. m_iTop = 0;
  20. }
  21. BOOLEAN Push(int iOperator, int iNumOperandsLeft)
  22. {
  23. if(m_iTop == s_iMax)
  24. return FALSE;
  25. m_stack[m_iTop].m_iOperator = iOperator;
  26. m_stack[m_iTop].m_iNumOperandsLeft = iNumOperandsLeft;
  27. m_iTop ++;
  28. return TRUE;
  29. }
  30. BOOLEAN Pop(int *piOperator, int *piNumOperandsLeft)
  31. {
  32. if(m_iTop == 0)
  33. return FALSE;
  34. m_iTop --;
  35. *piOperator = m_stack[m_iTop].m_iOperator;
  36. *piNumOperandsLeft = m_stack[m_iTop].m_iNumOperandsLeft;
  37. return TRUE;
  38. }
  39. };
  40. class QueryConvertor
  41. {
  42. private:
  43. static const WCHAR wchAND;
  44. static const WCHAR wchOR;
  45. static const WCHAR wchNOT;
  46. static const WCHAR wchEQUAL;
  47. static const WCHAR wchSTAR;
  48. static const WCHAR wchLEFT_BRACKET;
  49. static const WCHAR wchRIGHT_BRACKET;
  50. static LPCWSTR pszGE;
  51. static LPCWSTR pszLE;
  52. // Special characters excluding ( and ) and *
  53. static const WCHAR wchBACK_SLASH;
  54. static BOOLEAN TranslateExpression(LPWSTR pszLDAPQuery, int *piOutputIndex,
  55. int iOperator, LPCWSTR pszPropertyName, VARIANT *pValue);
  56. static BOOLEAN TranslateValueToLDAP(LPWSTR pszLDAPQuery, int *piOutputIndex, VARIANT *pValue);
  57. static LPWSTR EscapeStringValue(LPCWSTR pszValue);
  58. public:
  59. // This assumes that enough memory has been allocated to the resulting query
  60. static BOOLEAN ConvertQueryToLDAP(SQL_LEVEL_1_RPN_EXPRESSION *pExp, LPWSTR pszLDAPQuery);
  61. };
  62. #endif /* QUERY_H */