diff options
Diffstat (limited to 'libraries/irrlicht-1.8.1/include/irrXML.h')
-rw-r--r-- | libraries/irrlicht-1.8.1/include/irrXML.h | 575 |
1 files changed, 575 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8.1/include/irrXML.h b/libraries/irrlicht-1.8.1/include/irrXML.h new file mode 100644 index 0000000..dd55b1a --- /dev/null +++ b/libraries/irrlicht-1.8.1/include/irrXML.h | |||
@@ -0,0 +1,575 @@ | |||
1 | // Copyright (C) 2002-2012 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 "Irrlicht Engine". | ||
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-2012 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 <foo> | ||
187 | EXN_ELEMENT, | ||
188 | |||
189 | //! End of an xml element such as </foo> | ||
190 | EXN_ELEMENT_END, | ||
191 | |||
192 | //! Text within an xml element: <foo> this is the text. </foo> | ||
193 | //! Also text between 2 xml elements: </foo> this is the text. <foo> | ||
194 | EXN_TEXT, | ||
195 | |||
196 | //! An xml comment like <!-- I am a comment --> or a DTD definition. | ||
197 | EXN_COMMENT, | ||
198 | |||
199 | //! An xml cdata section like <![CDATA[ this is some CDATA ]]> | ||
200 | EXN_CDATA, | ||
201 | |||
202 | //! Unknown element. | ||
203 | EXN_UNKNOWN | ||
204 | }; | ||
205 | |||
206 | //! Callback class for file read abstraction. | ||
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 | ||
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 | ||
211 | two methods to read your data and give a pointer to an instance of | ||
212 | your implementation when calling createIrrXMLReader(), | ||
213 | createIrrXMLReaderUTF16() or createIrrXMLReaderUTF32() */ | ||
214 | class IFileReadCallBack | ||
215 | { | ||
216 | public: | ||
217 | |||
218 | //! Destructor | ||
219 | virtual ~IFileReadCallBack() {} | ||
220 | |||
221 | //! Reads an amount of bytes from the file. | ||
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. | ||
224 | \return Returns how much bytes were read. */ | ||
225 | virtual int read(void* buffer, int sizeToRead) = 0; | ||
226 | |||
227 | //! Returns size of file in bytes | ||
228 | virtual long getSize() const = 0; | ||
229 | }; | ||
230 | |||
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 | ||
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 | ||
235 | let it automaticly reference countend, hence it replaces IXMLBase with IReferenceCounted. | ||
236 | See irrXML.cpp on how this can be done in detail. */ | ||
237 | class IXMLBase | ||
238 | { | ||
239 | }; | ||
240 | |||
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 | ||
243 | createIrrXMLReader(), createIrrXMLReaderUTF16() and createIrrXMLReaderUTF32(). | ||
244 | If using the parser from the Irrlicht Engine, please use IFileSystem::createXMLReader() | ||
245 | instead. | ||
246 | For a detailed intro how to use the parser, see \ref irrxmlexample and \ref features. | ||
247 | |||
248 | The typical usage of this parser looks like this: | ||
249 | \code | ||
250 | #include <irrXML.h> | ||
251 | using namespace irr; // irrXML is located in the namespace irr::io | ||
252 | using namespace io; | ||
253 | |||
254 | void main() | ||
255 | { | ||
256 | // create the reader using one of the factory functions | ||
257 | IrrXMLReader* xml = createIrrXMLReader("config.xml"); | ||
258 | |||
259 | if (xml == 0) | ||
260 | return; // file could not be opened | ||
261 | |||
262 | // parse the file until end reached | ||
263 | while(xml->read()) | ||
264 | { | ||
265 | // based on xml->getNodeType(), do something. | ||
266 | } | ||
267 | |||
268 | // delete the xml parser after usage | ||
269 | delete xml; | ||
270 | } | ||
271 | \endcode | ||
272 | See \ref irrxmlexample for a more detailed example. | ||
273 | */ | ||
274 | template<class char_type, class super_class> | ||
275 | class IIrrXMLReader : public super_class | ||
276 | { | ||
277 | public: | ||
278 | |||
279 | //! Destructor | ||
280 | virtual ~IIrrXMLReader() {} | ||
281 | |||
282 | //! Reads forward to the next xml node. | ||
283 | /** \return Returns false, if there was no further node. */ | ||
284 | virtual bool read() = 0; | ||
285 | |||
286 | //! Returns the type of the current XML node. | ||
287 | virtual EXML_NODE getNodeType() const = 0; | ||
288 | |||
289 | //! Returns attribute count of the current XML node. | ||
290 | /** This is usually | ||
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. */ | ||
293 | virtual unsigned int getAttributeCount() const = 0; | ||
294 | |||
295 | //! Returns name of an attribute. | ||
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. */ | ||
298 | virtual const char_type* getAttributeName(int idx) const = 0; | ||
299 | |||
300 | //! Returns the value of an attribute. | ||
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. */ | ||
303 | virtual const char_type* getAttributeValue(int idx) const = 0; | ||
304 | |||
305 | //! Returns the value of an attribute. | ||
306 | /** \param name: Name of the attribute. | ||
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; | ||
309 | |||
310 | //! Returns the value of an attribute in a safe way. | ||
311 | /** Like getAttributeValue(), but does not | ||
312 | return 0 if the attribute does not exist. An empty string ("") is returned then. | ||
313 | \param name: Name of the attribute. | ||
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; | ||
316 | |||
317 | //! Returns the value of an attribute as integer. | ||
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 | ||
320 | the value could not be interpreted as integer. */ | ||
321 | virtual int getAttributeValueAsInt(const char_type* name) const = 0; | ||
322 | |||
323 | //! Returns the value of an attribute as integer. | ||
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 | ||
326 | the value could not be interpreted as integer. */ | ||
327 | virtual int getAttributeValueAsInt(int idx) const = 0; | ||
328 | |||
329 | //! Returns the value of an attribute as float. | ||
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 | ||
332 | the value could not be interpreted as float. */ | ||
333 | virtual float getAttributeValueAsFloat(const char_type* name) const = 0; | ||
334 | |||
335 | //! Returns the value of an attribute as float. | ||
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 | ||
338 | the value could not be interpreted as float. */ | ||
339 | virtual float getAttributeValueAsFloat(int idx) const = 0; | ||
340 | |||
341 | //! Returns the name of the current node. | ||
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. */ | ||
344 | virtual const char_type* getNodeName() const = 0; | ||
345 | |||
346 | //! Returns data of the current node. | ||
347 | /** Only valid if the node has some | ||
348 | data and it is of type EXN_TEXT, EXN_COMMENT, EXN_CDATA or EXN_UNKNOWN. */ | ||
349 | virtual const char_type* getNodeData() const = 0; | ||
350 | |||
351 | //! Returns if an element is an empty element, like <foo /> | ||
352 | virtual bool isEmptyElement() const = 0; | ||
353 | |||
354 | //! Returns format of the source xml file. | ||
355 | /** It is not necessary to use | ||
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 | ||
358 | method is useful to get/display additional informations. */ | ||
359 | virtual ETEXT_FORMAT getSourceFormat() const = 0; | ||
360 | |||
361 | //! Returns format of the strings returned by the parser. | ||
362 | /** This will be UTF8 for example when you created a parser with | ||
363 | IrrXMLReaderUTF8() and UTF32 when it has been created using | ||
364 | IrrXMLReaderUTF32. It should not be necessary to call this | ||
365 | method and only exists for informational purposes. */ | ||
366 | virtual ETEXT_FORMAT getParserFormat() const = 0; | ||
367 | }; | ||
368 | |||
369 | |||
370 | template <typename T> | ||
371 | struct xmlChar | ||
372 | { | ||
373 | T c; | ||
374 | xmlChar<T>() {} | ||
375 | xmlChar<T>(char in) : c(static_cast<T>(in)) {} | ||
376 | xmlChar<T>(wchar_t in) : c(static_cast<T>(in)) {} | ||
377 | #if defined(__BORLANDC__) | ||
378 | // Note - removing explicit for borland was to get it to even compile. | ||
379 | // There haven't been any kind of tests for that besides that. | ||
380 | xmlChar<T>(unsigned char in) : c(static_cast<T>(in)) {} | ||
381 | xmlChar<T>(unsigned short in) : c(static_cast<T>(in)) {} | ||
382 | xmlChar<T>(unsigned int in) : c(static_cast<T>(in)) {} | ||
383 | xmlChar<T>(unsigned long in) : c(static_cast<T>(in)) {} | ||
384 | #else | ||
385 | explicit xmlChar<T>(unsigned char in) : c(static_cast<T>(in)) {} | ||
386 | explicit xmlChar<T>(unsigned short in) : c(static_cast<T>(in)) {} | ||
387 | explicit xmlChar<T>(unsigned int in) : c(static_cast<T>(in)) {} | ||
388 | explicit xmlChar<T>(unsigned long in) : c(static_cast<T>(in)) {} | ||
389 | #endif | ||
390 | operator T() const { return c; } | ||
391 | void operator=(int t) { c=static_cast<T>(t); } | ||
392 | }; | ||
393 | |||
394 | //! defines the utf-16 type. | ||
395 | /** Not using wchar_t for this because | ||
396 | wchar_t has 16 bit on windows and 32 bit on other operating systems. */ | ||
397 | typedef xmlChar<unsigned short> char16; | ||
398 | |||
399 | //! defines the utf-32 type. | ||
400 | /** Not using wchar_t for this because | ||
401 | wchar_t has 16 bit on windows and 32 bit on other operating systems. */ | ||
402 | typedef xmlChar<unsigned int> char32; | ||
403 | |||
404 | //! A UTF-8 or ASCII character xml parser. | ||
405 | /** This means that all character data will be returned in 8 bit ASCII or UTF-8 by this parser. | ||
406 | The file to read can be in any format, it will be converted to UTF-8 if it is not | ||
407 | in this format. | ||
408 | Create an instance of this with createIrrXMLReader(); | ||
409 | See IIrrXMLReader for description on how to use it. */ | ||
410 | typedef IIrrXMLReader<char, IXMLBase> IrrXMLReader; | ||
411 | |||
412 | //! A UTF-16 xml parser. | ||
413 | /** This means that all character data will be returned in UTF-16 by this parser. | ||
414 | The file to read can be in any format, it will be converted to UTF-16 if it is not | ||
415 | in this format. | ||
416 | Create an instance of this with createIrrXMLReaderUTF16(); | ||
417 | See IIrrXMLReader for description on how to use it. */ | ||
418 | typedef IIrrXMLReader<char16, IXMLBase> IrrXMLReaderUTF16; | ||
419 | |||
420 | //! A UTF-32 xml parser. | ||
421 | /** This means that all character data will be returned in UTF-32 by this parser. | ||
422 | The file to read can be in any format, it will be converted to UTF-32 if it is not | ||
423 | in this format. | ||
424 | Create an instance of this with createIrrXMLReaderUTF32(); | ||
425 | See IIrrXMLReader for description on how to use it. */ | ||
426 | typedef IIrrXMLReader<char32, IXMLBase> IrrXMLReaderUTF32; | ||
427 | |||
428 | |||
429 | //! Creates an instance of an UFT-8 or ASCII character xml parser. | ||
430 | /** This means that all character data will be returned in 8 bit ASCII or UTF-8. | ||
431 | The file to read can be in any format, it will be converted to UTF-8 if it is not in this format. | ||
432 | If you are using the Irrlicht Engine, it is better not to use this function but | ||
433 | IFileSystem::createXMLReaderUTF8() instead. | ||
434 | \param filename: Name of file to be opened. | ||
435 | \return Returns a pointer to the created xml parser. This pointer should be | ||
436 | deleted using 'delete' after no longer needed. Returns 0 if an error occured | ||
437 | and the file could not be opened. */ | ||
438 | IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(const char* filename); | ||
439 | |||
440 | //! Creates an instance of an UFT-8 or ASCII character xml parser. | ||
441 | /** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can | ||
442 | be in any format, it will be converted to UTF-8 if it is not in this format. | ||
443 | If you are using the Irrlicht Engine, it is better not to use this function but | ||
444 | IFileSystem::createXMLReaderUTF8() instead. | ||
445 | \param file: Pointer to opened file, must have been opened in binary mode, e.g. | ||
446 | using fopen("foo.bar", "wb"); The file will not be closed after it has been read. | ||
447 | \return Returns a pointer to the created xml parser. This pointer should be | ||
448 | deleted using 'delete' after no longer needed. Returns 0 if an error occured | ||
449 | and the file could not be opened. */ | ||
450 | IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(FILE* file); | ||
451 | |||
452 | //! Creates an instance of an UFT-8 or ASCII character xml parser. | ||
453 | /** This means that all character data will be returned in 8 bit ASCII or UTF-8. The file to read can | ||
454 | be in any format, it will be converted to UTF-8 if it is not in this format. | ||
455 | If you are using the Irrlicht Engine, it is better not to use this function but | ||
456 | IFileSystem::createXMLReaderUTF8() instead. | ||
457 | \param callback: Callback for file read abstraction. Implement your own | ||
458 | callback to make the xml parser read in other things than just files. See | ||
459 | IFileReadCallBack for more information about this. | ||
460 | \param deleteCallback: if true, the callback will be deleted after the file | ||
461 | has been read. Otherwise the caller si responsible for cleaning it up. | ||
462 | \return Returns a pointer to the created xml parser. This pointer should be | ||
463 | deleted using 'delete' after no longer needed. Returns 0 if an error occured | ||
464 | and the file could not be opened. */ | ||
465 | IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(IFileReadCallBack* callback, | ||
466 | bool deleteCallback = false); | ||
467 | |||
468 | //! Creates an instance of an UFT-16 xml parser. | ||
469 | /** This means that | ||
470 | all character data will be returned in UTF-16. The file to read can | ||
471 | be in any format, it will be converted to UTF-16 if it is not in this format. | ||
472 | If you are using the Irrlicht Engine, it is better not to use this function but | ||
473 | IFileSystem::createXMLReader() instead. | ||
474 | \param filename: Name of file to be opened. | ||
475 | \return Returns a pointer to the created xml parser. This pointer should be | ||
476 | deleted using 'delete' after no longer needed. Returns 0 if an error occured | ||
477 | and the file could not be opened. */ | ||
478 | IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(const char* filename); | ||
479 | |||
480 | //! Creates an instance of an UFT-16 xml parser. | ||
481 | /** This means that all character data will be returned in UTF-16. The file to read can | ||
482 | be in any format, it will be converted to UTF-16 if it is not in this format. | ||
483 | If you are using the Irrlicht Engine, it is better not to use this function but | ||
484 | IFileSystem::createXMLReader() instead. | ||
485 | \param file: Pointer to opened file, must have been opened in binary mode, e.g. | ||
486 | using fopen("foo.bar", "wb"); The file will not be closed after it has been read. | ||
487 | \return Returns a pointer to the created xml parser. This pointer should be | ||
488 | deleted using 'delete' after no longer needed. Returns 0 if an error occured | ||
489 | and the file could not be opened. */ | ||
490 | IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(FILE* file); | ||
491 | |||
492 | //! Creates an instance of an UFT-16 xml parser. | ||
493 | /** This means that all character data will be returned in UTF-16. The file to read can | ||
494 | be in any format, it will be converted to UTF-16 if it is not in this format. | ||
495 | If you are using the Irrlicht Engine, it is better not to use this function but | ||
496 | IFileSystem::createXMLReader() instead. | ||
497 | \param callback: Callback for file read abstraction. Implement your own | ||
498 | callback to make the xml parser read in other things than just files. See | ||
499 | IFileReadCallBack for more information about this. | ||
500 | \param deleteCallback: if true, the callback will be deleted after the file | ||
501 | has been read. Otherwise the caller si responsible for cleaning it up. | ||
502 | \return Returns a pointer to the created xml parser. This pointer should be | ||
503 | deleted using 'delete' after no longer needed. Returns 0 if an error occured | ||
504 | and the file could not be opened. */ | ||
505 | IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(IFileReadCallBack* callback, | ||
506 | bool deleteCallback = false); | ||
507 | |||
508 | |||
509 | //! Creates an instance of an UFT-32 xml parser. | ||
510 | /** This means that all character data will be returned in UTF-32. The file to read can | ||
511 | be in any format, it will be converted to UTF-32 if it is not in this format. | ||
512 | If you are using the Irrlicht Engine, it is better not to use this function but | ||
513 | IFileSystem::createXMLReader() instead. | ||
514 | \param filename: Name of file to be opened. | ||
515 | \return Returns a pointer to the created xml parser. This pointer should be | ||
516 | deleted using 'delete' after no longer needed. Returns 0 if an error occured | ||
517 | and the file could not be opened. */ | ||
518 | IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(const char* filename); | ||
519 | |||
520 | //! Creates an instance of an UFT-32 xml parser. | ||
521 | /** This means that all character data will be returned in UTF-32. The file to read can | ||
522 | be in any format, it will be converted to UTF-32 if it is not in this format. | ||
523 | if you are using the Irrlicht Engine, it is better not to use this function but | ||
524 | IFileSystem::createXMLReader() instead. | ||
525 | \param file: Pointer to opened file, must have been opened in binary mode, e.g. | ||
526 | using fopen("foo.bar", "wb"); The file will not be closed after it has been read. | ||
527 | \return Returns a pointer to the created xml parser. This pointer should be | ||
528 | deleted using 'delete' after no longer needed. Returns 0 if an error occured | ||
529 | and the file could not be opened. */ | ||
530 | IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(FILE* file); | ||
531 | |||
532 | //! Creates an instance of an UFT-32 xml parser. | ||
533 | /** This means that | ||
534 | all character data will be returned in UTF-32. The file to read can | ||
535 | be in any format, it will be converted to UTF-32 if it is not in this format. | ||
536 | If you are using the Irrlicht Engine, it is better not to use this function but | ||
537 | IFileSystem::createXMLReader() instead. | ||
538 | \param callback: Callback for file read abstraction. Implement your own | ||
539 | callback to make the xml parser read in other things than just files. See | ||
540 | IFileReadCallBack for more information about this. | ||
541 | \param deleteCallback: if true, the callback will be deleted after the file | ||
542 | has been read. Otherwise the caller si responsible for cleaning it up. | ||
543 | \return Returns a pointer to the created xml parser. This pointer should be | ||
544 | deleted using 'delete' after no longer needed. Returns 0 if an error occured | ||
545 | and the file could not be opened. */ | ||
546 | IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(IFileReadCallBack* callback, | ||
547 | bool deleteCallback = false); | ||
548 | |||
549 | |||
550 | /*! \file irrXML.h | ||
551 | \brief Header file of the irrXML, the Irrlicht XML parser. | ||
552 | |||
553 | This file includes everything needed for using irrXML, | ||
554 | the XML parser of the Irrlicht Engine. To use irrXML, | ||
555 | you only need to include this file in your project: | ||
556 | |||
557 | \code | ||
558 | #include <irrXML.h> | ||
559 | \endcode | ||
560 | |||
561 | It is also common to use the two namespaces in which irrXML is included, | ||
562 | directly after including irrXML.h: | ||
563 | |||
564 | \code | ||
565 | #include <irrXML.h> | ||
566 | using namespace irr; | ||
567 | using namespace io; | ||
568 | \endcode | ||
569 | */ | ||
570 | |||
571 | } // end namespace io | ||
572 | } // end namespace irr | ||
573 | |||
574 | #endif // __IRR_XML_H_INCLUDED__ | ||
575 | |||