parser.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /**
  2. * This file is part of the mingw-w64 runtime package.
  3. * No warranty is given; refer to the file DISCLAIMER within this package.
  4. */
  5. #ifndef _PARSER_H
  6. #define _PARSER_H
  7. #include <winapifamily.h>
  8. #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
  9. #include <stdio.h>
  10. #undef CLASS_IMPORT_EXPORT
  11. #ifdef HHCTRL
  12. #define CLASS_IMPORT_EXPORT
  13. #elif defined (HHSETUP)
  14. #define CLASS_IMPORT_EXPORT __declspec (dllexport)
  15. #else
  16. #define CLASS_IMPORT_EXPORT __declspec (dllimport)
  17. #endif
  18. #define PARSER_API_INLINE
  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:
  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:
  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. typedef struct fifo {
  68. CHAR *string;
  69. fifo *prev;
  70. } FIFO;
  71. class CLASS_IMPORT_EXPORT CFIFOString {
  72. private:
  73. FIFO *m_fifoTail;
  74. public:
  75. CFIFOString () { m_fifoTail = NULL; }
  76. ~CFIFOString ();
  77. void RemoveAll ();
  78. DWORD AddTail (CHAR *sz);
  79. DWORD GetTail (PZPSTR sz);
  80. };
  81. #endif
  82. #endif