tinyxml.h
Go to the documentation of this file.
1 /*
2 www.sourceforge.net/projects/tinyxml
3 Original code by 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 #define TIXML_USE_STL
47 
48 #ifdef TIXML_USE_STL
49  #include <string>
50  #include <iostream>
51  #include <sstream>
52  #define TIXML_STRING std::string
53 #else
54  #include "tinystr.h"
55  #define TIXML_STRING TiXmlString
56 #endif
57 
58 // Deprecated library function hell. Compilers want to use the
59 // new safe versions. This probably doesn't fully address the problem,
60 // but it gets closer. There are too many compilers for me to fully
61 // test. If you get compilation troubles, undefine TIXML_SAFE
62 #define TIXML_SAFE
63 
64 #ifdef TIXML_SAFE
65  #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
66  // Microsoft visual studio, version 2005 and higher.
67  #define TIXML_SNPRINTF _snprintf_s
68  #define TIXML_SSCANF sscanf_s
69  #elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
70  // Microsoft visual studio, version 6 and higher.
71  //#pragma message( "Using _sn* functions." )
72  #define TIXML_SNPRINTF _snprintf
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_SSCANF sscanf
79  #else
80  #define TIXML_SNPRINTF snprintf
81  #define TIXML_SSCANF sscanf
82  #endif
83 #endif
84 
85 class TiXmlDocument;
86 class TiXmlElement;
87 class TiXmlComment;
88 class TiXmlUnknown;
89 class TiXmlAttribute;
90 class TiXmlText;
91 class TiXmlDeclaration;
92 class TiXmlParsingData;
93 
94 const int TIXML_MAJOR_VERSION = 2;
95 const int TIXML_MINOR_VERSION = 6;
96 const int TIXML_PATCH_VERSION = 2;
97 
98 /* Internal structure for tracking location of items
99  in the XML file.
100 */
102 {
104  void Clear() { row = col = -1; }
105 
106  int row; // 0 based.
107  int col; // 0 based.
108 };
109 
110 
131 {
132 public:
133  virtual ~TiXmlVisitor() {}
134 
136  virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; }
138  virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; }
139 
141  virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; }
143  virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; }
144 
146  virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; }
148  virtual bool Visit( const TiXmlText& /*text*/ ) { return true; }
150  virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; }
152  virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; }
153 };
154 
155 // Only used by Attribute::Query functions
156 enum
157 {
161 };
162 
163 
164 // Used by the parsing routines.
166 {
170 };
171 
173 
197 {
198  friend class TiXmlNode;
199  friend class TiXmlElement;
200  friend class TiXmlDocument;
201 
202 public:
203  TiXmlBase() : userData(0) {}
204  virtual ~TiXmlBase() {}
205 
215  virtual void Print( FILE* cfile, int depth ) const = 0;
216 
223  static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; }
224 
226  static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; }
227 
246  int Row() const { return location.row + 1; }
247  int Column() const { return location.col + 1; }
248 
249  void SetUserData( void* user ) { userData = user; }
250  void* GetUserData() { return userData; }
251  const void* GetUserData() const { return userData; }
252 
253  // Table that returs, for a given lead byte, the total number of bytes
254  // in the UTF-8 sequence.
255  static const int utf8ByteTable[256];
256 
257  virtual const char* Parse( const char* p,
258  TiXmlParsingData* data,
259  TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
260 
264  static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out );
265 
266  enum
267  {
284 
286  };
287 
288 protected:
289 
290  static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
291 
292  inline static bool IsWhiteSpace( char c )
293  {
294  return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
295  }
296  inline static bool IsWhiteSpace( int c )
297  {
298  if ( c < 256 )
299  return IsWhiteSpace( (char) c );
300  return false; // Again, only truly correct for English/Latin...but usually works.
301  }
302 
303  #ifdef TIXML_USE_STL
304  static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag );
305  static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag );
306  #endif
307 
308  /* Reads an XML name into the string provided. Returns
309  a pointer just past the last character of the name,
310  or 0 if the function has an error.
311  */
312  static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding );
313 
314  /* Reads text. Returns a pointer past the given end tag.
315  Wickedly complex options, but it keeps the (sensitive) code in one place.
316  */
317  static const char* ReadText( const char* in, // where to start
318  TIXML_STRING* text, // the string read
319  bool ignoreWhiteSpace, // whether to keep the white space
320  const char* endTag, // what ends this text
321  bool ignoreCase, // whether to ignore case in the end tag
322  TiXmlEncoding encoding ); // the current encoding
323 
324  // If an entity has been found, transform it into a character.
325  static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding );
326 
327  // Get a character, while interpreting entities.
328  // The length can be from 0 to 4 bytes.
329  inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding )
330  {
331  assert( p );
332  if ( encoding == TIXML_ENCODING_UTF8 )
333  {
334  *length = utf8ByteTable[ *((const unsigned char*)p) ];
335  assert( *length >= 0 && *length < 5 );
336  }
337  else
338  {
339  *length = 1;
340  }
341 
342  if ( *length == 1 )
343  {
344  if ( *p == '&' )
345  return GetEntity( p, _value, length, encoding );
346  *_value = *p;
347  return p+1;
348  }
349  else if ( *length )
350  {
351  //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe),
352  // and the null terminator isn't needed
353  for( int i=0; p[i] && i<*length; ++i ) {
354  _value[i] = p[i];
355  }
356  return p + (*length);
357  }
358  else
359  {
360  // Not valid text.
361  return 0;
362  }
363  }
364 
365  // Return true if the next characters in the stream are any of the endTag sequences.
366  // Ignore case only works for english, and should only be relied on when comparing
367  // to English words: StringEqual( p, "version", true ) is fine.
368  static bool StringEqual( const char* p,
369  const char* endTag,
370  bool ignoreCase,
371  TiXmlEncoding encoding );
372 
373  static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
374 
376 
378  void* userData;
379 
380  // None of these methods are reliable for any language except English.
381  // Good for approximation, not great for accuracy.
382  static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding );
383  static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding );
384  inline static int ToLower( int v, TiXmlEncoding encoding )
385  {
386  if ( encoding == TIXML_ENCODING_UTF8 )
387  {
388  if ( v < 128 ) return tolower( v );
389  return v;
390  }
391  else
392  {
393  return tolower( v );
394  }
395  }
396  static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
397 
398 private:
399  TiXmlBase( const TiXmlBase& ); // not implemented.
400  void operator=( const TiXmlBase& base ); // not allowed.
401 
402  struct Entity
403  {
404  const char* str;
405  unsigned int strLength;
406  char chr;
407  };
408  enum
409  {
410  NUM_ENTITY = 5,
411  MAX_ENTITY_LENGTH = 6
412 
413  };
414  static Entity entity[ NUM_ENTITY ];
415  static bool condenseWhiteSpace;
416 };
417 
418 
425 class TiXmlNode : public TiXmlBase
426 {
427  friend class TiXmlDocument;
428  friend class TiXmlElement;
429 
430 public:
431  #ifdef TIXML_USE_STL
432 
436  friend std::istream& operator >> (std::istream& in, TiXmlNode& base);
437 
454  friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
455 
457  friend std::string& operator<< (std::string& out, const TiXmlNode& base );
458 
459  #endif
460 
464  enum NodeType
465  {
473  };
474 
475  virtual ~TiXmlNode();
476 
489  const char *Value() const { return value.c_str (); }
490 
491  #ifdef TIXML_USE_STL
492 
496  const std::string& ValueStr() const { return value; }
497  #endif
498 
499  const TIXML_STRING& ValueTStr() const { return value; }
500 
510  void SetValue(const char * _value) { value = _value;}
511 
512  #ifdef TIXML_USE_STL
513  void SetValue( const std::string& _value ) { value = _value; }
515  #endif
516 
518  void Clear();
519 
521  TiXmlNode* Parent() { return parent; }
522  const TiXmlNode* Parent() const { return parent; }
523 
524  const TiXmlNode* FirstChild() const { return firstChild; }
526  const TiXmlNode* FirstChild( const char * value ) const;
527  TiXmlNode* FirstChild( const char * _value ) {
529  // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe)
530  // call the method, cast the return back to non-const.
531  return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value ));
532  }
533  const TiXmlNode* LastChild() const { return lastChild; }
535 
536  const TiXmlNode* LastChild( const char * value ) const;
537  TiXmlNode* LastChild( const char * _value ) {
538  return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value ));
539  }
540 
541  #ifdef TIXML_USE_STL
542  const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); }
543  TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); }
544  const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); }
545  TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); }
546  #endif
547 
564  const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const;
565  TiXmlNode* IterateChildren( const TiXmlNode* previous ) {
566  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) );
567  }
568 
570  const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const;
571  TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) {
572  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) );
573  }
574 
575  #ifdef TIXML_USE_STL
576  const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); }
577  TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); }
578  #endif
579 
583  TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
584 
585 
595  TiXmlNode* LinkEndChild( TiXmlNode* addThis );
596 
600  TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
601 
605  TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis );
606 
610  TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
611 
613  bool RemoveChild( TiXmlNode* removeThis );
614 
616  const TiXmlNode* PreviousSibling() const { return prev; }
618 
620  const TiXmlNode* PreviousSibling( const char * ) const;
621  TiXmlNode* PreviousSibling( const char *_prev ) {
622  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) );
623  }
624 
625  #ifdef TIXML_USE_STL
626  const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); }
627  TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); }
628  const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); }
629  TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); }
630  #endif
631 
633  const TiXmlNode* NextSibling() const { return next; }
634  TiXmlNode* NextSibling() { return next; }
635 
637  const TiXmlNode* NextSibling( const char * ) const;
638  TiXmlNode* NextSibling( const char* _next ) {
639  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) );
640  }
641 
646  const TiXmlElement* NextSiblingElement() const;
648  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() );
649  }
650 
655  const TiXmlElement* NextSiblingElement( const char * ) const;
656  TiXmlElement* NextSiblingElement( const char *_next ) {
657  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) );
658  }
659 
660  #ifdef TIXML_USE_STL
661  const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); }
662  TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); }
663  #endif
664 
666  const TiXmlElement* FirstChildElement() const;
668  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() );
669  }
670 
672  const TiXmlElement* FirstChildElement( const char * _value ) const;
673  TiXmlElement* FirstChildElement( const char * _value ) {
674  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) );
675  }
676 
677  #ifdef TIXML_USE_STL
678  const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); }
679  TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); }
680  #endif
681 
686  int Type() const { return type; }
687 
691  const TiXmlDocument* GetDocument() const;
693  return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() );
694  }
695 
697  bool NoChildren() const { return !firstChild; }
698 
699  virtual const TiXmlDocument* ToDocument() const { return 0; }
700  virtual const TiXmlElement* ToElement() const { return 0; }
701  virtual const TiXmlComment* ToComment() const { return 0; }
702  virtual const TiXmlUnknown* ToUnknown() const { return 0; }
703  virtual const TiXmlText* ToText() const { return 0; }
704  virtual const TiXmlDeclaration* ToDeclaration() const { return 0; }
705 
706  virtual TiXmlDocument* ToDocument() { return 0; }
707  virtual TiXmlElement* ToElement() { return 0; }
708  virtual TiXmlComment* ToComment() { return 0; }
709  virtual TiXmlUnknown* ToUnknown() { return 0; }
710  virtual TiXmlText* ToText() { return 0; }
711  virtual TiXmlDeclaration* ToDeclaration() { return 0; }
712 
716  virtual TiXmlNode* Clone() const = 0;
717 
740  virtual bool Accept( TiXmlVisitor* visitor ) const = 0;
741 
742 protected:
743  TiXmlNode( NodeType _type );
744 
745  // Copy to the allocated object. Shared functionality between Clone, Copy constructor,
746  // and the assignment operator.
747  void CopyTo( TiXmlNode* target ) const;
748 
749  #ifdef TIXML_USE_STL
750  // The real work of the input operator.
751  virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0;
752  #endif
753 
754  // Figure out what is at *p, and parse it. Returns null if it is not an xml node.
755  TiXmlNode* Identify( const char* start, TiXmlEncoding encoding );
756 
759 
762 
764 
767 
768 private:
769  TiXmlNode( const TiXmlNode& ); // not implemented.
770  void operator=( const TiXmlNode& base ); // not allowed.
771 };
772 
773 
781 class TiXmlAttribute : public TiXmlBase
782 {
783  friend class TiXmlAttributeSet;
784 
785 public:
788  {
789  document = 0;
790  prev = next = 0;
791  }
792 
793  #ifdef TIXML_USE_STL
794  TiXmlAttribute( const std::string& _name, const std::string& _value )
796  {
797  name = _name;
798  value = _value;
799  document = 0;
800  prev = next = 0;
801  }
802  #endif
803 
805  TiXmlAttribute( const char * _name, const char * _value )
806  {
807  name = _name;
808  value = _value;
809  document = 0;
810  prev = next = 0;
811  }
812 
813  const char* Name() const { return name.c_str(); }
814  const char* Value() const { return value.c_str(); }
815  #ifdef TIXML_USE_STL
816  const std::string& ValueStr() const { return value; }
817  #endif
818  int IntValue() const;
819  double DoubleValue() const;
820 
821  // Get the tinyxml string representation
822  const TIXML_STRING& NameTStr() const { return name; }
823 
833  int QueryIntValue( int* _value ) const;
835  int QueryDoubleValue( double* _value ) const;
836 
837  void SetName( const char* _name ) { name = _name; }
838  void SetValue( const char* _value ) { value = _value; }
839 
840  void SetIntValue( int _value );
841  void SetDoubleValue( double _value );
842 
843  #ifdef TIXML_USE_STL
844  void SetName( const std::string& _name ) { name = _name; }
847  void SetValue( const std::string& _value ) { value = _value; }
848  #endif
849 
851  const TiXmlAttribute* Next() const;
853  return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() );
854  }
855 
857  const TiXmlAttribute* Previous() const;
859  return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() );
860  }
861 
862  bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
863  bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; }
864  bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; }
865 
866  /* Attribute parsing starts: first letter of the name
867  returns: the next char after the value end quote
868  */
869  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
870 
871  // Prints this Attribute to a FILE stream.
872  virtual void Print( FILE* cfile, int depth ) const {
873  Print( cfile, depth, 0 );
874  }
875  void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
876 
877  // [internal use]
878  // Set the document pointer so the attribute can report errors.
879  void SetDocument( TiXmlDocument* doc ) { document = doc; }
880 
881 private:
882  TiXmlAttribute( const TiXmlAttribute& ); // not implemented.
883  void operator=( const TiXmlAttribute& base ); // not allowed.
884 
885  TiXmlDocument* document; // A pointer back to a document, for error reporting.
886  TIXML_STRING name;
887  TIXML_STRING value;
888  TiXmlAttribute* prev;
889  TiXmlAttribute* next;
890 };
891 
892 
893 /* A class used to manage a group of attributes.
894  It is only used internally, both by the ELEMENT and the DECLARATION.
895 
896  The set can be changed transparent to the Element and Declaration
897  classes that use it, but NOT transparent to the Attribute
898  which has to implement a next() and previous() method. Which makes
899  it a bit problematic and prevents the use of STL.
900 
901  This version is implemented with circular lists because:
902  - I like circular lists
903  - it demonstrates some independence from the (typical) doubly linked list.
904 */
906 {
907 public:
910 
911  void Add( TiXmlAttribute* attribute );
912  void Remove( TiXmlAttribute* attribute );
913 
914  const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
915  TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
916  const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
917  TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
918 
919  TiXmlAttribute* Find( const char* _name ) const;
920  TiXmlAttribute* FindOrCreate( const char* _name );
921 
922 # ifdef TIXML_USE_STL
923  TiXmlAttribute* Find( const std::string& _name ) const;
924  TiXmlAttribute* FindOrCreate( const std::string& _name );
925 # endif
926 
927 
928 private:
929  //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
930  //*ME: this class must be also use a hidden/disabled copy-constructor !!!
931  TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed
932  void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute)
933 
934  TiXmlAttribute sentinel;
935 };
936 
937 
942 class TiXmlElement : public TiXmlNode
943 {
944 public:
946  TiXmlElement (const char * in_value);
947 
948  #ifdef TIXML_USE_STL
949  TiXmlElement( const std::string& _value );
951  #endif
952 
953  TiXmlElement( const TiXmlElement& );
954 
955  TiXmlElement& operator=( const TiXmlElement& base );
956 
957  virtual ~TiXmlElement();
958 
962  const char* Attribute( const char* name ) const;
963 
970  const char* Attribute( const char* name, int* i ) const;
971 
978  const char* Attribute( const char* name, double* d ) const;
979 
987  int QueryIntAttribute( const char* name, int* _value ) const;
989  int QueryUnsignedAttribute( const char* name, unsigned* _value ) const;
994  int QueryBoolAttribute( const char* name, bool* _value ) const;
996  int QueryDoubleAttribute( const char* name, double* _value ) const;
998  int QueryFloatAttribute( const char* name, float* _value ) const {
999  double d;
1000  int result = QueryDoubleAttribute( name, &d );
1001  if ( result == TIXML_SUCCESS ) {
1002  *_value = (float)d;
1003  }
1004  return result;
1005  }
1006 
1007  #ifdef TIXML_USE_STL
1008  int QueryStringAttribute( const char* name, std::string* _value ) const {
1010  const char* cstr = Attribute( name );
1011  if ( cstr ) {
1012  *_value = std::string( cstr );
1013  return TIXML_SUCCESS;
1014  }
1015  return TIXML_NO_ATTRIBUTE;
1016  }
1017 
1026  template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const
1027  {
1028  const TiXmlAttribute* node = attributeSet.Find( name );
1029  if ( !node )
1030  return TIXML_NO_ATTRIBUTE;
1031 
1032  std::stringstream sstream( node->ValueStr() );
1033  sstream >> *outValue;
1034  if ( !sstream.fail() )
1035  return TIXML_SUCCESS;
1036  return TIXML_WRONG_TYPE;
1037  }
1038 
1039  int QueryValueAttribute( const std::string& name, std::string* outValue ) const
1040  {
1041  const TiXmlAttribute* node = attributeSet.Find( name );
1042  if ( !node )
1043  return TIXML_NO_ATTRIBUTE;
1044  *outValue = node->ValueStr();
1045  return TIXML_SUCCESS;
1046  }
1047  #endif
1048 
1052  void SetAttribute( const char* name, const char * _value );
1053 
1054  #ifdef TIXML_USE_STL
1055  const std::string* Attribute( const std::string& name ) const;
1056  const std::string* Attribute( const std::string& name, int* i ) const;
1057  const std::string* Attribute( const std::string& name, double* d ) const;
1058  int QueryIntAttribute( const std::string& name, int* _value ) const;
1059  int QueryDoubleAttribute( const std::string& name, double* _value ) const;
1060 
1062  void SetAttribute( const std::string& name, const std::string& _value );
1064  void SetAttribute( const std::string& name, int _value );
1066  void SetDoubleAttribute( const std::string& name, double value );
1067  #endif
1068 
1072  void SetAttribute( const char * name, int value );
1073 
1077  void SetDoubleAttribute( const char * name, double value );
1078 
1081  void RemoveAttribute( const char * name );
1082  #ifdef TIXML_USE_STL
1083  void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); }
1084  #endif
1085 
1086  const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); }
1087  TiXmlAttribute* FirstAttribute() { return attributeSet.First(); }
1088  const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); }
1089  TiXmlAttribute* LastAttribute() { return attributeSet.Last(); }
1090 
1123  const char* GetText() const;
1124 
1126  virtual TiXmlNode* Clone() const;
1127  // Print the Element to a FILE stream.
1128  virtual void Print( FILE* cfile, int depth ) const;
1129 
1130  /* Attribtue parsing starts: next char past '<'
1131  returns: next char past '>'
1132  */
1133  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1134 
1135  virtual const TiXmlElement* ToElement() const { return this; }
1136  virtual TiXmlElement* ToElement() { return this; }
1137 
1140  virtual bool Accept( TiXmlVisitor* visitor ) const;
1141 
1142 protected:
1143 
1144  void CopyTo( TiXmlElement* target ) const;
1145  void ClearThis(); // like clear, but initializes 'this' object as well
1146 
1147  // Used to be public [internal use]
1148  #ifdef TIXML_USE_STL
1149  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1150  #endif
1151  /* [internal use]
1152  Reads the "value" of the element -- another element, or text.
1153  This should terminate with the current end tag.
1154  */
1155  const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
1156 
1157 private:
1158  TiXmlAttributeSet attributeSet;
1159 };
1160 
1161 
1164 class TiXmlComment : public TiXmlNode
1165 {
1166 public:
1170  TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {
1171  SetValue( _value );
1172  }
1173  TiXmlComment( const TiXmlComment& );
1174  TiXmlComment& operator=( const TiXmlComment& base );
1175 
1176  virtual ~TiXmlComment() {}
1177 
1179  virtual TiXmlNode* Clone() const;
1180  // Write this Comment to a FILE stream.
1181  virtual void Print( FILE* cfile, int depth ) const;
1182 
1183  /* Attribtue parsing starts: at the ! of the !--
1184  returns: next char past '>'
1185  */
1186  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1187 
1188  virtual const TiXmlComment* ToComment() const { return this; }
1189  virtual TiXmlComment* ToComment() { return this; }
1190 
1193  virtual bool Accept( TiXmlVisitor* visitor ) const;
1194 
1195 protected:
1196  void CopyTo( TiXmlComment* target ) const;
1197 
1198  // used to be public
1199  #ifdef TIXML_USE_STL
1200  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1201  #endif
1202 // virtual void StreamOut( TIXML_OSTREAM * out ) const;
1203 
1204 private:
1205 
1206 };
1207 
1208 
1214 class TiXmlText : public TiXmlNode
1215 {
1216  friend class TiXmlElement;
1217 public:
1222  TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT)
1223  {
1224  SetValue( initValue );
1225  cdata = false;
1226  }
1227  virtual ~TiXmlText() {}
1228 
1229  #ifdef TIXML_USE_STL
1230  TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT)
1232  {
1233  SetValue( initValue );
1234  cdata = false;
1235  }
1236  #endif
1237 
1238  TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TINYXML_TEXT ) { copy.CopyTo( this ); }
1239  TiXmlText& operator=( const TiXmlText& base ) { base.CopyTo( this ); return *this; }
1240 
1241  // Write this text object to a FILE stream.
1242  virtual void Print( FILE* cfile, int depth ) const;
1243 
1245  bool CDATA() const { return cdata; }
1247  void SetCDATA( bool _cdata ) { cdata = _cdata; }
1248 
1249  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1250 
1251  virtual const TiXmlText* ToText() const { return this; }
1252  virtual TiXmlText* ToText() { return this; }
1253 
1256  virtual bool Accept( TiXmlVisitor* content ) const;
1257 
1258 protected :
1260  virtual TiXmlNode* Clone() const;
1261  void CopyTo( TiXmlText* target ) const;
1262 
1263  bool Blank() const; // returns true if all white space and new lines
1264  // [internal use]
1265  #ifdef TIXML_USE_STL
1266  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1267  #endif
1268 
1269 private:
1270  bool cdata; // true if this should be input and output as a CDATA style text element
1271 };
1272 
1273 
1288 {
1289 public:
1292 
1293 #ifdef TIXML_USE_STL
1294  TiXmlDeclaration( const std::string& _version,
1296  const std::string& _encoding,
1297  const std::string& _standalone );
1298 #endif
1299 
1301  TiXmlDeclaration( const char* _version,
1302  const char* _encoding,
1303  const char* _standalone );
1304 
1305  TiXmlDeclaration( const TiXmlDeclaration& copy );
1307 
1308  virtual ~TiXmlDeclaration() {}
1309 
1311  const char *Version() const { return version.c_str (); }
1313  const char *Encoding() const { return encoding.c_str (); }
1315  const char *Standalone() const { return standalone.c_str (); }
1316 
1318  virtual TiXmlNode* Clone() const;
1319  // Print this declaration to a FILE stream.
1320  virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
1321  virtual void Print( FILE* cfile, int depth ) const {
1322  Print( cfile, depth, 0 );
1323  }
1324 
1325  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1326 
1327  virtual const TiXmlDeclaration* ToDeclaration() const { return this; }
1328  virtual TiXmlDeclaration* ToDeclaration() { return this; }
1329 
1332  virtual bool Accept( TiXmlVisitor* visitor ) const;
1333 
1334 protected:
1335  void CopyTo( TiXmlDeclaration* target ) const;
1336  // used to be public
1337  #ifdef TIXML_USE_STL
1338  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1339  #endif
1340 
1341 private:
1342 
1343  TIXML_STRING version;
1344  TIXML_STRING encoding;
1345  TIXML_STRING standalone;
1346 };
1347 
1348 
1356 class TiXmlUnknown : public TiXmlNode
1357 {
1358 public:
1360  virtual ~TiXmlUnknown() {}
1361 
1362  TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) { copy.CopyTo( this ); }
1363  TiXmlUnknown& operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); return *this; }
1364 
1366  virtual TiXmlNode* Clone() const;
1367  // Print this Unknown to a FILE stream.
1368  virtual void Print( FILE* cfile, int depth ) const;
1369 
1370  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1371 
1372  virtual const TiXmlUnknown* ToUnknown() const { return this; }
1373  virtual TiXmlUnknown* ToUnknown() { return this; }
1374 
1377  virtual bool Accept( TiXmlVisitor* content ) const;
1378 
1379 protected:
1380  void CopyTo( TiXmlUnknown* target ) const;
1381 
1382  #ifdef TIXML_USE_STL
1383  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1384  #endif
1385 
1386 private:
1387 
1388 };
1389 
1390 
1395 class TiXmlDocument : public TiXmlNode
1396 {
1397 public:
1399  TiXmlDocument();
1401  TiXmlDocument( const char * documentName );
1402 
1403  #ifdef TIXML_USE_STL
1404  TiXmlDocument( const std::string& documentName );
1406  #endif
1407 
1408  TiXmlDocument( const TiXmlDocument& copy );
1409  TiXmlDocument& operator=( const TiXmlDocument& copy );
1410 
1411  virtual ~TiXmlDocument() {}
1412 
1417  bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1419  bool SaveFile() const;
1421  bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1423  bool SaveFile( const char * filename ) const;
1429  bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1431  bool SaveFile( FILE* ) const;
1432 
1433  #ifdef TIXML_USE_STL
1434  bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING )
1435  {
1436  return LoadFile( filename.c_str(), encoding );
1437  }
1438  bool SaveFile( const std::string& filename ) const
1439  {
1440  return SaveFile( filename.c_str() );
1441  }
1442  #endif
1443 
1448  virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1449 
1454  const TiXmlElement* RootElement() const { return FirstChildElement(); }
1456 
1462  bool Error() const { return error; }
1463 
1465  const char * ErrorDesc() const { return errorDesc.c_str (); }
1466 
1470  int ErrorId() const { return errorId; }
1471 
1479  int ErrorRow() const { return errorLocation.row+1; }
1480  int ErrorCol() const { return errorLocation.col+1; }
1481 
1506  void SetTabSize( int _tabsize ) { tabsize = _tabsize; }
1507 
1508  int TabSize() const { return tabsize; }
1509 
1513  void ClearError() { error = false;
1514  errorId = 0;
1515  errorDesc = "";
1516  errorLocation.row = errorLocation.col = 0;
1517  //errorLocation.last = 0;
1518  }
1519 
1521  void Print() const { Print( stdout, 0 ); }
1522 
1523  /* Write the document to a string using formatted printing ("pretty print"). This
1524  will allocate a character array (new char[]) and return it as a pointer. The
1525  calling code pust call delete[] on the return char* to avoid a memory leak.
1526  */
1527  //char* PrintToMemory() const;
1528 
1530  virtual void Print( FILE* cfile, int depth = 0 ) const;
1531  // [internal use]
1532  void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding );
1533 
1534  virtual const TiXmlDocument* ToDocument() const { return this; }
1535  virtual TiXmlDocument* ToDocument() { return this; }
1536 
1539  virtual bool Accept( TiXmlVisitor* content ) const;
1540 
1541 protected :
1542  // [internal use]
1543  virtual TiXmlNode* Clone() const;
1544  #ifdef TIXML_USE_STL
1545  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1546  #endif
1547 
1548 private:
1549  void CopyTo( TiXmlDocument* target ) const;
1550 
1551  bool error;
1552  int errorId;
1553  TIXML_STRING errorDesc;
1554  int tabsize;
1555  TiXmlCursor errorLocation;
1556  bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write.
1557 };
1558 
1559 
1641 {
1642 public:
1644  TiXmlHandle( TiXmlNode* _node ) { this->node = _node; }
1646  TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; }
1647  TiXmlHandle operator=( const TiXmlHandle& ref ) { if ( &ref != this ) this->node = ref.node; return *this; }
1648 
1650  TiXmlHandle FirstChild() const;
1652  TiXmlHandle FirstChild( const char * value ) const;
1656  TiXmlHandle FirstChildElement( const char * value ) const;
1657 
1661  TiXmlHandle Child( const char* value, int index ) const;
1665  TiXmlHandle Child( int index ) const;
1670  TiXmlHandle ChildElement( const char* value, int index ) const;
1675  TiXmlHandle ChildElement( int index ) const;
1676 
1677  #ifdef TIXML_USE_STL
1678  TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); }
1679  TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); }
1680 
1681  TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); }
1682  TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); }
1683  #endif
1684 
1687  TiXmlNode* ToNode() const { return node; }
1690  TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
1693  TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
1696  TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
1697 
1701  TiXmlNode* Node() const { return ToNode(); }
1705  TiXmlElement* Element() const { return ToElement(); }
1709  TiXmlText* Text() const { return ToText(); }
1713  TiXmlUnknown* Unknown() const { return ToUnknown(); }
1714 
1715 private:
1716  TiXmlNode* node;
1717 };
1718 
1719 
1740 {
1741 public:
1742  TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ),
1743  buffer(), indent( " " ), lineBreak( "\n" ) {}
1744 
1745  virtual bool VisitEnter( const TiXmlDocument& doc );
1746  virtual bool VisitExit( const TiXmlDocument& doc );
1747 
1748  virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute );
1749  virtual bool VisitExit( const TiXmlElement& element );
1750 
1751  virtual bool Visit( const TiXmlDeclaration& declaration );
1752  virtual bool Visit( const TiXmlText& text );
1753  virtual bool Visit( const TiXmlComment& comment );
1754  virtual bool Visit( const TiXmlUnknown& unknown );
1755 
1759  void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; }
1761  const char* Indent() { return indent.c_str(); }
1766  void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; }
1768  const char* LineBreak() { return lineBreak.c_str(); }
1769 
1773  void SetStreamPrinting() { indent = "";
1774  lineBreak = "";
1775  }
1777  const char* CStr() { return buffer.c_str(); }
1779  size_t Size() { return buffer.size(); }
1780 
1781  #ifdef TIXML_USE_STL
1782  const std::string& Str() { return buffer; }
1784  #endif
1785 
1786 private:
1787  void DoIndent() {
1788  for( int i=0; i<depth; ++i )
1789  buffer += indent;
1790  }
1791  void DoLineBreak() {
1792  buffer += lineBreak;
1793  }
1794 
1795  int depth;
1796  bool simpleTextPrint;
1797  TIXML_STRING buffer;
1798  TIXML_STRING indent;
1799  TIXML_STRING lineBreak;
1800 };
1801 
1802 
1803 #ifdef _MSC_VER
1804 #pragma warning( pop )
1805 #endif
1806 
1807 #endif
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:711
TiXmlElement * FirstChildElement()
Definition: tinyxml.h:667
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
virtual ~TiXmlDeclaration()
Definition: tinyxml.h:1308
void SetDoubleAttribute(const std::string &name, double value)
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
Definition: tinyxml.h:616
virtual bool Accept(TiXmlVisitor *visitor) const
TiXmlNode * NextSibling()
Definition: tinyxml.h:634
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:701
const char * CStr()
Return the result.
Definition: tinyxml.h:1777
Definition: tinyxml.h:101
TiXmlElement * FirstChildElement(const char *_value)
Definition: tinyxml.h:673
int QueryValueAttribute(const std::string &name, T *outValue) const
Definition: tinyxml.h:1026
virtual TiXmlNode * Clone() const
Creates a new Element and returns it - the returned element is a copy.
TiXmlHandle ChildElement(const std::string &_value, int index) const
Definition: tinyxml.h:1682
Definition: tinyxml.h:942
TiXmlNode * prev
Definition: tinyxml.h:765
void Remove(TiXmlAttribute *attribute)
virtual void Print(FILE *cfile, int depth) const
Definition: tinyxml.h:1287
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
int IntValue() const
Return the value of this attribute, converted to an integer.
virtual bool VisitEnter(const TiXmlElement &, const TiXmlAttribute *)
Visit an element.
Definition: tinyxml.h:141
TiXmlComment(const char *_value)
Construct a comment from text.
Definition: tinyxml.h:1170
TiXmlNode * PreviousSibling(const char *_prev)
Definition: tinyxml.h:621
Definition: tinyxml.h:472
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)
virtual bool Accept(TiXmlVisitor *visitor) const =0
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)
void ClearError()
Definition: tinyxml.h:1513
TiXmlCursor location
Definition: tinyxml.h:375
virtual void Print(FILE *cfile, int depth) const
Definition: tinyxml.h:1321
virtual void Print(FILE *cfile, int depth) const
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:707
virtual bool Visit(const TiXmlText &)
Visit a text node.
Definition: tinyxml.h:148
virtual ~TiXmlComment()
Definition: tinyxml.h:1176
void Clear()
Definition: tinyxml.h:104
TiXmlElement * Element() const
Definition: tinyxml.h:1705
const TiXmlNode * PreviousSibling(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:626
Definition: tinyxml.h:469
virtual TiXmlNode * Clone() const
Creates a copy of this Unknown and returns it.
Definition: tinyxml.h:270
friend std::ostream & operator<<(std::ostream &out, const TiXmlNode &base)
const TiXmlAttribute * LastAttribute() const
Access the last attribute in this element.
Definition: tinyxml.h:1088
TiXmlNode * IterateChildren(const char *_value, const TiXmlNode *previous)
Definition: tinyxml.h:571
virtual void Print(FILE *cfile, int depth) const
Definition: tinyxml.h:169
const TiXmlNode * LastChild() const
Definition: tinyxml.h:533
int QueryFloatAttribute(const char *name, float *_value) const
QueryFloatAttribute examines the attribute - see QueryIntAttribute().
Definition: tinyxml.h:998
Definition: tinyxml.h:158
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
TiXmlHandle FirstChild() const
Return a handle to the first child node.
virtual bool Visit(const TiXmlUnknown &)
Visit an unknown node.
Definition: tinyxml.h:152
void SetDoubleValue(double _value)
Set the value from a double.
TiXmlPrinter()
Definition: tinyxml.h:1742
virtual ~TiXmlDocument()
Definition: tinyxml.h:1411
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
TiXmlNode * firstChild
Definition: tinyxml.h:760
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
const int TIXML_PATCH_VERSION
Definition: tinyxml.h:96
#define TIXML_STRING
Definition: tinyxml.h:52
TiXmlElement(const char *in_value)
Construct an element.
virtual TiXmlNode * Clone() const =0
const int TIXML_MAJOR_VERSION
Definition: tinyxml.h:94
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1328
TiXmlNode * NextSibling(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:629
virtual ~TiXmlNode()
void RemoveAttribute(const std::string &name)
STL std::string form.
Definition: tinyxml.h:1083
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)
void SetIndent(const char *_indent)
Definition: tinyxml.h:1759
const TiXmlAttribute * Previous() const
Get the previous sibling attribute in the DOM. Returns null at beginning.
static const char * GetChar(const char *p, char *_value, int *length, TiXmlEncoding encoding)
Definition: tinyxml.h:329
TiXmlHandle FirstChild(const std::string &_value) const
Definition: tinyxml.h:1678
bool operator==(const TiXmlAttribute &rhs) const
Definition: tinyxml.h:862
virtual ~TiXmlText()
Definition: tinyxml.h:1227
virtual ~TiXmlUnknown()
Definition: tinyxml.h:1360
TiXmlNode(NodeType _type)
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:702
virtual bool Accept(TiXmlVisitor *content) const
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
const char * ReadValue(const char *in, TiXmlParsingData *prevData, TiXmlEncoding encoding)
Definition: tinyxml.h:1214
TiXmlCursor()
Definition: tinyxml.h:103
Definition: tinyxml.h:1739
bool Error() const
Definition: tinyxml.h:1462
TiXmlNode * lastChild
Definition: tinyxml.h:761
Definition: tinyxml.h:1640
Definition: tinyxml.h:159
virtual bool Accept(TiXmlVisitor *visitor) const
TiXmlText * Text() const
Definition: tinyxml.h:1709
void * GetUserData()
Get a pointer to arbitrary user data.
Definition: tinyxml.h:250
virtual bool Accept(TiXmlVisitor *content) const
TiXmlEncoding
Definition: tinyxml.h:165
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:704
Definition: tinyxml.h:471
const void * GetUserData() const
Get a pointer to arbitrary user data.
Definition: tinyxml.h:251
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
TiXmlDeclaration()
Construct an empty declaration.
Definition: tinyxml.h:1291
const TiXmlNode * LastChild(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:544
bool LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
const int TIXML_MINOR_VERSION
Definition: tinyxml.h:95
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
TiXmlNode * FirstChild()
Definition: tinyxml.h:525
Definition: tinyxml.h:160
const char * Encoding() const
Encoding. Will return an empty string if none was found.
Definition: tinyxml.h:1313
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)=0
const char * Value() const
Return the value of this attribute.
Definition: tinyxml.h:814
Definition: tinyxml.h:275
void * userData
Field containing a generic user pointer.
Definition: tinyxml.h:378
TiXmlAttribute * First()
Definition: tinyxml.h:915
static const char * ReadName(const char *p, TIXML_STRING *name, TiXmlEncoding encoding)
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
Definition: tinyxml.h:524
friend std::istream & operator>>(std::istream &in, TiXmlNode &base)
virtual TiXmlComment * ToComment()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:708
Definition: tinyxml.h:268
const char * Version() const
Version. Will return an empty string if none was found.
Definition: tinyxml.h:1311
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
Definition: tinyxml.h:633
TiXmlNode * ToNode() const
Definition: tinyxml.h:1687
void SetDocument(TiXmlDocument *doc)
Definition: tinyxml.h:879
TiXmlNode * next
Definition: tinyxml.h:766
Definition: tinyxml.h:470
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:710
TiXmlNode * Identify(const char *start, TiXmlEncoding encoding)
TiXmlDeclaration & operator=(const TiXmlDeclaration &copy)
const std::string & Str()
Return the result.
Definition: tinyxml.h:1783
virtual TiXmlNode * Clone() const
int ErrorRow() const
Definition: tinyxml.h:1479
TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.h:167
void CopyTo(TiXmlDeclaration *target) const
TiXmlElement * FirstChildElement(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:679
const TiXmlElement * NextSiblingElement(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:661
void SetAttribute(const char *name, const char *_value)
static const char * GetEntity(const char *in, char *value, int *length, TiXmlEncoding encoding)
TiXmlElement * RootElement()
Definition: tinyxml.h:1455
int row
Definition: tinyxml.h:106
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1373
double DoubleValue() const
Return the value of this attribute, converted to a double.
virtual void Print(FILE *cfile, int depth, TIXML_STRING *str) const
const std::string & ValueStr() const
Definition: tinyxml.h:496
int QueryBoolAttribute(const char *name, bool *_value) const
TiXmlUnknown & operator=(const TiXmlUnknown &copy)
Definition: tinyxml.h:1363
TiXmlComment & operator=(const TiXmlComment &base)
Definition: tinyxml.h:269
TiXmlNode * FirstChild(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:543
static int IsAlpha(unsigned char anyByte, TiXmlEncoding encoding)
int Row() const
Definition: tinyxml.h:246
const TiXmlAttribute * Last() const
Definition: tinyxml.h:916
static bool StreamTo(std::istream *in, int character, TIXML_STRING *tag)
TiXmlElement & operator=(const TiXmlElement &base)
static bool IsWhiteSpaceCondensed()
Return the current white space setting.
Definition: tinyxml.h:226
int ErrorId() const
Definition: tinyxml.h:1470
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:699
TiXmlHandle Child(const char *value, int index) const
int Type() const
Definition: tinyxml.h:686
TiXmlBase()
Definition: tinyxml.h:203
const TiXmlEncoding TIXML_DEFAULT_ENCODING
Definition: tinyxml.h:172
static const char * SkipWhiteSpace(const char *, TiXmlEncoding encoding)
void SetValue(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:847
Definition: tinyxml.h:468
const std::string & ValueStr() const
Return the value of this attribute.
Definition: tinyxml.h:816
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1534
void CopyTo(TiXmlComment *target) const
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1188
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0
NodeType
Definition: tinyxml.h:464
TiXmlAttribute()
Construct an empty attribute.
Definition: tinyxml.h:787
virtual bool Accept(TiXmlVisitor *visitor) const
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1327
TiXmlAttribute(const char *_name, const char *_value)
Construct an attribute with a name and value.
Definition: tinyxml.h:805
void CopyTo(TiXmlNode *target) const
Definition: tinyxml.h:905
TiXmlNode * Parent()
One step up the DOM.
Definition: tinyxml.h:521
int ErrorCol() const
The column where the error occured. See ErrorRow()
Definition: tinyxml.h:1480
NodeType type
Definition: tinyxml.h:758
const char * Name() const
Return the name of this attribute.
Definition: tinyxml.h:813
const TiXmlDocument * GetDocument() const
Definition: tinyxml.h:196
void SetStreamPrinting()
Definition: tinyxml.h:1773
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1251
const TiXmlElement * RootElement() const
Definition: tinyxml.h:1454
virtual TiXmlNode * Clone() const
Returns a copy of this Comment.
virtual bool VisitExit(const TiXmlElement &)
Visit an element.
Definition: tinyxml.h:143
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:700
Definition: tinyxml.h:425
virtual ~TiXmlElement()
virtual ~TiXmlVisitor()
Definition: tinyxml.h:133
size_t Size()
Return the length of the result string.
Definition: tinyxml.h:1779
void SetTabSize(int _tabsize)
Definition: tinyxml.h:1506
void SetValue(const char *_value)
Definition: tinyxml.h:510
TiXmlHandle operator=(const TiXmlHandle &ref)
Definition: tinyxml.h:1647
int QueryDoubleValue(double *_value) const
QueryDoubleValue examines the value string. See QueryIntValue().
virtual void Print(FILE *cfile, int depth) const
Definition: tinyxml.h:872
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
virtual bool Visit(const TiXmlDeclaration &)
Visit a declaration.
Definition: tinyxml.h:146
void Add(TiXmlAttribute *attribute)
TiXmlHandle FirstChildElement() const
Return a handle to the first child element.
virtual TiXmlNode * Clone() const
[internal use] Creates a new Element and returns it.
TiXmlNode * PreviousSibling(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:627
bool LoadFile(const std::string &filename, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Definition: tinyxml.h:1434
void RemoveAttribute(const char *name)
const TiXmlNode * FirstChild(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:542
static const char * ReadText(const char *in, TIXML_STRING *text, bool ignoreWhiteSpace, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
const char * Attribute(const char *name) const
const TIXML_STRING & NameTStr() const
Definition: tinyxml.h:822
void CopyTo(TiXmlUnknown *target) const
void SetCDATA(bool _cdata)
Turns on or off a CDATA representation of text.
Definition: tinyxml.h:1247
static const char * errorString[TIXML_ERROR_STRING_COUNT]
Definition: tinyxml.h:373
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
void CopyTo(TiXmlElement *target) const
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
const TIXML_STRING & ValueTStr() const
Definition: tinyxml.h:499
void SetName(const char *_name)
Set the name of this attribute.
Definition: tinyxml.h:837
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
Definition: tinyxml.h:136
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1136
TiXmlAttribute * FindOrCreate(const char *_name)
virtual void Print(FILE *cfile, int depth) const =0
TiXmlNode * PreviousSibling()
Definition: tinyxml.h:617
TiXmlUnknown(const TiXmlUnknown &copy)
Definition: tinyxml.h:1362
TiXmlUnknown * Unknown() const
Definition: tinyxml.h:1713
const TiXmlAttribute * First() const
Definition: tinyxml.h:914
const TiXmlElement * NextSiblingElement() const
bool SaveFile() const
Save a file using the current document value. Returns true if successful.
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
int QueryStringAttribute(const char *name, std::string *_value) const
QueryStringAttribute examines the attribute - see QueryIntAttribute().
Definition: tinyxml.h:1009
bool operator<(const TiXmlAttribute &rhs) const
Definition: tinyxml.h:863
const TiXmlAttribute * Next() const
Get the next sibling attribute in the DOM. Returns null at end.
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1252
TiXmlNode * LastChild(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:545
virtual TiXmlComment * ToComment()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1189
TiXmlDocument()
Create an empty document, that has no name.
Definition: tinyxml.h:281
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
virtual bool VisitExit(const TiXmlDocument &doc)
Visit a document.
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)
Definition: tinyxml.h:1356
bool Blank() const
virtual bool VisitEnter(const TiXmlDocument &doc)
Visit a document.
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:628
void SetLineBreak(const char *_lineBreak)
Definition: tinyxml.h:1766
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
int QueryIntValue(int *_value) const
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)
static int IsAlphaNum(unsigned char anyByte, TiXmlEncoding encoding)
virtual bool Visit(const TiXmlComment &)
Visit a comment node.
Definition: tinyxml.h:150
TiXmlNode * Node() const
Definition: tinyxml.h:1701
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:709
TiXmlElement * NextSiblingElement(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:662
TiXmlNode * LastChild(const char *_value)
The last child of this node matching 'value'. Will be null if there are no children.
Definition: tinyxml.h:537
TiXmlHandle FirstChildElement(const std::string &_value) const
Definition: tinyxml.h:1679
const char * Standalone() const
Is this a standalone document?
Definition: tinyxml.h:1315
bool CDATA() const
Queries whether this represents text using a CDATA section.
Definition: tinyxml.h:1245
TiXmlAttribute * LastAttribute()
Definition: tinyxml.h:1089
int TabSize() const
Definition: tinyxml.h:1508
Definition: tinyxml.h:1164
Definition: tinyxml.h:168
int QueryUnsignedAttribute(const char *name, unsigned *_value) const
QueryUnsignedAttribute examines the attribute - see QueryIntAttribute().
static bool IsWhiteSpace(char c)
Definition: tinyxml.h:292
TiXmlText & operator=(const TiXmlText &base)
Definition: tinyxml.h:1239
Definition: tinyxml.h:781
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)
static bool StreamWhiteSpace(std::istream *in, TIXML_STRING *tag)
Definition: tinyxml.h:285
TiXmlAttribute * Last()
Definition: tinyxml.h:917
TiXmlNode * IterateChildren(const std::string &_value, const TiXmlNode *previous)
STL std::string form.
Definition: tinyxml.h:577
Definition: tinyxml.h:130
TiXmlUnknown * ToUnknown() const
Definition: tinyxml.h:1696
void SetUserData(void *user)
Set a pointer to arbitrary user data.
Definition: tinyxml.h:249
TiXmlComment()
Constructs an empty comment.
Definition: tinyxml.h:1168
int QueryDoubleAttribute(const char *name, double *_value) const
QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
virtual TiXmlNode * Clone() const
Creates a copy of this Declaration and returns it.
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml.h:697
TiXmlElement * ToElement() const
Definition: tinyxml.h:1690
TiXmlDocument & operator=(const TiXmlDocument &copy)
TiXmlNode * LastChild()
The last child of this node. Will be null if there are no children.
Definition: tinyxml.h:534
void SetIntValue(int _value)
Set the value from an integer.
TiXmlNode * IterateChildren(const TiXmlNode *previous)
Definition: tinyxml.h:565
TiXmlUnknown()
Definition: tinyxml.h:1359
void ClearThis()
TiXmlAttribute * Next()
Definition: tinyxml.h:852
TiXmlElement * NextSiblingElement()
Definition: tinyxml.h:647
void SetValue(const char *_value)
Set the value.
Definition: tinyxml.h:838
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
Definition: tinyxml.h:1465
const TiXmlNode * IterateChildren(const std::string &_value, const TiXmlNode *previous) const
STL std::string form.
Definition: tinyxml.h:576
int col
Definition: tinyxml.h:107
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:703
TiXmlHandle(TiXmlNode *_node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml.h:1644
TiXmlAttribute * FirstAttribute()
Definition: tinyxml.h:1087
static int ToLower(int v, TiXmlEncoding encoding)
Definition: tinyxml.h:384
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1535
static bool IsWhiteSpace(int c)
Definition: tinyxml.h:296
const char * LineBreak()
Query the current line breaking string.
Definition: tinyxml.h:1768
Definition: tinyxml.h:466
static const int utf8ByteTable[256]
Definition: tinyxml.h:255
virtual void Print(FILE *cfile, int depth) const
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1372
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:706
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
virtual bool Visit(const TiXmlDeclaration &declaration)
Visit a declaration.
virtual ~TiXmlBase()
Definition: tinyxml.h:204
Definition: tinyxml.h:467
virtual bool VisitExit(const TiXmlDocument &)
Visit a document.
Definition: tinyxml.h:138
const char * Value() const
Definition: tinyxml.h:489
static void EncodeString(const TIXML_STRING &str, TIXML_STRING *out)
const char * Indent()
Query the indention string.
Definition: tinyxml.h:1761
TiXmlNode * parent
Definition: tinyxml.h:757
int Column() const
See Row()
Definition: tinyxml.h:247
const TiXmlAttribute * FirstAttribute() const
Access the first attribute in this element.
Definition: tinyxml.h:1086
TiXmlText * ToText() const
Definition: tinyxml.h:1693
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1135
void Clear()
Delete all the children of this node. Does not affect 'this'.
void CopyTo(TiXmlText *target) const
const char * GetText() const
TiXmlNode * NextSibling(const char *_next)
Definition: tinyxml.h:638
const TiXmlNode * Parent() const
Definition: tinyxml.h:522
TiXmlHandle(const TiXmlHandle &ref)
Copy constructor.
Definition: tinyxml.h:1646
bool SaveFile(const std::string &filename) const
< STL std::string version.
Definition: tinyxml.h:1438
TiXmlDocument * GetDocument()
Definition: tinyxml.h:692
TiXmlAttribute * Previous()
Definition: tinyxml.h:858
TiXmlText(const char *initValue)
Definition: tinyxml.h:1222
Definition: tinyxml.h:1395
static void SetCondenseWhiteSpace(bool condense)
Definition: tinyxml.h:223
TIXML_STRING value
Definition: tinyxml.h:763
TiXmlText(const TiXmlText &copy)
Definition: tinyxml.h:1238
TiXmlElement * NextSiblingElement(const char *_next)
Definition: tinyxml.h:656
const TiXmlElement * FirstChildElement(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:678
TiXmlHandle ChildElement(const char *value, int index) const
int QueryValueAttribute(const std::string &name, std::string *outValue) const
Definition: tinyxml.h:1039
void Print() const
Definition: tinyxml.h:1521
int QueryIntAttribute(const char *name, int *_value) const
Definition: tinyxml.h:280
virtual bool Accept(TiXmlVisitor *content) const
Definition: tinyxml.h:282
TiXmlHandle Child(const std::string &_value, int index) const
Definition: tinyxml.h:1681
bool operator>(const TiXmlAttribute &rhs) const
Definition: tinyxml.h:864