00001
00002
00003
00004
00005 #ifndef __IRR_XML_H_INCLUDED__
00006 #define __IRR_XML_H_INCLUDED__
00007
00008 #include <stdio.h>
00009
00152 namespace irr
00153 {
00154 namespace io
00155 {
00157 enum ETEXT_FORMAT
00158 {
00160 ETF_ASCII,
00161
00163 ETF_UTF8,
00164
00166 ETF_UTF16_BE,
00167
00169 ETF_UTF16_LE,
00170
00172 ETF_UTF32_BE,
00173
00175 ETF_UTF32_LE,
00176 };
00177
00178
00180 enum EXML_NODE
00181 {
00183 EXN_NONE,
00184
00186 EXN_ELEMENT,
00187
00189 EXN_ELEMENT_END,
00190
00192 EXN_TEXT,
00193
00195 EXN_COMMENT,
00196
00198 EXN_CDATA,
00199
00201 EXN_UNKNOWN
00202 };
00203
00205
00212 class IFileReadCallBack
00213 {
00214 public:
00215
00217 virtual ~IFileReadCallBack() {};
00218
00220
00223 virtual int read(void* buffer, int sizeToRead) = 0;
00224
00226 virtual int getSize() = 0;
00227 };
00228
00230
00235 class IXMLBase
00236 {
00237 };
00238
00240
00272 template<class char_type, class super_class>
00273 class IIrrXMLReader : public super_class
00274 {
00275 public:
00276
00278 virtual ~IIrrXMLReader() {};
00279
00281
00282 virtual bool read() = 0;
00283
00285 virtual EXML_NODE getNodeType() const = 0;
00286
00288
00291 virtual int getAttributeCount() const = 0;
00292
00294
00296 virtual const char_type* getAttributeName(int idx) const = 0;
00297
00299
00301 virtual const char_type* getAttributeValue(int idx) const = 0;
00302
00304
00306 virtual const char_type* getAttributeValue(const char_type* name) const = 0;
00307
00309
00313 virtual const char_type* getAttributeValueSafe(const char_type* name) const = 0;
00314
00316
00319 virtual int getAttributeValueAsInt(const char_type* name) const = 0;
00320
00322
00325 virtual int getAttributeValueAsInt(int idx) const = 0;
00326
00328
00331 virtual float getAttributeValueAsFloat(const char_type* name) const = 0;
00332
00334
00337 virtual float getAttributeValueAsFloat(int idx) const = 0;
00338
00340
00342 virtual const char_type* getNodeName() const = 0;
00343
00345
00347 virtual const char_type* getNodeData() const = 0;
00348
00350 virtual bool isEmptyElement() const = 0;
00351
00353
00357 virtual ETEXT_FORMAT getSourceFormat() const = 0;
00358
00360
00364 virtual ETEXT_FORMAT getParserFormat() const = 0;
00365 };
00366
00367
00369
00371 typedef unsigned short char16;
00372
00374
00376 typedef unsigned long char32;
00377
00379
00384 typedef IIrrXMLReader<char, IXMLBase> IrrXMLReader;
00385
00387
00392 typedef IIrrXMLReader<char16, IXMLBase> IrrXMLReaderUTF16;
00393
00395
00400 typedef IIrrXMLReader<char32, IXMLBase> IrrXMLReaderUTF32;
00401
00402
00404
00412 IrrXMLReader* createIrrXMLReader(const char* filename);
00413
00415
00424 IrrXMLReader* createIrrXMLReader(FILE* file);
00425
00427
00437 IrrXMLReader* createIrrXMLReader(IFileReadCallBack* callback);
00438
00440
00449 IrrXMLReaderUTF16* createIrrXMLReaderUTF16(const char* filename);
00450
00452
00461 IrrXMLReaderUTF16* createIrrXMLReaderUTF16(FILE* file);
00462
00464
00474 IrrXMLReaderUTF16* createIrrXMLReaderUTF16(IFileReadCallBack* callback);
00475
00476
00478
00486 IrrXMLReaderUTF32* createIrrXMLReaderUTF32(const char* filename);
00487
00489
00498 IrrXMLReaderUTF32* createIrrXMLReaderUTF32(FILE* file);
00499
00501
00512 IrrXMLReaderUTF32* createIrrXMLReaderUTF32(IFileReadCallBack* callback);
00513
00514
00536 }
00537 }
00538
00539 #endif // __IRR_XML_H_INCLUDED__
00540