Nirtcpp 2.1.0
Nirtcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
irrXML.hpp
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 nirtcpp/nirtcpp.hpp and/or irrXML.h
4
5#ifndef NIRT_XML_HPP_INCLUDED
6#define NIRT_XML_HPP_INCLUDED
7
8#include <nirtcpp/core/engine/NirtCompileConfig.hpp>
9#include <nirtcpp/core/engine/irrArray.hpp>
10#include <nirtcpp/core/engine/irrString.hpp>
11
154namespace nirt
155{
156namespace io
157{
179
180
206
208
216 {
217 public:
218
221
223
226 virtual int read(void* buffer, int sizeToRead) = 0;
227
229 virtual long getSize() const = 0;
230 };
231
233
239 {
240 };
241
243
275 template<class char_type, class super_class>
276 class IIrrXMLReader : public super_class
277 {
278 public:
279
281 virtual ~IIrrXMLReader() {}
282
284
285 virtual bool read() = 0;
286
288 virtual EXML_NODE getNodeType() const = 0;
289
291
294 virtual unsigned int getAttributeCount() const = 0;
295
297
299 virtual const char_type* getAttributeName(int idx) const = 0;
300
302
304 virtual const char_type* getAttributeValue(int idx) const = 0;
305
307
309 virtual const char_type* getAttributeValue(const char_type* name) const = 0;
310
312
316 virtual const char_type* getAttributeValueSafe(const char_type* name) const = 0;
317
319
323 virtual int getAttributeValueAsInt(const char_type* name, int defaultNotFound=0) const = 0;
324
326
330 virtual int getAttributeValueAsInt(int idx, int defaultNotFound=0) const = 0;
331
333
337 virtual float getAttributeValueAsFloat(const char_type* name, float defaultNotFound=0.f) const = 0;
338
340
344 virtual float getAttributeValueAsFloat(int idx, float defaultNotFound=0.f) const = 0;
345
347
349 virtual const char_type* getNodeName() const = 0;
350
352
354 virtual const char_type* getNodeData() const = 0;
355
357 virtual bool isEmptyElement() const = 0;
358
360
364 virtual ETEXT_FORMAT getSourceFormat() const = 0;
365
367
371 virtual ETEXT_FORMAT getParserFormat() const = 0;
372 };
373
375 template<class char_type, class super_class>
376 class IIrrXMLWriter : public super_class
377 {
378 public:
379
381 virtual ~IIrrXMLWriter() {}
382
384
387 virtual void writeXMLHeader() = 0;
388
391
406 virtual void writeElement(const char_type* name, bool empty=false,
407 const char_type* attr1Name = 0, const char_type* attr1Value = 0,
408 const char_type* attr2Name = 0, const char_type* attr2Value = 0,
409 const char_type* attr3Name = 0, const char_type* attr3Value = 0,
410 const char_type* attr4Name = 0, const char_type* attr4Value = 0,
411 const char_type* attr5Name = 0, const char_type* attr5Value = 0) = 0;
412
414 virtual void writeElement(const char_type* name, bool empty,
416
418 virtual void writeComment(const char_type* comment) = 0;
419
421 virtual void writeClosingTag(const char_type* name) = 0;
422
424
427 virtual void writeText(const char_type* text) = 0;
428
430 virtual void writeLineBreak() = 0;
431 };
432
433
434 template <typename T>
436 {
437 public:
438 T c;
439 xmlChar() {}
440 xmlChar(char in) : c(static_cast<T>(in)) {}
441 xmlChar(wchar_t in) : c(static_cast<T>(in)) {}
442#if defined(__BORLANDC__)
443 // Note - removing explicit for Borland was to get it to even compile.
444 // There haven't been any kind of tests for that besides that.
445 xmlChar(unsigned char in) : c(static_cast<T>(in)) {}
446 xmlChar(unsigned short in) : c(static_cast<T>(in)) {}
447 xmlChar(unsigned int in) : c(static_cast<T>(in)) {}
448 xmlChar(unsigned long in) : c(static_cast<T>(in)) {}
449#else
450 explicit xmlChar(unsigned char in) : c(static_cast<T>(in)) {}
451
452#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED) // VS compiling without native wchar_t can't have it
453 explicit xmlChar(unsigned short in) : c(static_cast<T>(in)) {}
454#endif
455 explicit xmlChar(unsigned int in) : c(static_cast<T>(in)) {}
456 explicit xmlChar(unsigned long in) : c(static_cast<T>(in)) {}
457#endif
458 operator T() const { return c; }
459 void operator=(int t) { c=static_cast<T>(t); }
460 };
461
463
466
468
471
473
479
481
487
489
495
496#ifdef _NIRT_COMPILE_WITH_XML_
497
499
507 NIRTCPP_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(const char* filename);
508
510
519 NIRTCPP_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(FILE* file);
520
522
534 NIRTCPP_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(IFileReadCallBack* callback,
535 bool deleteCallback = false);
536
538
547 NIRTCPP_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(const char* filename);
548
550
559 NIRTCPP_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(FILE* file);
560
562
574 NIRTCPP_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(IFileReadCallBack* callback,
575 bool deleteCallback = false);
576
577
579
587 NIRTCPP_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(const char* filename);
588
590
599 NIRTCPP_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(FILE* file);
600
602
615 NIRTCPP_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(IFileReadCallBack* callback,
616 bool deleteCallback = false);
617
618#endif // _NIRT_COMPILE_WITH_XML_
619
641} // end namespace io
642} // end namespace nirt
643
644#endif // NIRT_XML_HPP_INCLUDED
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
Self reallocating template array (like stl vector) with additional features.
Definition irrArray.hpp:23
Callback class for file read abstraction.
Definition irrXML.hpp:216
virtual int read(void *buffer, int sizeToRead)=0
Reads an amount of bytes from the file.
virtual ~IFileReadCallBack()
Destructor.
Definition irrXML.hpp:220
virtual long getSize() const =0
Returns size of file in bytes on success or -1L on failure.
Interface providing easy read access to a XML file.
Definition irrXML.hpp:277
virtual int getAttributeValueAsInt(int idx, int defaultNotFound=0) const =0
Returns the value of an attribute as integer.
virtual int getAttributeValueAsInt(const char_type *name, int defaultNotFound=0) const =0
Returns the value of an attribute as integer.
virtual const char_type * getAttributeValueSafe(const char_type *name) const =0
Returns the value of an attribute in a safe way.
virtual const char_type * getAttributeValue(int idx) const =0
Returns the value of an attribute.
virtual float getAttributeValueAsFloat(const char_type *name, float defaultNotFound=0.f) const =0
Returns the value of an attribute as float.
virtual float getAttributeValueAsFloat(int idx, float defaultNotFound=0.f) const =0
Returns the value of an attribute as float.
virtual EXML_NODE getNodeType() const =0
Returns the type of the current XML node.
virtual bool read()=0
Reads forward to the next xml node.
virtual unsigned int getAttributeCount() const =0
Returns attribute count of the current XML node.
virtual const char_type * getAttributeName(int idx) const =0
Returns name of an attribute.
virtual ETEXT_FORMAT getSourceFormat() const =0
Returns format of the source xml file.
virtual const char_type * getAttributeValue(const char_type *name) const =0
Returns the value of an attribute.
virtual const char_type * getNodeData() const =0
Returns data of the current node.
virtual ~IIrrXMLReader()
Destructor.
Definition irrXML.hpp:281
virtual const char_type * getNodeName() const =0
Returns the name of the current node.
virtual bool isEmptyElement() const =0
Returns if an element is an empty element, like <foo />
virtual ETEXT_FORMAT getParserFormat() const =0
Returns format of the strings returned by the parser.
Interface providing methods for making it easier to write XML files.
Definition irrXML.hpp:377
virtual void writeLineBreak()=0
Writes a line break.
virtual void writeClosingTag(const char_type *name)=0
Writes the closing tag for an element. Like "</foo>".
virtual void writeElement(const char_type *name, bool empty=false, const char_type *attr1Name=0, const char_type *attr1Value=0, const char_type *attr2Name=0, const char_type *attr2Value=0, const char_type *attr3Name=0, const char_type *attr3Value=0, const char_type *attr4Name=0, const char_type *attr4Value=0, const char_type *attr5Name=0, const char_type *attr5Value=0)=0
virtual void writeElement(const char_type *name, bool empty, core::array< core::string< char_type > > &names, core::array< core::string< char_type > > &values)=0
Writes an xml element with any number of attributes.
virtual ~IIrrXMLWriter()
Destructor.
Definition irrXML.hpp:381
virtual void writeText(const char_type *text)=0
Writes a text into the file.
virtual void writeXMLHeader()=0
Writes an xml 1.0 header.
virtual void writeComment(const char_type *comment)=0
Writes a comment into the xml file.
Empty class to be used as parent class for IrrXMLReader.
Definition irrXML.hpp:239
Definition irrXML.hpp:436
ETEXT_FORMAT
Enumeration of all supported source text file formats.
Definition irrXML.hpp:160
@ ETF_ASCII
ASCII, file without byte order mark, or not a text file.
Definition irrXML.hpp:162
@ ETF_UTF32_BE
UTF-32 format, big endian.
Definition irrXML.hpp:174
@ ETF_UTF16_BE
UTF-16 format, big endian.
Definition irrXML.hpp:168
@ ETF_UTF16_LE
UTF-16 format, little endian.
Definition irrXML.hpp:171
@ ETF_UTF8
UTF-8 format.
Definition irrXML.hpp:165
@ ETF_UTF32_LE
UTF-32 format, little endian.
Definition irrXML.hpp:177
EXML_NODE
Enumeration for all xml nodes which are parsed by IrrXMLReader.
Definition irrXML.hpp:183
@ EXN_CDATA
An xml cdata section like <![CDATA[ this is some CDATA ]]>.
Definition irrXML.hpp:201
@ EXN_NONE
No xml node. This is usually the node if you did not read anything yet.
Definition irrXML.hpp:185
@ EXN_COMMENT
An xml comment like <!– I am a comment –> or a DTD definition.
Definition irrXML.hpp:198
@ EXN_ELEMENT_END
End of an xml element such as </foo>.
Definition irrXML.hpp:191
@ EXN_ELEMENT
An xml element such as <foo>.
Definition irrXML.hpp:188
@ EXN_TEXT
Definition irrXML.hpp:195
@ EXN_UNKNOWN
Unknown element.
Definition irrXML.hpp:204
As of Nirtcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11

Nirtcpp    @cppfx.xyz

Esvcpp    esv::print