Loading...
Searching...
No Matches
irrXML.h
Go to the documentation of this file.
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine" and the "irrXML" project.
// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h
#ifndef __IRR_XML_H_INCLUDED__
#define __IRR_XML_H_INCLUDED__
#include <stdio.h>
#include "IrrCompileConfig.h"
namespace irr
{
namespace io
{
enum ETEXT_FORMAT
{
ETF_ASCII,
ETF_UTF8,
ETF_UTF16_BE,
ETF_UTF16_LE,
ETF_UTF32_BE,
ETF_UTF32_LE
};
enum EXML_NODE
{
EXN_NONE,
EXN_ELEMENT,
EXN_ELEMENT_END,
EXN_TEXT,
EXN_COMMENT,
EXN_CDATA,
EXN_UNKNOWN
};
class IFileReadCallBack
{
public:
virtual ~IFileReadCallBack() {}
virtual int read(void* buffer, int sizeToRead) = 0;
virtual long getSize() const = 0;
};
class IXMLBase
{
};
template<class char_type, class super_class>
class IIrrXMLReader : public super_class
{
public:
virtual ~IIrrXMLReader() {}
virtual bool read() = 0;
virtual EXML_NODE getNodeType() const = 0;
virtual unsigned int getAttributeCount() const = 0;
virtual const char_type* getAttributeName(int idx) const = 0;
virtual const char_type* getAttributeValue(int idx) const = 0;
virtual const char_type* getAttributeValue(const char_type* name) const = 0;
virtual const char_type* getAttributeValueSafe(const char_type* name) const = 0;
virtual int getAttributeValueAsInt(const char_type* name) const = 0;
virtual int getAttributeValueAsInt(int idx) const = 0;
virtual float getAttributeValueAsFloat(const char_type* name) const = 0;
virtual float getAttributeValueAsFloat(int idx) const = 0;
virtual const char_type* getNodeName() const = 0;
virtual const char_type* getNodeData() const = 0;
virtual bool isEmptyElement() const = 0;
virtual ETEXT_FORMAT getSourceFormat() const = 0;
virtual ETEXT_FORMAT getParserFormat() const = 0;
};
template <typename T>
struct xmlChar
{
T c;
xmlChar<T>() {}
xmlChar<T>(char in) : c(static_cast<T>(in)) {}
xmlChar<T>(wchar_t in) : c(static_cast<T>(in)) {}
#if defined(__BORLANDC__)
// Note - removing explicit for borland was to get it to even compile.
// There haven't been any kind of tests for that besides that.
xmlChar<T>(unsigned char in) : c(static_cast<T>(in)) {}
xmlChar<T>(unsigned short in) : c(static_cast<T>(in)) {}
xmlChar<T>(unsigned int in) : c(static_cast<T>(in)) {}
xmlChar<T>(unsigned long in) : c(static_cast<T>(in)) {}
#else
explicit xmlChar<T>(unsigned char in) : c(static_cast<T>(in)) {}
explicit xmlChar<T>(unsigned short in) : c(static_cast<T>(in)) {}
explicit xmlChar<T>(unsigned int in) : c(static_cast<T>(in)) {}
explicit xmlChar<T>(unsigned long in) : c(static_cast<T>(in)) {}
#endif
operator T() const { return c; }
void operator=(int t) { c=static_cast<T>(t); }
};
typedef xmlChar<unsigned short> char16;
typedef xmlChar<unsigned int> char32;
typedef IIrrXMLReader<char, IXMLBase> IrrXMLReader;
typedef IIrrXMLReader<char16, IXMLBase> IrrXMLReaderUTF16;
typedef IIrrXMLReader<char32, IXMLBase> IrrXMLReaderUTF32;
IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(const char* filename);
IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(FILE* file);
IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(IFileReadCallBack* callback,
bool deleteCallback = false);
IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(const char* filename);
IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(FILE* file);
IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(IFileReadCallBack* callback,
bool deleteCallback = false);
IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(const char* filename);
IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(FILE* file);
IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(IFileReadCallBack* callback,
bool deleteCallback = false);
} // end namespace io
} // end namespace irr
#endif // __IRR_XML_H_INCLUDED__
IrrCompileConfig.h
IRRCALLCONV
#define IRRCALLCONV
Definition IrrCompileConfig.h:697
IRRLICHT_API
#define IRRLICHT_API
Set FPU settings.
Definition IrrCompileConfig.h:694
irr::io::IFileReadCallBack
Callback class for file read abstraction.
Definition irrXML.h:215
irr::io::IFileReadCallBack::~IFileReadCallBack
virtual ~IFileReadCallBack()
Destructor.
Definition irrXML.h:219
irr::io::IFileReadCallBack::getSize
virtual long getSize() const =0
Returns size of file in bytes.
irr::io::IFileReadCallBack::read
virtual int read(void *buffer, int sizeToRead)=0
Reads an amount of bytes from the file.
irr::io::IIrrXMLReader
Interface providing easy read access to a XML file.
Definition irrXML.h:276
irr::io::IIrrXMLReader::getSourceFormat
virtual ETEXT_FORMAT getSourceFormat() const =0
Returns format of the source xml file.
irr::io::IIrrXMLReader::read
virtual bool read()=0
Reads forward to the next xml node.
irr::io::IIrrXMLReader::getAttributeValueAsFloat
virtual float getAttributeValueAsFloat(const char_type *name) const =0
Returns the value of an attribute as float.
irr::io::IIrrXMLReader::getNodeType
virtual EXML_NODE getNodeType() const =0
Returns the type of the current XML node.
irr::io::IIrrXMLReader::getAttributeValueSafe
virtual const char_type * getAttributeValueSafe(const char_type *name) const =0
Returns the value of an attribute in a safe way.
irr::io::IIrrXMLReader::getAttributeValueAsFloat
virtual float getAttributeValueAsFloat(int idx) const =0
Returns the value of an attribute as float.
irr::io::IIrrXMLReader::isEmptyElement
virtual bool isEmptyElement() const =0
Returns if an element is an empty element, like <foo />.
irr::io::IIrrXMLReader::getNodeName
virtual const char_type * getNodeName() const =0
Returns the name of the current node.
irr::io::IIrrXMLReader::getAttributeValueAsInt
virtual int getAttributeValueAsInt(int idx) const =0
Returns the value of an attribute as integer.
irr::io::IIrrXMLReader::getAttributeCount
virtual unsigned int getAttributeCount() const =0
Returns attribute count of the current XML node.
irr::io::IIrrXMLReader::getParserFormat
virtual ETEXT_FORMAT getParserFormat() const =0
Returns format of the strings returned by the parser.
irr::io::IIrrXMLReader::getAttributeValue
virtual const char_type * getAttributeValue(const char_type *name) const =0
Returns the value of an attribute.
irr::io::IIrrXMLReader::getAttributeName
virtual const char_type * getAttributeName(int idx) const =0
Returns name of an attribute.
irr::io::IIrrXMLReader::getAttributeValueAsInt
virtual int getAttributeValueAsInt(const char_type *name) const =0
Returns the value of an attribute as integer.
irr::io::IIrrXMLReader::getAttributeValue
virtual const char_type * getAttributeValue(int idx) const =0
Returns the value of an attribute.
irr::io::IIrrXMLReader::~IIrrXMLReader
virtual ~IIrrXMLReader()
Destructor.
Definition irrXML.h:280
irr::io::IIrrXMLReader::getNodeData
virtual const char_type * getNodeData() const =0
Returns data of the current node.
irr::io::IXMLBase
Empty class to be used as parent class for IrrXMLReader.
Definition irrXML.h:238
irr::io
This namespace provides interfaces for input/output: Reading and writing files, accessing zip archive...
Definition EAttributes.h:11
irr::io::IrrXMLReader
IIrrXMLReader< char, IXMLBase > IrrXMLReader
A UTF-8 or ASCII character xml parser.
Definition irrXML.h:410
irr::io::createIrrXMLReaderUTF16
IRRLICHT_API IrrXMLReaderUTF16 *IRRCALLCONV createIrrXMLReaderUTF16(const char *filename)
Creates an instance of an UFT-16 xml parser.
irr::io::IrrXMLReaderUTF16
IIrrXMLReader< char16, IXMLBase > IrrXMLReaderUTF16
A UTF-16 xml parser.
Definition irrXML.h:418
irr::io::createIrrXMLReader
IRRLICHT_API IrrXMLReader *IRRCALLCONV createIrrXMLReader(const char *filename)
Creates an instance of an UFT-8 or ASCII character xml parser.
irr::io::createIrrXMLReaderUTF32
IRRLICHT_API IrrXMLReaderUTF32 *IRRCALLCONV createIrrXMLReaderUTF32(const char *filename)
Creates an instance of an UFT-32 xml parser.
irr::io::IrrXMLReaderUTF32
IIrrXMLReader< char32, IXMLBase > IrrXMLReaderUTF32
A UTF-32 xml parser.
Definition irrXML.h:426
irr::io::EXML_NODE
EXML_NODE
Enumeration for all xml nodes which are parsed by IrrXMLReader.
Definition irrXML.h:182
irr::io::EXN_TEXT
@ EXN_TEXT
Definition irrXML.h:194
irr::io::EXN_ELEMENT_END
@ EXN_ELEMENT_END
End of an xml element such as </foo>.
Definition irrXML.h:190
irr::io::EXN_ELEMENT
@ EXN_ELEMENT
An xml element such as <foo>.
Definition irrXML.h:187
irr::io::EXN_NONE
@ EXN_NONE
No xml node. This is usually the node if you did not read anything yet.
Definition irrXML.h:184
irr::io::EXN_CDATA
@ EXN_CDATA
An xml cdata section like <![CDATA[ this is some CDATA ]]>.
Definition irrXML.h:200
irr::io::EXN_COMMENT
@ EXN_COMMENT
An xml comment like <!– I am a comment –> or a DTD definition.
Definition irrXML.h:197
irr::io::EXN_UNKNOWN
@ EXN_UNKNOWN
Unknown element.
Definition irrXML.h:203
irr::io::char16
xmlChar< unsigned short > char16
defines the utf-16 type.
Definition irrXML.h:397
irr::io::ETEXT_FORMAT
ETEXT_FORMAT
Enumeration of all supported source text file formats.
Definition irrXML.h:159
irr::io::ETF_UTF32_LE
@ ETF_UTF32_LE
UTF-32 format, little endian.
Definition irrXML.h:176
irr::io::ETF_UTF16_LE
@ ETF_UTF16_LE
UTF-16 format, little endian.
Definition irrXML.h:170
irr::io::ETF_UTF16_BE
@ ETF_UTF16_BE
UTF-16 format, big endian.
Definition irrXML.h:167
irr::io::ETF_UTF32_BE
@ ETF_UTF32_BE
UTF-32 format, big endian.
Definition irrXML.h:173
irr::io::ETF_ASCII
@ ETF_ASCII
ASCII, file without byte order mark, or not a text file.
Definition irrXML.h:161
irr::io::ETF_UTF8
@ ETF_UTF8
UTF-8 format.
Definition irrXML.h:164
irr::io::char32
xmlChar< unsigned int > char32
defines the utf-32 type.
Definition irrXML.h:402
irr
Everything in the Irrlicht Engine can be found in this namespace.
Definition aabbox3d.h:13
irr::io::xmlChar
Definition irrXML.h:372
irr::io::xmlChar< unsigned short >::c
unsigned short c
Definition irrXML.h:373
irr::io::xmlChar::operator=
void operator=(int t)
Definition irrXML.h:391
irr::io::xmlChar::xmlChar
xmlChar()
Definition irrXML.h:374
- Irrlicht Engine Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on for Irrlicht 3D Engine by Doxygen 1.15.0