1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
\r
2 // This file is part of the "Irrlicht Engine" and the "irrXML" project.
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h
\r
5 #ifndef __IRR_XML_H_INCLUDED__
\r
6 #define __IRR_XML_H_INCLUDED__
\r
9 #include "IrrCompileConfig.h"
\r
10 #include "irrArray.h"
\r
11 #include "irrString.h"
\r
13 /** \mainpage irrXML 1.2 API documentation
\r
14 <div align="center"><img src="logobig.png" ></div>
\r
16 \section intro Introduction
\r
18 Welcome to the irrXML API documentation.
\r
19 Here you'll find any information you'll need to develop applications with
\r
20 irrXML. If you look for a tutorial on how to start, take a look at the \ref irrxmlexample,
\r
21 at the homepage of irrXML at <A HREF="http://www.ambiera.com/irrxml/">www.ambiera.com/irrxml/</A>
\r
22 or into the SDK in the directory example.
\r
24 irrXML is intended to be a high speed and easy-to-use XML Parser for C++, and
\r
25 this documentation is an important part of it. If you have any questions or
\r
26 suggestions, just send a email to the author of the engine, Nikolaus Gebhardt
\r
27 (niko (at) irrlicht3d.org). For more information about this parser, see \ref history.
\r
29 \section features Features
\r
31 irrXML provides forward-only, read-only
\r
32 access to a stream of non validated XML data. It was fully implemented by
\r
33 Nikolaus Gebhardt. Its current features are:
\r
35 - It it fast as lighting and has very low memory usage. It was
\r
36 developed with the intention of being used in 3D games, as it already has been.
\r
37 - irrXML is very small: It only consists of 60 KB of code and can be added easily
\r
38 to your existing project.
\r
39 - Of course, it is platform independent and works with lots of compilers.
\r
40 - It is able to parse ASCII, UTF-8, UTF-16 and UTF-32 text files, both in
\r
41 little and big endian format.
\r
42 - Independent of the input file format, the parser can return all strings in ASCII, UTF-8,
\r
43 UTF-16 and UTF-32 format.
\r
44 - With its optional file access abstraction it has the advantage that it can read not
\r
45 only from files but from any type of data (memory, network, ...). For example when
\r
46 used with the Irrlicht Engine, it directly reads from compressed .zip files.
\r
47 - Just like the Irrlicht Engine for which it was originally created, it is extremely easy
\r
49 - It has no external dependencies, it does not even need the STL.
\r
51 Although irrXML has some strengths, it currently also has the following limitations:
\r
53 - The input xml file is not validated and assumed to be correct.
\r
55 \section irrxmlexample Example
\r
57 The following code demonstrates the basic usage of irrXML. A simple xml
\r
58 file like this is parsed:
\r
60 <?xml version="1.0"?>
\r
62 <!-- This is a config file for the mesh viewer -->
\r
63 <model file="dwarf.dea" />
\r
64 <messageText caption="Irrlicht Engine Mesh Viewer">
\r
65 Welcome to the Mesh Viewer of the "Irrlicht Engine".
\r
70 The code for parsing this file would look like this:
\r
73 using namespace irr; // irrXML is located in the namespace irr::io
\r
76 #include <string> // we use STL strings to store data in this example
\r
80 // create the reader using one of the factory functions
\r
82 IrrXMLReader* xml = createIrrXMLReader("config.xml");
\r
84 // strings for storing the data we want to get out of the file
\r
85 std::string modelFile;
\r
86 std::string messageText;
\r
87 std::string caption;
\r
89 // parse the file until end reached
\r
91 while(xml && xml->read())
\r
93 switch(xml->getNodeType())
\r
96 // in this xml file, the only text which occurs is the messageText
\r
97 messageText = xml->getNodeData();
\r
101 if (!strcmp("model", xml->getNodeName()))
\r
102 modelFile = xml->getAttributeValue("file");
\r
104 if (!strcmp("messageText", xml->getNodeName()))
\r
105 caption = xml->getAttributeValue("caption");
\r
111 // delete the xml parser after usage
\r
116 \section howto How to use
\r
118 Simply add the source files in the /src directory of irrXML to your project. Done.
\r
120 \section license License
\r
122 The irrXML license is based on the zlib license. Basically, this means you can do with
\r
123 irrXML whatever you want:
\r
125 Copyright (C) 2002-2012 Nikolaus Gebhardt
\r
127 This software is provided 'as-is', without any express or implied
\r
128 warranty. In no event will the authors be held liable for any damages
\r
129 arising from the use of this software.
\r
131 Permission is granted to anyone to use this software for any purpose,
\r
132 including commercial applications, and to alter it and redistribute it
\r
133 freely, subject to the following restrictions:
\r
135 1. The origin of this software must not be misrepresented; you must not
\r
136 claim that you wrote the original software. If you use this software
\r
137 in a product, an acknowledgment in the product documentation would be
\r
138 appreciated but is not required.
\r
140 2. Altered source versions must be plainly marked as such, and must not be
\r
141 misrepresented as being the original software.
\r
143 3. This notice may not be removed or altered from any source distribution.
\r
145 \section history History
\r
147 As lots of references in this documentation and the source show, this xml
\r
148 parser has originally been a part of the
\r
149 <A HREF="http://irrlicht.sourceforge.net" >Irrlicht Engine</A>. But because
\r
150 the parser has become very useful with the latest release, people asked for a
\r
151 separate version of it, to be able to use it in non Irrlicht projects. With
\r
152 irrXML 1.0, this has now been done.
\r
159 //! Enumeration of all supported source text file formats
\r
162 //! ASCII, file without byte order mark, or not a text file
\r
168 //! UTF-16 format, big endian
\r
171 //! UTF-16 format, little endian
\r
174 //! UTF-32 format, big endian
\r
177 //! UTF-32 format, little endian
\r
182 //! Enumeration for all xml nodes which are parsed by IrrXMLReader
\r
185 //! No xml node. This is usually the node if you did not read anything yet.
\r
188 //! An xml element such as <foo>
\r
191 //! End of an xml element such as </foo>
\r
194 //! Text within an xml element: <foo> this is the text. </foo>
\r
195 //! Also text between 2 xml elements: </foo> this is the text. <foo>
\r
198 //! An xml comment like <!-- I am a comment --> or a DTD definition.
\r
201 //! An xml cdata section like <![CDATA[ this is some CDATA ]]>
\r
204 //! Unknown element.
\r
208 //! Callback class for file read abstraction.
\r
209 /** With this, it is possible to make the xml parser read in other
\r
210 things than just files. The Irrlicht engine is using this for example to
\r
211 read xml from compressed .zip files. To make the parser read in
\r
212 any other data, derive a class from this interface, implement the
\r
213 two methods to read your data and give a pointer to an instance of
\r
214 your implementation when calling createIrrXMLReader(),
\r
215 createIrrXMLReaderUTF16() or createIrrXMLReaderUTF32() */
\r
216 class IFileReadCallBack
\r
221 virtual ~IFileReadCallBack() {}
\r
223 //! Reads an amount of bytes from the file.
\r
224 /** \param buffer: Pointer to buffer where to read bytes will be written to.
\r
225 \param sizeToRead: Amount of bytes to read from the file.
\r
226 \return Returns how much bytes were read. */
\r
227 virtual int read(void* buffer, int sizeToRead) = 0;
\r
229 //! Returns size of file in bytes on success or -1L on failure.
\r
230 virtual long getSize() const = 0;
\r
233 //! Empty class to be used as parent class for IrrXMLReader.
\r
234 /** If you need another class as base class for the xml reader, you can do this by creating
\r
235 the reader using for example new CXMLReaderImpl<char, YourBaseClass>(yourcallback);
\r
236 The Irrlicht Engine for example needs IReferenceCounted as base class for every object to
\r
237 let it automatically reference counted, hence it replaces IXMLBase with IReferenceCounted.
\r
238 See irrXML.cpp on how this can be done in detail. */
\r
243 //! Interface providing easy read access to a XML file.
\r
244 /** You can create an instance of this reader using one of the factory functions
\r
245 createIrrXMLReader(), createIrrXMLReaderUTF16() and createIrrXMLReaderUTF32().
\r
246 If using the parser from the Irrlicht Engine, please use IFileSystem::createXMLReader()
\r
248 For a detailed intro how to use the parser, see \ref irrxmlexample and \ref features.
\r
250 The typical usage of this parser looks like this:
\r
252 #include <irrXML.h>
\r
253 using namespace irr; // irrXML is located in the namespace irr::io
\r
254 using namespace io;
\r
258 // create the reader using one of the factory functions
\r
259 IrrXMLReader* xml = createIrrXMLReader("config.xml");
\r
262 return; // file could not be opened
\r
264 // parse the file until end reached
\r
267 // based on xml->getNodeType(), do something.
\r
270 // delete the xml parser after usage
\r
274 See \ref irrxmlexample for a more detailed example.
\r
276 template<class char_type, class super_class>
\r
277 class IIrrXMLReader : public super_class
\r
282 virtual ~IIrrXMLReader() {}
\r
284 //! Reads forward to the next xml node.
\r
285 /** \return Returns false, if there was no further node. */
\r
286 virtual bool read() = 0;
\r
288 //! Returns the type of the current XML node.
\r
289 virtual EXML_NODE getNodeType() const = 0;
\r
291 //! Returns attribute count of the current XML node.
\r
292 /** This is usually
\r
293 non null if the current node is EXN_ELEMENT, and the element has attributes.
\r
294 \return Returns amount of attributes of this xml node. */
\r
295 virtual unsigned int getAttributeCount() const = 0;
\r
297 //! Returns name of an attribute.
\r
298 /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1.
\r
299 \return Name of the attribute, 0 if an attribute with this index does not exist. */
\r
300 virtual const char_type* getAttributeName(int idx) const = 0;
\r
302 //! Returns the value of an attribute.
\r
303 /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1.
\r
304 \return Value of the attribute, 0 if an attribute with this index does not exist. */
\r
305 virtual const char_type* getAttributeValue(int idx) const = 0;
\r
307 //! Returns the value of an attribute.
\r
308 /** \param name: Name of the attribute.
\r
309 \return Value of the attribute, 0 if an attribute with this name does not exist. */
\r
310 virtual const char_type* getAttributeValue(const char_type* name) const = 0;
\r
312 //! Returns the value of an attribute in a safe way.
\r
313 /** Like getAttributeValue(), but does not
\r
314 return 0 if the attribute does not exist. An empty string ("") is returned then.
\r
315 \param name: Name of the attribute.
\r
316 \return Value of the attribute, and "" if an attribute with this name does not exist */
\r
317 virtual const char_type* getAttributeValueSafe(const char_type* name) const = 0;
\r
319 //! Returns the value of an attribute as integer.
\r
320 /** \param name Name of the attribute.
\r
321 \param defaultNotFound Value returned when name does not exist
\r
322 \return Value of the attribute as integer or value of defaultNotFound
\r
323 when name was not found or 0 when value could not be interpreted as integer */
\r
324 virtual int getAttributeValueAsInt(const char_type* name, int defaultNotFound=0) const = 0;
\r
326 //! Returns the value of an attribute as integer.
\r
327 /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1.
\r
328 \param defaultNotFound Value returned when index does not exist.
\r
329 \return Value of the attribute as integer or value of defaultNotFound parameter for invalid index
\r
330 or 0 when value could not be interpreted as integer */
\r
331 virtual int getAttributeValueAsInt(int idx, int defaultNotFound=0) const = 0;
\r
333 //! Returns the value of an attribute as float.
\r
334 /** \param name: Name of the attribute.
\r
335 \param defaultNotFound Value returned when name does not exist.
\r
336 \return Value of the attribute as float or value of defaultNotFound parameter on failure
\r
337 or 0 when value could not be interpreted as float. */
\r
338 virtual float getAttributeValueAsFloat(const char_type* name, float defaultNotFound=0.f) const = 0;
\r
340 //! Returns the value of an attribute as float.
\r
341 /** \param idx: Zero based index, should be something between 0 and getAttributeCount()-1.
\r
342 \param defaultNotFound Value returned when index does not exist.
\r
343 \return Value of the attribute as float or value of defaultNotFound parameter on failure
\r
344 or 0 when value could not be interpreted as float. */
\r
345 virtual float getAttributeValueAsFloat(int idx, float defaultNotFound=0.f) const = 0;
\r
347 //! Returns the name of the current node.
\r
348 /** Only valid, if the node type is EXN_ELEMENT.
\r
349 \return Name of the current node or 0 if the node has no name. */
\r
350 virtual const char_type* getNodeName() const = 0;
\r
352 //! Returns data of the current node.
\r
353 /** Only valid if the node has some
\r
354 data and it is of type EXN_TEXT, EXN_COMMENT, EXN_CDATA or EXN_UNKNOWN. */
\r
355 virtual const char_type* getNodeData() const = 0;
\r
357 //! Returns if an element is an empty element, like <foo />
\r
358 virtual bool isEmptyElement() const = 0;
\r
360 //! Returns format of the source xml file.
\r
361 /** It is not necessary to use
\r
362 this method because the parser will convert the input file format
\r
363 to the format wanted by the user when creating the parser. This
\r
364 method is useful to get/display additional information. */
\r
365 virtual ETEXT_FORMAT getSourceFormat() const = 0;
\r
367 //! Returns format of the strings returned by the parser.
\r
368 /** This will be UTF8 for example when you created a parser with
\r
369 IrrXMLReaderUTF8() and UTF32 when it has been created using
\r
370 IrrXMLReaderUTF32. It should not be necessary to call this
\r
371 method and only exists for informational purposes. */
\r
372 virtual ETEXT_FORMAT getParserFormat() const = 0;
\r
375 //! Interface providing methods for making it easier to write XML files.
\r
376 template<class char_type, class super_class>
\r
377 class IIrrXMLWriter : public super_class
\r
382 virtual ~IIrrXMLWriter() {}
\r
384 //! Writes an xml 1.0 header.
\r
385 /** Looks like <?xml version="1.0"?>. This should always
\r
386 be called before writing anything other, because also the text
\r
387 file header for Unicode texts is written out with this method. */
\r
388 virtual void writeXMLHeader() = 0;
\r
390 //! Writes an xml element with maximal 5 attributes like "<foo />" or
\r
391 //! <foo optAttr="value" />.
\r
392 /** The element can be empty or not.
\r
393 \param name: Name of the element
\r
394 \param empty: Specifies if the element should be empty. Like
\r
395 "<foo />". If You set this to false, something like this is
\r
396 written instead: "<foo>".
\r
397 \param attr1Name: 1st attributes name
\r
398 \param attr1Value: 1st attributes value
\r
399 \param attr2Name: 2nd attributes name
\r
400 \param attr2Value: 2nd attributes value
\r
401 \param attr3Name: 3rd attributes name
\r
402 \param attr3Value: 3rd attributes value
\r
403 \param attr4Name: 4th attributes name
\r
404 \param attr4Value: 4th attributes value
\r
405 \param attr5Name: 5th attributes name
\r
406 \param attr5Value: 5th attributes value */
\r
407 virtual void writeElement(const char_type* name, bool empty=false,
\r
408 const char_type* attr1Name = 0, const char_type* attr1Value = 0,
\r
409 const char_type* attr2Name = 0, const char_type* attr2Value = 0,
\r
410 const char_type* attr3Name = 0, const char_type* attr3Value = 0,
\r
411 const char_type* attr4Name = 0, const char_type* attr4Value = 0,
\r
412 const char_type* attr5Name = 0, const char_type* attr5Value = 0) = 0;
\r
414 //! Writes an xml element with any number of attributes
\r
415 virtual void writeElement(const char_type* name, bool empty,
\r
416 core::array<core::string<char_type> > &names, core::array<core::string<char_type> > &values) = 0;
\r
418 //! Writes a comment into the xml file
\r
419 virtual void writeComment(const char_type* comment) = 0;
\r
421 //! Writes the closing tag for an element. Like "</foo>"
\r
422 virtual void writeClosingTag(const char_type* name) = 0;
\r
424 //! Writes a text into the file.
\r
425 /** All occurrences of special characters such as
\r
426 & (&), < (<), > (>), and " (") are automatically
\r
428 virtual void writeText(const char_type* text) = 0;
\r
430 //! Writes a line break
\r
431 virtual void writeLineBreak() = 0;
\r
435 template <typename T>
\r
440 xmlChar<T>(char in) : c(static_cast<T>(in)) {}
\r
441 xmlChar<T>(wchar_t in) : c(static_cast<T>(in)) {}
\r
442 #if defined(__BORLANDC__)
\r
443 // Note - removing explicit for Borland was to get it to even compile.
\r
444 // There haven't been any kind of tests for that besides that.
\r
445 xmlChar<T>(unsigned char in) : c(static_cast<T>(in)) {}
\r
446 xmlChar<T>(unsigned short in) : c(static_cast<T>(in)) {}
\r
447 xmlChar<T>(unsigned int in) : c(static_cast<T>(in)) {}
\r
448 xmlChar<T>(unsigned long in) : c(static_cast<T>(in)) {}
\r
450 explicit xmlChar<T>(unsigned char in) : c(static_cast<T>(in)) {}
\r
452 #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED) // VS compiling without native wchar_t can't have it
\r
453 explicit xmlChar<T>(unsigned short in) : c(static_cast<T>(in)) {}
\r
455 explicit xmlChar<T>(unsigned int in) : c(static_cast<T>(in)) {}
\r
456 explicit xmlChar<T>(unsigned long in) : c(static_cast<T>(in)) {}
\r
458 operator T() const { return c; }
\r
459 void operator=(int t) { c=static_cast<T>(t); }
\r
462 //! defines the utf-16 type.
\r
463 /** Not using wchar_t for this because
\r
464 wchar_t has 16 bit on windows and 32 bit on other operating systems. */
\r
465 typedef xmlChar<unsigned short> char16;
\r
467 //! defines the utf-32 type.
\r
468 /** Not using wchar_t for this because
\r
469 wchar_t has 16 bit on windows and 32 bit on other operating systems. */
\r
470 typedef xmlChar<unsigned int> char32;
\r
472 //! A UTF-8 or ASCII character xml parser.
\r
473 /** This means that all character data will be returned in 8 bit ASCII or UTF-8 by this parser.
\r
474 The file to read can be in any format, it will be converted to UTF-8 if it is not
\r
476 Create an instance of this with createIrrXMLReader();
\r
477 See IIrrXMLReader for description on how to use it. */
\r
478 typedef IIrrXMLReader<char, IXMLBase> IrrXMLReader;
\r
480 //! A UTF-16 xml parser.
\r
481 /** This means that all character data will be returned in UTF-16 by this parser.
\r
482 The file to read can be in any format, it will be converted to UTF-16 if it is not
\r
484 Create an instance of this with createIrrXMLReaderUTF16();
\r
485 See IIrrXMLReader for description on how to use it. */
\r
486 typedef IIrrXMLReader<char16, IXMLBase> IrrXMLReaderUTF16;
\r
488 //! A UTF-32 xml parser.
\r
489 /** This means that all character data will be returned in UTF-32 by this parser.
\r
490 The file to read can be in any format, it will be converted to UTF-32 if it is not
\r
492 Create an instance of this with createIrrXMLReaderUTF32();
\r
493 See IIrrXMLReader for description on how to use it. */
\r
494 typedef IIrrXMLReader<char32, IXMLBase> IrrXMLReaderUTF32;
\r
496 #ifdef _IRR_COMPILE_WITH_XML_
\r
498 //! Creates an instance of an UFT-8 or ASCII character xml parser.
\r
499 /** This means that all character data will be returned in 8 bit ASCII or UTF-8.
\r
500 The file to read can be in any format, it will be converted to UTF-8 if it is not in this format.
\r
501 If you are using the Irrlicht Engine, it is better not to use this function but
\r
502 IFileSystem::createXMLReaderUTF8() instead.
\r
503 \param filename: Name of file to be opened.
\r
504 \return Returns a pointer to the created xml parser. This pointer should be
\r
505 deleted using 'delete' after no longer needed. Returns 0 if an error occurred
\r
506 and the file could not be opened. */
\r
507 IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(const char* filename);
\r
509 //! Creates an instance of an UFT-8 or ASCII character xml parser.
\r
510 /** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can
\r
511 be in any format, it will be converted to UTF-8 if it is not in this format.
\r
512 If you are using the Irrlicht Engine, it is better not to use this function but
\r
513 IFileSystem::createXMLReaderUTF8() instead.
\r
514 \param file: Pointer to opened file, must have been opened in binary mode, e.g.
\r
515 using fopen("foo.bar", "wb"); The file will not be closed after it has been read.
\r
516 \return Returns a pointer to the created xml parser. This pointer should be
\r
517 deleted using 'delete' after no longer needed. Returns 0 if an error occurred
\r
518 and the file could not be opened. */
\r
519 IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(FILE* file);
\r
521 //! Creates an instance of an UFT-8 or ASCII character xml parser.
\r
522 /** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can
\r
523 be in any format, it will be converted to UTF-8 if it is not in this format.
\r
524 If you are using the Irrlicht Engine, it is better not to use this function but
\r
525 IFileSystem::createXMLReaderUTF8() instead.
\r
526 \param callback: Callback for file read abstraction. Implement your own
\r
527 callback to make the xml parser read in other things than just files. See
\r
528 IFileReadCallBack for more information about this.
\r
529 \param deleteCallback: if true, the callback will be deleted after the file
\r
530 has been read. Otherwise the caller is responsible for cleaning it up.
\r
531 \return Returns a pointer to the created xml parser. This pointer should be
\r
532 deleted using 'delete' after no longer needed. Returns 0 if an error occurred
\r
533 and the file could not be opened. */
\r
534 IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(IFileReadCallBack* callback,
\r
535 bool deleteCallback = false);
\r
537 //! Creates an instance of an UFT-16 xml parser.
\r
538 /** This means that
\r
539 all character data will be returned in UTF-16. The file to read can
\r
540 be in any format, it will be converted to UTF-16 if it is not in this format.
\r
541 If you are using the Irrlicht Engine, it is better not to use this function but
\r
542 IFileSystem::createXMLReader() instead.
\r
543 \param filename: Name of file to be opened.
\r
544 \return Returns a pointer to the created xml parser. This pointer should be
\r
545 deleted using 'delete' after no longer needed. Returns 0 if an error occurred
\r
546 and the file could not be opened. */
\r
547 IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(const char* filename);
\r
549 //! Creates an instance of an UFT-16 xml parser.
\r
550 /** This means that all character data will be returned in UTF-16. The file to read can
\r
551 be in any format, it will be converted to UTF-16 if it is not in this format.
\r
552 If you are using the Irrlicht Engine, it is better not to use this function but
\r
553 IFileSystem::createXMLReader() instead.
\r
554 \param file: Pointer to opened file, must have been opened in binary mode, e.g.
\r
555 using fopen("foo.bar", "wb"); The file will not be closed after it has been read.
\r
556 \return Returns a pointer to the created xml parser. This pointer should be
\r
557 deleted using 'delete' after no longer needed. Returns 0 if an error occurred
\r
558 and the file could not be opened. */
\r
559 IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(FILE* file);
\r
561 //! Creates an instance of an UFT-16 xml parser.
\r
562 /** This means that all character data will be returned in UTF-16. The file to read can
\r
563 be in any format, it will be converted to UTF-16 if it is not in this format.
\r
564 If you are using the Irrlicht Engine, it is better not to use this function but
\r
565 IFileSystem::createXMLReader() instead.
\r
566 \param callback: Callback for file read abstraction. Implement your own
\r
567 callback to make the xml parser read in other things than just files. See
\r
568 IFileReadCallBack for more information about this.
\r
569 \param deleteCallback: if true, the callback will be deleted after the file
\r
570 has been read. Otherwise the caller is responsible for cleaning it up.
\r
571 \return Returns a pointer to the created xml parser. This pointer should be
\r
572 deleted using 'delete' after no longer needed. Returns 0 if an error occurred
\r
573 and the file could not be opened. */
\r
574 IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(IFileReadCallBack* callback,
\r
575 bool deleteCallback = false);
\r
578 //! Creates an instance of an UFT-32 xml parser.
\r
579 /** This means that all character data will be returned in UTF-32. The file to read can
\r
580 be in any format, it will be converted to UTF-32 if it is not in this format.
\r
581 If you are using the Irrlicht Engine, it is better not to use this function but
\r
582 IFileSystem::createXMLReader() instead.
\r
583 \param filename: Name of file to be opened.
\r
584 \return Returns a pointer to the created xml parser. This pointer should be
\r
585 deleted using 'delete' after no longer needed. Returns 0 if an error occurred
\r
586 and the file could not be opened. */
\r
587 IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(const char* filename);
\r
589 //! Creates an instance of an UFT-32 xml parser.
\r
590 /** This means that all character data will be returned in UTF-32. The file to read can
\r
591 be in any format, it will be converted to UTF-32 if it is not in this format.
\r
592 if you are using the Irrlicht Engine, it is better not to use this function but
\r
593 IFileSystem::createXMLReader() instead.
\r
594 \param file: Pointer to opened file, must have been opened in binary mode, e.g.
\r
595 using fopen("foo.bar", "wb"); The file will not be closed after it has been read.
\r
596 \return Returns a pointer to the created xml parser. This pointer should be
\r
597 deleted using 'delete' after no longer needed. Returns 0 if an error occurred
\r
598 and the file could not be opened. */
\r
599 IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(FILE* file);
\r
601 //! Creates an instance of an UFT-32 xml parser.
\r
602 /** This means that
\r
603 all character data will be returned in UTF-32. The file to read can
\r
604 be in any format, it will be converted to UTF-32 if it is not in this format.
\r
605 If you are using the Irrlicht Engine, it is better not to use this function but
\r
606 IFileSystem::createXMLReader() instead.
\r
607 \param callback: Callback for file read abstraction. Implement your own
\r
608 callback to make the xml parser read in other things than just files. See
\r
609 IFileReadCallBack for more information about this.
\r
610 \param deleteCallback: if true, the callback will be deleted after the file
\r
611 has been read. Otherwise the caller is responsible for cleaning it up.
\r
612 \return Returns a pointer to the created xml parser. This pointer should be
\r
613 deleted using 'delete' after no longer needed. Returns 0 if an error occurred
\r
614 and the file could not be opened. */
\r
615 IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(IFileReadCallBack* callback,
\r
616 bool deleteCallback = false);
\r
618 #endif // _IRR_COMPILE_WITH_XML_
\r
621 \brief Header file of the irrXML, the Irrlicht XML parser.
\r
623 This file includes everything needed for using irrXML,
\r
624 the XML parser of the Irrlicht Engine. To use irrXML,
\r
625 you only need to include this file in your project:
\r
628 #include <irrXML.h>
\r
631 It is also common to use the two namespaces in which irrXML is included,
\r
632 directly after including irrXML.h:
\r
635 #include <irrXML.h>
\r
636 using namespace irr;
\r
637 using namespace io;
\r
641 } // end namespace io
\r
642 } // end namespace irr
\r
644 #endif // __IRR_XML_H_INCLUDED__
\r