Irrlicht 3D Engine
irrXML.h
Go to the documentation of this file.
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 
153 namespace irr
154 {
155 namespace io
156 {
159  {
162 
165 
168 
171 
174 
177  };
178 
179 
182  {
185 
188 
191 
195 
198 
201 
204  };
205 
207 
215  {
216  public:
217 
219  virtual ~IFileReadCallBack() {}
220 
222 
225  virtual int read(void* buffer, int sizeToRead) = 0;
226 
228  virtual long getSize() const = 0;
229  };
230 
232 
237  class IXMLBase
238  {
239  };
240 
242 
274  template<class char_type, class super_class>
275  class IIrrXMLReader : public super_class
276  {
277  public:
278 
280  virtual ~IIrrXMLReader() {}
281 
283 
284  virtual bool read() = 0;
285 
287  virtual EXML_NODE getNodeType() const = 0;
288 
290 
293  virtual unsigned int getAttributeCount() const = 0;
294 
296 
298  virtual const char_type* getAttributeName(int idx) const = 0;
299 
301 
303  virtual const char_type* getAttributeValue(int idx) const = 0;
304 
306 
308  virtual const char_type* getAttributeValue(const char_type* name) const = 0;
309 
311 
315  virtual const char_type* getAttributeValueSafe(const char_type* name) const = 0;
316 
318 
321  virtual int getAttributeValueAsInt(const char_type* name) const = 0;
322 
324 
327  virtual int getAttributeValueAsInt(int idx) const = 0;
328 
330 
333  virtual float getAttributeValueAsFloat(const char_type* name) const = 0;
334 
336 
339  virtual float getAttributeValueAsFloat(int idx) const = 0;
340 
342 
344  virtual const char_type* getNodeName() const = 0;
345 
347 
349  virtual const char_type* getNodeData() const = 0;
350 
352  virtual bool isEmptyElement() const = 0;
353 
355 
359  virtual ETEXT_FORMAT getSourceFormat() const = 0;
360 
362 
366  virtual ETEXT_FORMAT getParserFormat() const = 0;
367  };
368 
369 
370  template <typename T>
371  struct xmlChar
372  {
373  T c;
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 
395 
398 
400 
403 
405 
411 
413 
419 
421 
427 
428 
430 
438  IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(const char* filename);
439 
441 
450  IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(FILE* file);
451 
453 
466  bool deleteCallback = false);
467 
469 
478  IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(const char* filename);
479 
481 
490  IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(FILE* file);
491 
493 
506  bool deleteCallback = false);
507 
508 
510 
518  IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(const char* filename);
519 
521 
530  IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(FILE* file);
531 
533 
547  bool deleteCallback = false);
548 
549 
571 } // end namespace io
572 } // end namespace irr
573 
574 #endif // __IRR_XML_H_INCLUDED__
575 
End of an xml element such as </foo>.
Definition: irrXML.h:190
Unknown element.
Definition: irrXML.h:203
An xml comment like <!– I am a comment –> or a DTD definition.
Definition: irrXML.h:197
#define IRRLICHT_API
Set FPU settings.
An xml element such as <foo>.
Definition: irrXML.h:187
Empty class to be used as parent class for IrrXMLReader.
Definition: irrXML.h:237
xmlChar< unsigned int > char32
defines the utf-32 type.
Definition: irrXML.h:402
Everything in the Irrlicht Engine can be found in this namespace.
Definition: aabbox3d.h:12
virtual long getSize() const =0
Returns size of file in bytes.
An xml cdata section like <![CDATA[ this is some CDATA ]]>.
Definition: irrXML.h:200
UTF-16 format, little endian.
Definition: irrXML.h:170
IIrrXMLReader< char, IXMLBase > IrrXMLReader
A UTF-8 or ASCII character xml parser.
Definition: irrXML.h:410
UTF-16 format, big endian.
Definition: irrXML.h:167
virtual ~IFileReadCallBack()
Destructor.
Definition: irrXML.h:219
ETEXT_FORMAT
Enumeration of all supported source text file formats.
Definition: irrXML.h:158
xmlChar< unsigned short > char16
defines the utf-16 type.
Definition: irrXML.h:397
UTF-32 format, big endian.
Definition: irrXML.h:173
IIrrXMLReader< char16, IXMLBase > IrrXMLReaderUTF16
A UTF-16 xml parser.
Definition: irrXML.h:418
virtual int read(void *buffer, int sizeToRead)=0
Reads an amount of bytes from the file.
Interface providing easy read access to a XML file.
Definition: irrXML.h:275
EXML_NODE
Enumeration for all xml nodes which are parsed by IrrXMLReader.
Definition: irrXML.h:181
IRRLICHT_API IrrXMLReaderUTF32 *IRRCALLCONV createIrrXMLReaderUTF32(const char *filename)
Creates an instance of an UFT-32 xml parser.
#define IRRCALLCONV
virtual ~IIrrXMLReader()
Destructor.
Definition: irrXML.h:280
IRRLICHT_API IrrXMLReader *IRRCALLCONV createIrrXMLReader(const char *filename)
Creates an instance of an UFT-8 or ASCII character xml parser.
Callback class for file read abstraction.
Definition: irrXML.h:214
IIrrXMLReader< char32, IXMLBase > IrrXMLReaderUTF32
A UTF-32 xml parser.
Definition: irrXML.h:426
IRRLICHT_API IrrXMLReaderUTF16 *IRRCALLCONV createIrrXMLReaderUTF16(const char *filename)
Creates an instance of an UFT-16 xml parser.
void operator=(int t)
Definition: irrXML.h:391
UTF-32 format, little endian.
Definition: irrXML.h:176
No xml node. This is usually the node if you did not read anything yet.
Definition: irrXML.h:184
ASCII, file without byte order mark, or not a text file.
Definition: irrXML.h:161
UTF-8 format.
Definition: irrXML.h:164