ScummVM API documentation
XMLDoc.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 /*
23  * This code is based on the CRAB engine
24  *
25  * Copyright (c) Arvind Raja Yadav
26  *
27  * Licensed under MIT
28  *
29  */
30 
31 #ifndef CRAB_XMLDOC_H
32 #define CRAB_XMLDOC_H
33 
34 #include "crab/filesystem.h"
35 #include "crab/rapidxml/rapidxml.hpp"
36 
37 namespace Crab {
38 
39 class XMLDoc {
40  rapidxml::xml_document<char> _doc;
41  char *_text;
42 
43 public:
44  XMLDoc() {
45  _text = nullptr;
46  }
47 
48  XMLDoc(const Common::Path &filename) {
49  _text = nullptr;
50  load(filename);
51  }
52 
53  XMLDoc(uint8 *data) {
54  _text = (char*)data;
55  _doc.parse<0>(_text);
56  }
57 
58  ~XMLDoc() {
59  delete[] _text;
60  }
61 
62  // Load the text from the specified file into the rapidxml format
63  // Each function that references it must parse it there
64  void load(const Common::Path &filename);
65 
66  // Check if document is ready for parsing
67  bool ready() const {
68  return _text != nullptr;
69  }
70 
71  const rapidxml::xml_document<> *doc() const;
72 };
73 
74 } // End of namespace Crab
75 
76 #endif // CRAB_XMLDOC_H
Definition: path.h:52
Definition: XMLDoc.h:39
Definition: moveeffect.h:37