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.

115 lines
2.1 KiB

  1. /*++
  2. Copyright (C) 1998-2001 Microsoft Corporation
  3. Module Name:
  4. WQLSCAN.H
  5. Abstract:
  6. WQL Prefix Scanner
  7. History:
  8. raymcc 26-Mar-98
  9. --*/
  10. #ifndef _WQLSCAN_H_
  11. #define _WQLSCAN_H_
  12. struct WSLexToken
  13. {
  14. int m_nToken;
  15. wchar_t *m_pszTokenText;
  16. WSLexToken() { m_pszTokenText = 0; }
  17. ~WSLexToken() { delete [] m_pszTokenText; }
  18. };
  19. typedef WSLexToken *PWSLexToken;
  20. struct WSTableRef
  21. {
  22. wchar_t *m_pszTable;
  23. wchar_t *m_pszAlias; // Can be NULL if no alias specified
  24. WSTableRef() { m_pszTable = m_pszAlias = 0; }
  25. ~WSTableRef() { delete [] m_pszTable; delete [] m_pszAlias; }
  26. };
  27. typedef WSTableRef * PWSTableRef;
  28. class POLARITY CWQLScanner
  29. {
  30. // Data.
  31. // =====
  32. CGenLexer *m_pLexer;
  33. int m_nLine;
  34. wchar_t *m_pTokenText;
  35. int m_nCurrentToken;
  36. BOOL m_bCount;
  37. CFlexArray m_aTokens; // Array of ptrs to WSLexToken structs.
  38. CFlexArray m_aPropRefs; // Array of ptrs to SWQLColRef structs.
  39. CFlexArray m_aTableRefs; // Ptrs to WSTableRef structs.
  40. // Local functions.
  41. // ==================
  42. BOOL Next();
  43. PWSLexToken ExtractNext(BOOL bRemoveToken = TRUE);
  44. int Pushback(PWSLexToken);
  45. BOOL StripWhereClause();
  46. BOOL SelectList();
  47. BOOL ReduceSql92Joins();
  48. BOOL ReduceSql89Joins();
  49. BOOL ExtractSelectType();
  50. void ClearTableRefs();
  51. void ClearPropRefs();
  52. void ClearTokens();
  53. BOOL BuildSWQLColRef(
  54. CFlexArray &aTokens,
  55. SWQLColRef &ColRef // Empty on entry
  56. );
  57. public:
  58. enum {
  59. SUCCESS,
  60. SYNTAX_ERROR,
  61. LEXICAL_ERROR,
  62. FAILED,
  63. BUFFER_TOO_SMALL,
  64. INVALID_PARAMETER,
  65. INTERNAL_ERROR
  66. };
  67. const LPWSTR AliasToTable(LPWSTR pszAlias);
  68. BOOL GetReferencedAliases(CWStringArray &aClasses);
  69. BOOL GetReferencedTables(CWStringArray &aClasses);
  70. BOOL CountQuery() {return m_bCount;}
  71. CWQLScanner(CGenLexSource *pSrc);
  72. ~CWQLScanner();
  73. int Parse();
  74. void Dump();
  75. const CFlexArray *GetSelectedColumns() { return &m_aPropRefs; }
  76. // Returns pointer to array of SWQLColRef*
  77. };
  78. #endif