25 #include "common/scummsys.h" 26 #include "common/types.h" 28 #include "common/fs.h" 29 #include "common/list.h" 30 #include "common/hashmap.h" 31 #include "common/hash-str.h" 32 #include "common/stack.h" 33 #include "common/memorypool.h" 47 class SeekableReadStream;
49 #define MAX_XML_DEPTH 8 51 #define XML_KEY(keyName) {\ 52 lay = new CustomXMLKeyLayout;\ 53 lay->callback = (&kLocalParserName::parserCallback_##keyName);\ 54 layout.top()->children[#keyName] = lay;\ 56 _layoutList.push_back(lay); 58 #define XML_KEY_RECURSIVE(keyName) {\ 59 layout.top()->children[#keyName] = layout.top();\ 60 layout.push(layout.top());\ 63 #define KEY_END() layout.pop(); } 65 #define XML_PROP(propName, req) {\ 66 prop.name = #propName; \ 67 prop.required = req; \ 68 layout.top()->properties.push_back(prop); } 72 #define CUSTOM_XML_PARSER(parserName) \ 74 typedef parserName kLocalParserName; \ 75 bool keyCallback(ParserNode *node) override {return node->layout->doCallback(this, node); }\ 76 struct CustomXMLKeyLayout : public XMLKeyLayout {\ 77 typedef bool (parserName::*ParserCallback)(ParserNode *node);\ 78 ParserCallback callback;\ 79 bool doCallback(XMLParser *parent, ParserNode *node) {return ((kLocalParserName *)parent->*callback)(node);} };\ 80 void buildLayout() override { \ 81 Common::Stack<XMLKeyLayout *> layout; \ 82 CustomXMLKeyLayout *lay = 0; \ 83 XMLKeyLayout::XMLKeyProperty prop; \ 84 _XMLkeys = new CustomXMLKeyLayout; \ 85 layout.push(_XMLkeys); 87 #define PARSER_END() layout.clear(); } 103 XMLParser() : _XMLkeys(nullptr), _stream(nullptr), _allowText(false), _char(0) {}
113 kParserNeedPropertyName,
114 kParserNeedPropertyOperator,
115 kParserNeedPropertyValue,
186 bool loadBuffer(
const byte *buffer, uint32 size, DisposeAfterUse::Flag disposable = DisposeAfterUse::NO);
203 if (!_activeKey.empty())
204 return _activeKey.top();
213 return child->depth > 0 ? _activeKey[child->depth - 1] : 0;
354 bool vparseIntegerKey(
const char *key,
int count, va_list args);
bool parseActiveKey(bool closed)
Definition: xmlparser.h:126
bool loadFile(const Path &filename)
virtual bool closedKeyCallback(ParserNode *node)
Definition: xmlparser.h:271
virtual bool handleUnknownKey(ParserNode *node)
Definition: xmlparser.h:372
void setAllowText()
Definition: xmlparser.h:223
ParserNode * getActiveNode()
Definition: xmlparser.h:202
Definition: xmlparser.h:145
bool parserError(const String &errStr)
bool loadBuffer(const byte *buffer, uint32 size, DisposeAfterUse::Flag disposable=DisposeAfterUse::NO)
virtual bool keyCallback(ParserNode *node)=0
Definition: xmlparser.h:98
void deleteChunk(T *ptr)
Definition: memorypool.h:145
Definition: algorithm.h:29
Definition: memorypool.h:139
void clear()
Definition: list.h:206
virtual void buildLayout()=0
XMLParser()
Definition: xmlparser.h:103
ParserState
Definition: xmlparser.h:108
virtual bool isValidNameChar(char c)
Definition: xmlparser.h:325
ParserNode * getParentNode(ParserNode *child)
Definition: xmlparser.h:212
virtual bool textCallback(const String &val)
Definition: xmlparser.h:280
Definition: xmlparser.h:127
virtual void cleanup()
Definition: xmlparser.h:363
bool parseKeyValue(String keyName)
bool parseIntegerKey(const char *key, int count,...)