Newton Dynamics  4.00
tinyxml.h
1 /*
2 www.sourceforge.net/projects/tinyxml
3 Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
4 
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any
7 damages arising from the use of this software.
8 
9 Permission is granted to anyone to use this software for any
10 purpose, including commercial applications, and to alter it and
11 redistribute it freely, subject to the following restrictions:
12 
13 1. The origin of this software must not be misrepresented; you must
14 not claim that you wrote the original software. If you use this
15 software in a product, an acknowledgment in the product documentation
16 would be appreciated but is not required.
17 
18 2. Altered source versions must be plainly marked as such, and
19 must not be misrepresented as being the original software.
20 
21 3. This notice may not be removed or altered from any source
22 distribution.
23 */
24 
25 
26 #ifndef TINYXML_INCLUDED
27 #define TINYXML_INCLUDED
28 
29 #ifdef _MSC_VER
30 #pragma warning( push )
31 #pragma warning( disable : 4530 )
32 #pragma warning( disable : 4786 )
33 #endif
34 
35 #include <ctype.h>
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <string.h>
39 #include <assert.h>
40 
41 // Help out windows:
42 #if defined( _DEBUG ) && !defined( DEBUG )
43 #define DEBUG
44 #endif
45 
46 #ifdef TIXML_USE_STL
47  #include <string>
48  #include <iostream>
49  #include <sstream>
50  #define TIXML_STRING std::string
51 #else
52  #include "tinystr.h"
53  #define TIXML_STRING TiXmlString
54 #endif
55 
56 // Deprecated library function hell. Compilers want to use the
57 // new safe versions. This probably doesn't fully address the problem,
58 // but it gets closer. There are too many compilers for me to fully
59 // test. If you get compilation troubles, undefine TIXML_SAFE
60 #define TIXML_SAFE
61 
62 #ifdef TIXML_SAFE
63  #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
64  // Microsoft visual studio, version 2005 and higher.
65  #define TIXML_SNPRINTF _snprintf_s
66  #define TIXML_SNSCANF _snscanf_s
67  #define TIXML_SSCANF sscanf_s
68  #elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
69  // Microsoft visual studio, version 6 and higher.
70  //#pragma message( "Using _sn* functions." )
71  #define TIXML_SNPRINTF _snprintf
72  #define TIXML_SNSCANF _snscanf
73  #define TIXML_SSCANF sscanf
74  #elif defined(__GNUC__) && (__GNUC__ >= 3 )
75  // GCC version 3 and higher.s
76  //#warning( "Using sn* functions." )
77  #define TIXML_SNPRINTF snprintf
78  #define TIXML_SNSCANF snscanf
79  #define TIXML_SSCANF sscanf
80  #else
81  #define TIXML_SSCANF sscanf
82  #endif
83 #endif
84 
85 namespace nd
86 {
87 class TiXmlDocument;
88 class TiXmlElement;
89 class TiXmlComment;
90 class TiXmlUnknown;
91 class TiXmlAttribute;
92 class TiXmlText;
93 class TiXmlDeclaration;
94 class TiXmlParsingData;
95 
96 const int TIXML_MAJOR_VERSION = 2;
97 const int TIXML_MINOR_VERSION = 5;
98 const int TIXML_PATCH_VERSION = 3;
99 
100 /* Internal structure for tracking location of items
101  in the XML file.
102 */
103 struct D_TINY_API TiXmlCursor
104 {
105  TiXmlCursor() { Clear(); }
106  void Clear() { row = col = -1; }
107 
108  int row; // 0 based.
109  int col; // 0 based.
110 };
111 
112 
131 class D_TINY_API TiXmlVisitor
132 {
133 public:
134  virtual ~TiXmlVisitor() {}
135 
136  void *operator new (size_t size);
137  void *operator new[](size_t size);
138  void operator delete (void* ptr);
139  void operator delete[](void* ptr);
140 
142  virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; }
144  virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; }
145 
147  virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; }
149  virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; }
150 
152  virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; }
154  virtual bool Visit( const TiXmlText& /*text*/ ) { return true; }
156  virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; }
158  virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; }
159 };
160 
161 // Only used by Attribute::Query functions
162 enum
163 {
164  TIXML_SUCCESS,
165  TIXML_NO_ATTRIBUTE,
166  TIXML_WRONG_TYPE
167 };
168 
169 
170 // Used by the parsing routines.
171 enum TiXmlEncoding
172 {
173  TIXML_ENCODING_UNKNOWN,
174  TIXML_ENCODING_UTF8,
175  TIXML_ENCODING_LEGACY
176 };
177 
178 const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN;
179 
202 class D_TINY_API TiXmlBase
203 {
204  friend class TiXmlNode;
205  friend class TiXmlElement;
206  friend class TiXmlDocument;
207 
208 public:
209  TiXmlBase() : userData(0) {}
210  virtual ~TiXmlBase() {}
211 
212  void *operator new (size_t size);
213  void *operator new[](size_t size);
214  void operator delete (void* ptr);
215  void operator delete[](void* ptr);
216 
226  virtual void Print( FILE* cfile, int depth ) const = 0;
227 
234  static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; }
235 
237  static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; }
238 
257  int Row() const { return location.row + 1; }
258  int Column() const { return location.col + 1; }
259 
260  void SetUserData( void* user ) { userData = user; }
261  void* GetUserData() { return userData; }
262  const void* GetUserData() const { return userData; }
263 
264  // Table that returs, for a given lead byte, the total number of bytes
265  // in the UTF-8 sequence.
266  static const int utf8ByteTable[256];
267 
268  virtual const char* Parse( const char* p,
269  TiXmlParsingData* data,
270  TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
271 
275  static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out );
276 
277  enum
278  {
279  TIXML_NO_ERROR = 0,
280  TIXML_ERROR,
281  TIXML_ERROR_OPENING_FILE,
282  TIXML_ERROR_OUT_OF_MEMORY,
283  TIXML_ERROR_PARSING_ELEMENT,
284  TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
285  TIXML_ERROR_READING_ELEMENT_VALUE,
286  TIXML_ERROR_READING_ATTRIBUTES,
287  TIXML_ERROR_PARSING_EMPTY,
288  TIXML_ERROR_READING_END_TAG,
289  TIXML_ERROR_PARSING_UNKNOWN,
290  TIXML_ERROR_PARSING_COMMENT,
291  TIXML_ERROR_PARSING_DECLARATION,
292  TIXML_ERROR_DOCUMENT_EMPTY,
293  TIXML_ERROR_EMBEDDED_NULL,
294  TIXML_ERROR_PARSING_CDATA,
295  TIXML_ERROR_DOCUMENT_TOP_ONLY,
296 
297  TIXML_ERROR_STRING_COUNT
298  };
299 
300 protected:
301 
302  static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
303  inline static bool IsWhiteSpace( char c )
304  {
305  return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
306  }
307  inline static bool IsWhiteSpace( int c )
308  {
309  if ( c < 256 )
310  return IsWhiteSpace( (char) c );
311  return false; // Again, only truly correct for English/Latin...but usually works.
312  }
313 
314  #ifdef TIXML_USE_STL
315  static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag );
316  static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag );
317  #endif
318 
319  /* Reads an XML name into the string provided. Returns
320  a pointer just past the last character of the name,
321  or 0 if the function has an error.
322  */
323  static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding );
324 
325  /* Reads text. Returns a pointer past the given end tag.
326  Wickedly complex options, but it keeps the (sensitive) code in one place.
327  */
328  static const char* ReadText( const char* in, // where to start
329  TIXML_STRING* text, // the string read
330  bool ignoreWhiteSpace, // whether to keep the white space
331  const char* endTag, // what ends this text
332  bool ignoreCase, // whether to ignore case in the end tag
333  TiXmlEncoding encoding ); // the current encoding
334 
335  // If an entity has been found, transform it into a character.
336  static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding );
337 
338  // Get a character, while interpreting entities.
339  // The length can be from 0 to 4 bytes.
340  inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding )
341  {
342  assert( p );
343  if ( encoding == TIXML_ENCODING_UTF8 )
344  {
345  *length = utf8ByteTable[ *((const unsigned char*)p) ];
346  assert( *length >= 0 && *length < 5 );
347  }
348  else
349  {
350  *length = 1;
351  }
352 
353  if ( *length == 1 )
354  {
355  if ( *p == '&' )
356  return GetEntity( p, _value, length, encoding );
357  *_value = *p;
358  return p+1;
359  }
360  else if ( *length )
361  {
362  //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe),
363  // and the null terminator isn't needed
364  for( int i=0; p[i] && i<*length; ++i ) {
365  _value[i] = p[i];
366  }
367  return p + (*length);
368  }
369  else
370  {
371  // Not valid text.
372  return 0;
373  }
374  }
375 
376  // Return true if the next characters in the stream are any of the endTag sequences.
377  // Ignore case only works for english, and should only be relied on when comparing
378  // to English words: StringEqual( p, "version", true ) is fine.
379  static bool StringEqual( const char* p,
380  const char* endTag,
381  bool ignoreCase,
382  TiXmlEncoding encoding );
383 
384  static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
385 
386  TiXmlCursor location;
387 
389  void* userData;
390 
391  // None of these methods are reliable for any language except English.
392  // Good for approximation, not great for accuracy.
393  static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding );
394  static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding );
395  inline static int ToLower( int v, TiXmlEncoding encoding )
396  {
397  if ( encoding == TIXML_ENCODING_UTF8 )
398  {
399  if ( v < 128 ) return tolower( v );
400  return v;
401  }
402  else
403  {
404  return tolower( v );
405  }
406  }
407  static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
408 
409 private:
410  TiXmlBase( const TiXmlBase& ); // not implemented.
411  void operator=( const TiXmlBase& base ); // not allowed.
412 
413  struct Entity
414  {
415  const char* str;
416  unsigned int strLength;
417  char chr;
418  };
419  enum
420  {
421  NUM_ENTITY = 5,
422  MAX_ENTITY_LENGTH = 6
423 
424  };
425  static Entity entity[ NUM_ENTITY ];
426  static bool condenseWhiteSpace;
427 };
428 
429 
436 class D_TINY_API TiXmlNode : public TiXmlBase
437 {
438  friend class TiXmlDocument;
439  friend class TiXmlElement;
440 
441 public:
442  #ifdef TIXML_USE_STL
443 
447  friend std::istream& operator >> (std::istream& in, TiXmlNode& base);
448 
465  friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
466 
468  friend std::string& operator<< (std::string& out, const TiXmlNode& base );
469 
470  #endif
471 
475  enum NodeType
476  {
477  DOCUMENT,
478  ELEMENT,
479  COMMENT,
480  UNKNOWN,
481  TEXT,
482  DECLARATION,
483  TYPECOUNT
484  };
485 
486  virtual ~TiXmlNode();
487 
500  const char *Value() const { return value.c_str (); }
501 
502  #ifdef TIXML_USE_STL
503 
507  const std::string& ValueStr() const { return value; }
508  #endif
509 
510  const TIXML_STRING& ValueTStr() const { return value; }
511 
521  void SetValue(const char * _value) { value = _value;}
522 
523  #ifdef TIXML_USE_STL
524  void SetValue( const std::string& _value ) { value = _value; }
526  #endif
527 
529  void Clear();
530 
532  TiXmlNode* Parent() { return parent; }
533  const TiXmlNode* Parent() const { return parent; }
534 
535  const TiXmlNode* FirstChild() const { return firstChild; }
536  TiXmlNode* FirstChild() { return firstChild; }
537  const TiXmlNode* FirstChild( const char * value ) const;
538  TiXmlNode* FirstChild( const char * _value ) {
540  // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe)
541  // call the method, cast the return back to non-const.
542  return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value ));
543  }
544  const TiXmlNode* LastChild() const { return lastChild; }
545  TiXmlNode* LastChild() { return lastChild; }
546 
547  const TiXmlNode* LastChild( const char * value ) const;
548  TiXmlNode* LastChild( const char * _value ) {
549  return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value ));
550  }
551 
552  #ifdef TIXML_USE_STL
553  const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); }
554  TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); }
555  const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); }
556  TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); }
557  #endif
558 
575  const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const;
576  TiXmlNode* IterateChildren( const TiXmlNode* previous ) {
577  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) );
578  }
579 
581  const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const;
582  TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) {
583  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) );
584  }
585 
586  #ifdef TIXML_USE_STL
587  const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); }
588  TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); }
589  #endif
590 
594  TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
595 
596 
606  TiXmlNode* LinkEndChild( TiXmlNode* addThis );
607 
611  TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
612 
616  TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis );
617 
621  TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
622 
624  bool RemoveChild( TiXmlNode* removeThis );
625 
627  const TiXmlNode* PreviousSibling() const { return prev; }
628  TiXmlNode* PreviousSibling() { return prev; }
629 
631  const TiXmlNode* PreviousSibling( const char * ) const;
632  TiXmlNode* PreviousSibling( const char *_prev ) {
633  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) );
634  }
635 
636  #ifdef TIXML_USE_STL
637  const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); }
638  TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); }
639  const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); }
640  TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); }
641  #endif
642 
644  const TiXmlNode* NextSibling() const { return next; }
645  TiXmlNode* NextSibling() { return next; }
646 
648  const TiXmlNode* NextSibling( const char * ) const;
649  TiXmlNode* NextSibling( const char* _next ) {
650  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) );
651  }
652 
657  const TiXmlElement* NextSiblingElement() const;
658  TiXmlElement* NextSiblingElement() {
659  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() );
660  }
661 
666  const TiXmlElement* NextSiblingElement( const char * ) const;
667  TiXmlElement* NextSiblingElement( const char *_next ) {
668  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) );
669  }
670 
671  #ifdef TIXML_USE_STL
672  const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); }
673  TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); }
674  #endif
675 
677  const TiXmlElement* FirstChildElement() const;
678  TiXmlElement* FirstChildElement() {
679  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() );
680  }
681 
683  const TiXmlElement* FirstChildElement( const char * _value ) const;
684  TiXmlElement* FirstChildElement( const char * _value ) {
685  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) );
686  }
687 
688  #ifdef TIXML_USE_STL
689  const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); }
690  TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); }
691  #endif
692 
697  int Type() const { return type; }
698 
702  const TiXmlDocument* GetDocument() const;
703  TiXmlDocument* GetDocument() {
704  return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() );
705  }
706 
708  bool NoChildren() const { return !firstChild; }
709 
710  virtual const TiXmlDocument* ToDocument() const { return 0; }
711  virtual const TiXmlElement* ToElement() const { return 0; }
712  virtual const TiXmlComment* ToComment() const { return 0; }
713  virtual const TiXmlUnknown* ToUnknown() const { return 0; }
714  virtual const TiXmlText* ToText() const { return 0; }
715  virtual const TiXmlDeclaration* ToDeclaration() const { return 0; }
716 
717  virtual TiXmlDocument* ToDocument() { return 0; }
718  virtual TiXmlElement* ToElement() { return 0; }
719  virtual TiXmlComment* ToComment() { return 0; }
720  virtual TiXmlUnknown* ToUnknown() { return 0; }
721  virtual TiXmlText* ToText() { return 0; }
722  virtual TiXmlDeclaration* ToDeclaration() { return 0; }
723 
727  virtual TiXmlNode* Clone() const = 0;
728 
751  virtual bool Accept( TiXmlVisitor* visitor ) const = 0;
752 
753 protected:
754  TiXmlNode( NodeType _type );
755 
756  // Copy to the allocated object. Shared functionality between Clone, Copy constructor,
757  // and the assignment operator.
758  void CopyTo( TiXmlNode* target ) const;
759 
760  #ifdef TIXML_USE_STL
761  // The real work of the input operator.
762  virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0;
763  #endif
764 
765  // Figure out what is at *p, and parse it. Returns null if it is not an xml node.
766  TiXmlNode* Identify( const char* start, TiXmlEncoding encoding );
767 
768  TiXmlNode* parent;
769  NodeType type;
770 
771  TiXmlNode* firstChild;
772  TiXmlNode* lastChild;
773 
774  TIXML_STRING value;
775 
776  TiXmlNode* prev;
777  TiXmlNode* next;
778 
779 private:
780  TiXmlNode( const TiXmlNode& ); // not implemented.
781  void operator=( const TiXmlNode& base ); // not allowed.
782 };
783 
784 
792 class D_TINY_API TiXmlAttribute : public TiXmlBase
793 {
794  friend class TiXmlAttributeSet;
795 
796 public:
799  {
800  document = 0;
801  prev = next = 0;
802  }
803 
804  #ifdef TIXML_USE_STL
805  TiXmlAttribute( const std::string& _name, const std::string& _value )
807  {
808  name = _name;
809  value = _value;
810  document = 0;
811  prev = next = 0;
812  }
813  #endif
814 
816  TiXmlAttribute( const char * _name, const char * _value )
817  {
818  name = _name;
819  value = _value;
820  document = 0;
821  prev = next = 0;
822  }
823 
824  const char* Name() const { return name.c_str(); }
825  const char* Value() const { return value.c_str(); }
826  #ifdef TIXML_USE_STL
827  const std::string& ValueStr() const { return value; }
828  #endif
829  int IntValue() const;
830  double DoubleValue() const;
831 
832  // Get the tinyxml string representation
833  const TIXML_STRING& NameTStr() const { return name; }
834 
844  int QueryIntValue( int* _value ) const;
846  int QueryDoubleValue( double* _value ) const;
847 
848  void SetName( const char* _name ) { name = _name; }
849  void SetValue( const char* _value ) { value = _value; }
850 
851  void SetIntValue( int _value );
852  void SetDoubleValue( double _value );
853 
854  #ifdef TIXML_USE_STL
855  void SetName( const std::string& _name ) { name = _name; }
858  void SetValue( const std::string& _value ) { value = _value; }
859  #endif
860 
862  const TiXmlAttribute* Next() const;
863  TiXmlAttribute* Next() {
864  return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() );
865  }
866 
868  const TiXmlAttribute* Previous() const;
869  TiXmlAttribute* Previous() {
870  return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() );
871  }
872 
873  bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
874  bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; }
875  bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; }
876 
877  /* Attribute parsing starts: first letter of the name
878  returns: the next char after the value end quote
879  */
880  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
881 
882  // Prints this Attribute to a FILE stream.
883  virtual void Print( FILE* cfile, int depth ) const {
884  Print( cfile, depth, 0 );
885  }
886  void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
887 
888  // [internal use]
889  // Set the document pointer so the attribute can report errors.
890  void SetDocument( TiXmlDocument* doc ) { document = doc; }
891 
892 private:
893  TiXmlAttribute( const TiXmlAttribute& ); // not implemented.
894  void operator=( const TiXmlAttribute& base ); // not allowed.
895 
896  TiXmlDocument* document; // A pointer back to a document, for error reporting.
897  TIXML_STRING name;
898  TIXML_STRING value;
899  TiXmlAttribute* prev;
900  TiXmlAttribute* next;
901 };
902 
903 
904 /* A class used to manage a group of attributes.
905  It is only used internally, both by the ELEMENT and the DECLARATION.
906 
907  The set can be changed transparent to the Element and Declaration
908  classes that use it, but NOT transparent to the Attribute
909  which has to implement a next() and previous() method. Which makes
910  it a bit problematic and prevents the use of STL.
911 
912  This version is implemented with circular lists because:
913  - I like circular lists
914  - it demonstrates some independence from the (typical) doubly linked list.
915 */
916 class D_TINY_API TiXmlAttributeSet
917 {
918 public:
921 
922  void *operator new (size_t size);
923  void *operator new[](size_t size);
924  void operator delete (void* ptr);
925  void operator delete[](void* ptr);
926 
927  void Add( TiXmlAttribute* attribute );
928  void Remove( TiXmlAttribute* attribute );
929 
930  const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
931  TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
932  const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
933  TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
934 
935  const TiXmlAttribute* Find( const char* _name ) const;
936  TiXmlAttribute* Find( const char* _name ) {
937  return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
938  }
939  #ifdef TIXML_USE_STL
940  const TiXmlAttribute* Find( const std::string& _name ) const;
941  TiXmlAttribute* Find( const std::string& _name ) {
942  return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
943  }
944 
945  #endif
946 
947 private:
948  //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
949  //*ME: this class must be also use a hidden/disabled copy-constructor !!!
950  TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed
951  void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute)
952 
953  TiXmlAttribute sentinel;
954 };
955 
956 
961 class D_TINY_API TiXmlElement : public TiXmlNode
962 {
963 public:
965  TiXmlElement (const char * in_value);
966 
967  #ifdef TIXML_USE_STL
968  TiXmlElement( const std::string& _value );
970  #endif
971 
972  TiXmlElement( const TiXmlElement& );
973 
974  void operator=( const TiXmlElement& base );
975 
976  virtual ~TiXmlElement();
977 
981  const char* Attribute( const char* name ) const;
982 
989  const char* Attribute( const char* name, int* i ) const;
990 
997  const char* Attribute( const char* name, double* d ) const;
998 
1006  int QueryIntAttribute( const char* name, int* _value ) const;
1008  int QueryDoubleAttribute( const char* name, double* _value ) const;
1010  int QueryFloatAttribute( const char* name, float* _value ) const {
1011  double d;
1012  int result = QueryDoubleAttribute( name, &d );
1013  if ( result == TIXML_SUCCESS ) {
1014  *_value = (float)d;
1015  }
1016  return result;
1017  }
1018 
1019  #ifdef TIXML_USE_STL
1020 
1028  template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const
1029  {
1030  const TiXmlAttribute* node = attributeSet.Find( name );
1031  if ( !node )
1032  return TIXML_NO_ATTRIBUTE;
1033 
1034  std::stringstream sstream( node->ValueStr() );
1035  sstream >> *outValue;
1036  if ( !sstream.fail() )
1037  return TIXML_SUCCESS;
1038  return TIXML_WRONG_TYPE;
1039  }
1040  /*
1041  This is - in theory - a bug fix for "QueryValueAtribute returns truncated std::string"
1042  but template specialization is hard to get working cross-compiler. Leaving the bug for now.
1043 
1044  // The above will fail for std::string because the space character is used as a seperator.
1045  // Specialize for strings. Bug [ 1695429 ] QueryValueAtribute returns truncated std::string
1046  template<> int QueryValueAttribute( const std::string& name, std::string* outValue ) const
1047  {
1048  const TiXmlAttribute* node = attributeSet.Find( name );
1049  if ( !node )
1050  return TIXML_NO_ATTRIBUTE;
1051  *outValue = node->ValueStr();
1052  return TIXML_SUCCESS;
1053  }
1054  */
1055  #endif
1056 
1060  void SetAttribute( const char* name, const char * _value );
1061 
1062  #ifdef TIXML_USE_STL
1063  const std::string* Attribute( const std::string& name ) const;
1064  const std::string* Attribute( const std::string& name, int* i ) const;
1065  const std::string* Attribute( const std::string& name, double* d ) const;
1066  int QueryIntAttribute( const std::string& name, int* _value ) const;
1067  int QueryDoubleAttribute( const std::string& name, double* _value ) const;
1068 
1070  void SetAttribute( const std::string& name, const std::string& _value );
1072  void SetAttribute( const std::string& name, int _value );
1073  #endif
1074 
1078  void SetAttribute( const char * name, int value );
1079 
1083  void SetDoubleAttribute( const char * name, double value );
1084 
1087  void RemoveAttribute( const char * name );
1088  #ifdef TIXML_USE_STL
1089  void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); }
1090  #endif
1091 
1092  const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); }
1093  TiXmlAttribute* FirstAttribute() { return attributeSet.First(); }
1094  const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); }
1095  TiXmlAttribute* LastAttribute() { return attributeSet.Last(); }
1096 
1129  const char* GetText() const;
1130 
1132  virtual TiXmlNode* Clone() const;
1133  // Print the Element to a FILE stream.
1134  virtual void Print( FILE* cfile, int depth ) const;
1135 
1136  /* Attribtue parsing starts: next char past '<'
1137  returns: next char past '>'
1138  */
1139  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1140 
1141  virtual const TiXmlElement* ToElement() const { return this; }
1142  virtual TiXmlElement* ToElement() { return this; }
1143 
1146  virtual bool Accept( TiXmlVisitor* visitor ) const;
1147 
1148 protected:
1149 
1150  void CopyTo( TiXmlElement* target ) const;
1151  void ClearThis(); // like clear, but initializes 'this' object as well
1152 
1153  // Used to be public [internal use]
1154  #ifdef TIXML_USE_STL
1155  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1156  #endif
1157  /* [internal use]
1158  Reads the "value" of the element -- another element, or text.
1159  This should terminate with the current end tag.
1160  */
1161  const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
1162 
1163 private:
1164 
1165  TiXmlAttributeSet attributeSet;
1166 };
1167 
1168 
1171 class D_TINY_API TiXmlComment : public TiXmlNode
1172 {
1173 public:
1175  TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {}
1177  TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) {
1178  SetValue( _value );
1179  }
1180  TiXmlComment( const TiXmlComment& );
1181  void operator=( const TiXmlComment& base );
1182 
1183  virtual ~TiXmlComment() {}
1184 
1186  virtual TiXmlNode* Clone() const;
1187  // Write this Comment to a FILE stream.
1188  virtual void Print( FILE* cfile, int depth ) const;
1189 
1190  /* Attribtue parsing starts: at the ! of the !--
1191  returns: next char past '>'
1192  */
1193  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1194 
1195  virtual const TiXmlComment* ToComment() const { return this; }
1196  virtual TiXmlComment* ToComment() { return this; }
1197 
1200  virtual bool Accept( TiXmlVisitor* visitor ) const;
1201 
1202 protected:
1203  void CopyTo( TiXmlComment* target ) const;
1204 
1205  // used to be public
1206  #ifdef TIXML_USE_STL
1207  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1208  #endif
1209 // virtual void StreamOut( TIXML_OSTREAM * out ) const;
1210 
1211 private:
1212 
1213 };
1214 
1215 
1221 class D_TINY_API TiXmlText : public TiXmlNode
1222 {
1223  friend class TiXmlElement;
1224 public:
1229  TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT)
1230  {
1231  SetValue( initValue );
1232  cdata = false;
1233  }
1234  virtual ~TiXmlText() {}
1235 
1236  #ifdef TIXML_USE_STL
1237  TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT)
1239  {
1240  SetValue( initValue );
1241  cdata = false;
1242  }
1243  #endif
1244 
1245  TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT ) { copy.CopyTo( this ); }
1246  void operator=( const TiXmlText& base ) { base.CopyTo( this ); }
1247 
1248  // Write this text object to a FILE stream.
1249  virtual void Print( FILE* cfile, int depth ) const;
1250 
1252  bool CDATA() const { return cdata; }
1254  void SetCDATA( bool _cdata ) { cdata = _cdata; }
1255 
1256  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1257 
1258  virtual const TiXmlText* ToText() const { return this; }
1259  virtual TiXmlText* ToText() { return this; }
1260 
1263  virtual bool Accept( TiXmlVisitor* content ) const;
1264 
1265 protected :
1267  virtual TiXmlNode* Clone() const;
1268  void CopyTo( TiXmlText* target ) const;
1269 
1270  bool Blank() const; // returns true if all white space and new lines
1271  // [internal use]
1272  #ifdef TIXML_USE_STL
1273  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1274  #endif
1275 
1276 private:
1277  bool cdata; // true if this should be input and output as a CDATA style text element
1278 };
1279 
1280 
1294 class D_TINY_API TiXmlDeclaration : public TiXmlNode
1295 {
1296 public:
1298  TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {}
1299 
1300 #ifdef TIXML_USE_STL
1301  TiXmlDeclaration( const std::string& _version,
1303  const std::string& _encoding,
1304  const std::string& _standalone );
1305 #endif
1306 
1308  TiXmlDeclaration( const char* _version,
1309  const char* _encoding,
1310  const char* _standalone );
1311 
1312  TiXmlDeclaration( const TiXmlDeclaration& copy );
1313  void operator=( const TiXmlDeclaration& copy );
1314 
1315  virtual ~TiXmlDeclaration() {}
1316 
1318  const char *Version() const { return version.c_str (); }
1320  const char *Encoding() const { return encoding.c_str (); }
1322  const char *Standalone() const { return standalone.c_str (); }
1323 
1325  virtual TiXmlNode* Clone() const;
1326  // Print this declaration to a FILE stream.
1327  virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
1328  virtual void Print( FILE* cfile, int depth ) const {
1329  Print( cfile, depth, 0 );
1330  }
1331 
1332  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1333 
1334  virtual const TiXmlDeclaration* ToDeclaration() const { return this; }
1335  virtual TiXmlDeclaration* ToDeclaration() { return this; }
1336 
1339  virtual bool Accept( TiXmlVisitor* visitor ) const;
1340 
1341 protected:
1342  void CopyTo( TiXmlDeclaration* target ) const;
1343  // used to be public
1344  #ifdef TIXML_USE_STL
1345  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1346  #endif
1347 
1348 private:
1349 
1350  TIXML_STRING version;
1351  TIXML_STRING encoding;
1352  TIXML_STRING standalone;
1353 };
1354 
1355 
1363 class D_TINY_API TiXmlUnknown : public TiXmlNode
1364 {
1365 public:
1366  TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {}
1367  virtual ~TiXmlUnknown() {}
1368 
1369  TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN ) { copy.CopyTo( this ); }
1370  void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); }
1371 
1373  virtual TiXmlNode* Clone() const;
1374  // Print this Unknown to a FILE stream.
1375  virtual void Print( FILE* cfile, int depth ) const;
1376 
1377  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1378 
1379  virtual const TiXmlUnknown* ToUnknown() const { return this; }
1380  virtual TiXmlUnknown* ToUnknown() { return this; }
1381 
1384  virtual bool Accept( TiXmlVisitor* content ) const;
1385 
1386 protected:
1387  void CopyTo( TiXmlUnknown* target ) const;
1388 
1389  #ifdef TIXML_USE_STL
1390  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1391  #endif
1392 
1393 private:
1394 
1395 };
1396 
1397 
1402 class D_TINY_API TiXmlDocument : public TiXmlNode
1403 {
1404 public:
1406  TiXmlDocument();
1408  TiXmlDocument( const char * documentName );
1409 
1410  #ifdef TIXML_USE_STL
1411  TiXmlDocument( const std::string& documentName );
1413  #endif
1414 
1415  TiXmlDocument( const TiXmlDocument& copy );
1416  void operator=( const TiXmlDocument& copy );
1417 
1418  virtual ~TiXmlDocument() {}
1419 
1424  bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1426  bool SaveFile() const;
1428  bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1430  bool SaveFile( const char * filename ) const;
1436  bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1438  bool SaveFile( FILE* ) const;
1439 
1440  #ifdef TIXML_USE_STL
1441  bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING )
1442  {
1443 // StringToBuffer f( filename );
1444 // return ( f.buffer && LoadFile( f.buffer, encoding ));
1445  return LoadFile( filename.c_str(), encoding );
1446  }
1447  bool SaveFile( const std::string& filename ) const
1448  {
1449 // StringToBuffer f( filename );
1450 // return ( f.buffer && SaveFile( f.buffer ));
1451  return SaveFile( filename.c_str() );
1452  }
1453  #endif
1454 
1459  virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1460 
1465  const TiXmlElement* RootElement() const { return FirstChildElement(); }
1466  TiXmlElement* RootElement() { return FirstChildElement(); }
1467 
1473  bool Error() const { return error; }
1474 
1476  const char * ErrorDesc() const { return errorDesc.c_str (); }
1477 
1481  int ErrorId() const { return errorId; }
1482 
1490  int ErrorRow() const { return errorLocation.row+1; }
1491  int ErrorCol() const { return errorLocation.col+1; }
1492 
1517  void SetTabSize( int _tabsize ) { tabsize = _tabsize; }
1518 
1519  int TabSize() const { return tabsize; }
1520 
1524  void ClearError() { error = false;
1525  errorId = 0;
1526  errorDesc = "";
1527  errorLocation.row = errorLocation.col = 0;
1528  //errorLocation.last = 0;
1529  }
1530 
1532  void Print() const { Print( stdout, 0 ); }
1533 
1534  /* Write the document to a string using formatted printing ("pretty print"). This
1535  will allocate a character array (new char[]) and return it as a pointer. The
1536  calling code pust call delete[] on the return char* to avoid a memory leak.
1537  */
1538  //char* PrintToMemory() const;
1539 
1541  virtual void Print( FILE* cfile, int depth = 0 ) const;
1542  // [internal use]
1543  void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding );
1544 
1545  virtual const TiXmlDocument* ToDocument() const { return this; }
1546  virtual TiXmlDocument* ToDocument() { return this; }
1547 
1550  virtual bool Accept( TiXmlVisitor* content ) const;
1551 
1552 protected :
1553  // [internal use]
1554  virtual TiXmlNode* Clone() const;
1555  #ifdef TIXML_USE_STL
1556  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1557  #endif
1558 
1559 private:
1560  void CopyTo( TiXmlDocument* target ) const;
1561 
1562  bool error;
1563  int errorId;
1564  TIXML_STRING errorDesc;
1565  int tabsize;
1566  TiXmlCursor errorLocation;
1567  bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write.
1568 };
1569 
1570 
1651 class D_TINY_API TiXmlHandle
1652 {
1653 public:
1655  TiXmlHandle( TiXmlNode* _node ) { this->node = _node; }
1657  TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; }
1658 
1659  void *operator new (size_t size);
1660  void *operator new[](size_t size);
1661  void operator delete (void* ptr);
1662  void operator delete[](void* ptr);
1663 
1664  TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; }
1665 
1667  TiXmlHandle FirstChild() const;
1669  TiXmlHandle FirstChild( const char * value ) const;
1671  TiXmlHandle FirstChildElement() const;
1673  TiXmlHandle FirstChildElement( const char * value ) const;
1674 
1678  TiXmlHandle Child( const char* value, int index ) const;
1682  TiXmlHandle Child( int index ) const;
1687  TiXmlHandle ChildElement( const char* value, int index ) const;
1692  TiXmlHandle ChildElement( int index ) const;
1693 
1694  #ifdef TIXML_USE_STL
1695  TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); }
1696  TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); }
1697 
1698  TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); }
1699  TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); }
1700  #endif
1701 
1704  TiXmlNode* ToNode() const { return node; }
1707  TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
1710  TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
1713  TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
1714 
1718  TiXmlNode* Node() const { return ToNode(); }
1722  TiXmlElement* Element() const { return ToElement(); }
1726  TiXmlText* Text() const { return ToText(); }
1730  TiXmlUnknown* Unknown() const { return ToUnknown(); }
1731 
1732 private:
1733  TiXmlNode* node;
1734 };
1735 
1736 
1756 class D_TINY_API TiXmlPrinter : public TiXmlVisitor
1757 {
1758 public:
1759  TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ),
1760  buffer(), indent( " " ), lineBreak( "\n" ) {}
1761 
1762  virtual bool VisitEnter( const TiXmlDocument& doc );
1763  virtual bool VisitExit( const TiXmlDocument& doc );
1764 
1765  virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute );
1766  virtual bool VisitExit( const TiXmlElement& element );
1767 
1768  virtual bool Visit( const TiXmlDeclaration& declaration );
1769  virtual bool Visit( const TiXmlText& text );
1770  virtual bool Visit( const TiXmlComment& comment );
1771  virtual bool Visit( const TiXmlUnknown& unknown );
1772 
1776  void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; }
1778  const char* Indent() { return indent.c_str(); }
1783  void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; }
1785  const char* LineBreak() { return lineBreak.c_str(); }
1786 
1790  void SetStreamPrinting() { indent = "";
1791  lineBreak = "";
1792  }
1794  const char* CStr() { return buffer.c_str(); }
1796  size_t Size() { return buffer.size(); }
1797 
1798  #ifdef TIXML_USE_STL
1799  const std::string& Str() { return buffer; }
1801  #endif
1802 
1803 private:
1804  void DoIndent() {
1805  for( int i=0; i<depth; ++i )
1806  buffer += indent;
1807  }
1808  void DoLineBreak() {
1809  buffer += lineBreak;
1810  }
1811 
1812  int depth;
1813  bool simpleTextPrint;
1814  TIXML_STRING buffer;
1815  TIXML_STRING indent;
1816  TIXML_STRING lineBreak;
1817 };
1818 
1819 }; // end nd namespace
1820 
1821 #ifdef _MSC_VER
1822 #pragma warning( pop )
1823 #endif
1824 
1825 #endif
1826 
nd::TiXmlVisitor::Visit
virtual bool Visit(const TiXmlDeclaration &)
Visit a declaration.
Definition: tinyxml.h:152
nd::TiXmlNode::ToText
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:714
nd::TiXmlDeclaration::TiXmlDeclaration
TiXmlDeclaration()
Construct an empty declaration.
Definition: tinyxml.h:1298
nd::TiXmlBase::IsWhiteSpaceCondensed
static bool IsWhiteSpaceCondensed()
Return the current white space setting.
Definition: tinyxml.h:237
nd::TiXmlAttribute::Name
const char * Name() const
Return the name of this attribute.
Definition: tinyxml.h:824
nd::TiXmlNode::ToDeclaration
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:715
nd::TiXmlBase::Print
virtual void Print(FILE *cfile, int depth) const =0
All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL ...
nd::TiXmlVisitor::Visit
virtual bool Visit(const TiXmlText &)
Visit a text node.
Definition: tinyxml.h:154
nd::TiXmlVisitor
If you call the Accept() method, it requires being passed a TiXmlVisitor class to handle callbacks.
Definition: tinyxml.h:132
nd::TiXmlNode::ToUnknown
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:720
nd::TiXmlHandle::ToText
TiXmlText * ToText() const
Return the handle as a TiXmlText.
Definition: tinyxml.h:1710
nd::TiXmlNode
The parent class for everything in the Document Object Model.
Definition: tinyxml.h:437
nd::TiXmlNode::Accept
virtual bool Accept(TiXmlVisitor *visitor) const =0
Accept a hierchical visit the nodes in the TinyXML DOM.
nd::TiXmlPrinter::SetLineBreak
void SetLineBreak(const char *_lineBreak)
Set the line breaking string.
Definition: tinyxml.h:1783
nd::TiXmlUnknown
Any tag that tinyXml doesn't recognize is saved as an unknown.
Definition: tinyxml.h:1364
nd::TiXmlBase
TiXmlBase is a base class for every class in TinyXml.
Definition: tinyxml.h:203
nd::TiXmlPrinter
Print to memory functionality.
Definition: tinyxml.h:1757
nd::TiXmlNode::LastChild
TiXmlNode * LastChild()
The last child of this node. Will be null if there are no children.
Definition: tinyxml.h:545
nd::TiXmlText::ToText
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1259
nd::TiXmlDeclaration::Print
virtual void Print(FILE *cfile, int depth) const
All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL ...
Definition: tinyxml.h:1328
nd::TiXmlNode::PreviousSibling
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
Definition: tinyxml.h:627
nd::TiXmlHandle::ToNode
TiXmlNode * ToNode() const
Return the handle as a TiXmlNode.
Definition: tinyxml.h:1704
nd::TiXmlVisitor::Visit
virtual bool Visit(const TiXmlUnknown &)
Visit an unknow node.
Definition: tinyxml.h:158
nd::TiXmlVisitor::VisitEnter
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
Definition: tinyxml.h:142
nd::TiXmlUnknown::ToUnknown
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1380
nd::TiXmlElement::ToElement
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1142
nd::TiXmlBase::Row
int Row() const
Return the position, in the original source file, of this node or attribute.
Definition: tinyxml.h:257
nd::TiXmlVisitor::Visit
virtual bool Visit(const TiXmlComment &)
Visit a comment node.
Definition: tinyxml.h:156
nd::TiXmlComment::ToComment
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1195
nd::TiXmlNode::ToDocument
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:710
nd::TiXmlNode::Type
int Type() const
Query the type (as an enumerated value, above) of this node.
Definition: tinyxml.h:697
nd::TiXmlNode::NodeType
NodeType
The types of XML nodes supported by TinyXml.
Definition: tinyxml.h:476
nd::TiXmlAttribute::TiXmlAttribute
TiXmlAttribute(const char *_name, const char *_value)
Construct an attribute with a name and value.
Definition: tinyxml.h:816
nd::TiXmlNode::ToElement
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:718
nd::TiXmlHandle::TiXmlHandle
TiXmlHandle(TiXmlNode *_node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml.h:1655
nd::TiXmlAttributeSet
Definition: tinyxml.h:917
nd::TiXmlPrinter::Size
size_t Size()
Return the length of the result string.
Definition: tinyxml.h:1796
nd::TiXmlBase::Column
int Column() const
See Row()
Definition: tinyxml.h:258
nd::TiXmlNode::ToDocument
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:717
nd::TiXmlNode::ToDeclaration
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:722
nd::TiXmlPrinter::SetStreamPrinting
void SetStreamPrinting()
Switch over to "stream printing" which is the most dense formatting without linebreaks.
Definition: tinyxml.h:1790
nd::TiXmlPrinter::LineBreak
const char * LineBreak()
Query the current line breaking string.
Definition: tinyxml.h:1785
nd::TiXmlBase::SetCondenseWhiteSpace
static void SetCondenseWhiteSpace(bool condense)
The world does not agree on whether white space should be kept or not.
Definition: tinyxml.h:234
nd::TiXmlBase::SetUserData
void SetUserData(void *user)
Set a pointer to arbitrary user data.
Definition: tinyxml.h:260
nd::TiXmlHandle::ToUnknown
TiXmlUnknown * ToUnknown() const
Return the handle as a TiXmlUnknown.
Definition: tinyxml.h:1713
nd::TiXmlText
XML text.
Definition: tinyxml.h:1222
nd::TiXmlElement::QueryFloatAttribute
int QueryFloatAttribute(const char *name, float *_value) const
QueryFloatAttribute examines the attribute - see QueryIntAttribute().
Definition: tinyxml.h:1010
nd::TiXmlBase::userData
void * userData
Field containing a generic user pointer.
Definition: tinyxml.h:389
nd::TiXmlDocument::Print
void Print() const
Write the document to standard out using formatted printing ("pretty print").
Definition: tinyxml.h:1532
nd::TiXmlNode::Value
const char * Value() const
The meaning of 'value' changes for the specific type of TiXmlNode.
Definition: tinyxml.h:500
nd::TiXmlDocument::ErrorId
int ErrorId() const
Generally, you probably want the error string ( ErrorDesc() ).
Definition: tinyxml.h:1481
nd::TiXmlNode::Parent
TiXmlNode * Parent()
One step up the DOM.
Definition: tinyxml.h:532
nd::TiXmlDocument::RootElement
const TiXmlElement * RootElement() const
Get the root element – the only top level element – of the document.
Definition: tinyxml.h:1465
nd::TiXmlParsingData
Definition: tinyxmlparser.cpp:177
nd::TiXmlText::TiXmlText
TiXmlText(const char *initValue)
Constructor for text element.
Definition: tinyxml.h:1229
nd::TiXmlAttribute::TiXmlAttribute
TiXmlAttribute()
Construct an empty attribute.
Definition: tinyxml.h:798
nd::TiXmlComment
An XML comment.
Definition: tinyxml.h:1172
nd::TiXmlElement
The element is a container class.
Definition: tinyxml.h:962
nd::TiXmlDocument::SetTabSize
void SetTabSize(int _tabsize)
SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) to report the correct v...
Definition: tinyxml.h:1517
nd::TiXmlDocument::ErrorDesc
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
Definition: tinyxml.h:1476
nd::TiXmlUnknown::ToUnknown
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1379
nd::TiXmlDeclaration::Encoding
const char * Encoding() const
Encoding. Will return an empty string if none was found.
Definition: tinyxml.h:1320
nd::TiXmlBase::GetUserData
const void * GetUserData() const
Get a pointer to arbitrary user data.
Definition: tinyxml.h:262
nd::TiXmlVisitor::VisitExit
virtual bool VisitExit(const TiXmlDocument &)
Visit a document.
Definition: tinyxml.h:144
nd::TiXmlDeclaration::Version
const char * Version() const
Version. Will return an empty string if none was found.
Definition: tinyxml.h:1318
nd::TiXmlElement::LastAttribute
const TiXmlAttribute * LastAttribute() const
Access the last attribute in this element.
Definition: tinyxml.h:1094
nd::TiXmlDocument::ToDocument
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1545
nd::TiXmlText::SetCDATA
void SetCDATA(bool _cdata)
Turns on or off a CDATA representation of text.
Definition: tinyxml.h:1254
nd::TiXmlNode::ToText
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:721
nd::TiXmlNode::ToUnknown
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:713
nd::TiXmlDocument
Always the top level node.
Definition: tinyxml.h:1403
nd::TiXmlCursor
Definition: tinyxml.h:104
nd::TiXmlNode::LastChild
TiXmlNode * LastChild(const char *_value)
The last child of this node matching 'value'. Will be null if there are no children.
Definition: tinyxml.h:548
nd::TiXmlHandle::Node
TiXmlNode * Node() const
Definition: tinyxml.h:1718
nd::TiXmlNode::Clone
virtual TiXmlNode * Clone() const =0
Create an exact duplicate of this node and return it.
nd::TiXmlText::ToText
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1258
nd::TiXmlNode::SetValue
void SetValue(const char *_value)
Changes the value of the node.
Definition: tinyxml.h:521
nd::TiXmlDeclaration
In correct XML the declaration is the first entry in the file.
Definition: tinyxml.h:1295
nd::TiXmlHandle::Element
TiXmlElement * Element() const
Definition: tinyxml.h:1722
nd::TiXmlDeclaration::ToDeclaration
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1334
nd::TiXmlDocument::Error
bool Error() const
If an error occurs, Error will be set to true.
Definition: tinyxml.h:1473
nd::TiXmlNode::FirstChild
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
Definition: tinyxml.h:535
nd::TiXmlNode::NextSibling
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
Definition: tinyxml.h:644
nd::TiXmlDocument::ErrorCol
int ErrorCol() const
The column where the error occured. See ErrorRow()
Definition: tinyxml.h:1491
nd::TiXmlDocument::ToDocument
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1546
nd::TiXmlPrinter::SetIndent
void SetIndent(const char *_indent)
Set the indent characters for printing.
Definition: tinyxml.h:1776
nd::TiXmlVisitor::VisitEnter
virtual bool VisitEnter(const TiXmlElement &, const TiXmlAttribute *)
Visit an element.
Definition: tinyxml.h:147
nd::TiXmlNode::ToComment
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:712
nd::TiXmlDeclaration::ToDeclaration
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1335
nd::TiXmlDocument::ClearError
void ClearError()
If you have handled the error, it can be reset with this call.
Definition: tinyxml.h:1524
nd::TiXmlNode::ToElement
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:711
nd::TiXmlAttribute::SetName
void SetName(const char *_name)
Set the name of this attribute.
Definition: tinyxml.h:848
nd::TiXmlPrinter::Indent
const char * Indent()
Query the indention string.
Definition: tinyxml.h:1778
nd::TiXmlBase::GetUserData
void * GetUserData()
Get a pointer to arbitrary user data.
Definition: tinyxml.h:261
nd::TiXmlComment::TiXmlComment
TiXmlComment()
Constructs an empty comment.
Definition: tinyxml.h:1175
nd::TiXmlHandle
A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thi...
Definition: tinyxml.h:1652
nd::TiXmlNode::NoChildren
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml.h:708
nd::TiXmlHandle::Text
TiXmlText * Text() const
Definition: tinyxml.h:1726
nd::TiXmlHandle::Unknown
TiXmlUnknown * Unknown() const
Definition: tinyxml.h:1730
nd::TiXmlPrinter::CStr
const char * CStr()
Return the result.
Definition: tinyxml.h:1794
nd::TiXmlAttribute::Value
const char * Value() const
Return the value of this attribute.
Definition: tinyxml.h:825
nd::TiXmlHandle::TiXmlHandle
TiXmlHandle(const TiXmlHandle &ref)
Copy constructor.
Definition: tinyxml.h:1657
nd::TiXmlComment::ToComment
virtual TiXmlComment * ToComment()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1196
nd::TiXmlAttribute::SetValue
void SetValue(const char *_value)
Set the value.
Definition: tinyxml.h:849
nd::TiXmlHandle::ToElement
TiXmlElement * ToElement() const
Return the handle as a TiXmlElement.
Definition: tinyxml.h:1707
nd::TiXmlComment::TiXmlComment
TiXmlComment(const char *_value)
Construct a comment from text.
Definition: tinyxml.h:1177
nd::TiXmlDeclaration::Standalone
const char * Standalone() const
Is this a standalone document?
Definition: tinyxml.h:1322
nd::TiXmlAttribute
An attribute is a name-value pair.
Definition: tinyxml.h:793
nd::TiXmlText::CDATA
bool CDATA() const
Queries whether this represents text using a CDATA section.
Definition: tinyxml.h:1252
nd::TiXmlVisitor::VisitExit
virtual bool VisitExit(const TiXmlElement &)
Visit an element.
Definition: tinyxml.h:149
nd::TiXmlNode::ToComment
virtual TiXmlComment * ToComment()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:719
nd::TiXmlElement::ToElement
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1141
nd::TiXmlDocument::ErrorRow
int ErrorRow() const
Returns the location (if known) of the error.
Definition: tinyxml.h:1490
nd::TiXmlAttribute::Print
virtual void Print(FILE *cfile, int depth) const
All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL ...
Definition: tinyxml.h:883
nd::TiXmlElement::FirstAttribute
const TiXmlAttribute * FirstAttribute() const
Access the first attribute in this element.
Definition: tinyxml.h:1092