ScummVM API documentation
xml_parser.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef QDENGINE_PARSER_XML_PARSER_H
23#define QDENGINE_PARSER_XML_PARSER_H
24
25#include "common/system.h"
26#include "common/hashmap.h"
27#include "common/stack.h"
28
29#include "qdengine/parser/xml_tag_buffer.h"
30
31namespace QDEngine {
32
33namespace xml {
34
35class parser {
36public:
39
40 parser();
41 virtual ~parser();
42
43 bool parse_file(const char *fname);
44
45 bool read_binary_script(const char *fname);
46 bool is_script_binary(const char *fname) const;
47 bool is_script_binary() const {
48 return _binary_script;
49 }
50
51 const tag &root_tag() const {
52 return _root_tag;
53 }
54
55 void clear();
56
57 void resize_data_pool(uint32 pool_sz) {
58 _data_pool.resize(pool_sz);
59 }
60
61 bool register_tag_format(const char *tag_name, const tag &tg) {
62 tag_format_t::iterator it = _tag_format.find(tag_name);
63 if (it != _tag_format.end())
64 return false;
65
66 _tag_format[tag_name] = tg;
67 return true;
68 }
69 const tag *get_tag_format(const char *tag_name) const {
70 tag_format_t::const_iterator it = _tag_format.find(tag_name);
71 if (it != _tag_format.end())
72 return &it->_value;
73
74 return NULL;
75 }
76
77 int num_tag_formats() const {
78 return _tag_format.size();
79 }
80
81private:
82
83 tag _root_tag;
84
85 Std::vector<char> _data_pool;
86 Common::String _data_buffer;
87
88 bool _binary_script;
89
90 tag_stack_t _tag_stack;
91 tag_format_t _tag_format;
92 int _cur_level;
93 bool _skip_mode;
94};
95
96} /* namespace xml */
97
98} // namespace QDEngine
99
100#endif // QDENGINE_PARSER_XML_PARSER_H
void resize(size_type newSize)
Definition: array.h:412
Definition: str.h:59
Definition: xml_parser.h:35
XML тег.
Definition: xml_tag.h:33
Базовый класс для игровых ресурсов.
Definition: console.h:28