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.2 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: parser.h
  8. //
  9. //--------------------------------------------------------------------------
  10. //*********************************************************************************************************************************************
  11. //
  12. // File: Parser.h
  13. // Author: Donald Drake
  14. // Purpose: Defines classes to support parsing tokens from a xml file
  15. #ifndef _PARSER_H
  16. #define _PARSER_H
  17. #undef CLASS_IMPORT_EXPORT
  18. #ifdef HHCTRL // define this only when building the HHCtrl DLL
  19. #define CLASS_IMPORT_EXPORT /**/
  20. #else
  21. #ifdef HHSETUP // define this only when building the HHSetup DLL
  22. #define CLASS_IMPORT_EXPORT __declspec( dllexport )
  23. #else
  24. #define CLASS_IMPORT_EXPORT __declspec( dllimport )
  25. #endif
  26. #endif
  27. #define MAX_LINE_LEN 1024
  28. #define F_OK 0
  29. #define F_NOFILE 1
  30. #define F_READ 2
  31. #define F_WRITE 3
  32. #define F_MEMORY 4
  33. #define F_EOF 5
  34. #define F_END 6
  35. #define F_TAGMISSMATCH 7
  36. #define F_MISSINGENDTAG 8
  37. #define F_NOTFOUND 9
  38. #define F_NOPARENT 10
  39. #define F_NULL 11
  40. #define F_NOTITLE 12
  41. #define F_LOCATION 13
  42. #define F_REFERENCED 14
  43. #define F_DUPLICATE 15
  44. #define F_DELETE 16
  45. #define F_CLOSE 17
  46. #define F_EXISTCHECK 19
  47. class CParseXML {
  48. private: // data
  49. TCHAR m_cCurToken[MAX_LINE_LEN];
  50. TCHAR m_cCurWord[MAX_LINE_LEN];
  51. TCHAR m_cCurBuffer[MAX_LINE_LEN];
  52. FILE *m_fh;
  53. TCHAR * m_pCurrentIndex;
  54. DWORD m_dwError;
  55. private: // functions
  56. DWORD Read();
  57. DWORD SetError(DWORD dw) { m_dwError = dw; return m_dwError; }
  58. public:
  59. CParseXML() {
  60. m_fh = NULL;
  61. m_cCurBuffer[0] = '\0';
  62. m_pCurrentIndex = NULL;
  63. m_dwError = F_OK;
  64. }
  65. ~CParseXML() {
  66. End();
  67. }
  68. TCHAR * GetFirstWord(TCHAR *);
  69. TCHAR * GetValue(TCHAR *);
  70. DWORD Start(const TCHAR *szFile);
  71. void End();
  72. TCHAR *GetToken();
  73. DWORD GetError() { return m_dwError; }
  74. };
  75. // class to support a FIFO queue of strings
  76. typedef struct fifo {
  77. TCHAR *string;
  78. fifo *prev;
  79. } FIFO;
  80. class CLASS_IMPORT_EXPORT CFIFOString {
  81. private:
  82. FIFO *m_fifoTail;
  83. public:
  84. CFIFOString() { m_fifoTail = NULL; }
  85. ~CFIFOString();
  86. void RemoveAll();
  87. DWORD AddTail(TCHAR *sz);
  88. DWORD GetTail(TCHAR **sz);
  89. };
  90. #endif