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