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.

91 lines
1.7 KiB

  1. // Copyright 1997-1997 Microsoft Corporation. All Rights Reserved.
  2. //*********************************************************************************************************************************************
  3. //
  4. // File: Parser.h
  5. // Author: Donald Drake
  6. // Purpose: Defines classes to support parsing tokens from a xml file
  7. #ifndef _PARSER_H
  8. #define _PARSER_H
  9. #include "cinput.h"
  10. #define MAX_LINE_LEN 1024
  11. #define F_OK 0
  12. #define F_NOFILE 1
  13. #define F_READ 2
  14. #define F_WRITE 3
  15. #define F_MEMORY 4
  16. #define F_EOF 5
  17. #define F_END 6
  18. #define F_TAGMISSMATCH 7
  19. #define F_MISSINGENDTAG 8
  20. #define F_NOTFOUND 9
  21. #define F_NOPARENT 10
  22. #define F_NULL 11
  23. #define F_NOTITLE 12
  24. #define F_LOCATION 13
  25. #define F_REFERENCED 14
  26. #define F_DUPLICATE 15
  27. #define F_DELETE 16
  28. #define F_CLOSE 17
  29. #define F_EXISTCHECK 19
  30. class CParseXML {
  31. private: // data
  32. CInput* m_pin;
  33. CStr m_cszLine;
  34. TCHAR m_cCurToken[MAX_LINE_LEN];
  35. TCHAR m_cCurWord[MAX_LINE_LEN];
  36. TCHAR m_cCurBuffer[MAX_LINE_LEN];
  37. TCHAR * m_pCurrentIndex;
  38. DWORD m_dwError;
  39. private: // functions
  40. DWORD Read();
  41. DWORD SetError(DWORD dw) { m_dwError = dw; return m_dwError; }
  42. public:
  43. CParseXML() {
  44. m_pin = NULL;
  45. m_cCurBuffer[0] = '\0';
  46. m_pCurrentIndex = NULL;
  47. m_dwError = F_OK;
  48. }
  49. ~CParseXML() {
  50. End();
  51. }
  52. TCHAR * GetFirstWord(const TCHAR *);
  53. TCHAR * GetValue(const TCHAR *);
  54. DWORD Start(const TCHAR *szFile);
  55. void End();
  56. TCHAR *GetToken();
  57. DWORD GetError() { return m_dwError; }
  58. };
  59. // class to support a FIFO queue of strings
  60. typedef struct fifo {
  61. CHAR *string;
  62. fifo *prev;
  63. } FIFO;
  64. class CFIFOString {
  65. private:
  66. FIFO *m_fifoTail;
  67. public:
  68. CFIFOString() { m_fifoTail = NULL; }
  69. ~CFIFOString();
  70. void RemoveAll();
  71. DWORD AddTail(PCSTR psz);
  72. DWORD GetTail(CHAR **sz);
  73. };
  74. #endif _PARSER_H