Luiza  v03-01
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 F.Gaede, DESY : added #define TIXML_USE_STL for use with marlin
26 */
27 
28 #ifndef TIXML_USE_STL
29 #define TIXML_USE_STL
30 #endif
31 
32 
33 #ifndef TINYXML_INCLUDED
34 #define TINYXML_INCLUDED
35 
36 #ifdef _MSC_VER
37 #pragma warning( push )
38 #pragma warning( disable : 4530 )
39 #pragma warning( disable : 4786 )
40 #endif
41 
42 #include <ctype.h>
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include <string.h>
46 #include <assert.h>
47 
48 // Help out windows:
49 #if defined( _DEBUG ) && !defined( DEBUG )
50 #define DEBUG
51 #endif
52 
53 #ifdef TIXML_USE_STL
54  #include <string>
55  #include <iostream>
56  #include <sstream>
57  #define TIXML_STRING std::string
58 #else
59  #include "tinystr.h"
60  #define TIXML_STRING TiXmlString
61 #endif
62 
63 // Deprecated library function hell. Compilers want to use the
64 // new safe versions. This probably doesn't fully address the problem,
65 // but it gets closer. There are too many compilers for me to fully
66 // test. If you get compilation troubles, undefine TIXML_SAFE
67 #define TIXML_SAFE
68 
69 #ifdef TIXML_SAFE
70  #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
71  // Microsoft visual studio, version 2005 and higher.
72  #define TIXML_SNPRINTF _snprintf_s
73  #define TIXML_SNSCANF _snscanf_s
74  #elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
75  // Microsoft visual studio, version 6 and higher.
76  //#pragma message( "Using _sn* functions." )
77  #define TIXML_SNPRINTF _snprintf
78  #define TIXML_SNSCANF _snscanf
79  #elif defined(__GNUC__) && (__GNUC__ >= 3 )
80  // GCC version 3 and higher.s
81  //#warning( "Using sn* functions." )
82  #define TIXML_SNPRINTF snprintf
83  #define TIXML_SNSCANF snscanf
84  #endif
85 #endif
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 = 2;
99 
100 /* Internal structure for tracking location of items
101  in the XML file.
102 */
103 struct 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 
132 {
133 public:
134  virtual ~TiXmlVisitor() {}
135 
137  virtual bool VisitEnter( const TiXmlDocument& doc ) { return true; }
139  virtual bool VisitExit( const TiXmlDocument& doc ) { return true; }
140 
142  virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) { return true; }
144  virtual bool VisitExit( const TiXmlElement& element ) { return true; }
145 
147  virtual bool Visit( const TiXmlDeclaration& declaration ) { return true; }
149  virtual bool Visit( const TiXmlText& text ) { return true; }
151  virtual bool Visit( const TiXmlComment& comment ) { return true; }
153  virtual bool Visit( const TiXmlUnknown& unknown ) { return true; }
154 };
155 
156 // Only used by Attribute::Query functions
157 enum
158 {
159  TIXML_SUCCESS,
160  TIXML_NO_ATTRIBUTE,
161  TIXML_WRONG_TYPE
162 };
163 
164 
165 // Used by the parsing routines.
166 enum TiXmlEncoding
167 {
168  TIXML_ENCODING_UNKNOWN,
169  TIXML_ENCODING_UTF8,
170  TIXML_ENCODING_LEGACY
171 };
172 
173 const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN;
174 
198 {
199  friend class TiXmlNode;
200  friend class TiXmlElement;
201  friend class TiXmlDocument;
202 
203 public:
204  TiXmlBase() : userData(0) {}
205  virtual ~TiXmlBase() {}
206 
216  virtual void Print( FILE* cfile, int depth ) const = 0;
217 
224  static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; }
225 
227  static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; }
228 
247  int Row() const { return location.row + 1; }
248  int Column() const { return location.col + 1; }
249 
250  void SetUserData( void* user ) { userData = user; }
251  void* GetUserData() { return userData; }
252  const void* GetUserData() const { return userData; }
253 
254  // Table that returs, for a given lead byte, the total number of bytes
255  // in the UTF-8 sequence.
256  static const int utf8ByteTable[256];
257 
258  virtual const char* Parse( const char* p,
259  TiXmlParsingData* data,
260  TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
261 
262  enum
263  {
264  TIXML_NO_ERROR = 0,
265  TIXML_ERROR,
266  TIXML_ERROR_OPENING_FILE,
267  TIXML_ERROR_OUT_OF_MEMORY,
268  TIXML_ERROR_PARSING_ELEMENT,
269  TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
270  TIXML_ERROR_READING_ELEMENT_VALUE,
271  TIXML_ERROR_READING_ATTRIBUTES,
272  TIXML_ERROR_PARSING_EMPTY,
273  TIXML_ERROR_READING_END_TAG,
274  TIXML_ERROR_PARSING_UNKNOWN,
275  TIXML_ERROR_PARSING_COMMENT,
276  TIXML_ERROR_PARSING_DECLARATION,
277  TIXML_ERROR_DOCUMENT_EMPTY,
278  TIXML_ERROR_EMBEDDED_NULL,
279  TIXML_ERROR_PARSING_CDATA,
280  TIXML_ERROR_DOCUMENT_TOP_ONLY,
281 
282  TIXML_ERROR_STRING_COUNT
283  };
284 
285 protected:
286 
287  static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
288  inline static bool IsWhiteSpace( char c )
289  {
290  return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
291  }
292  inline static bool IsWhiteSpace( int c )
293  {
294  if ( c < 256 )
295  return IsWhiteSpace( (char) c );
296  return false; // Again, only truly correct for English/Latin...but usually works.
297  }
298 
299  #ifdef TIXML_USE_STL
300  static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag );
301  static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag );
302  #endif
303 
304  /* Reads an XML name into the string provided. Returns
305  a pointer just past the last character of the name,
306  or 0 if the function has an error.
307  */
308  static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding );
309 
310  /* Reads text. Returns a pointer past the given end tag.
311  Wickedly complex options, but it keeps the (sensitive) code in one place.
312  */
313  static const char* ReadText( const char* in, // where to start
314  TIXML_STRING* text, // the string read
315  bool ignoreWhiteSpace, // whether to keep the white space
316  const char* endTag, // what ends this text
317  bool ignoreCase, // whether to ignore case in the end tag
318  TiXmlEncoding encoding ); // the current encoding
319 
320  // If an entity has been found, transform it into a character.
321  static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding );
322 
323  // Get a character, while interpreting entities.
324  // The length can be from 0 to 4 bytes.
325  inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding )
326  {
327  assert( p );
328  if ( encoding == TIXML_ENCODING_UTF8 )
329  {
330  *length = utf8ByteTable[ *((const unsigned char*)p) ];
331  assert( *length >= 0 && *length < 5 );
332  }
333  else
334  {
335  *length = 1;
336  }
337 
338  if ( *length == 1 )
339  {
340  if ( *p == '&' )
341  return GetEntity( p, _value, length, encoding );
342  *_value = *p;
343  return p+1;
344  }
345  else if ( *length )
346  {
347  //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe),
348  // and the null terminator isn't needed
349  for( int i=0; p[i] && i<*length; ++i ) {
350  _value[i] = p[i];
351  }
352  return p + (*length);
353  }
354  else
355  {
356  // Not valid text.
357  return 0;
358  }
359  }
360 
361  // Puts a string to a stream, expanding entities as it goes.
362  // Note this should not contian the '<', '>', etc, or they will be transformed into entities!
363  static void PutString( const TIXML_STRING& str, TIXML_STRING* out );
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 
375  TiXmlCursor location;
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  {
466  DOCUMENT,
467  ELEMENT,
468  COMMENT,
469  UNKNOWN,
470  TEXT,
471  DECLARATION,
472  TYPECOUNT
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 
508  void SetValue(const char * _value) { value = _value;}
509 
510  #ifdef TIXML_USE_STL
511  void SetValue( const std::string& _value ) { value = _value; }
513  #endif
514 
516  void Clear();
517 
519  TiXmlNode* Parent() { return parent; }
520  const TiXmlNode* Parent() const { return parent; }
521 
522  const TiXmlNode* FirstChild() const { return firstChild; }
523  TiXmlNode* FirstChild() { return firstChild; }
524  const TiXmlNode* FirstChild( const char * value ) const;
525  TiXmlNode* FirstChild( const char * _value ) {
527  // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe)
528  // call the method, cast the return back to non-const.
529  return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value ));
530  }
531  const TiXmlNode* LastChild() const { return lastChild; }
532  TiXmlNode* LastChild() { return lastChild; }
533 
534  const TiXmlNode* LastChild( const char * value ) const;
535  TiXmlNode* LastChild( const char * _value ) {
536  return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value ));
537  }
538 
539  #ifdef TIXML_USE_STL
540  const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); }
541  TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); }
542  const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); }
543  TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); }
544  #endif
545 
562  const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const;
563  TiXmlNode* IterateChildren( const TiXmlNode* previous ) {
564  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) );
565  }
566 
568  const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const;
569  TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) {
570  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) );
571  }
572 
573  #ifdef TIXML_USE_STL
574  const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); }
575  TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); }
576  #endif
577 
581  TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
582 
583 
593  TiXmlNode* LinkEndChild( TiXmlNode* addThis );
594 
598  TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
599 
603  TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis );
604 
608  TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
609 
611  bool RemoveChild( TiXmlNode* removeThis );
612 
614  const TiXmlNode* PreviousSibling() const { return prev; }
615  TiXmlNode* PreviousSibling() { return prev; }
616 
618  const TiXmlNode* PreviousSibling( const char * ) const;
619  TiXmlNode* PreviousSibling( const char *_prev ) {
620  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) );
621  }
622 
623  #ifdef TIXML_USE_STL
624  const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); }
625  TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); }
626  const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); }
627  TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); }
628  #endif
629 
631  const TiXmlNode* NextSibling() const { return next; }
632  TiXmlNode* NextSibling() { return next; }
633 
635  const TiXmlNode* NextSibling( const char * ) const;
636  TiXmlNode* NextSibling( const char* _next ) {
637  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) );
638  }
639 
644  const TiXmlElement* NextSiblingElement() const;
646  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() );
647  }
648 
653  const TiXmlElement* NextSiblingElement( const char * ) const;
654  TiXmlElement* NextSiblingElement( const char *_next ) {
655  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) );
656  }
657 
658  #ifdef TIXML_USE_STL
659  const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); }
660  TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); }
661  #endif
662 
664  const TiXmlElement* FirstChildElement() const;
666  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() );
667  }
668 
670  const TiXmlElement* FirstChildElement( const char * _value ) const;
671  TiXmlElement* FirstChildElement( const char * _value ) {
672  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) );
673  }
674 
675  #ifdef TIXML_USE_STL
676  const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); }
677  TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); }
678  #endif
679 
684  int Type() const { return type; }
685 
689  const TiXmlDocument* GetDocument() const;
691  return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() );
692  }
693 
695  bool NoChildren() const { return !firstChild; }
696 
697  virtual const TiXmlDocument* ToDocument() const { return 0; }
698  virtual const TiXmlElement* ToElement() const { return 0; }
699  virtual const TiXmlComment* ToComment() const { return 0; }
700  virtual const TiXmlUnknown* ToUnknown() const { return 0; }
701  virtual const TiXmlText* ToText() const { return 0; }
702  virtual const TiXmlDeclaration* ToDeclaration() const { return 0; }
703 
704  virtual TiXmlDocument* ToDocument() { return 0; }
705  virtual TiXmlElement* ToElement() { return 0; }
706  virtual TiXmlComment* ToComment() { return 0; }
707  virtual TiXmlUnknown* ToUnknown() { return 0; }
708  virtual TiXmlText* ToText() { return 0; }
709  virtual TiXmlDeclaration* ToDeclaration() { return 0; }
710 
714  virtual TiXmlNode* Clone() const = 0;
715 
738  virtual bool Accept( TiXmlVisitor* visitor ) const = 0;
739 
740 protected:
741  TiXmlNode( NodeType _type );
742 
743  // Copy to the allocated object. Shared functionality between Clone, Copy constructor,
744  // and the assignment operator.
745  void CopyTo( TiXmlNode* target ) const;
746 
747  #ifdef TIXML_USE_STL
748  // The real work of the input operator.
749  virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0;
750  #endif
751 
752  // Figure out what is at *p, and parse it. Returns null if it is not an xml node.
753  TiXmlNode* Identify( const char* start, TiXmlEncoding encoding );
754 
755  TiXmlNode* parent;
756  NodeType type;
757 
758  TiXmlNode* firstChild;
759  TiXmlNode* lastChild;
760 
761  TIXML_STRING value;
762 
763  TiXmlNode* prev;
764  TiXmlNode* next;
765 
766 private:
767  TiXmlNode( const TiXmlNode& ); // not implemented.
768  void operator=( const TiXmlNode& base ); // not allowed.
769 };
770 
771 
779 class TiXmlAttribute : public TiXmlBase
780 {
781  friend class TiXmlAttributeSet;
782 
783 public:
786  {
787  document = 0;
788  prev = next = 0;
789  }
790 
791  #ifdef TIXML_USE_STL
792  TiXmlAttribute( const std::string& _name, const std::string& _value )
794  {
795  name = _name;
796  value = _value;
797  document = 0;
798  prev = next = 0;
799  }
800  #endif
801 
803  TiXmlAttribute( const char * _name, const char * _value )
804  {
805  name = _name;
806  value = _value;
807  document = 0;
808  prev = next = 0;
809  }
810 
811  const char* Name() const { return name.c_str(); }
812  const char* Value() const { return value.c_str(); }
813  #ifdef TIXML_USE_STL
814  const std::string& ValueStr() const { return value; }
815  #endif
816  int IntValue() const;
817  double DoubleValue() const;
818 
819  // Get the tinyxml string representation
820  const TIXML_STRING& NameTStr() const { return name; }
821 
831  int QueryIntValue( int* _value ) const;
833  int QueryDoubleValue( double* _value ) const;
834 
835  void SetName( const char* _name ) { name = _name; }
836  void SetValue( const char* _value ) { value = _value; }
837 
838  void SetIntValue( int _value );
839  void SetDoubleValue( double _value );
840 
841  #ifdef TIXML_USE_STL
842  void SetName( const std::string& _name ) { name = _name; }
845  void SetValue( const std::string& _value ) { value = _value; }
846  #endif
847 
849  const TiXmlAttribute* Next() const;
850  TiXmlAttribute* Next() {
851  return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() );
852  }
853 
855  const TiXmlAttribute* Previous() const;
857  return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() );
858  }
859 
860  bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
861  bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; }
862  bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; }
863 
864  /* Attribute parsing starts: first letter of the name
865  returns: the next char after the value end quote
866  */
867  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
868 
869  // Prints this Attribute to a FILE stream.
870  virtual void Print( FILE* cfile, int depth ) const {
871  Print( cfile, depth, 0 );
872  }
873  void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
874 
875  // [internal use]
876  // Set the document pointer so the attribute can report errors.
877  void SetDocument( TiXmlDocument* doc ) { document = doc; }
878 
879 private:
880  TiXmlAttribute( const TiXmlAttribute& ); // not implemented.
881  void operator=( const TiXmlAttribute& base ); // not allowed.
882 
883  TiXmlDocument* document; // A pointer back to a document, for error reporting.
884  TIXML_STRING name;
885  TIXML_STRING value;
886  TiXmlAttribute* prev;
887  TiXmlAttribute* next;
888 };
889 
890 
891 /* A class used to manage a group of attributes.
892  It is only used internally, both by the ELEMENT and the DECLARATION.
893 
894  The set can be changed transparent to the Element and Declaration
895  classes that use it, but NOT transparent to the Attribute
896  which has to implement a next() and previous() method. Which makes
897  it a bit problematic and prevents the use of STL.
898 
899  This version is implemented with circular lists because:
900  - I like circular lists
901  - it demonstrates some independence from the (typical) doubly linked list.
902 */
903 class TiXmlAttributeSet
904 {
905 public:
906  TiXmlAttributeSet();
907  ~TiXmlAttributeSet();
908 
909  void Add( TiXmlAttribute* attribute );
910  void Remove( TiXmlAttribute* attribute );
911 
912  const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
913  TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
914  const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
915  TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
916 
917  const TiXmlAttribute* Find( const char* _name ) const;
918  TiXmlAttribute* Find( const char* _name ) {
919  return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
920  }
921  #ifdef TIXML_USE_STL
922  const TiXmlAttribute* Find( const std::string& _name ) const;
923  TiXmlAttribute* Find( const std::string& _name ) {
924  return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
925  }
926 
927  #endif
928 
929 private:
930  //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
931  //*ME: this class must be also use a hidden/disabled copy-constructor !!!
932  TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed
933  void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute)
934 
935  TiXmlAttribute sentinel;
936 };
937 
938 
943 class TiXmlElement : public TiXmlNode
944 {
945 public:
947  TiXmlElement (const char * in_value);
948 
949  #ifdef TIXML_USE_STL
950  TiXmlElement( const std::string& _value );
952  #endif
953 
954  TiXmlElement( const TiXmlElement& );
955 
956  void operator=( const TiXmlElement& base );
957 
958  virtual ~TiXmlElement();
959 
963  const char* Attribute( const char* name ) const;
964 
971  const char* Attribute( const char* name, int* i ) const;
972 
979  const char* Attribute( const char* name, double* d ) const;
980 
988  int QueryIntAttribute( const char* name, int* _value ) const;
990  int QueryDoubleAttribute( const char* name, double* _value ) const;
992  int QueryFloatAttribute( const char* name, float* _value ) const {
993  double d;
994  int result = QueryDoubleAttribute( name, &d );
995  if ( result == TIXML_SUCCESS ) {
996  *_value = (float)d;
997  }
998  return result;
999  }
1000  #ifdef TIXML_USE_STL
1001 
1007  template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const
1008  {
1009  const TiXmlAttribute* node = attributeSet.Find( name );
1010  if ( !node )
1011  return TIXML_NO_ATTRIBUTE;
1012 
1013  std::stringstream sstream( node->ValueStr() );
1014  sstream >> *outValue;
1015  if ( !sstream.fail() )
1016  return TIXML_SUCCESS;
1017  return TIXML_WRONG_TYPE;
1018  }
1019  #endif
1020 
1024  void SetAttribute( const char* name, const char * _value );
1025 
1026  #ifdef TIXML_USE_STL
1027  const std::string* Attribute( const std::string& name ) const;
1028  const std::string* Attribute( const std::string& name, int* i ) const;
1029  const std::string* Attribute( const std::string& name, double* d ) const;
1030  int QueryIntAttribute( const std::string& name, int* _value ) const;
1031  int QueryDoubleAttribute( const std::string& name, double* _value ) const;
1032 
1034  void SetAttribute( const std::string& name, const std::string& _value );
1036  void SetAttribute( const std::string& name, int _value );
1037  #endif
1038 
1042  void SetAttribute( const char * name, int value );
1043 
1047  void SetDoubleAttribute( const char * name, double value );
1048 
1051  void RemoveAttribute( const char * name );
1052  #ifdef TIXML_USE_STL
1053  void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); }
1054  #endif
1055 
1056  const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); }
1057  TiXmlAttribute* FirstAttribute() { return attributeSet.First(); }
1058  const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); }
1059  TiXmlAttribute* LastAttribute() { return attributeSet.Last(); }
1060 
1093  const char* GetText() const;
1094 
1096  virtual TiXmlNode* Clone() const;
1097  // Print the Element to a FILE stream.
1098  virtual void Print( FILE* cfile, int depth ) const;
1099 
1100  /* Attribtue parsing starts: next char past '<'
1101  returns: next char past '>'
1102  */
1103  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1104 
1105  virtual const TiXmlElement* ToElement() const { return this; }
1106  virtual TiXmlElement* ToElement() { return this; }
1107 
1110  virtual bool Accept( TiXmlVisitor* visitor ) const;
1111 
1112 protected:
1113 
1114  void CopyTo( TiXmlElement* target ) const;
1115  void ClearThis(); // like clear, but initializes 'this' object as well
1116 
1117  // Used to be public [internal use]
1118  #ifdef TIXML_USE_STL
1119  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1120  #endif
1121  /* [internal use]
1122  Reads the "value" of the element -- another element, or text.
1123  This should terminate with the current end tag.
1124  */
1125  const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
1126 
1127 private:
1128 
1129  TiXmlAttributeSet attributeSet;
1130 };
1131 
1132 
1135 class TiXmlComment : public TiXmlNode
1136 {
1137 public:
1139  TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {}
1141  TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) {
1142  SetValue( _value );
1143  }
1144  TiXmlComment( const TiXmlComment& );
1145  void operator=( const TiXmlComment& base );
1146 
1147  virtual ~TiXmlComment() {}
1148 
1150  virtual TiXmlNode* Clone() const;
1151  // Write this Comment to a FILE stream.
1152  virtual void Print( FILE* cfile, int depth ) const;
1153 
1154  /* Attribtue parsing starts: at the ! of the !--
1155  returns: next char past '>'
1156  */
1157  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1158 
1159  virtual const TiXmlComment* ToComment() const { return this; }
1160  virtual TiXmlComment* ToComment() { return this; }
1161 
1164  virtual bool Accept( TiXmlVisitor* visitor ) const;
1165 
1166 protected:
1167  void CopyTo( TiXmlComment* target ) const;
1168 
1169  // used to be public
1170  #ifdef TIXML_USE_STL
1171  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1172  #endif
1173 // virtual void StreamOut( TIXML_OSTREAM * out ) const;
1174 
1175 private:
1176 
1177 };
1178 
1179 
1185 class TiXmlText : public TiXmlNode
1186 {
1187  friend class TiXmlElement;
1188 public:
1193  TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT)
1194  {
1195  SetValue( initValue );
1196  cdata = false;
1197  }
1198  virtual ~TiXmlText() {}
1199 
1200  #ifdef TIXML_USE_STL
1201  TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT)
1203  {
1204  SetValue( initValue );
1205  cdata = false;
1206  }
1207  #endif
1208 
1209  TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT ) { copy.CopyTo( this ); }
1210  void operator=( const TiXmlText& base ) { base.CopyTo( this ); }
1211 
1212  // Write this text object to a FILE stream.
1213  virtual void Print( FILE* cfile, int depth ) const;
1214 
1216  bool CDATA() const { return cdata; }
1218  void SetCDATA( bool _cdata ) { cdata = _cdata; }
1219 
1220  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1221 
1222  virtual const TiXmlText* ToText() const { return this; }
1223  virtual TiXmlText* ToText() { return this; }
1224 
1227  virtual bool Accept( TiXmlVisitor* content ) const;
1228 
1229 protected :
1231  virtual TiXmlNode* Clone() const;
1232  void CopyTo( TiXmlText* target ) const;
1233 
1234  bool Blank() const; // returns true if all white space and new lines
1235  // [internal use]
1236  #ifdef TIXML_USE_STL
1237  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1238  #endif
1239 
1240 private:
1241  bool cdata; // true if this should be input and output as a CDATA style text element
1242 };
1243 
1244 
1259 {
1260 public:
1262  TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {}
1263 
1264 #ifdef TIXML_USE_STL
1265  TiXmlDeclaration( const std::string& _version,
1267  const std::string& _encoding,
1268  const std::string& _standalone );
1269 #endif
1270 
1272  TiXmlDeclaration( const char* _version,
1273  const char* _encoding,
1274  const char* _standalone );
1275 
1276  TiXmlDeclaration( const TiXmlDeclaration& copy );
1277  void operator=( const TiXmlDeclaration& copy );
1278 
1279  virtual ~TiXmlDeclaration() {}
1280 
1282  const char *Version() const { return version.c_str (); }
1284  const char *Encoding() const { return encoding.c_str (); }
1286  const char *Standalone() const { return standalone.c_str (); }
1287 
1289  virtual TiXmlNode* Clone() const;
1290  // Print this declaration to a FILE stream.
1291  virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
1292  virtual void Print( FILE* cfile, int depth ) const {
1293  Print( cfile, depth, 0 );
1294  }
1295 
1296  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1297 
1298  virtual const TiXmlDeclaration* ToDeclaration() const { return this; }
1299  virtual TiXmlDeclaration* ToDeclaration() { return this; }
1300 
1303  virtual bool Accept( TiXmlVisitor* visitor ) const;
1304 
1305 protected:
1306  void CopyTo( TiXmlDeclaration* target ) const;
1307  // used to be public
1308  #ifdef TIXML_USE_STL
1309  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1310  #endif
1311 
1312 private:
1313 
1314  TIXML_STRING version;
1315  TIXML_STRING encoding;
1316  TIXML_STRING standalone;
1317 };
1318 
1319 
1327 class TiXmlUnknown : public TiXmlNode
1328 {
1329 public:
1330  TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {}
1331  virtual ~TiXmlUnknown() {}
1332 
1333  TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN ) { copy.CopyTo( this ); }
1334  void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); }
1335 
1337  virtual TiXmlNode* Clone() const;
1338  // Print this Unknown to a FILE stream.
1339  virtual void Print( FILE* cfile, int depth ) const;
1340 
1341  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1342 
1343  virtual const TiXmlUnknown* ToUnknown() const { return this; }
1344  virtual TiXmlUnknown* ToUnknown() { return this; }
1345 
1348  virtual bool Accept( TiXmlVisitor* content ) const;
1349 
1350 protected:
1351  void CopyTo( TiXmlUnknown* target ) const;
1352 
1353  #ifdef TIXML_USE_STL
1354  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1355  #endif
1356 
1357 private:
1358 
1359 };
1360 
1361 
1366 class TiXmlDocument : public TiXmlNode
1367 {
1368 public:
1370  TiXmlDocument();
1372  TiXmlDocument( const char * documentName );
1373 
1374  #ifdef TIXML_USE_STL
1375  TiXmlDocument( const std::string& documentName );
1377  #endif
1378 
1379  TiXmlDocument( const TiXmlDocument& copy );
1380  void operator=( const TiXmlDocument& copy );
1381 
1382  virtual ~TiXmlDocument() {}
1383 
1388  bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1390  bool SaveFile() const;
1392  bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1394  bool SaveFile( const char * filename ) const;
1400  bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1402  bool SaveFile( FILE* ) const;
1403 
1404  #ifdef TIXML_USE_STL
1405  bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING )
1406  {
1407 // StringToBuffer f( filename );
1408 // return ( f.buffer && LoadFile( f.buffer, encoding ));
1409  return LoadFile( filename.c_str(), encoding );
1410  }
1411  bool SaveFile( const std::string& filename ) const
1412  {
1413 // StringToBuffer f( filename );
1414 // return ( f.buffer && SaveFile( f.buffer ));
1415  return SaveFile( filename.c_str() );
1416  }
1417  #endif
1418 
1423  virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1424 
1429  const TiXmlElement* RootElement() const { return FirstChildElement(); }
1430  TiXmlElement* RootElement() { return FirstChildElement(); }
1431 
1437  bool Error() const { return error; }
1438 
1440  const char * ErrorDesc() const { return errorDesc.c_str (); }
1441 
1445  int ErrorId() const { return errorId; }
1446 
1454  int ErrorRow() const { return errorLocation.row+1; }
1455  int ErrorCol() const { return errorLocation.col+1; }
1456 
1481  void SetTabSize( int _tabsize ) { tabsize = _tabsize; }
1482 
1483  int TabSize() const { return tabsize; }
1484 
1488  void ClearError() { error = false;
1489  errorId = 0;
1490  errorDesc = "";
1491  errorLocation.row = errorLocation.col = 0;
1492  //errorLocation.last = 0;
1493  }
1494 
1496  void Print() const { Print( stdout, 0 ); }
1497 
1498  /* Write the document to a string using formatted printing ("pretty print"). This
1499  will allocate a character array (new char[]) and return it as a pointer. The
1500  calling code pust call delete[] on the return char* to avoid a memory leak.
1501  */
1502  //char* PrintToMemory() const;
1503 
1505  virtual void Print( FILE* cfile, int depth = 0 ) const;
1506  // [internal use]
1507  void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding );
1508 
1509  virtual const TiXmlDocument* ToDocument() const { return this; }
1510  virtual TiXmlDocument* ToDocument() { return this; }
1511 
1514  virtual bool Accept( TiXmlVisitor* content ) const;
1515 
1516 protected :
1517  // [internal use]
1518  virtual TiXmlNode* Clone() const;
1519  #ifdef TIXML_USE_STL
1520  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1521  #endif
1522 
1523 private:
1524  void CopyTo( TiXmlDocument* target ) const;
1525 
1526  bool error;
1527  int errorId;
1528  TIXML_STRING errorDesc;
1529  int tabsize;
1530  TiXmlCursor errorLocation;
1531  bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write.
1532 };
1533 
1534 
1616 {
1617 public:
1619  TiXmlHandle( TiXmlNode* _node ) { this->node = _node; }
1621  TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; }
1622  TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; }
1623 
1625  TiXmlHandle FirstChild() const;
1627  TiXmlHandle FirstChild( const char * value ) const;
1631  TiXmlHandle FirstChildElement( const char * value ) const;
1632 
1636  TiXmlHandle Child( const char* value, int index ) const;
1640  TiXmlHandle Child( int index ) const;
1645  TiXmlHandle ChildElement( const char* value, int index ) const;
1650  TiXmlHandle ChildElement( int index ) const;
1651 
1652  #ifdef TIXML_USE_STL
1653  TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); }
1654  TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); }
1655 
1656  TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); }
1657  TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); }
1658  #endif
1659 
1662  TiXmlNode* ToNode() const { return node; }
1665  TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
1668  TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
1671  TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
1672 
1676  TiXmlNode* Node() const { return ToNode(); }
1680  TiXmlElement* Element() const { return ToElement(); }
1684  TiXmlText* Text() const { return ToText(); }
1688  TiXmlUnknown* Unknown() const { return ToUnknown(); }
1689 
1690 private:
1691  TiXmlNode* node;
1692 };
1693 
1694 
1715 {
1716 public:
1717  TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ),
1718  buffer(), indent( " " ), lineBreak( "\n" ) {}
1719 
1720  virtual bool VisitEnter( const TiXmlDocument& doc );
1721  virtual bool VisitExit( const TiXmlDocument& doc );
1722 
1723  virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute );
1724  virtual bool VisitExit( const TiXmlElement& element );
1725 
1726  virtual bool Visit( const TiXmlDeclaration& declaration );
1727  virtual bool Visit( const TiXmlText& text );
1728  virtual bool Visit( const TiXmlComment& comment );
1729  virtual bool Visit( const TiXmlUnknown& unknown );
1730 
1734  void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; }
1736  const char* Indent() { return indent.c_str(); }
1741  void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; }
1743  const char* LineBreak() { return lineBreak.c_str(); }
1744 
1748  void SetStreamPrinting() { indent = "";
1749  lineBreak = "";
1750  }
1752  const char* CStr() { return buffer.c_str(); }
1754  size_t Size() { return buffer.size(); }
1755 
1756  #ifdef TIXML_USE_STL
1757  const std::string& Str() { return buffer; }
1759  #endif
1760 
1761 private:
1762  void DoIndent() {
1763  for( int i=0; i<depth; ++i )
1764  buffer += indent;
1765  }
1766  void DoLineBreak() {
1767  buffer += lineBreak;
1768  }
1769 
1770  int depth;
1771  bool simpleTextPrint;
1772  TIXML_STRING buffer;
1773  TIXML_STRING indent;
1774  TIXML_STRING lineBreak;
1775 };
1776 
1777 
1778 #ifdef _MSC_VER
1779 #pragma warning( pop )
1780 #endif
1781 
1782 #endif
1783 
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1159
virtual bool Visit(const TiXmlComment &comment)
Visit a comment node.
Definition: tinyxml.h:151
TiXmlNode * LastChild(const char *_value)
The last child of this node matching 'value'. Will be null if there are no children.
Definition: tinyxml.h:535
Definition: tinyxml.h:779
TiXmlHandle(TiXmlNode *_node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml.h:1619
virtual TiXmlNode * Clone() const
Creates a copy of this Declaration and returns it.
Definition: tinyxml.cc:1445
TiXmlUnknown * Unknown() const
Definition: tinyxml.h:1688
TiXmlNode * FirstChild(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:541
virtual bool Accept(TiXmlVisitor *visitor) const
Definition: tinyxml.cc:837
friend std::ostream & operator<<(std::ostream &out, const TiXmlNode &base)
void SetUserData(void *user)
Set a pointer to arbitrary user data.
Definition: tinyxml.h:250
Definition: tinyxml.h:131
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1509
const std::string & ValueStr() const
Definition: tinyxml.h:496
const TiXmlElement * RootElement() const
Definition: tinyxml.h:1429
TiXmlComment()
Constructs an empty comment.
Definition: tinyxml.h:1139
void SetLineBreak(const char *_lineBreak)
Definition: tinyxml.h:1741
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1105
TiXmlHandle(const TiXmlHandle &ref)
Copy constructor.
Definition: tinyxml.h:1621
TiXmlNode * LastChild()
The last child of this node. Will be null if there are no children.
Definition: tinyxml.h:532
const char * LineBreak()
Query the current line breaking string.
Definition: tinyxml.h:1743
virtual TiXmlNode * Clone() const
Creates a new Element and returns it - the returned element is a copy.
Definition: tinyxml.cc:851
bool Error() const
Definition: tinyxml.h:1437
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:705
double DoubleValue() const
Return the value of this attribute, converted to a double.
Definition: tinyxml.cc:1268
TiXmlAttribute(const char *_name, const char *_value)
Construct an attribute with a name and value.
Definition: tinyxml.h:803
int IntValue() const
Return the value of this attribute, converted to an integer.
Definition: tinyxml.cc:1263
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1222
TiXmlHandle FirstChild() const
Return a handle to the first child node.
Definition: tinyxml.cc:1621
const void * GetUserData() const
Get a pointer to arbitrary user data.
Definition: tinyxml.h:252
int Type() const
Definition: tinyxml.h:684
TiXmlNode * IterateChildren(const std::string &_value, const TiXmlNode *previous)
STL std::string form.
Definition: tinyxml.h:575
const TiXmlElement * FirstChildElement(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:676
void SetDoubleAttribute(const char *name, double value)
Definition: tinyxml.cc:696
virtual void Print(FILE *cfile, int depth) const
Definition: tinyxml.cc:1457
int ErrorId() const
Definition: tinyxml.h:1445
virtual void Print(FILE *cfile, int depth) const
Definition: tinyxml.h:1292
TiXmlElement * NextSiblingElement(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:660
virtual TiXmlNode * Clone() const
[internal use] Creates a new Element and returns it.
Definition: tinyxml.cc:1356
void SetValue(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:845
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
Definition: tinyxml.cc:281
bool SaveFile(const std::string &filename) const
< STL std::string version.
Definition: tinyxml.h:1411
const TiXmlAttribute * LastAttribute() const
Access the last attribute in this element.
Definition: tinyxml.h:1058
void SetName(const char *_name)
Set the name of this attribute.
Definition: tinyxml.h:835
void SetTabSize(int _tabsize)
Definition: tinyxml.h:1481
TiXmlDocument()
Create an empty document, that has no name.
Definition: tinyxml.cc:875
TiXmlAttribute()
Construct an empty attribute.
Definition: tinyxml.h:785
virtual bool VisitExit(const TiXmlDocument &doc)
Visit a document.
Definition: tinyxml.h:139
const char * Standalone() const
Is this a standalone document?
Definition: tinyxml.h:1286
TiXmlElement * ToElement() const
Definition: tinyxml.h:1665
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:704
void ClearError()
Definition: tinyxml.h:1488
const char * Value() const
Return the value of this attribute.
Definition: tinyxml.h:812
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:699
int QueryIntValue(int *_value) const
Definition: tinyxml.cc:1227
virtual void Print(FILE *cfile, int depth) const
Definition: tinyxml.cc:762
virtual TiXmlComment * ToComment()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1160
friend std::istream & operator>>(std::istream &in, TiXmlNode &base)
virtual bool VisitEnter(const TiXmlDocument &doc)
Visit a document.
Definition: tinyxml.h:137
bool LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Definition: tinyxml.cc:915
void SetValue(const char *_value)
Definition: tinyxml.h:508
int ErrorCol() const
The column where the error occured. See ErrorRow()
Definition: tinyxml.h:1455
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
Definition: tinyxml.cc:202
virtual bool VisitExit(const TiXmlDocument &doc)
Visit a document.
Definition: tinyxml.cc:1750
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1106
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
Definition: tinyxml.cc:217
NodeType
Definition: tinyxml.h:464
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:702
TiXmlHandle FirstChildElement() const
Return a handle to the first child element.
Definition: tinyxml.cc:1645
const char * Encoding() const
Encoding. Will return an empty string if none was found.
Definition: tinyxml.h:1284
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
Definition: tinyxml.cc:175
const char * Name() const
Return the name of this attribute.
Definition: tinyxml.h:811
void SetDoubleValue(double _value)
Set the value from a double.
Definition: tinyxml.cc:1252
void * userData
Field containing a generic user pointer.
Definition: tinyxml.h:378
virtual void Print(FILE *cfile, int depth) const
Definition: tinyxml.cc:1287
virtual bool Accept(TiXmlVisitor *visitor) const =0
void Print() const
Definition: tinyxml.h:1496
Definition: tinyxml.h:1258
virtual bool VisitEnter(const TiXmlElement &element, const TiXmlAttribute *firstAttribute)
Visit an element.
Definition: tinyxml.h:142
Definition: tinyxml.h:1327
int ErrorRow() const
Definition: tinyxml.h:1454
const char * Version() const
Version. Will return an empty string if none was found.
Definition: tinyxml.h:1282
virtual bool Visit(const TiXmlUnknown &unknown)
Visit an unknow node.
Definition: tinyxml.h:153
TiXmlHandle ChildElement(const char *value, int index) const
Definition: tinyxml.cc:1726
virtual bool Accept(TiXmlVisitor *content) const
Definition: tinyxml.cc:1471
int Column() const
See Row()
Definition: tinyxml.h:248
static bool IsWhiteSpaceCondensed()
Return the current white space setting.
Definition: tinyxml.h:227
void SetIndent(const char *_indent)
Definition: tinyxml.h:1734
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
Definition: tinyxml.h:522
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
Definition: tinyxml.h:1440
bool LoadFile(const std::string &filename, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Definition: tinyxml.h:1405
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1343
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1510
const TiXmlAttribute * Next() const
Get the next sibling attribute in the DOM. Returns null at end.
Definition: tinyxml.cc:1161
void RemoveAttribute(const char *name)
Definition: tinyxml.cc:407
virtual TiXmlNode * Clone() const
Definition: tinyxml.cc:1125
void SetAttribute(const char *name, const char *_value)
Definition: tinyxml.cc:708
virtual void Print(FILE *cfile, int depth) const
Definition: tinyxml.cc:1322
virtual void Print(FILE *cfile, int depth) const
Definition: tinyxml.h:870
void SetCDATA(bool _cdata)
Turns on or off a CDATA representation of text.
Definition: tinyxml.h:1218
const char * Indent()
Query the indention string.
Definition: tinyxml.h:1736
TiXmlElement * FirstChildElement(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:677
bool SaveFile() const
Save a file using the current document value. Returns true if successful.
Definition: tinyxml.cc:924
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1299
Definition: tinyxml.h:1366
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
Definition: tinyxml.cc:422
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1298
int QueryDoubleValue(double *_value) const
QueryDoubleValue examines the value string. See QueryIntValue().
Definition: tinyxml.cc:1234
TiXmlElement(const char *in_value)
Construct an element.
Definition: tinyxml.cc:495
const TiXmlNode * LastChild(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:542
int QueryFloatAttribute(const char *name, float *_value) const
QueryFloatAttribute examines the attribute - see QueryIntAttribute().
Definition: tinyxml.h:992
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
Definition: tinyxml.h:614
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:626
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
Definition: tinyxml.cc:249
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:709
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:698
TiXmlHandle Child(const char *value, int index) const
Definition: tinyxml.cc:1688
const std::string & ValueStr() const
Return the value of this attribute.
Definition: tinyxml.h:814
const TiXmlDocument * GetDocument() const
Definition: tinyxml.cc:482
bool CDATA() const
Queries whether this represents text using a CDATA section.
Definition: tinyxml.h:1216
Definition: tinyxml.h:1615
virtual bool Accept(TiXmlVisitor *visitor) const
Definition: tinyxml.cc:1304
virtual TiXmlComment * ToComment()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:706
const TiXmlNode * IterateChildren(const std::string &_value, const TiXmlNode *previous) const
STL std::string form.
Definition: tinyxml.h:574
TiXmlText * Text() const
Definition: tinyxml.h:1684
TiXmlNode * Node() const
Definition: tinyxml.h:1676
TiXmlNode * ToNode() const
Definition: tinyxml.h:1662
const TiXmlAttribute * Previous() const
Get the previous sibling attribute in the DOM. Returns null at beginning.
Definition: tinyxml.cc:1181
static void SetCondenseWhiteSpace(bool condense)
Definition: tinyxml.h:224
Definition: tinyxml.h:197
const TiXmlElement * NextSiblingElement() const
Definition: tinyxml.cc:452
TiXmlNode * Parent()
One step up the DOM.
Definition: tinyxml.h:519
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:707
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:700
virtual bool VisitExit(const TiXmlElement &element)
Visit an element.
Definition: tinyxml.h:144
TiXmlComment(const char *_value)
Construct a comment from text.
Definition: tinyxml.h:1141
virtual bool VisitEnter(const TiXmlDocument &doc)
Visit a document.
Definition: tinyxml.cc:1745
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Definition: tinyxmlparser.cc:712
int QueryIntAttribute(const char *name, int *_value) const
Definition: tinyxml.cc:634
int Row() const
Definition: tinyxml.h:247
TiXmlElement * Element() const
Definition: tinyxml.h:1680
virtual bool Accept(TiXmlVisitor *content) const
Definition: tinyxml.cc:1147
int QueryValueAttribute(const std::string &name, T *outValue) const
Definition: tinyxml.h:1007
void * GetUserData()
Get a pointer to arbitrary user data.
Definition: tinyxml.h:251
Definition: tinyxml.h:425
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:701
TiXmlNode * LastChild(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:543
size_t Size()
Return the length of the result string.
Definition: tinyxml.h:1754
void SetIntValue(int _value)
Set the value from an integer.
Definition: tinyxml.cc:1241
Definition: tinyxml.h:1714
TiXmlNode * PreviousSibling(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:625
virtual TiXmlNode * Clone() const
Creates a copy of this Unknown and returns it.
Definition: tinyxml.cc:1477
Definition: tinyxml.h:1185
const TiXmlNode * FirstChild(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:540
int QueryDoubleAttribute(const char *name, double *_value) const
QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
Definition: tinyxml.cc:654
TiXmlText(const char *initValue)
Definition: tinyxml.h:1193
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
Definition: tinyxml.cc:355
const char * Value() const
Definition: tinyxml.h:489
TiXmlNode * NextSibling(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:627
virtual bool Visit(const TiXmlText &text)
Visit a text node.
Definition: tinyxml.h:149
virtual TiXmlNode * Clone() const
Returns a copy of this Comment.
Definition: tinyxml.cc:1310
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml.h:695
virtual bool Accept(TiXmlVisitor *visitor) const
Definition: tinyxml.cc:1439
const TiXmlAttribute * FirstAttribute() const
Access the first attribute in this element.
Definition: tinyxml.h:1056
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
Definition: tinyxml.cc:309
void RemoveAttribute(const std::string &name)
STL std::string form.
Definition: tinyxml.h:1053
Definition: tinyxml.h:1135
const char * GetText() const
Definition: tinyxml.cc:862
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1344
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:697
void Clear()
Delete all the children of this node. Does not affect 'this'.
Definition: tinyxml.cc:158
void SetValue(const char *_value)
Set the value.
Definition: tinyxml.h:836
const std::string & Str()
Return the result.
Definition: tinyxml.h:1758
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
Definition: tinyxml.h:631
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1223
TiXmlText * ToText() const
Definition: tinyxml.h:1668
TiXmlDeclaration()
Construct an empty declaration.
Definition: tinyxml.h:1262
void SetStreamPrinting()
Definition: tinyxml.h:1748
const char * Attribute(const char *name) const
Definition: tinyxml.cc:546
virtual void Print(FILE *cfile, int depth) const =0
virtual bool Visit(const TiXmlDeclaration &declaration)
Visit a declaration.
Definition: tinyxml.h:147
virtual bool Accept(TiXmlVisitor *content) const
Definition: tinyxml.cc:1350
virtual TiXmlNode * Clone() const =0
const TiXmlElement * NextSiblingElement(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:659
virtual bool Visit(const TiXmlDeclaration &declaration)
Visit a declaration.
Definition: tinyxml.cc:1842
TiXmlUnknown * ToUnknown() const
Definition: tinyxml.h:1671
const TiXmlNode * PreviousSibling(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:624
const char * CStr()
Return the result.
Definition: tinyxml.h:1752
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:708
Definition: tinyxml.h:943