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.

101 lines
1.9 KiB

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