1 2 #ifndef _XML_READER_ 3 #define _XML_READER_ 4 5 #define MAX_SECTION_NESTING 40 6 7 typedef struct { 8 char *start; 9 char *end; 10 char *string; 11 char *tag; 12 } XML_SECTION; 13 14 class xml_reader 15 { 16 public: 17 xml_reader(); 18 ~xml_reader(); 19 20 BOOL ReadFile(CString &pathname); 21 BOOL ReadFile(CFile *memfile); 22 BOOL ReadBool(const char *tagname, BOOL &put); 23 BOOL ReadInt(const char *tagname, int &put, int defval = 0); 24 BOOL ReadUByte(const char *tagname, GX_UBYTE &put, GX_UBYTE defval = 0); 25 BOOL ReadUnsigned(const char *tagname, ULONG &put, ULONG defval = 0); 26 BOOL ReadHex(const char *tagname, ULONG &put, ULONG defval = 0); 27 BOOL ReadUShort(const char *tagname, USHORT &put, USHORT defval = 0); 28 BOOL ReadValue(const char *tagname, GX_VALUE &put, GX_VALUE defval = 0); 29 BOOL ReadRect(const char *tagname, GX_RECTANGLE &rect); 30 BOOL ReadString(const char *tagname, char *put, int bufsize); 31 BOOL ReadString(const char *tagname, CString &put); 32 33 void ReadPathInfo(PATHINFO &put); 34 35 void CloseSection(BOOL skip_to_end = FALSE, BOOL MarkRead = FALSE); 36 void CloseTag(); 37 38 char *FindTag(const char *tagname, BOOL mark_used = FALSE); 39 char *FindTag(char *start, char *stop, 40 const char *tagname, BOOL mark_used = FALSE); 41 42 char *EndTag(char *start, char *stop); 43 44 BOOL EnterSection(const char *tagname); 45 BOOL EnterTag(const char *tagname); 46 47 char *GetString(void); 48 float GetTagValueFloat(char *name, float def_val); 49 BOOL GetTagString(char *name, CString &put); 50 51 private: 52 53 BOOL PopSection(void); 54 BOOL PushSection(void); 55 56 char *mpBuffer; 57 XML_SECTION mSectionStack[MAX_SECTION_NESTING]; 58 XML_SECTION *mpSectionStackPtr; 59 XML_SECTION mSection; 60 int mSectionLevel; 61 }; 62 #endif 63