~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to include/irrXML.h

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

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