Scheduler
tinyxml.h
Go to the documentation of this file.
1 
10 /*
11 www.sourceforge.net/projects/tinyxml
12 Original code by Lee Thomason (www.grinninglizard.com)
13 
14 This software is provided 'as-is', without any express or implied
15 warranty. In no event will the authors be held liable for any
16 damages arising from the use of this software.
17 
18 Permission is granted to anyone to use this software for any
19 purpose, including commercial applications, and to alter it and
20 redistribute it freely, subject to the following restrictions:
21 
22 1. The origin of this software must not be misrepresented; you must
23 not claim that you wrote the original software. If you use this
24 software in a product, an acknowledgment in the product documentation
25 would be appreciated but is not required.
26 
27 2. Altered source versions must be plainly marked as such, and
28 must not be misrepresented as being the original software.
29 
30 3. This notice may not be removed or altered from any source
31 distribution.
32 */
33 
34 
35 #ifndef TINYXML_INCLUDED
36 #define TINYXML_INCLUDED
37 
38 #ifdef _MSC_VER
39 #pragma warning( push )
40 #pragma warning( disable : 4530 )
41 #pragma warning( disable : 4786 )
42 #endif
43 
44 #include <ctype.h>
45 #include <stdio.h>
46 #include <stdlib.h>
47 #include <string.h>
48 #include <assert.h>
49 
50 // Help out windows:
51 #if defined( _DEBUG ) && !defined( DEBUG )
52 #define DEBUG
53 #endif
54 
55 #ifdef TIXML_USE_STL
56  #include <string>
57  #include <iostream>
58  #include <sstream>
59  #define TIXML_STRING std::string
60 #else
61  #include "tinystr.h"
62  #define TIXML_STRING TiXmlString
63 #endif
64 
65 // Deprecated library function hell. Compilers want to use the
66 // new safe versions. This probably doesn't fully address the problem,
67 // but it gets closer. There are too many compilers for me to fully
68 // test. If you get compilation troubles, undefine TIXML_SAFE
69 #define TIXML_SAFE
70 
71 #ifdef TIXML_SAFE
72  #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
73  // Microsoft visual studio, version 2005 and higher.
74  #define TIXML_SNPRINTF _snprintf_s
75  #define TIXML_SSCANF sscanf_s
76  #elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
77  // Microsoft visual studio, version 6 and higher.
78  //#pragma message( "Using _sn* functions." )
79  #define TIXML_SNPRINTF _snprintf
80  #define TIXML_SSCANF sscanf
81  #elif defined(__GNUC__) && (__GNUC__ >= 3 )
82  // GCC version 3 and higher.s
83  //#warning( "Using sn* functions." )
84  #define TIXML_SNPRINTF snprintf
85  #define TIXML_SSCANF sscanf
86  #else
87  #define TIXML_SNPRINTF snprintf
88  #define TIXML_SSCANF sscanf
89  #endif
90 #endif
91 
92 class TiXmlDocument;
93 class TiXmlElement;
94 class TiXmlComment;
95 class TiXmlUnknown;
96 class TiXmlAttribute;
97 class TiXmlText;
98 class TiXmlDeclaration;
99 class TiXmlParsingData;
100 
101 const int TIXML_MAJOR_VERSION = 2;
102 const int TIXML_MINOR_VERSION = 6;
103 const int TIXML_PATCH_VERSION = 2;
104 
105 /* Internal structure for tracking location of items
106  in the XML file.
107 */
109 {
111  void Clear() { row = col = -1; }
112 
113  int row; // 0 based.
114  int col; // 0 based.
115 };
116 
117 
138 {
139 public:
140  virtual ~TiXmlVisitor() {}
141 
143  virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; }
145  virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; }
146 
148  virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; }
150  virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; }
151 
153  virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; }
155  virtual bool Visit( const TiXmlText& /*text*/ ) { return true; }
157  virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; }
159  virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; }
160 };
161 
162 // Only used by Attribute::Query functions
163 enum
164 {
168 };
169 
170 
171 // Used by the parsing routines.
173 {
177 };
178 
180 
204 {
205  friend class TiXmlNode;
206  friend class TiXmlElement;
207  friend class TiXmlDocument;
208 
209 public:
210  TiXmlBase() : userData(0) {}
211  virtual ~TiXmlBase() {}
212 
222  virtual void Print( FILE* cfile, int depth ) const = 0;
223 
230  static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; }
231 
233  static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; }
234 
253  int Row() const { return location.row + 1; }
254  int Column() const { return location.col + 1; }
255 
256  void SetUserData( void* user ) { userData = user; }
257  void* GetUserData() { return userData; }
258  const void* GetUserData() const { return userData; }
259 
260  // Table that returs, for a given lead byte, the total number of bytes
261  // in the UTF-8 sequence.
262  static const int utf8ByteTable[256];
263 
264  virtual const char* Parse( const char* p,
265  TiXmlParsingData* data,
266  TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
267 
271  static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out );
272 
273  enum
274  {
291 
293  };
294 
295 protected:
296 
297  static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
298 
299  inline static bool IsWhiteSpace( char c )
300  {
301  return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
302  }
303  inline static bool IsWhiteSpace( int c )
304  {
305  if ( c < 256 )
306  return IsWhiteSpace( (char) c );
307  return false; // Again, only truly correct for English/Latin...but usually works.
308  }
309 
310  #ifdef TIXML_USE_STL
311  static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag );
312  static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag );
313  #endif
314 
315  /* Reads an XML name into the string provided. Returns
316  a pointer just past the last character of the name,
317  or 0 if the function has an error.
318  */
319  static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding );
320 
321  /* Reads text. Returns a pointer past the given end tag.
322  Wickedly complex options, but it keeps the (sensitive) code in one place.
323  */
324  static const char* ReadText( const char* in, // where to start
325  TIXML_STRING* text, // the string read
326  bool ignoreWhiteSpace, // whether to keep the white space
327  const char* endTag, // what ends this text
328  bool ignoreCase, // whether to ignore case in the end tag
329  TiXmlEncoding encoding ); // the current encoding
330 
331  // If an entity has been found, transform it into a character.
332  static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding );
333 
334  // Get a character, while interpreting entities.
335  // The length can be from 0 to 4 bytes.
336  inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding )
337  {
338  assert( p );
339  if ( encoding == TIXML_ENCODING_UTF8 )
340  {
341  *length = utf8ByteTable[ *((const unsigned char*)p) ];
342  assert( *length >= 0 && *length < 5 );
343  }
344  else
345  {
346  *length = 1;
347  }
348 
349  if ( *length == 1 )
350  {
351  if ( *p == '&' )
352  return GetEntity( p, _value, length, encoding );
353  *_value = *p;
354  return p+1;
355  }
356  else if ( *length )
357  {
358  //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe),
359  // and the null terminator isn't needed
360  for( int i=0; p[i] && i<*length; ++i ) {
361  _value[i] = p[i];
362  }
363  return p + (*length);
364  }
365  else
366  {
367  // Not valid text.
368  return 0;
369  }
370  }
371 
372  // Return true if the next characters in the stream are any of the endTag sequences.
373  // Ignore case only works for english, and should only be relied on when comparing
374  // to English words: StringEqual( p, "version", true ) is fine.
375  static bool StringEqual( const char* p,
376  const char* endTag,
377  bool ignoreCase,
378  TiXmlEncoding encoding );
379 
380  static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
381 
383 
385  void* userData;
386 
387  // None of these methods are reliable for any language except English.
388  // Good for approximation, not great for accuracy.
389  static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding );
390  static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding );
391  inline static int ToLower( int v, TiXmlEncoding encoding )
392  {
393  if ( encoding == TIXML_ENCODING_UTF8 )
394  {
395  if ( v < 128 ) return tolower( v );
396  return v;
397  }
398  else
399  {
400  return tolower( v );
401  }
402  }
403  static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
404 
405 private:
406  TiXmlBase( const TiXmlBase& ); // not implemented.
407  void operator=( const TiXmlBase& base ); // not allowed.
408 
409  struct Entity
410  {
411  const char* str;
412  unsigned int strLength;
413  char chr;
414  };
415  enum
416  {
417  NUM_ENTITY = 5,
418  MAX_ENTITY_LENGTH = 6
419 
420  };
421  static Entity entity[ NUM_ENTITY ];
422  static bool condenseWhiteSpace;
423 };
424 
425 
432 class TiXmlNode : public TiXmlBase
433 {
434  friend class TiXmlDocument;
435  friend class TiXmlElement;
436 
437 public:
438  #ifdef TIXML_USE_STL
439 
443  friend std::istream& operator >> (std::istream& in, TiXmlNode& base);
444 
461  friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
462 
464  friend std::string& operator<< (std::string& out, const TiXmlNode& base );
465 
466  #endif
467 
471  enum NodeType
472  {
480  };
481 
482  virtual ~TiXmlNode();
483 
496  const char *Value() const { return value.c_str (); }
497 
498  #ifdef TIXML_USE_STL
499 
503  const std::string& ValueStr() const { return value; }
504  #endif
505 
506  const TIXML_STRING& ValueTStr() const { return value; }
507 
517  void SetValue(const char * _value) { value = _value;}
518 
519  #ifdef TIXML_USE_STL
520  void SetValue( const std::string& _value ) { value = _value; }
522  #endif
523 
525  void Clear();
526 
528  TiXmlNode* Parent() { return parent; }
529  const TiXmlNode* Parent() const { return parent; }
530 
531  const TiXmlNode* FirstChild() const { return firstChild; }
533  const TiXmlNode* FirstChild( const char * value ) const;
534  TiXmlNode* FirstChild( const char * _value ) {
536  // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe)
537  // call the method, cast the return back to non-const.
538  return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value ));
539  }
540  const TiXmlNode* LastChild() const { return lastChild; }
542 
543  const TiXmlNode* LastChild( const char * value ) const;
544  TiXmlNode* LastChild( const char * _value ) {
545  return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value ));
546  }
547 
548  #ifdef TIXML_USE_STL
549  const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); }
550  TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); }
551  const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); }
552  TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); }
553  #endif
554 
571  const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const;
572  TiXmlNode* IterateChildren( const TiXmlNode* previous ) {
573  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) );
574  }
575 
577  const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const;
578  TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) {
579  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) );
580  }
581 
582  #ifdef TIXML_USE_STL
583  const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); }
584  TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); }
585  #endif
586 
590  TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
591 
592 
602  TiXmlNode* LinkEndChild( TiXmlNode* addThis );
603 
607  TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
608 
612  TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis );
613 
617  TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
618 
620  bool RemoveChild( TiXmlNode* removeThis );
621 
623  const TiXmlNode* PreviousSibling() const { return prev; }
625 
627  const TiXmlNode* PreviousSibling( const char * ) const;
628  TiXmlNode* PreviousSibling( const char *_prev ) {
629  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) );
630  }
631 
632  #ifdef TIXML_USE_STL
633  const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); }
634  TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); }
635  const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); }
636  TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); }
637  #endif
638 
640  const TiXmlNode* NextSibling() const { return next; }
641  TiXmlNode* NextSibling() { return next; }
642 
644  const TiXmlNode* NextSibling( const char * ) const;
645  TiXmlNode* NextSibling( const char* _next ) {
646  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) );
647  }
648 
653  const TiXmlElement* NextSiblingElement() const;
655  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() );
656  }
657 
662  const TiXmlElement* NextSiblingElement( const char * ) const;
663  TiXmlElement* NextSiblingElement( const char *_next ) {
664  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) );
665  }
666 
667  #ifdef TIXML_USE_STL
668  const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); }
669  TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); }
670  #endif
671 
673  const TiXmlElement* FirstChildElement() const;
675  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() );
676  }
677 
679  const TiXmlElement* FirstChildElement( const char * _value ) const;
680  TiXmlElement* FirstChildElement( const char * _value ) {
681  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) );
682  }
683 
684  #ifdef TIXML_USE_STL
685  const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); }
686  TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); }
687  #endif
688 
693  int Type() const { return type; }
694 
698  const TiXmlDocument* GetDocument() const;
700  return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() );
701  }
702 
704  bool NoChildren() const { return !firstChild; }
705 
706  virtual const TiXmlDocument* ToDocument() const { return 0; }
707  virtual const TiXmlElement* ToElement() const { return 0; }
708  virtual const TiXmlComment* ToComment() const { return 0; }
709  virtual const TiXmlUnknown* ToUnknown() const { return 0; }
710  virtual const TiXmlText* ToText() const { return 0; }
711  virtual const TiXmlDeclaration* ToDeclaration() const { return 0; }
712 
713  virtual TiXmlDocument* ToDocument() { return 0; }
714  virtual TiXmlElement* ToElement() { return 0; }
715  virtual TiXmlComment* ToComment() { return 0; }
716  virtual TiXmlUnknown* ToUnknown() { return 0; }
717  virtual TiXmlText* ToText() { return 0; }
718  virtual TiXmlDeclaration* ToDeclaration() { return 0; }
719 
723  virtual TiXmlNode* Clone() const = 0;
724 
747  virtual bool Accept( TiXmlVisitor* visitor ) const = 0;
748 
749 protected:
750  TiXmlNode( NodeType _type );
751 
752  // Copy to the allocated object. Shared functionality between Clone, Copy constructor,
753  // and the assignment operator.
754  void CopyTo( TiXmlNode* target ) const;
755 
756  #ifdef TIXML_USE_STL
757  // The real work of the input operator.
758  virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0;
759  #endif
760 
761  // Figure out what is at *p, and parse it. Returns null if it is not an xml node.
762  TiXmlNode* Identify( const char* start, TiXmlEncoding encoding );
763 
766 
769 
771 
774 
775 private:
776  TiXmlNode( const TiXmlNode& ); // not implemented.
777  void operator=( const TiXmlNode& base ); // not allowed.
778 };
779 
780 
788 class TiXmlAttribute : public TiXmlBase
789 {
790  friend class TiXmlAttributeSet;
791 
792 public:
795  {
796  document = 0;
797  prev = next = 0;
798  }
799 
800  #ifdef TIXML_USE_STL
801  TiXmlAttribute( const std::string& _name, const std::string& _value )
803  {
804  name = _name;
805  value = _value;
806  document = 0;
807  prev = next = 0;
808  }
809  #endif
810 
812  TiXmlAttribute( const char * _name, const char * _value )
813  {
814  name = _name;
815  value = _value;
816  document = 0;
817  prev = next = 0;
818  }
819 
820  const char* Name() const { return name.c_str(); }
821  const char* Value() const { return value.c_str(); }
822  #ifdef TIXML_USE_STL
823  const std::string& ValueStr() const { return value; }
824  #endif
825  int IntValue() const;
826  double DoubleValue() const;
827 
828  // Get the tinyxml string representation
829  const TIXML_STRING& NameTStr() const { return name; }
830 
840  int QueryIntValue( int* _value ) const;
842  int QueryDoubleValue( double* _value ) const;
843 
844  void SetName( const char* _name ) { name = _name; }
845  void SetValue( const char* _value ) { value = _value; }
846 
847  void SetIntValue( int _value );
848  void SetDoubleValue( double _value );
849 
850  #ifdef TIXML_USE_STL
851  void SetName( const std::string& _name ) { name = _name; }
854  void SetValue( const std::string& _value ) { value = _value; }
855  #endif
856 
858  const TiXmlAttribute* Next() const;
860  return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() );
861  }
862 
864  const TiXmlAttribute* Previous() const;
866  return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() );
867  }
868 
869  bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
870  bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; }
871  bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; }
872 
873  /* Attribute parsing starts: first letter of the name
874  returns: the next char after the value end quote
875  */
876  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
877 
878  // Prints this Attribute to a FILE stream.
879  virtual void Print( FILE* cfile, int depth ) const {
880  Print( cfile, depth, 0 );
881  }
882  void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
883 
884  // [internal use]
885  // Set the document pointer so the attribute can report errors.
886  void SetDocument( TiXmlDocument* doc ) { document = doc; }
887 
888 private:
889  TiXmlAttribute( const TiXmlAttribute& ); // not implemented.
890  void operator=( const TiXmlAttribute& base ); // not allowed.
891 
892  TiXmlDocument* document; // A pointer back to a document, for error reporting.
893  TIXML_STRING name;
894  TIXML_STRING value;
895  TiXmlAttribute* prev;
896  TiXmlAttribute* next;
897 };
898 
899 
900 /* A class used to manage a group of attributes.
901  It is only used internally, both by the ELEMENT and the DECLARATION.
902 
903  The set can be changed transparent to the Element and Declaration
904  classes that use it, but NOT transparent to the Attribute
905  which has to implement a next() and previous() method. Which makes
906  it a bit problematic and prevents the use of STL.
907 
908  This version is implemented with circular lists because:
909  - I like circular lists
910  - it demonstrates some independence from the (typical) doubly linked list.
911 */
913 {
914 public:
917 
918  void Add( TiXmlAttribute* attribute );
919  void Remove( TiXmlAttribute* attribute );
920 
921  const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
922  TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
923  const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
924  TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
925 
926  TiXmlAttribute* Find( const char* _name ) const;
927  TiXmlAttribute* FindOrCreate( const char* _name );
928 
929 # ifdef TIXML_USE_STL
930  TiXmlAttribute* Find( const std::string& _name ) const;
931  TiXmlAttribute* FindOrCreate( const std::string& _name );
932 # endif
933 
934 
935 private:
936  //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
937  //*ME: this class must be also use a hidden/disabled copy-constructor !!!
938  TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed
939  void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute)
940 
941  TiXmlAttribute sentinel;
942 };
943 
944 
949 class TiXmlElement : public TiXmlNode
950 {
951 public:
953  TiXmlElement (const char * in_value);
954 
955  #ifdef TIXML_USE_STL
956  TiXmlElement( const std::string& _value );
958  #endif
959 
960  TiXmlElement( const TiXmlElement& );
961 
962  TiXmlElement& operator=( const TiXmlElement& base );
963 
964  virtual ~TiXmlElement();
965 
969  const char* Attribute( const char* name ) const;
970 
977  const char* Attribute( const char* name, int* i ) const;
978 
985  const char* Attribute( const char* name, double* d ) const;
986 
994  int QueryIntAttribute( const char* name, int* _value ) const;
996  int QueryUnsignedAttribute( const char* name, unsigned* _value ) const;
1001  int QueryBoolAttribute( const char* name, bool* _value ) const;
1003  int QueryDoubleAttribute( const char* name, double* _value ) const;
1005  int QueryFloatAttribute( const char* name, float* _value ) const {
1006  double d;
1007  int result = QueryDoubleAttribute( name, &d );
1008  if ( result == TIXML_SUCCESS ) {
1009  *_value = (float)d;
1010  }
1011  return result;
1012  }
1013 
1014  #ifdef TIXML_USE_STL
1015  int QueryStringAttribute( const char* name, std::string* _value ) const {
1017  const char* cstr = Attribute( name );
1018  if ( cstr ) {
1019  *_value = std::string( cstr );
1020  return TIXML_SUCCESS;
1021  }
1022  return TIXML_NO_ATTRIBUTE;
1023  }
1024 
1033  template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const
1034  {
1035  const TiXmlAttribute* node = attributeSet.Find( name );
1036  if ( !node )
1037  return TIXML_NO_ATTRIBUTE;
1038 
1039  std::stringstream sstream( node->ValueStr() );
1040  sstream >> *outValue;
1041  if ( !sstream.fail() )
1042  return TIXML_SUCCESS;
1043  return TIXML_WRONG_TYPE;
1044  }
1045 
1046  int QueryValueAttribute( const std::string& name, std::string* outValue ) const
1047  {
1048  const TiXmlAttribute* node = attributeSet.Find( name );
1049  if ( !node )
1050  return TIXML_NO_ATTRIBUTE;
1051  *outValue = node->ValueStr();
1052  return TIXML_SUCCESS;
1053  }
1054  #endif
1055 
1059  void SetAttribute( const char* name, const char * _value );
1060 
1061  #ifdef TIXML_USE_STL
1062  const std::string* Attribute( const std::string& name ) const;
1063  const std::string* Attribute( const std::string& name, int* i ) const;
1064  const std::string* Attribute( const std::string& name, double* d ) const;
1065  int QueryIntAttribute( const std::string& name, int* _value ) const;
1066  int QueryDoubleAttribute( const std::string& name, double* _value ) const;
1067 
1069  void SetAttribute( const std::string& name, const std::string& _value );
1071  void SetAttribute( const std::string& name, int _value );
1073  void SetDoubleAttribute( const std::string& name, double value );
1074  #endif
1075 
1079  void SetAttribute( const char * name, int value );
1080 
1084  void SetDoubleAttribute( const char * name, double value );
1085 
1088  void RemoveAttribute( const char * name );
1089  #ifdef TIXML_USE_STL
1090  void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); }
1091  #endif
1092 
1093  const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); }
1094  TiXmlAttribute* FirstAttribute() { return attributeSet.First(); }
1095  const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); }
1096  TiXmlAttribute* LastAttribute() { return attributeSet.Last(); }
1097 
1130  const char* GetText() const;
1131 
1133  virtual TiXmlNode* Clone() const;
1134  // Print the Element to a FILE stream.
1135  virtual void Print( FILE* cfile, int depth ) const;
1136 
1137  /* Attribtue parsing starts: next char past '<'
1138  returns: next char past '>'
1139  */
1140  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1141 
1142  virtual const TiXmlElement* ToElement() const { return this; }
1143  virtual TiXmlElement* ToElement() { return this; }
1144 
1147  virtual bool Accept( TiXmlVisitor* visitor ) const;
1148 
1149 protected:
1150 
1151  void CopyTo( TiXmlElement* target ) const;
1152  void ClearThis(); // like clear, but initializes 'this' object as well
1153 
1154  // Used to be public [internal use]
1155  #ifdef TIXML_USE_STL
1156  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1157  #endif
1158  /* [internal use]
1159  Reads the "value" of the element -- another element, or text.
1160  This should terminate with the current end tag.
1161  */
1162  const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
1163 
1164 private:
1165  TiXmlAttributeSet attributeSet;
1166 };
1167 
1168 
1171 class TiXmlComment : public TiXmlNode
1172 {
1173 public:
1175  TiXmlComment() : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {}
1177  TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {
1178  SetValue( _value );
1179  }
1180  TiXmlComment( const TiXmlComment& );
1181  TiXmlComment& operator=( const TiXmlComment& base );
1182 
1183  virtual ~TiXmlComment() {}
1184 
1186  virtual TiXmlNode* Clone() const;
1187  // Write this Comment to a FILE stream.
1188  virtual void Print( FILE* cfile, int depth ) const;
1189 
1190  /* Attribtue parsing starts: at the ! of the !--
1191  returns: next char past '>'
1192  */
1193  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1194 
1195  virtual const TiXmlComment* ToComment() const { return this; }
1196  virtual TiXmlComment* ToComment() { return this; }
1197 
1200  virtual bool Accept( TiXmlVisitor* visitor ) const;
1201 
1202 protected:
1203  void CopyTo( TiXmlComment* target ) const;
1204 
1205  // used to be public
1206  #ifdef TIXML_USE_STL
1207  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1208  #endif
1209 // virtual void StreamOut( TIXML_OSTREAM * out ) const;
1210 
1211 private:
1212 
1213 };
1214 
1215 
1221 class TiXmlText : public TiXmlNode
1222 {
1223  friend class TiXmlElement;
1224 public:
1229  TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT)
1230  {
1231  SetValue( initValue );
1232  cdata = false;
1233  }
1234  virtual ~TiXmlText() {}
1235 
1236  #ifdef TIXML_USE_STL
1237  TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT)
1239  {
1240  SetValue( initValue );
1241  cdata = false;
1242  }
1243  #endif
1244 
1245  TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TINYXML_TEXT ) { copy.CopyTo( this ); }
1246  TiXmlText& operator=( const TiXmlText& base ) { base.CopyTo( this ); return *this; }
1247 
1248  // Write this text object to a FILE stream.
1249  virtual void Print( FILE* cfile, int depth ) const;
1250 
1252  bool CDATA() const { return cdata; }
1254  void SetCDATA( bool _cdata ) { cdata = _cdata; }
1255 
1256  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1257 
1258  virtual const TiXmlText* ToText() const { return this; }
1259  virtual TiXmlText* ToText() { return this; }
1260 
1263  virtual bool Accept( TiXmlVisitor* content ) const;
1264 
1265 protected :
1267  virtual TiXmlNode* Clone() const;
1268  void CopyTo( TiXmlText* target ) const;
1269 
1270  bool Blank() const; // returns true if all white space and new lines
1271  // [internal use]
1272  #ifdef TIXML_USE_STL
1273  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1274  #endif
1275 
1276 private:
1277  bool cdata; // true if this should be input and output as a CDATA style text element
1278 };
1279 
1280 
1295 {
1296 public:
1298  TiXmlDeclaration() : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) {}
1299 
1300 #ifdef TIXML_USE_STL
1301  TiXmlDeclaration( const std::string& _version,
1303  const std::string& _encoding,
1304  const std::string& _standalone );
1305 #endif
1306 
1308  TiXmlDeclaration( const char* _version,
1309  const char* _encoding,
1310  const char* _standalone );
1311 
1312  TiXmlDeclaration( const TiXmlDeclaration& copy );
1313  TiXmlDeclaration& operator=( const TiXmlDeclaration& copy );
1314 
1315  virtual ~TiXmlDeclaration() {}
1316 
1318  const char *Version() const { return version.c_str (); }
1320  const char *Encoding() const { return encoding.c_str (); }
1322  const char *Standalone() const { return standalone.c_str (); }
1323 
1325  virtual TiXmlNode* Clone() const;
1326  // Print this declaration to a FILE stream.
1327  virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
1328  virtual void Print( FILE* cfile, int depth ) const {
1329  Print( cfile, depth, 0 );
1330  }
1331 
1332  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1333 
1334  virtual const TiXmlDeclaration* ToDeclaration() const { return this; }
1335  virtual TiXmlDeclaration* ToDeclaration() { return this; }
1336 
1339  virtual bool Accept( TiXmlVisitor* visitor ) const;
1340 
1341 protected:
1342  void CopyTo( TiXmlDeclaration* target ) const;
1343  // used to be public
1344  #ifdef TIXML_USE_STL
1345  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1346  #endif
1347 
1348 private:
1349 
1350  TIXML_STRING version;
1351  TIXML_STRING encoding;
1352  TIXML_STRING standalone;
1353 };
1354 
1355 
1363 class TiXmlUnknown : public TiXmlNode
1364 {
1365 public:
1366  TiXmlUnknown() : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) {}
1367  virtual ~TiXmlUnknown() {}
1368 
1369  TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) { copy.CopyTo( this ); }
1370  TiXmlUnknown& operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); return *this; }
1371 
1373  virtual TiXmlNode* Clone() const;
1374  // Print this Unknown to a FILE stream.
1375  virtual void Print( FILE* cfile, int depth ) const;
1376 
1377  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1378 
1379  virtual const TiXmlUnknown* ToUnknown() const { return this; }
1380  virtual TiXmlUnknown* ToUnknown() { return this; }
1381 
1384  virtual bool Accept( TiXmlVisitor* content ) const;
1385 
1386 protected:
1387  void CopyTo( TiXmlUnknown* target ) const;
1388 
1389  #ifdef TIXML_USE_STL
1390  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1391  #endif
1392 
1393 private:
1394 
1395 };
1396 
1397 
1402 class TiXmlDocument : public TiXmlNode
1403 {
1404 public:
1406  TiXmlDocument();
1408  TiXmlDocument( const char * documentName );
1409 
1410  #ifdef TIXML_USE_STL
1411  TiXmlDocument( const std::string& documentName );
1413  #endif
1414 
1415  TiXmlDocument( const TiXmlDocument& copy );
1416  TiXmlDocument& operator=( const TiXmlDocument& copy );
1417 
1418  virtual ~TiXmlDocument() {}
1419 
1424  bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1426  bool SaveFile() const;
1428  bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1430  bool SaveFile( const char * filename ) const;
1436  bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1438  bool SaveFile( FILE* ) const;
1439 
1440  #ifdef TIXML_USE_STL
1441  bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING )
1442  {
1443  return LoadFile( filename.c_str(), encoding );
1444  }
1445  bool SaveFile( const std::string& filename ) const
1446  {
1447  return SaveFile( filename.c_str() );
1448  }
1449  #endif
1450 
1455  virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1456 
1461  const TiXmlElement* RootElement() const { return FirstChildElement(); }
1462  TiXmlElement* RootElement() { return FirstChildElement(); }
1463 
1469  bool Error() const { return error; }
1470 
1472  const char * ErrorDesc() const { return errorDesc.c_str (); }
1473 
1477  int ErrorId() const { return errorId; }
1478 
1486  int ErrorRow() const { return errorLocation.row+1; }
1487  int ErrorCol() const { return errorLocation.col+1; }
1488 
1513  void SetTabSize( int _tabsize ) { tabsize = _tabsize; }
1514 
1515  int TabSize() const { return tabsize; }
1516 
1520  void ClearError() { error = false;
1521  errorId = 0;
1522  errorDesc = "";
1523  errorLocation.row = errorLocation.col = 0;
1524  //errorLocation.last = 0;
1525  }
1526 
1528  void Print() const { Print( stdout, 0 ); }
1529 
1530  /* Write the document to a string using formatted printing ("pretty print"). This
1531  will allocate a character array (new char[]) and return it as a pointer. The
1532  calling code pust call delete[] on the return char* to avoid a memory leak.
1533  */
1534  //char* PrintToMemory() const;
1535 
1537  virtual void Print( FILE* cfile, int depth = 0 ) const;
1538  // [internal use]
1539  void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding );
1540 
1541  virtual const TiXmlDocument* ToDocument() const { return this; }
1542  virtual TiXmlDocument* ToDocument() { return this; }
1543 
1546  virtual bool Accept( TiXmlVisitor* content ) const;
1547 
1548 protected :
1549  // [internal use]
1550  virtual TiXmlNode* Clone() const;
1551  #ifdef TIXML_USE_STL
1552  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1553  #endif
1554 
1555 private:
1556  void CopyTo( TiXmlDocument* target ) const;
1557 
1558  bool error;
1559  int errorId;
1560  TIXML_STRING errorDesc;
1561  int tabsize;
1562  TiXmlCursor errorLocation;
1563  bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write.
1564 };
1565 
1566 
1648 {
1649 public:
1651  TiXmlHandle( TiXmlNode* _node ) { this->node = _node; }
1653  TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; }
1654  TiXmlHandle operator=( const TiXmlHandle& ref ) { if ( &ref != this ) this->node = ref.node; return *this; }
1655 
1657  TiXmlHandle FirstChild() const;
1659  TiXmlHandle FirstChild( const char * value ) const;
1661  TiXmlHandle FirstChildElement() const;
1663  TiXmlHandle FirstChildElement( const char * value ) const;
1664 
1668  TiXmlHandle Child( const char* value, int index ) const;
1672  TiXmlHandle Child( int index ) const;
1677  TiXmlHandle ChildElement( const char* value, int index ) const;
1682  TiXmlHandle ChildElement( int index ) const;
1683 
1684  #ifdef TIXML_USE_STL
1685  TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); }
1686  TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); }
1687 
1688  TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); }
1689  TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); }
1690  #endif
1691 
1694  TiXmlNode* ToNode() const { return node; }
1697  TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
1700  TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
1703  TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
1704 
1708  TiXmlNode* Node() const { return ToNode(); }
1712  TiXmlElement* Element() const { return ToElement(); }
1716  TiXmlText* Text() const { return ToText(); }
1720  TiXmlUnknown* Unknown() const { return ToUnknown(); }
1721 
1722 private:
1723  TiXmlNode* node;
1724 };
1725 
1726 
1747 {
1748 public:
1749  TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ),
1750  buffer(), indent( " " ), lineBreak( "\n" ) {}
1751 
1752  virtual bool VisitEnter( const TiXmlDocument& doc );
1753  virtual bool VisitExit( const TiXmlDocument& doc );
1754 
1755  virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute );
1756  virtual bool VisitExit( const TiXmlElement& element );
1757 
1758  virtual bool Visit( const TiXmlDeclaration& declaration );
1759  virtual bool Visit( const TiXmlText& text );
1760  virtual bool Visit( const TiXmlComment& comment );
1761  virtual bool Visit( const TiXmlUnknown& unknown );
1762 
1766  void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; }
1768  const char* Indent() { return indent.c_str(); }
1773  void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; }
1775  const char* LineBreak() { return lineBreak.c_str(); }
1776 
1780  void SetStreamPrinting() { indent = "";
1781  lineBreak = "";
1782  }
1784  const char* CStr() { return buffer.c_str(); }
1786  size_t Size() { return buffer.size(); }
1787 
1788  #ifdef TIXML_USE_STL
1789  const std::string& Str() { return buffer; }
1791  #endif
1792 
1793 private:
1794  void DoIndent() {
1795  for( int i=0; i<depth; ++i )
1796  buffer += indent;
1797  }
1798  void DoLineBreak() {
1799  buffer += lineBreak;
1800  }
1801 
1802  int depth;
1803  bool simpleTextPrint;
1804  TIXML_STRING buffer;
1805  TIXML_STRING indent;
1806  TIXML_STRING lineBreak;
1807 };
1808 
1809 
1810 #ifdef _MSC_VER
1811 #pragma warning( pop )
1812 #endif
1813 
1814 #endif
virtual ~TiXmlVisitor()
Definition: tinyxml.h:140
static const int utf8ByteTable[256]
Definition: tinyxml.h:262
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1195
const TiXmlAttribute * First() const
Definition: tinyxml.h:921
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
TiXmlNode * LastChild(const char *_value)
The last child of this node matching &#39;value&#39;. Will be null if there are no children.
Definition: tinyxml.h:544
TiXmlHandle(TiXmlNode *_node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml.h:1651
TiXmlUnknown * Unknown() const
Definition: tinyxml.h:1720
virtual bool Accept(TiXmlVisitor *visitor) const
Definition: tinyxml.cpp:884
void SetUserData(void *user)
Set a pointer to arbitrary user data.
Definition: tinyxml.h:256
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1541
TiXmlUnknown(const TiXmlUnknown &copy)
Definition: tinyxml.h:1369
const TiXmlNode * Parent() const
Definition: tinyxml.h:529
const TiXmlElement * RootElement() const
Definition: tinyxml.h:1461
TiXmlComment()
Constructs an empty comment.
Definition: tinyxml.h:1175
void SetLineBreak(const char *_lineBreak)
Definition: tinyxml.h:1773
const TIXML_STRING & ValueTStr() const
Definition: tinyxml.h:506
TiXmlElement * NextSiblingElement()
Definition: tinyxml.h:654
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1142
TiXmlHandle(const TiXmlHandle &ref)
Copy constructor.
Definition: tinyxml.h:1653
TiXmlNode * PreviousSibling(const char *_prev)
Definition: tinyxml.h:628
TiXmlNode * LastChild()
The last child of this node. Will be null if there are no children.
Definition: tinyxml.h:541
const char * LineBreak()
Query the current line breaking string.
Definition: tinyxml.h:1775
virtual TiXmlNode * Clone() const
Creates a new Element and returns it - the returned element is a copy.
Definition: tinyxml.cpp:898
bool Error() const
Definition: tinyxml.h:1469
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:714
virtual bool Visit(const TiXmlUnknown &)
Visit an unknown node.
Definition: tinyxml.h:159
TiXmlAttribute(const char *_name, const char *_value)
Construct an attribute with a name and value.
Definition: tinyxml.h:812
TiXmlNode * prev
Definition: tinyxml.h:772
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1258
void CopyTo(TiXmlUnknown *target) const
Definition: tinyxml.cpp:1485
const void * GetUserData() const
Get a pointer to arbitrary user data.
Definition: tinyxml.h:258
int Type() const
Definition: tinyxml.h:693
static int ToLower(int v, TiXmlEncoding encoding)
Definition: tinyxml.h:391
TiXmlNode * IterateChildren(const char *_value, const TiXmlNode *previous)
Definition: tinyxml.h:578
TiXmlNode * firstChild
Definition: tinyxml.h:767
static int IsAlphaNum(unsigned char anyByte, TiXmlEncoding encoding)
TiXmlElement & operator=(const TiXmlElement &base)
Definition: tinyxml.cpp:560
int TabSize() const
Definition: tinyxml.h:1515
int ErrorId() const
Definition: tinyxml.h:1477
virtual void Print(FILE *cfile, int depth) const
Definition: tinyxml.h:1328
const TIXML_STRING & NameTStr() const
Definition: tinyxml.h:829
TiXmlAttribute * FirstAttribute()
Definition: tinyxml.h:1094
TiXmlElement * FirstChildElement(const char *_value)
Definition: tinyxml.h:680
TiXmlAttribute * Next()
Definition: tinyxml.h:859
static const char * ReadName(const char *p, TIXML_STRING *name, TiXmlEncoding encoding)
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
Definition: tinyxml.cpp:305
const TiXmlAttribute * LastAttribute() const
Access the last attribute in this element.
Definition: tinyxml.h:1095
virtual bool VisitExit(const TiXmlElement &)
Visit an element.
Definition: tinyxml.h:150
void SetName(const char *_name)
Set the name of this attribute.
Definition: tinyxml.h:844
TiXmlNode * NextSibling()
Definition: tinyxml.h:641
void SetTabSize(int _tabsize)
Definition: tinyxml.h:1513
TiXmlAttribute()
Construct an empty attribute.
Definition: tinyxml.h:794
const int TIXML_PATCH_VERSION
Definition: tinyxml.h:103
const char * Standalone() const
Is this a standalone document?
Definition: tinyxml.h:1322
TiXmlElement * ToElement() const
Definition: tinyxml.h:1697
TiXmlElement * NextSiblingElement(const char *_next)
Definition: tinyxml.h:663
virtual ~TiXmlText()
Definition: tinyxml.h:1234
TiXmlElement * FirstChildElement()
Definition: tinyxml.h:674
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:713
void ClearError()
Definition: tinyxml.h:1520
const char * Value() const
Return the value of this attribute.
Definition: tinyxml.h:821
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:708
void Clear()
Definition: tinyxml.h:111
virtual void Print(FILE *cfile, int depth) const
Definition: tinyxml.cpp:809
virtual TiXmlComment * ToComment()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1196
virtual ~TiXmlComment()
Definition: tinyxml.h:1183
static const char * errorString[TIXML_ERROR_STRING_COUNT]
Definition: tinyxml.h:380
void SetValue(const char *_value)
Definition: tinyxml.h:517
int ErrorCol() const
The column where the error occured. See ErrorRow()
Definition: tinyxml.h:1487
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
Definition: tinyxml.cpp:223
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1143
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
Definition: tinyxml.cpp:239
virtual ~TiXmlDocument()
Definition: tinyxml.h:1418
TiXmlNode * PreviousSibling()
Definition: tinyxml.h:624
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:711
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
Definition: tinyxml.h:143
const char * Encoding() const
Encoding. Will return an empty string if none was found.
Definition: tinyxml.h:1320
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
Definition: tinyxml.cpp:195
const TiXmlNode * LastChild() const
Definition: tinyxml.h:540
const char * Name() const
Return the name of this attribute.
Definition: tinyxml.h:820
void * userData
Field containing a generic user pointer.
Definition: tinyxml.h:385
TiXmlDocument * GetDocument()
Definition: tinyxml.h:699
void Print() const
Definition: tinyxml.h:1528
const TiXmlAttribute * Last() const
Definition: tinyxml.h:923
static bool IsWhiteSpace(char c)
Definition: tinyxml.h:299
TiXmlCursor()
Definition: tinyxml.h:110
virtual bool Visit(const TiXmlText &)
Visit a text node.
Definition: tinyxml.h:155
const TiXmlEncoding TIXML_DEFAULT_ENCODING
Definition: tinyxml.h:179
int ErrorRow() const
Definition: tinyxml.h:1486
const char * Version() const
Version. Will return an empty string if none was found.
Definition: tinyxml.h:1318
TiXmlNode * NextSibling(const char *_next)
Definition: tinyxml.h:645
TiXmlNode * FirstChild()
Definition: tinyxml.h:532
int Column() const
See Row()
Definition: tinyxml.h:254
static bool IsWhiteSpaceCondensed()
Return the current white space setting.
Definition: tinyxml.h:233
TiXmlText(const TiXmlText &copy)
Definition: tinyxml.h:1245
static const char * ReadText(const char *in, TIXML_STRING *text, bool ignoreWhiteSpace, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
TiXmlCursor location
Definition: tinyxml.h:382
const int TIXML_MAJOR_VERSION
Definition: tinyxml.h:101
void SetIndent(const char *_indent)
Definition: tinyxml.h:1766
virtual ~TiXmlUnknown()
Definition: tinyxml.h:1367
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
Definition: tinyxml.h:531
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
Definition: tinyxml.h:1472
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1379
string filename
Definition: aging.py:5
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1542
TiXmlAttribute * Last()
Definition: tinyxml.h:924
virtual void Print(FILE *cfile, int depth) const
Definition: tinyxml.h:879
void SetCDATA(bool _cdata)
Turns on or off a CDATA representation of text.
Definition: tinyxml.h:1254
const char * Indent()
Query the indention string.
Definition: tinyxml.h:1768
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1335
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
Definition: tinyxml.cpp:461
TiXmlEncoding
Definition: tinyxml.h:172
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1334
int QueryFloatAttribute(const char *name, float *_value) const
QueryFloatAttribute examines the attribute - see QueryIntAttribute().
Definition: tinyxml.h:1005
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
Definition: tinyxml.h:623
static const char * SkipWhiteSpace(const char *, TiXmlEncoding encoding)
TiXmlNode * Identify(const char *start, TiXmlEncoding encoding)
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
Definition: tinyxml.cpp:272
Log & operator<<(Log &log, T data)
Definition: log.h:38
TiXmlText & operator=(const TiXmlText &base)
Definition: tinyxml.h:1246
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:718
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:707
const TiXmlDocument * GetDocument() const
Definition: tinyxml.cpp:521
bool CDATA() const
Queries whether this represents text using a CDATA section.
Definition: tinyxml.h:1252
static bool IsWhiteSpace(int c)
Definition: tinyxml.h:303
virtual TiXmlComment * ToComment()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:715
bool operator>(const TiXmlAttribute &rhs) const
Definition: tinyxml.h:871
static const char * GetEntity(const char *in, char *value, int *length, TiXmlEncoding encoding)
TiXmlText * Text() const
Definition: tinyxml.h:1716
TiXmlNode * Node() const
Definition: tinyxml.h:1708
TiXmlNode * ToNode() const
Definition: tinyxml.h:1694
static void SetCondenseWhiteSpace(bool condense)
Definition: tinyxml.h:230
bool operator<(const TiXmlAttribute &rhs) const
Definition: tinyxml.h:870
const TiXmlElement * NextSiblingElement() const
Definition: tinyxml.cpp:491
TiXmlNode * Parent()
One step up the DOM.
Definition: tinyxml.h:528
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:716
bool operator==(const TiXmlAttribute &rhs) const
Definition: tinyxml.h:869
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:709
TiXmlComment(const char *_value)
Construct a comment from text.
Definition: tinyxml.h:1177
virtual ~TiXmlBase()
Definition: tinyxml.h:211
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
TiXmlHandle operator=(const TiXmlHandle &ref)
Definition: tinyxml.h:1654
TiXmlNode * parent
Definition: tinyxml.h:764
TiXmlNode * IterateChildren(const TiXmlNode *previous)
Definition: tinyxml.h:572
int Row() const
Definition: tinyxml.h:253
TiXmlAttribute * Previous()
Definition: tinyxml.h:865
TiXmlElement * Element() const
Definition: tinyxml.h:1712
TiXmlNode(NodeType _type)
Definition: tinyxml.cpp:145
TiXmlElement * RootElement()
Definition: tinyxml.h:1462
static void EncodeString(const TIXML_STRING &str, TIXML_STRING *out)
Definition: tinyxml.cpp:61
void * GetUserData()
Get a pointer to arbitrary user data.
Definition: tinyxml.h:257
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:710
size_t Size()
Return the length of the result string.
Definition: tinyxml.h:1786
TiXmlNode * next
Definition: tinyxml.h:773
virtual bool VisitExit(const TiXmlDocument &)
Visit a document.
Definition: tinyxml.h:145
virtual bool Visit(const TiXmlComment &)
Visit a comment node.
Definition: tinyxml.h:157
static const char * GetChar(const char *p, char *_value, int *length, TiXmlEncoding encoding)
Definition: tinyxml.h:336
TiXmlText(const char *initValue)
Definition: tinyxml.h:1229
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
Definition: tinyxml.cpp:394
const char * Value() const
Definition: tinyxml.h:496
TiXmlDocument & operator=(const TiXmlDocument &copy)
Definition: tinyxml.cpp:955
void CopyTo(TiXmlText *target) const
Definition: tinyxml.cpp:1362
TiXmlUnknown & operator=(const TiXmlUnknown &copy)
Definition: tinyxml.h:1370
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml.h:704
void CopyTo(TiXmlElement *target) const
Definition: tinyxml.cpp:862
const TiXmlAttribute * FirstAttribute() const
Access the first attribute in this element.
Definition: tinyxml.h:1093
NodeType type
Definition: tinyxml.h:765
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
Definition: tinyxml.cpp:344
TIXML_STRING value
Definition: tinyxml.h:770
void SetDocument(TiXmlDocument *doc)
Definition: tinyxml.h:886
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1380
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:706
void SetValue(const char *_value)
Set the value.
Definition: tinyxml.h:845
virtual ~TiXmlDeclaration()
Definition: tinyxml.h:1315
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
Definition: tinyxml.h:640
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1259
TiXmlAttribute * LastAttribute()
Definition: tinyxml.h:1096
TiXmlNode * lastChild
Definition: tinyxml.h:768
TiXmlText * ToText() const
Definition: tinyxml.h:1700
TiXmlDeclaration()
Construct an empty declaration.
Definition: tinyxml.h:1298
void SetStreamPrinting()
Definition: tinyxml.h:1780
static int IsAlpha(unsigned char anyByte, TiXmlEncoding encoding)
TiXmlAttribute * First()
Definition: tinyxml.h:922
virtual ~TiXmlNode()
Definition: tinyxml.cpp:156
TiXmlUnknown * ToUnknown() const
Definition: tinyxml.h:1703
const char * CStr()
Return the result.
Definition: tinyxml.h:1784
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:717
#define TIXML_STRING
Definition: tinyxml.h:62
const int TIXML_MINOR_VERSION
Definition: tinyxml.h:102
virtual bool VisitEnter(const TiXmlElement &, const TiXmlAttribute *)
Visit an element.
Definition: tinyxml.h:148
TiXmlBase()
Definition: tinyxml.h:210
virtual bool Visit(const TiXmlDeclaration &)
Visit a declaration.
Definition: tinyxml.h:153