aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/include/irrXML.h
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-13 18:54:10 +1000
committerDavid Walter Seikel2013-01-13 18:54:10 +1000
commit959831f4ef5a3e797f576c3de08cd65032c997ad (patch)
treee7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/include/irrXML.h
parentAdd info about changes to Irrlicht. (diff)
downloadSledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to 'libraries/irrlicht-1.8/include/irrXML.h')
-rw-r--r--libraries/irrlicht-1.8/include/irrXML.h1132
1 files changed, 566 insertions, 566 deletions
diff --git a/libraries/irrlicht-1.8/include/irrXML.h b/libraries/irrlicht-1.8/include/irrXML.h
index 024c641..b8331ac 100644
--- a/libraries/irrlicht-1.8/include/irrXML.h
+++ b/libraries/irrlicht-1.8/include/irrXML.h
@@ -1,566 +1,566 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt 1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine" and the "irrXML" project. 2// This file is part of the "Irrlicht Engine" and the "irrXML" project.
3// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h 3// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h
4 4
5#ifndef __IRR_XML_H_INCLUDED__ 5#ifndef __IRR_XML_H_INCLUDED__
6#define __IRR_XML_H_INCLUDED__ 6#define __IRR_XML_H_INCLUDED__
7 7
8#include <stdio.h> 8#include <stdio.h>
9#include "IrrCompileConfig.h" 9#include "IrrCompileConfig.h"
10 10
11/** \mainpage irrXML 1.2 API documentation 11/** \mainpage irrXML 1.2 API documentation
12 <div align="center"><img src="logobig.png" ></div> 12 <div align="center"><img src="logobig.png" ></div>
13 13
14 \section intro Introduction 14 \section intro Introduction
15 15
16 Welcome to the irrXML API documentation. 16 Welcome to the irrXML API documentation.
17 Here you'll find any information you'll need to develop applications with 17 Here you'll find any information you'll need to develop applications with
18 irrXML. If you look for a tutorial on how to start, take a look at the \ref irrxmlexample, 18 irrXML. If you look for a tutorial on how to start, take a look at the \ref irrxmlexample,
19 at the homepage of irrXML at <A HREF="http://www.ambiera.com/irrxml/">www.ambiera.com/irrxml/</A> 19 at the homepage of irrXML at <A HREF="http://www.ambiera.com/irrxml/">www.ambiera.com/irrxml/</A>
20 or into the SDK in the directory example. 20 or into the SDK in the directory example.
21 21
22 irrXML is intended to be a high speed and easy-to-use XML Parser for C++, and 22 irrXML is intended to be a high speed and easy-to-use XML Parser for C++, and
23 this documentation is an important part of it. If you have any questions or 23 this documentation is an important part of it. If you have any questions or
24 suggestions, just send a email to the author of the engine, Nikolaus Gebhardt 24 suggestions, just send a email to the author of the engine, Nikolaus Gebhardt
25 (niko (at) irrlicht3d.org). For more informations about this parser, see \ref history. 25 (niko (at) irrlicht3d.org). For more informations about this parser, see \ref history.
26 26
27 \section features Features 27 \section features Features
28 28
29 irrXML provides forward-only, read-only 29 irrXML provides forward-only, read-only
30 access to a stream of non validated XML data. It was fully implemented by 30 access to a stream of non validated XML data. It was fully implemented by
31 Nikolaus Gebhardt. Its current features are: 31 Nikolaus Gebhardt. Its current features are:
32 32
33 - It it fast as lighting and has very low memory usage. It was 33 - It it fast as lighting and has very low memory usage. It was
34 developed with the intention of being used in 3D games, as it already has been. 34 developed with the intention of being used in 3D games, as it already has been.
35 - irrXML is very small: It only consists of 60 KB of code and can be added easily 35 - irrXML is very small: It only consists of 60 KB of code and can be added easily
36 to your existing project. 36 to your existing project.
37 - Of course, it is platform independent and works with lots of compilers. 37 - Of course, it is platform independent and works with lots of compilers.
38 - It is able to parse ASCII, UTF-8, UTF-16 and UTF-32 text files, both in 38 - It is able to parse ASCII, UTF-8, UTF-16 and UTF-32 text files, both in
39 little and big endian format. 39 little and big endian format.
40 - Independent of the input file format, the parser can return all strings in ASCII, UTF-8, 40 - Independent of the input file format, the parser can return all strings in ASCII, UTF-8,
41 UTF-16 and UTF-32 format. 41 UTF-16 and UTF-32 format.
42 - With its optional file access abstraction it has the advantage that it can read not 42 - With its optional file access abstraction it has the advantage that it can read not
43 only from files but from any type of data (memory, network, ...). For example when 43 only from files but from any type of data (memory, network, ...). For example when
44 used with the Irrlicht Engine, it directly reads from compressed .zip files. 44 used with the Irrlicht Engine, it directly reads from compressed .zip files.
45 - Just like the Irrlicht Engine for which it was originally created, it is extremely easy 45 - Just like the Irrlicht Engine for which it was originally created, it is extremely easy
46 to use. 46 to use.
47 - It has no external dependencies, it does not even need the STL. 47 - It has no external dependencies, it does not even need the STL.
48 48
49 Although irrXML has some strenghts, it currently also has the following limitations: 49 Although irrXML has some strenghts, it currently also has the following limitations:
50 50
51 - The input xml file is not validated and assumed to be correct. 51 - The input xml file is not validated and assumed to be correct.
52 52
53 \section irrxmlexample Example 53 \section irrxmlexample Example
54 54
55 The following code demonstrates the basic usage of irrXML. A simple xml 55 The following code demonstrates the basic usage of irrXML. A simple xml
56 file like this is parsed: 56 file like this is parsed:
57 \code 57 \code
58 <?xml version="1.0"?> 58 <?xml version="1.0"?>
59 <config> 59 <config>
60 <!-- This is a config file for the mesh viewer --> 60 <!-- This is a config file for the mesh viewer -->
61 <model file="dwarf.dea" /> 61 <model file="dwarf.dea" />
62 <messageText caption="Irrlicht Engine Mesh Viewer"> 62 <messageText caption="Irrlicht Engine Mesh Viewer">
63 Welcome to the Mesh Viewer of the &quot;Irrlicht Engine&quot;. 63 Welcome to the Mesh Viewer of the &quot;Irrlicht Engine&quot;.
64 </messageText> 64 </messageText>
65 </config> 65 </config>
66 \endcode 66 \endcode
67 67
68 The code for parsing this file would look like this: 68 The code for parsing this file would look like this:
69 \code 69 \code
70 #include <irrXML.h> 70 #include <irrXML.h>
71 using namespace irr; // irrXML is located in the namespace irr::io 71 using namespace irr; // irrXML is located in the namespace irr::io
72 using namespace io; 72 using namespace io;
73 73
74 #include <string> // we use STL strings to store data in this example 74 #include <string> // we use STL strings to store data in this example
75 75
76 void main() 76 void main()
77 { 77 {
78 // create the reader using one of the factory functions 78 // create the reader using one of the factory functions
79 79
80 IrrXMLReader* xml = createIrrXMLReader("config.xml"); 80 IrrXMLReader* xml = createIrrXMLReader("config.xml");
81 81
82 // strings for storing the data we want to get out of the file 82 // strings for storing the data we want to get out of the file
83 std::string modelFile; 83 std::string modelFile;
84 std::string messageText; 84 std::string messageText;
85 std::string caption; 85 std::string caption;
86 86
87 // parse the file until end reached 87 // parse the file until end reached
88 88
89 while(xml && xml->read()) 89 while(xml && xml->read())
90 { 90 {
91 switch(xml->getNodeType()) 91 switch(xml->getNodeType())
92 { 92 {
93 case EXN_TEXT: 93 case EXN_TEXT:
94 // in this xml file, the only text which occurs is the messageText 94 // in this xml file, the only text which occurs is the messageText
95 messageText = xml->getNodeData(); 95 messageText = xml->getNodeData();
96 break; 96 break;
97 case EXN_ELEMENT: 97 case EXN_ELEMENT:
98 { 98 {
99 if (!strcmp("model", xml->getNodeName())) 99 if (!strcmp("model", xml->getNodeName()))
100 modelFile = xml->getAttributeValue("file"); 100 modelFile = xml->getAttributeValue("file");
101 else 101 else
102 if (!strcmp("messageText", xml->getNodeName())) 102 if (!strcmp("messageText", xml->getNodeName()))
103 caption = xml->getAttributeValue("caption"); 103 caption = xml->getAttributeValue("caption");
104 } 104 }
105 break; 105 break;
106 } 106 }
107 } 107 }
108 108
109 // delete the xml parser after usage 109 // delete the xml parser after usage
110 delete xml; 110 delete xml;
111 } 111 }
112 \endcode 112 \endcode
113 113
114 \section howto How to use 114 \section howto How to use
115 115
116 Simply add the source files in the /src directory of irrXML to your project. Done. 116 Simply add the source files in the /src directory of irrXML to your project. Done.
117 117
118 \section license License 118 \section license License
119 119
120 The irrXML license is based on the zlib license. Basicly, this means you can do with 120 The irrXML license is based on the zlib license. Basicly, this means you can do with
121 irrXML whatever you want: 121 irrXML whatever you want:
122 122
123 Copyright (C) 2002-2012 Nikolaus Gebhardt 123 Copyright (C) 2002-2012 Nikolaus Gebhardt
124 124
125 This software is provided 'as-is', without any express or implied 125 This software is provided 'as-is', without any express or implied
126 warranty. In no event will the authors be held liable for any damages 126 warranty. In no event will the authors be held liable for any damages
127 arising from the use of this software. 127 arising from the use of this software.
128 128
129 Permission is granted to anyone to use this software for any purpose, 129 Permission is granted to anyone to use this software for any purpose,
130 including commercial applications, and to alter it and redistribute it 130 including commercial applications, and to alter it and redistribute it
131 freely, subject to the following restrictions: 131 freely, subject to the following restrictions:
132 132
133 1. The origin of this software must not be misrepresented; you must not 133 1. The origin of this software must not be misrepresented; you must not
134 claim that you wrote the original software. If you use this software 134 claim that you wrote the original software. If you use this software
135 in a product, an acknowledgment in the product documentation would be 135 in a product, an acknowledgment in the product documentation would be
136 appreciated but is not required. 136 appreciated but is not required.
137 137
138 2. Altered source versions must be plainly marked as such, and must not be 138 2. Altered source versions must be plainly marked as such, and must not be
139 misrepresented as being the original software. 139 misrepresented as being the original software.
140 140
141 3. This notice may not be removed or altered from any source distribution. 141 3. This notice may not be removed or altered from any source distribution.
142 142
143 \section history History 143 \section history History
144 144
145 As lots of references in this documentation and the source show, this xml 145 As lots of references in this documentation and the source show, this xml
146 parser has originally been a part of the 146 parser has originally been a part of the
147 <A HREF="http://irrlicht.sourceforge.net" >Irrlicht Engine</A>. But because 147 <A HREF="http://irrlicht.sourceforge.net" >Irrlicht Engine</A>. But because
148 the parser has become very useful with the latest release, people asked for a 148 the parser has become very useful with the latest release, people asked for a
149 separate version of it, to be able to use it in non Irrlicht projects. With 149 separate version of it, to be able to use it in non Irrlicht projects. With
150 irrXML 1.0, this has now been done. 150 irrXML 1.0, this has now been done.
151*/ 151*/
152 152
153namespace irr 153namespace irr
154{ 154{
155namespace io 155namespace io
156{ 156{
157 //! Enumeration of all supported source text file formats 157 //! Enumeration of all supported source text file formats
158 enum ETEXT_FORMAT 158 enum ETEXT_FORMAT
159 { 159 {
160 //! ASCII, file without byte order mark, or not a text file 160 //! ASCII, file without byte order mark, or not a text file
161 ETF_ASCII, 161 ETF_ASCII,
162 162
163 //! UTF-8 format 163 //! UTF-8 format
164 ETF_UTF8, 164 ETF_UTF8,
165 165
166 //! UTF-16 format, big endian 166 //! UTF-16 format, big endian
167 ETF_UTF16_BE, 167 ETF_UTF16_BE,
168 168
169 //! UTF-16 format, little endian 169 //! UTF-16 format, little endian
170 ETF_UTF16_LE, 170 ETF_UTF16_LE,
171 171
172 //! UTF-32 format, big endian 172 //! UTF-32 format, big endian
173 ETF_UTF32_BE, 173 ETF_UTF32_BE,
174 174
175 //! UTF-32 format, little endian 175 //! UTF-32 format, little endian
176 ETF_UTF32_LE 176 ETF_UTF32_LE
177 }; 177 };
178 178
179 179
180 //! Enumeration for all xml nodes which are parsed by IrrXMLReader 180 //! Enumeration for all xml nodes which are parsed by IrrXMLReader
181 enum EXML_NODE 181 enum EXML_NODE
182 { 182 {
183 //! No xml node. This is usually the node if you did not read anything yet. 183 //! No xml node. This is usually the node if you did not read anything yet.
184 EXN_NONE, 184 EXN_NONE,
185 185
186 //! An xml element such as &lt;foo&gt; 186 //! An xml element such as &lt;foo&gt;
187 EXN_ELEMENT, 187 EXN_ELEMENT,
188 188
189 //! End of an xml element such as &lt;/foo&gt; 189 //! End of an xml element such as &lt;/foo&gt;
190 EXN_ELEMENT_END, 190 EXN_ELEMENT_END,
191 191
192 //! Text within an xml element: &lt;foo&gt; this is the text. &lt;/foo&gt; 192 //! Text within an xml element: &lt;foo&gt; this is the text. &lt;/foo&gt;
193 //! Also text between 2 xml elements: &lt;/foo&gt; this is the text. &lt;foo&gt; 193 //! Also text between 2 xml elements: &lt;/foo&gt; this is the text. &lt;foo&gt;
194 EXN_TEXT, 194 EXN_TEXT,
195 195
196 //! An xml comment like &lt;!-- I am a comment --&gt; or a DTD definition. 196 //! An xml comment like &lt;!-- I am a comment --&gt; or a DTD definition.
197 EXN_COMMENT, 197 EXN_COMMENT,
198 198
199 //! An xml cdata section like &lt;![CDATA[ this is some CDATA ]]&gt; 199 //! An xml cdata section like &lt;![CDATA[ this is some CDATA ]]&gt;
200 EXN_CDATA, 200 EXN_CDATA,
201 201
202 //! Unknown element. 202 //! Unknown element.
203 EXN_UNKNOWN 203 EXN_UNKNOWN
204 }; 204 };
205 205
206 //! Callback class for file read abstraction. 206 //! Callback class for file read abstraction.
207 /** With this, it is possible to make the xml parser read in other 207 /** With this, it is possible to make the xml parser read in other
208 things than just files. The Irrlicht engine is using this for example to 208 things than just files. The Irrlicht engine is using this for example to
209 read xml from compressed .zip files. To make the parser read in 209 read xml from compressed .zip files. To make the parser read in
210 any other data, derive a class from this interface, implement the 210 any other data, derive a class from this interface, implement the
211 two methods to read your data and give a pointer to an instance of 211 two methods to read your data and give a pointer to an instance of
212 your implementation when calling createIrrXMLReader(), 212 your implementation when calling createIrrXMLReader(),
213 createIrrXMLReaderUTF16() or createIrrXMLReaderUTF32() */ 213 createIrrXMLReaderUTF16() or createIrrXMLReaderUTF32() */
214 class IFileReadCallBack 214 class IFileReadCallBack
215 { 215 {
216 public: 216 public:
217 217
218 //! Destructor 218 //! Destructor
219 virtual ~IFileReadCallBack() {} 219 virtual ~IFileReadCallBack() {}
220 220
221 //! Reads an amount of bytes from the file. 221 //! Reads an amount of bytes from the file.
222 /** \param buffer: Pointer to buffer where to read bytes will be written to. 222 /** \param buffer: Pointer to buffer where to read bytes will be written to.
223 \param sizeToRead: Amount of bytes to read from the file. 223 \param sizeToRead: Amount of bytes to read from the file.
224 \return Returns how much bytes were read. */ 224 \return Returns how much bytes were read. */
225 virtual int read(void* buffer, int sizeToRead) = 0; 225 virtual int read(void* buffer, int sizeToRead) = 0;
226 226
227 //! Returns size of file in bytes 227 //! Returns size of file in bytes
228 virtual long getSize() const = 0; 228 virtual long getSize() const = 0;
229 }; 229 };
230 230
231 //! Empty class to be used as parent class for IrrXMLReader. 231 //! Empty class to be used as parent class for IrrXMLReader.
232 /** If you need another class as base class for the xml reader, you can do this by creating 232 /** If you need another class as base class for the xml reader, you can do this by creating
233 the reader using for example new CXMLReaderImpl<char, YourBaseClass>(yourcallback); 233 the reader using for example new CXMLReaderImpl<char, YourBaseClass>(yourcallback);
234 The Irrlicht Engine for example needs IReferenceCounted as base class for every object to 234 The Irrlicht Engine for example needs IReferenceCounted as base class for every object to
235 let it automaticly reference countend, hence it replaces IXMLBase with IReferenceCounted. 235 let it automaticly reference countend, hence it replaces IXMLBase with IReferenceCounted.
236 See irrXML.cpp on how this can be done in detail. */ 236 See irrXML.cpp on how this can be done in detail. */
237 class IXMLBase 237 class IXMLBase
238 { 238 {
239 }; 239 };
240 240
241 //! Interface providing easy read access to a XML file. 241 //! Interface providing easy read access to a XML file.
242 /** You can create an instance of this reader using one of the factory functions 242 /** You can create an instance of this reader using one of the factory functions
243 createIrrXMLReader(), createIrrXMLReaderUTF16() and createIrrXMLReaderUTF32(). 243 createIrrXMLReader(), createIrrXMLReaderUTF16() and createIrrXMLReaderUTF32().
244 If using the parser from the Irrlicht Engine, please use IFileSystem::createXMLReader() 244 If using the parser from the Irrlicht Engine, please use IFileSystem::createXMLReader()
245 instead. 245 instead.
246 For a detailed intro how to use the parser, see \ref irrxmlexample and \ref features. 246 For a detailed intro how to use the parser, see \ref irrxmlexample and \ref features.
247 247
248 The typical usage of this parser looks like this: 248 The typical usage of this parser looks like this:
249 \code 249 \code
250 #include <irrXML.h> 250 #include <irrXML.h>
251 using namespace irr; // irrXML is located in the namespace irr::io 251 using namespace irr; // irrXML is located in the namespace irr::io
252 using namespace io; 252 using namespace io;
253 253
254 void main() 254 void main()
255 { 255 {
256 // create the reader using one of the factory functions 256 // create the reader using one of the factory functions
257 IrrXMLReader* xml = createIrrXMLReader("config.xml"); 257 IrrXMLReader* xml = createIrrXMLReader("config.xml");
258 258
259 if (xml == 0) 259 if (xml == 0)
260 return; // file could not be opened 260 return; // file could not be opened
261 261
262 // parse the file until end reached 262 // parse the file until end reached
263 while(xml->read()) 263 while(xml->read())
264 { 264 {
265 // based on xml->getNodeType(), do something. 265 // based on xml->getNodeType(), do something.
266 } 266 }
267 267
268 // delete the xml parser after usage 268 // delete the xml parser after usage
269 delete xml; 269 delete xml;
270 } 270 }
271 \endcode 271 \endcode
272 See \ref irrxmlexample for a more detailed example. 272 See \ref irrxmlexample for a more detailed example.
273 */ 273 */
274 template<class char_type, class super_class> 274 template<class char_type, class super_class>
275 class IIrrXMLReader : public super_class 275 class IIrrXMLReader : public super_class
276 { 276 {
277 public: 277 public:
278 278
279 //! Destructor 279 //! Destructor
280 virtual ~IIrrXMLReader() {} 280 virtual ~IIrrXMLReader() {}
281 281
282 //! Reads forward to the next xml node. 282 //! Reads forward to the next xml node.
283 /** \return Returns false, if there was no further node. */ 283 /** \return Returns false, if there was no further node. */
284 virtual bool read() = 0; 284 virtual bool read() = 0;
285 285
286 //! Returns the type of the current XML node. 286 //! Returns the type of the current XML node.
287 virtual EXML_NODE getNodeType() const = 0; 287 virtual EXML_NODE getNodeType() const = 0;
288 288
289 //! Returns attribute count of the current XML node. 289 //! Returns attribute count of the current XML node.
290 /** This is usually 290 /** This is usually
291 non null if the current node is EXN_ELEMENT, and the element has attributes. 291 non null if the current node is EXN_ELEMENT, and the element has attributes.
292 \return Returns amount of attributes of this xml node. */ 292 \return Returns amount of attributes of this xml node. */
293 virtual unsigned int getAttributeCount() const = 0; 293 virtual unsigned int getAttributeCount() const = 0;
294 294
295 //! Returns name of an attribute. 295 //! Returns name of an attribute.
296 /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1. 296 /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1.
297 \return Name of the attribute, 0 if an attribute with this index does not exist. */ 297 \return Name of the attribute, 0 if an attribute with this index does not exist. */
298 virtual const char_type* getAttributeName(int idx) const = 0; 298 virtual const char_type* getAttributeName(int idx) const = 0;
299 299
300 //! Returns the value of an attribute. 300 //! Returns the value of an attribute.
301 /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1. 301 /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1.
302 \return Value of the attribute, 0 if an attribute with this index does not exist. */ 302 \return Value of the attribute, 0 if an attribute with this index does not exist. */
303 virtual const char_type* getAttributeValue(int idx) const = 0; 303 virtual const char_type* getAttributeValue(int idx) const = 0;
304 304
305 //! Returns the value of an attribute. 305 //! Returns the value of an attribute.
306 /** \param name: Name of the attribute. 306 /** \param name: Name of the attribute.
307 \return Value of the attribute, 0 if an attribute with this name does not exist. */ 307 \return Value of the attribute, 0 if an attribute with this name does not exist. */
308 virtual const char_type* getAttributeValue(const char_type* name) const = 0; 308 virtual const char_type* getAttributeValue(const char_type* name) const = 0;
309 309
310 //! Returns the value of an attribute in a safe way. 310 //! Returns the value of an attribute in a safe way.
311 /** Like getAttributeValue(), but does not 311 /** Like getAttributeValue(), but does not
312 return 0 if the attribute does not exist. An empty string ("") is returned then. 312 return 0 if the attribute does not exist. An empty string ("") is returned then.
313 \param name: Name of the attribute. 313 \param name: Name of the attribute.
314 \return Value of the attribute, and "" if an attribute with this name does not exist */ 314 \return Value of the attribute, and "" if an attribute with this name does not exist */
315 virtual const char_type* getAttributeValueSafe(const char_type* name) const = 0; 315 virtual const char_type* getAttributeValueSafe(const char_type* name) const = 0;
316 316
317 //! Returns the value of an attribute as integer. 317 //! Returns the value of an attribute as integer.
318 /** \param name Name of the attribute. 318 /** \param name Name of the attribute.
319 \return Value of the attribute as integer, and 0 if an attribute with this name does not exist or 319 \return Value of the attribute as integer, and 0 if an attribute with this name does not exist or
320 the value could not be interpreted as integer. */ 320 the value could not be interpreted as integer. */
321 virtual int getAttributeValueAsInt(const char_type* name) const = 0; 321 virtual int getAttributeValueAsInt(const char_type* name) const = 0;
322 322
323 //! Returns the value of an attribute as integer. 323 //! Returns the value of an attribute as integer.
324 /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1. 324 /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1.
325 \return Value of the attribute as integer, and 0 if an attribute with this index does not exist or 325 \return Value of the attribute as integer, and 0 if an attribute with this index does not exist or
326 the value could not be interpreted as integer. */ 326 the value could not be interpreted as integer. */
327 virtual int getAttributeValueAsInt(int idx) const = 0; 327 virtual int getAttributeValueAsInt(int idx) const = 0;
328 328
329 //! Returns the value of an attribute as float. 329 //! Returns the value of an attribute as float.
330 /** \param name: Name of the attribute. 330 /** \param name: Name of the attribute.
331 \return Value of the attribute as float, and 0 if an attribute with this name does not exist or 331 \return Value of the attribute as float, and 0 if an attribute with this name does not exist or
332 the value could not be interpreted as float. */ 332 the value could not be interpreted as float. */
333 virtual float getAttributeValueAsFloat(const char_type* name) const = 0; 333 virtual float getAttributeValueAsFloat(const char_type* name) const = 0;
334 334
335 //! Returns the value of an attribute as float. 335 //! Returns the value of an attribute as float.
336 /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1. 336 /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1.
337 \return Value of the attribute as float, and 0 if an attribute with this index does not exist or 337 \return Value of the attribute as float, and 0 if an attribute with this index does not exist or
338 the value could not be interpreted as float. */ 338 the value could not be interpreted as float. */
339 virtual float getAttributeValueAsFloat(int idx) const = 0; 339 virtual float getAttributeValueAsFloat(int idx) const = 0;
340 340
341 //! Returns the name of the current node. 341 //! Returns the name of the current node.
342 /** Only valid, if the node type is EXN_ELEMENT. 342 /** Only valid, if the node type is EXN_ELEMENT.
343 \return Name of the current node or 0 if the node has no name. */ 343 \return Name of the current node or 0 if the node has no name. */
344 virtual const char_type* getNodeName() const = 0; 344 virtual const char_type* getNodeName() const = 0;
345 345
346 //! Returns data of the current node. 346 //! Returns data of the current node.
347 /** Only valid if the node has some 347 /** Only valid if the node has some
348 data and it is of type EXN_TEXT, EXN_COMMENT, EXN_CDATA or EXN_UNKNOWN. */ 348 data and it is of type EXN_TEXT, EXN_COMMENT, EXN_CDATA or EXN_UNKNOWN. */
349 virtual const char_type* getNodeData() const = 0; 349 virtual const char_type* getNodeData() const = 0;
350 350
351 //! Returns if an element is an empty element, like &lt;foo /> 351 //! Returns if an element is an empty element, like &lt;foo />
352 virtual bool isEmptyElement() const = 0; 352 virtual bool isEmptyElement() const = 0;
353 353
354 //! Returns format of the source xml file. 354 //! Returns format of the source xml file.
355 /** It is not necessary to use 355 /** It is not necessary to use
356 this method because the parser will convert the input file format 356 this method because the parser will convert the input file format
357 to the format wanted by the user when creating the parser. This 357 to the format wanted by the user when creating the parser. This
358 method is useful to get/display additional informations. */ 358 method is useful to get/display additional informations. */
359 virtual ETEXT_FORMAT getSourceFormat() const = 0; 359 virtual ETEXT_FORMAT getSourceFormat() const = 0;
360 360
361 //! Returns format of the strings returned by the parser. 361 //! Returns format of the strings returned by the parser.
362 /** This will be UTF8 for example when you created a parser with 362 /** This will be UTF8 for example when you created a parser with
363 IrrXMLReaderUTF8() and UTF32 when it has been created using 363 IrrXMLReaderUTF8() and UTF32 when it has been created using
364 IrrXMLReaderUTF32. It should not be necessary to call this 364 IrrXMLReaderUTF32. It should not be necessary to call this
365 method and only exists for informational purposes. */ 365 method and only exists for informational purposes. */
366 virtual ETEXT_FORMAT getParserFormat() const = 0; 366 virtual ETEXT_FORMAT getParserFormat() const = 0;
367 }; 367 };
368 368
369 369
370 template <typename T> 370 template <typename T>
371 struct xmlChar 371 struct xmlChar
372 { 372 {
373 T c; 373 T c;
374 xmlChar<T>() {} 374 xmlChar<T>() {}
375 xmlChar<T>(char in) : c(static_cast<T>(in)) {} 375 xmlChar<T>(char in) : c(static_cast<T>(in)) {}
376 xmlChar<T>(wchar_t in) : c(static_cast<T>(in)) {} 376 xmlChar<T>(wchar_t in) : c(static_cast<T>(in)) {}
377 explicit xmlChar<T>(unsigned char in) : c(static_cast<T>(in)) {} 377 explicit xmlChar<T>(unsigned char in) : c(static_cast<T>(in)) {}
378 explicit xmlChar<T>(unsigned short in) : c(static_cast<T>(in)) {} 378 explicit xmlChar<T>(unsigned short in) : c(static_cast<T>(in)) {}
379 explicit xmlChar<T>(unsigned int in) : c(static_cast<T>(in)) {} 379 explicit xmlChar<T>(unsigned int in) : c(static_cast<T>(in)) {}
380 explicit xmlChar<T>(unsigned long in) : c(static_cast<T>(in)) {} 380 explicit xmlChar<T>(unsigned long in) : c(static_cast<T>(in)) {}
381 operator T() const { return c; } 381 operator T() const { return c; }
382 void operator=(int t) { c=static_cast<T>(t); } 382 void operator=(int t) { c=static_cast<T>(t); }
383 }; 383 };
384 384
385 //! defines the utf-16 type. 385 //! defines the utf-16 type.
386 /** Not using wchar_t for this because 386 /** Not using wchar_t for this because
387 wchar_t has 16 bit on windows and 32 bit on other operating systems. */ 387 wchar_t has 16 bit on windows and 32 bit on other operating systems. */
388 typedef xmlChar<unsigned short> char16; 388 typedef xmlChar<unsigned short> char16;
389 389
390 //! defines the utf-32 type. 390 //! defines the utf-32 type.
391 /** Not using wchar_t for this because 391 /** Not using wchar_t for this because
392 wchar_t has 16 bit on windows and 32 bit on other operating systems. */ 392 wchar_t has 16 bit on windows and 32 bit on other operating systems. */
393 typedef xmlChar<unsigned int> char32; 393 typedef xmlChar<unsigned int> char32;
394 394
395 //! A UTF-8 or ASCII character xml parser. 395 //! A UTF-8 or ASCII character xml parser.
396 /** This means that all character data will be returned in 8 bit ASCII or UTF-8 by this parser. 396 /** This means that all character data will be returned in 8 bit ASCII or UTF-8 by this parser.
397 The file to read can be in any format, it will be converted to UTF-8 if it is not 397 The file to read can be in any format, it will be converted to UTF-8 if it is not
398 in this format. 398 in this format.
399 Create an instance of this with createIrrXMLReader(); 399 Create an instance of this with createIrrXMLReader();
400 See IIrrXMLReader for description on how to use it. */ 400 See IIrrXMLReader for description on how to use it. */
401 typedef IIrrXMLReader<char, IXMLBase> IrrXMLReader; 401 typedef IIrrXMLReader<char, IXMLBase> IrrXMLReader;
402 402
403 //! A UTF-16 xml parser. 403 //! A UTF-16 xml parser.
404 /** This means that all character data will be returned in UTF-16 by this parser. 404 /** This means that all character data will be returned in UTF-16 by this parser.
405 The file to read can be in any format, it will be converted to UTF-16 if it is not 405 The file to read can be in any format, it will be converted to UTF-16 if it is not
406 in this format. 406 in this format.
407 Create an instance of this with createIrrXMLReaderUTF16(); 407 Create an instance of this with createIrrXMLReaderUTF16();
408 See IIrrXMLReader for description on how to use it. */ 408 See IIrrXMLReader for description on how to use it. */
409 typedef IIrrXMLReader<char16, IXMLBase> IrrXMLReaderUTF16; 409 typedef IIrrXMLReader<char16, IXMLBase> IrrXMLReaderUTF16;
410 410
411 //! A UTF-32 xml parser. 411 //! A UTF-32 xml parser.
412 /** This means that all character data will be returned in UTF-32 by this parser. 412 /** This means that all character data will be returned in UTF-32 by this parser.
413 The file to read can be in any format, it will be converted to UTF-32 if it is not 413 The file to read can be in any format, it will be converted to UTF-32 if it is not
414 in this format. 414 in this format.
415 Create an instance of this with createIrrXMLReaderUTF32(); 415 Create an instance of this with createIrrXMLReaderUTF32();
416 See IIrrXMLReader for description on how to use it. */ 416 See IIrrXMLReader for description on how to use it. */
417 typedef IIrrXMLReader<char32, IXMLBase> IrrXMLReaderUTF32; 417 typedef IIrrXMLReader<char32, IXMLBase> IrrXMLReaderUTF32;
418 418
419 419
420 //! Creates an instance of an UFT-8 or ASCII character xml parser. 420 //! Creates an instance of an UFT-8 or ASCII character xml parser.
421 /** This means that all character data will be returned in 8 bit ASCII or UTF-8. 421 /** This means that all character data will be returned in 8 bit ASCII or UTF-8.
422 The file to read can be in any format, it will be converted to UTF-8 if it is not in this format. 422 The file to read can be in any format, it will be converted to UTF-8 if it is not in this format.
423 If you are using the Irrlicht Engine, it is better not to use this function but 423 If you are using the Irrlicht Engine, it is better not to use this function but
424 IFileSystem::createXMLReaderUTF8() instead. 424 IFileSystem::createXMLReaderUTF8() instead.
425 \param filename: Name of file to be opened. 425 \param filename: Name of file to be opened.
426 \return Returns a pointer to the created xml parser. This pointer should be 426 \return Returns a pointer to the created xml parser. This pointer should be
427 deleted using 'delete' after no longer needed. Returns 0 if an error occured 427 deleted using 'delete' after no longer needed. Returns 0 if an error occured
428 and the file could not be opened. */ 428 and the file could not be opened. */
429 IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(const char* filename); 429 IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(const char* filename);
430 430
431 //! Creates an instance of an UFT-8 or ASCII character xml parser. 431 //! Creates an instance of an UFT-8 or ASCII character xml parser.
432 /** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can 432 /** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can
433 be in any format, it will be converted to UTF-8 if it is not in this format. 433 be in any format, it will be converted to UTF-8 if it is not in this format.
434 If you are using the Irrlicht Engine, it is better not to use this function but 434 If you are using the Irrlicht Engine, it is better not to use this function but
435 IFileSystem::createXMLReaderUTF8() instead. 435 IFileSystem::createXMLReaderUTF8() instead.
436 \param file: Pointer to opened file, must have been opened in binary mode, e.g. 436 \param file: Pointer to opened file, must have been opened in binary mode, e.g.
437 using fopen("foo.bar", "wb"); The file will not be closed after it has been read. 437 using fopen("foo.bar", "wb"); The file will not be closed after it has been read.
438 \return Returns a pointer to the created xml parser. This pointer should be 438 \return Returns a pointer to the created xml parser. This pointer should be
439 deleted using 'delete' after no longer needed. Returns 0 if an error occured 439 deleted using 'delete' after no longer needed. Returns 0 if an error occured
440 and the file could not be opened. */ 440 and the file could not be opened. */
441 IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(FILE* file); 441 IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(FILE* file);
442 442
443 //! Creates an instance of an UFT-8 or ASCII character xml parser. 443 //! Creates an instance of an UFT-8 or ASCII character xml parser.
444 /** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can 444 /** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can
445 be in any format, it will be converted to UTF-8 if it is not in this format. 445 be in any format, it will be converted to UTF-8 if it is not in this format.
446 If you are using the Irrlicht Engine, it is better not to use this function but 446 If you are using the Irrlicht Engine, it is better not to use this function but
447 IFileSystem::createXMLReaderUTF8() instead. 447 IFileSystem::createXMLReaderUTF8() instead.
448 \param callback: Callback for file read abstraction. Implement your own 448 \param callback: Callback for file read abstraction. Implement your own
449 callback to make the xml parser read in other things than just files. See 449 callback to make the xml parser read in other things than just files. See
450 IFileReadCallBack for more information about this. 450 IFileReadCallBack for more information about this.
451 \param deleteCallback: if true, the callback will be deleted after the file 451 \param deleteCallback: if true, the callback will be deleted after the file
452 has been read. Otherwise the caller si responsible for cleaning it up. 452 has been read. Otherwise the caller si responsible for cleaning it up.
453 \return Returns a pointer to the created xml parser. This pointer should be 453 \return Returns a pointer to the created xml parser. This pointer should be
454 deleted using 'delete' after no longer needed. Returns 0 if an error occured 454 deleted using 'delete' after no longer needed. Returns 0 if an error occured
455 and the file could not be opened. */ 455 and the file could not be opened. */
456 IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(IFileReadCallBack* callback, 456 IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(IFileReadCallBack* callback,
457 bool deleteCallback = false); 457 bool deleteCallback = false);
458 458
459 //! Creates an instance of an UFT-16 xml parser. 459 //! Creates an instance of an UFT-16 xml parser.
460 /** This means that 460 /** This means that
461 all character data will be returned in UTF-16. The file to read can 461 all character data will be returned in UTF-16. The file to read can
462 be in any format, it will be converted to UTF-16 if it is not in this format. 462 be in any format, it will be converted to UTF-16 if it is not in this format.
463 If you are using the Irrlicht Engine, it is better not to use this function but 463 If you are using the Irrlicht Engine, it is better not to use this function but
464 IFileSystem::createXMLReader() instead. 464 IFileSystem::createXMLReader() instead.
465 \param filename: Name of file to be opened. 465 \param filename: Name of file to be opened.
466 \return Returns a pointer to the created xml parser. This pointer should be 466 \return Returns a pointer to the created xml parser. This pointer should be
467 deleted using 'delete' after no longer needed. Returns 0 if an error occured 467 deleted using 'delete' after no longer needed. Returns 0 if an error occured
468 and the file could not be opened. */ 468 and the file could not be opened. */
469 IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(const char* filename); 469 IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(const char* filename);
470 470
471 //! Creates an instance of an UFT-16 xml parser. 471 //! Creates an instance of an UFT-16 xml parser.
472 /** This means that all character data will be returned in UTF-16. The file to read can 472 /** This means that all character data will be returned in UTF-16. The file to read can
473 be in any format, it will be converted to UTF-16 if it is not in this format. 473 be in any format, it will be converted to UTF-16 if it is not in this format.
474 If you are using the Irrlicht Engine, it is better not to use this function but 474 If you are using the Irrlicht Engine, it is better not to use this function but
475 IFileSystem::createXMLReader() instead. 475 IFileSystem::createXMLReader() instead.
476 \param file: Pointer to opened file, must have been opened in binary mode, e.g. 476 \param file: Pointer to opened file, must have been opened in binary mode, e.g.
477 using fopen("foo.bar", "wb"); The file will not be closed after it has been read. 477 using fopen("foo.bar", "wb"); The file will not be closed after it has been read.
478 \return Returns a pointer to the created xml parser. This pointer should be 478 \return Returns a pointer to the created xml parser. This pointer should be
479 deleted using 'delete' after no longer needed. Returns 0 if an error occured 479 deleted using 'delete' after no longer needed. Returns 0 if an error occured
480 and the file could not be opened. */ 480 and the file could not be opened. */
481 IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(FILE* file); 481 IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(FILE* file);
482 482
483 //! Creates an instance of an UFT-16 xml parser. 483 //! Creates an instance of an UFT-16 xml parser.
484 /** This means that all character data will be returned in UTF-16. The file to read can 484 /** This means that all character data will be returned in UTF-16. The file to read can
485 be in any format, it will be converted to UTF-16 if it is not in this format. 485 be in any format, it will be converted to UTF-16 if it is not in this format.
486 If you are using the Irrlicht Engine, it is better not to use this function but 486 If you are using the Irrlicht Engine, it is better not to use this function but
487 IFileSystem::createXMLReader() instead. 487 IFileSystem::createXMLReader() instead.
488 \param callback: Callback for file read abstraction. Implement your own 488 \param callback: Callback for file read abstraction. Implement your own
489 callback to make the xml parser read in other things than just files. See 489 callback to make the xml parser read in other things than just files. See
490 IFileReadCallBack for more information about this. 490 IFileReadCallBack for more information about this.
491 \param deleteCallback: if true, the callback will be deleted after the file 491 \param deleteCallback: if true, the callback will be deleted after the file
492 has been read. Otherwise the caller si responsible for cleaning it up. 492 has been read. Otherwise the caller si responsible for cleaning it up.
493 \return Returns a pointer to the created xml parser. This pointer should be 493 \return Returns a pointer to the created xml parser. This pointer should be
494 deleted using 'delete' after no longer needed. Returns 0 if an error occured 494 deleted using 'delete' after no longer needed. Returns 0 if an error occured
495 and the file could not be opened. */ 495 and the file could not be opened. */
496 IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(IFileReadCallBack* callback, 496 IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(IFileReadCallBack* callback,
497 bool deleteCallback = false); 497 bool deleteCallback = false);
498 498
499 499
500 //! Creates an instance of an UFT-32 xml parser. 500 //! Creates an instance of an UFT-32 xml parser.
501 /** This means that all character data will be returned in UTF-32. The file to read can 501 /** This means that all character data will be returned in UTF-32. The file to read can
502 be in any format, it will be converted to UTF-32 if it is not in this format. 502 be in any format, it will be converted to UTF-32 if it is not in this format.
503 If you are using the Irrlicht Engine, it is better not to use this function but 503 If you are using the Irrlicht Engine, it is better not to use this function but
504 IFileSystem::createXMLReader() instead. 504 IFileSystem::createXMLReader() instead.
505 \param filename: Name of file to be opened. 505 \param filename: Name of file to be opened.
506 \return Returns a pointer to the created xml parser. This pointer should be 506 \return Returns a pointer to the created xml parser. This pointer should be
507 deleted using 'delete' after no longer needed. Returns 0 if an error occured 507 deleted using 'delete' after no longer needed. Returns 0 if an error occured
508 and the file could not be opened. */ 508 and the file could not be opened. */
509 IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(const char* filename); 509 IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(const char* filename);
510 510
511 //! Creates an instance of an UFT-32 xml parser. 511 //! Creates an instance of an UFT-32 xml parser.
512 /** This means that all character data will be returned in UTF-32. The file to read can 512 /** This means that all character data will be returned in UTF-32. The file to read can
513 be in any format, it will be converted to UTF-32 if it is not in this format. 513 be in any format, it will be converted to UTF-32 if it is not in this format.
514 if you are using the Irrlicht Engine, it is better not to use this function but 514 if you are using the Irrlicht Engine, it is better not to use this function but
515 IFileSystem::createXMLReader() instead. 515 IFileSystem::createXMLReader() instead.
516 \param file: Pointer to opened file, must have been opened in binary mode, e.g. 516 \param file: Pointer to opened file, must have been opened in binary mode, e.g.
517 using fopen("foo.bar", "wb"); The file will not be closed after it has been read. 517 using fopen("foo.bar", "wb"); The file will not be closed after it has been read.
518 \return Returns a pointer to the created xml parser. This pointer should be 518 \return Returns a pointer to the created xml parser. This pointer should be
519 deleted using 'delete' after no longer needed. Returns 0 if an error occured 519 deleted using 'delete' after no longer needed. Returns 0 if an error occured
520 and the file could not be opened. */ 520 and the file could not be opened. */
521 IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(FILE* file); 521 IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(FILE* file);
522 522
523 //! Creates an instance of an UFT-32 xml parser. 523 //! Creates an instance of an UFT-32 xml parser.
524 /** This means that 524 /** This means that
525 all character data will be returned in UTF-32. The file to read can 525 all character data will be returned in UTF-32. The file to read can
526 be in any format, it will be converted to UTF-32 if it is not in this format. 526 be in any format, it will be converted to UTF-32 if it is not in this format.
527 If you are using the Irrlicht Engine, it is better not to use this function but 527 If you are using the Irrlicht Engine, it is better not to use this function but
528 IFileSystem::createXMLReader() instead. 528 IFileSystem::createXMLReader() instead.
529 \param callback: Callback for file read abstraction. Implement your own 529 \param callback: Callback for file read abstraction. Implement your own
530 callback to make the xml parser read in other things than just files. See 530 callback to make the xml parser read in other things than just files. See
531 IFileReadCallBack for more information about this. 531 IFileReadCallBack for more information about this.
532 \param deleteCallback: if true, the callback will be deleted after the file 532 \param deleteCallback: if true, the callback will be deleted after the file
533 has been read. Otherwise the caller si responsible for cleaning it up. 533 has been read. Otherwise the caller si responsible for cleaning it up.
534 \return Returns a pointer to the created xml parser. This pointer should be 534 \return Returns a pointer to the created xml parser. This pointer should be
535 deleted using 'delete' after no longer needed. Returns 0 if an error occured 535 deleted using 'delete' after no longer needed. Returns 0 if an error occured
536 and the file could not be opened. */ 536 and the file could not be opened. */
537 IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(IFileReadCallBack* callback, 537 IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(IFileReadCallBack* callback,
538 bool deleteCallback = false); 538 bool deleteCallback = false);
539 539
540 540
541 /*! \file irrXML.h 541 /*! \file irrXML.h
542 \brief Header file of the irrXML, the Irrlicht XML parser. 542 \brief Header file of the irrXML, the Irrlicht XML parser.
543 543
544 This file includes everything needed for using irrXML, 544 This file includes everything needed for using irrXML,
545 the XML parser of the Irrlicht Engine. To use irrXML, 545 the XML parser of the Irrlicht Engine. To use irrXML,
546 you only need to include this file in your project: 546 you only need to include this file in your project:
547 547
548 \code 548 \code
549 #include <irrXML.h> 549 #include <irrXML.h>
550 \endcode 550 \endcode
551 551
552 It is also common to use the two namespaces in which irrXML is included, 552 It is also common to use the two namespaces in which irrXML is included,
553 directly after including irrXML.h: 553 directly after including irrXML.h:
554 554
555 \code 555 \code
556 #include <irrXML.h> 556 #include <irrXML.h>
557 using namespace irr; 557 using namespace irr;
558 using namespace io; 558 using namespace io;
559 \endcode 559 \endcode
560 */ 560 */
561 561
562} // end namespace io 562} // end namespace io
563} // end namespace irr 563} // end namespace irr
564 564
565#endif // __IRR_XML_H_INCLUDED__ 565#endif // __IRR_XML_H_INCLUDED__
566 566