Orxonox  0.0.5 Codename: Arcturus
tinyxml.h
Go to the documentation of this file.
1 /*
2 www.sourceforge.net/projects/tinyxml
3 Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
4 
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any
7 damages arising from the use of this software.
8 
9 Permission is granted to anyone to use this software for any
10 purpose, including commercial applications, and to alter it and
11 redistribute it freely, subject to the following restrictions:
12 
13 1. The origin of this software must not be misrepresented; you must
14 not claim that you wrote the original software. If you use this
15 software in a product, an acknowledgment in the product documentation
16 would be appreciated but is not required.
17 
18 2. Altered source versions must be plainly marked as such, and
19 must not be misrepresented as being the original software.
20 
21 3. This notice may not be removed or altered from any source
22 distribution.
23 */
24 
25 
26 #ifndef TINYXML_INCLUDED
27 #define TINYXML_INCLUDED
28 
29 #ifdef _MSC_VER
30 #pragma warning( push )
31 #pragma warning( disable : 4530 )
32 #pragma warning( disable : 4786 )
33 #endif
34 
35 #include <ctype.h>
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <string.h>
39 #include <assert.h>
40 
41 // Help out windows:
42 #if defined( _DEBUG ) && !defined( DEBUG )
43 #define DEBUG
44 #endif
45 
46 #ifdef TIXML_USE_TICPP
47  #ifndef TIXML_USE_STL
48  #define TIXML_USE_STL
49  #endif
50 #endif
51 
52 #ifdef TIXML_USE_STL
53  #include <string>
54  #include <iostream>
55  #include <sstream>
56  #define TIXML_STRING std::string
57 #else
58  #include "tinystr.h"
59  #define TIXML_STRING TiXmlString
60 #endif
61 
62 // Deprecated library function hell. Compilers want to use the
63 // new safe versions. This probably doesn't fully address the problem,
64 // but it gets closer. There are too many compilers for me to fully
65 // test. If you get compilation troubles, undefine TIXML_SAFE
66 #define TIXML_SAFE
67 
68 #ifdef TIXML_SAFE
69  #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
70  // Microsoft visual studio, version 2005 and higher.
71  #define TIXML_SNPRINTF _snprintf_s
72  #define TIXML_SNSCANF _snscanf_s
73  #define TIXML_SSCANF sscanf_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  #define TIXML_SSCANF sscanf
80  #elif defined(__GNUC__) && (__GNUC__ >= 3 )
81  // GCC version 3 and higher.s
82  //#warning( "Using sn* functions." )
83  #define TIXML_SNPRINTF snprintf
84  #define TIXML_SNSCANF snscanf
85  #define TIXML_SSCANF sscanf
86  #else
87  #define TIXML_SSCANF sscanf
88  #endif
89 #endif
90 
91 class TiXmlDocument;
92 class TiXmlElement;
93 class TiXmlComment;
94 class TiXmlUnknown;
95 class TiXmlAttribute;
96 class TiXmlText;
97 class TiXmlDeclaration;
99 class TiXmlParsingData;
100 
101 const int TIXML_MAJOR_VERSION = 2;
102 const int TIXML_MINOR_VERSION = 5;
103 const int TIXML_PATCH_VERSION = 3;
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 
137 {
138 public:
139  virtual ~TiXmlVisitor() {}
140 
142  virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; }
144  virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; }
145 
147  virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; }
149  virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; }
150 
152  virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; }
154  virtual bool Visit( const TiXmlStylesheetReference& /*stylesheet*/ ) { return true; }
156  virtual bool Visit( const TiXmlText& /*text*/ ) { return true; }
158  virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; }
160  virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; }
161 };
162 
163 // Only used by Attribute::Query functions
164 enum
165 {
169 };
170 
171 
172 // Used by the parsing routines.
174 {
178 };
179 
181 
204 #ifdef TIXML_USE_TICPP
205 #include "ticpprc.h"
206 class TiXmlBase : public TiCppRC
207 #else
209 #endif
210 {
211  friend class TiXmlNode;
212  friend class TiXmlElement;
213  friend class TiXmlDocument;
214 
215 public:
216  TiXmlBase() : userData(0) {}
217  virtual ~TiXmlBase() {}
218 
228  virtual void Print( FILE* cfile, int depth ) const = 0;
229 
236  static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; }
237 
239  static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; }
240 
259  int Row() const { return location.row + 1; }
260  int Column() const { return location.col + 1; }
261 
262  void SetUserData( void* user ) { userData = user; }
263  void* GetUserData() { return userData; }
264  const void* GetUserData() const { return userData; }
265 
266  // Table that returs, for a given lead byte, the total number of bytes
267  // in the UTF-8 sequence.
268  static const int utf8ByteTable[256];
269 
270  virtual const char* Parse( const char* p,
271  TiXmlParsingData* data,
272  TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
273 
277  static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out );
278 
279  enum
280  {
298 
300  };
301 
302 protected:
303 
304  static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
305  inline static bool IsWhiteSpace( char c )
306  {
307  return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
308  }
309  inline static bool IsWhiteSpace( int c )
310  {
311  if ( c < 256 )
312  return IsWhiteSpace( (char) c );
313  return false; // Again, only truly correct for English/Latin...but usually works.
314  }
315 
316  #ifdef TIXML_USE_STL
317  static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag );
318  static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag );
319  #endif
320 
321  /* Reads an XML name into the string provided. Returns
322  a pointer just past the last character of the name,
323  or 0 if the function has an error.
324  */
325  static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding );
326 
327  /* Reads text. Returns a pointer past the given end tag.
328  Wickedly complex options, but it keeps the (sensitive) code in one place.
329  */
330  static const char* ReadText( const char* in, // where to start
331  TIXML_STRING* text, // the string read
332  bool ignoreWhiteSpace, // whether to keep the white space
333  const char* endTag, // what ends this text
334  bool ignoreCase, // whether to ignore case in the end tag
335  TiXmlEncoding encoding ); // the current encoding
336 
337  // If an entity has been found, transform it into a character.
338  static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding );
339 
340  // Get a character, while interpreting entities.
341  // The length can be from 0 to 4 bytes.
342  inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding )
343  {
344  assert( p );
345  if ( encoding == TIXML_ENCODING_UTF8 )
346  {
347  *length = utf8ByteTable[ *((const unsigned char*)p) ];
348  assert( *length >= 0 && *length < 5 );
349  }
350  else
351  {
352  *length = 1;
353  }
354 
355  if ( *length == 1 )
356  {
357  if ( *p == '&' )
358  return GetEntity( p, _value, length, encoding );
359  *_value = *p;
360  return p+1;
361  }
362  else if ( *length )
363  {
364  //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe),
365  // and the null terminator isn't needed
366  for( int i=0; p[i] && i<*length; ++i ) {
367  _value[i] = p[i];
368  }
369  return p + (*length);
370  }
371  else
372  {
373  // Not valid text.
374  return 0;
375  }
376  }
377 
378  // Return true if the next characters in the stream are any of the endTag sequences.
379  // Ignore case only works for english, and should only be relied on when comparing
380  // to English words: StringEqual( p, "version", true ) is fine.
381  static bool StringEqual( const char* p,
382  const char* endTag,
383  bool ignoreCase,
384  TiXmlEncoding encoding );
385 
386  static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
387 
389 
391  void* userData;
392 
393  // None of these methods are reliable for any language except English.
394  // Good for approximation, not great for accuracy.
395  static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding );
396  static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding );
397  inline static int ToLower( int v, TiXmlEncoding encoding )
398  {
399  if ( encoding == TIXML_ENCODING_UTF8 )
400  {
401  if ( v < 128 ) return tolower( v );
402  return v;
403  }
404  else
405  {
406  return tolower( v );
407  }
408  }
409  static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
410 
411 private:
412  TiXmlBase( const TiXmlBase& ); // not implemented.
413  void operator=( const TiXmlBase& base ); // not allowed.
414 
415  struct Entity
416  {
417  const char* str;
418  unsigned int strLength;
419  char chr;
420  };
421  enum
422  {
423  NUM_ENTITY = 5,
424  MAX_ENTITY_LENGTH = 6
425 
426  };
427  static Entity entity[ NUM_ENTITY ];
428  static bool condenseWhiteSpace;
429 };
430 
431 
438 class TiXmlNode : public TiXmlBase
439 {
440  friend class TiXmlDocument;
441  friend class TiXmlElement;
442 
443 public:
444  #ifdef TIXML_USE_STL
445 
449  friend std::istream& operator >> (std::istream& in, TiXmlNode& base);
450 
467  friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
468 
470  friend std::string& operator<< (std::string& out, const TiXmlNode& base );
471 
472  #endif
473 
477  enum NodeType
478  {
487  };
488 
489  virtual ~TiXmlNode();
490 
503  const char *Value() const { return value.c_str (); }
504 
505  #ifdef TIXML_USE_STL
506 
510  const std::string& ValueStr() const { return value; }
511  #endif
512 
513  const TIXML_STRING& ValueTStr() const { return value; }
514 
524  void SetValue(const char * _value) { value = _value;}
525 
526  #ifdef TIXML_USE_STL
527  void SetValue( const std::string& _value ) { value = _value; }
529  #endif
530 
532  void Clear();
533 
535  TiXmlNode* Parent() { return parent; }
536  const TiXmlNode* Parent() const { return parent; }
537 
538  const TiXmlNode* FirstChild() const { return firstChild; }
540  const TiXmlNode* FirstChild( const char * value ) const;
541  TiXmlNode* FirstChild( const char * _value ) {
543  // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe)
544  // call the method, cast the return back to non-const.
545  return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value ));
546  }
547  const TiXmlNode* LastChild() const { return lastChild; }
549 
550  const TiXmlNode* LastChild( const char * value ) const;
551  TiXmlNode* LastChild( const char * _value ) {
552  return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value ));
553  }
554 
555  #ifdef TIXML_USE_STL
556  const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); }
557  TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); }
558  const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); }
559  TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); }
560  #endif
561 
578  const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const;
579  TiXmlNode* IterateChildren( const TiXmlNode* previous ) {
580  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) );
581  }
582 
584  const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const;
585  TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) {
586  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) );
587  }
588 
589  #ifdef TIXML_USE_STL
590  const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); }
591  TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); }
592  #endif
593 
597  TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
598 
599 
609  TiXmlNode* LinkEndChild( TiXmlNode* addThis );
610 
614  TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
615 
619  TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis );
620 
624  TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
625 
627  bool RemoveChild( TiXmlNode* removeThis );
628 
630  const TiXmlNode* PreviousSibling() const { return prev; }
632 
634  const TiXmlNode* PreviousSibling( const char * ) const;
635  TiXmlNode* PreviousSibling( const char *_prev ) {
636  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) );
637  }
638 
639  #ifdef TIXML_USE_STL
640  const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); }
641  TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); }
642  const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); }
643  TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); }
644  #endif
645 
647  const TiXmlNode* NextSibling() const { return next; }
648  TiXmlNode* NextSibling() { return next; }
649 
651  const TiXmlNode* NextSibling( const char * ) const;
652  TiXmlNode* NextSibling( const char* _next ) {
653  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) );
654  }
655 
660  const TiXmlElement* NextSiblingElement() const;
662  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() );
663  }
664 
669  const TiXmlElement* NextSiblingElement( const char * ) const;
670  TiXmlElement* NextSiblingElement( const char *_next ) {
671  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) );
672  }
673 
674  #ifdef TIXML_USE_STL
675  const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); }
676  TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); }
677  #endif
678 
680  const TiXmlElement* FirstChildElement() const;
682  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() );
683  }
684 
686  const TiXmlElement* FirstChildElement( const char * _value ) const;
687  TiXmlElement* FirstChildElement( const char * _value ) {
688  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) );
689  }
690 
691  #ifdef TIXML_USE_STL
692  const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); }
693  TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); }
694  #endif
695 
700  int Type() const { return type; }
701 
705  const TiXmlDocument* GetDocument() const;
707  return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() );
708  }
709 
711  bool NoChildren() const { return !firstChild; }
712 
713  virtual const TiXmlDocument* ToDocument() const { return 0; }
714  virtual const TiXmlElement* ToElement() const { return 0; }
715  virtual const TiXmlComment* ToComment() const { return 0; }
716  virtual const TiXmlUnknown* ToUnknown() const { return 0; }
717  virtual const TiXmlText* ToText() const { return 0; }
718  virtual const TiXmlDeclaration* ToDeclaration() const { return 0; }
719  virtual const TiXmlStylesheetReference* ToStylesheetReference() const { return 0; }
720 
721  virtual TiXmlDocument* ToDocument() { return 0; }
722  virtual TiXmlElement* ToElement() { return 0; }
723  virtual TiXmlComment* ToComment() { return 0; }
724  virtual TiXmlUnknown* ToUnknown() { return 0; }
725  virtual TiXmlText* ToText() { return 0; }
726  virtual TiXmlDeclaration* ToDeclaration() { return 0; }
728 
732  virtual TiXmlNode* Clone() const = 0;
733 
756  virtual bool Accept( TiXmlVisitor* visitor ) const = 0;
757 
758 protected:
759  TiXmlNode( NodeType _type );
760 
761  // Copy to the allocated object. Shared functionality between Clone, Copy constructor,
762  // and the assignment operator.
763  void CopyTo( TiXmlNode* target ) const;
764 
765  #ifdef TIXML_USE_STL
766  // The real work of the input operator.
767  virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0;
768  #endif
769 
770  // Figure out what is at *p, and parse it. Returns null if it is not an xml node.
771  TiXmlNode* Identify( const char* start, TiXmlEncoding encoding );
772 
775 
778 
780 
783 
784 private:
785  TiXmlNode( const TiXmlNode& ); // not implemented.
786  void operator=( const TiXmlNode& base ); // not allowed.
787 };
788 
789 
797 class TiXmlAttribute : public TiXmlBase
798 {
799  friend class TiXmlAttributeSet;
800 
801 public:
804  {
805  document = 0;
806  prev = next = 0;
807  }
808 
809  #ifdef TIXML_USE_STL
810  TiXmlAttribute( const std::string& _name, const std::string& _value )
812  {
813  name = _name;
814  value = _value;
815  document = 0;
816  prev = next = 0;
817  }
818  #endif
819 
821  TiXmlAttribute( const char * _name, const char * _value )
822  {
823  name = _name;
824  value = _value;
825  document = 0;
826  prev = next = 0;
827  }
828 
829  const char* Name() const { return name.c_str(); }
830  const char* Value() const { return value.c_str(); }
831  #ifdef TIXML_USE_STL
832  const std::string& ValueStr() const { return value; }
833  #endif
834  int IntValue() const;
835  double DoubleValue() const;
836 
837  // Get the tinyxml string representation
838  const TIXML_STRING& NameTStr() const { return name; }
839 
849  int QueryIntValue( int* _value ) const;
851  int QueryDoubleValue( double* _value ) const;
852 
853  void SetName( const char* _name ) { name = _name; }
854  void SetValue( const char* _value ) { value = _value; }
855 
856  void SetIntValue( int _value );
857  void SetDoubleValue( double _value );
858 
859  #ifdef TIXML_USE_STL
860  void SetName( const std::string& _name ) { name = _name; }
863  void SetValue( const std::string& _value ) { value = _value; }
864  #endif
865 
867  const TiXmlAttribute* Next() const;
869  return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() );
870  }
871 
873  const TiXmlAttribute* Previous() const;
875  return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() );
876  }
877 
878  bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
879  bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; }
880  bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; }
881 
882  /* Attribute parsing starts: first letter of the name
883  returns: the next char after the value end quote
884  */
885  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
886 
887  // Prints this Attribute to a FILE stream.
888  virtual void Print( FILE* cfile, int depth ) const {
889  Print( cfile, depth, 0 );
890  }
891  void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
892 
893  // [internal use]
894  // Set the document pointer so the attribute can report errors.
895  void SetDocument( TiXmlDocument* doc ) { document = doc; }
896 
897 private:
898  TiXmlAttribute( const TiXmlAttribute& ); // not implemented.
899  void operator=( const TiXmlAttribute& base ); // not allowed.
900 
901  TiXmlDocument* document; // A pointer back to a document, for error reporting.
906 };
907 
908 
909 /* A class used to manage a group of attributes.
910  It is only used internally, both by the ELEMENT and the DECLARATION.
911 
912  The set can be changed transparent to the Element and Declaration
913  classes that use it, but NOT transparent to the Attribute
914  which has to implement a next() and previous() method. Which makes
915  it a bit problematic and prevents the use of STL.
916 
917  This version is implemented with circular lists because:
918  - I like circular lists
919  - it demonstrates some independence from the (typical) doubly linked list.
920 */
922 {
923 public:
926 
927  void Add( TiXmlAttribute* attribute );
928  void Remove( TiXmlAttribute* attribute );
929 
930  const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
931  TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
932  const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
933  TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
934 
935  const TiXmlAttribute* Find( const char* _name ) const;
936  TiXmlAttribute* Find( const char* _name ) {
937  return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
938  }
939  #ifdef TIXML_USE_STL
940  const TiXmlAttribute* Find( const std::string& _name ) const;
941  TiXmlAttribute* Find( const std::string& _name ) {
942  return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
943  }
944 
945  #endif
946 
947 private:
948  //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
949  //*ME: this class must be also use a hidden/disabled copy-constructor !!!
950  TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed
951  void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute)
952 
954 };
955 
956 
961 class TiXmlElement : public TiXmlNode
962 {
963 public:
965  TiXmlElement (const char * in_value);
966 
967  #ifdef TIXML_USE_STL
968  TiXmlElement( const std::string& _value );
970  #endif
971 
972  TiXmlElement( const TiXmlElement& );
973 
974  void operator=( const TiXmlElement& base );
975 
976  virtual ~TiXmlElement();
977 
981  const char* Attribute( const char* name ) const;
982 
989  const char* Attribute( const char* name, int* i ) const;
990 
997  const char* Attribute( const char* name, double* d ) const;
998 
1006  int QueryIntAttribute( const char* name, int* _value ) const;
1008  int QueryDoubleAttribute( const char* name, double* _value ) const;
1010  int QueryFloatAttribute( const char* name, float* _value ) const {
1011  double d;
1012  int result = QueryDoubleAttribute( name, &d );
1013  if ( result == TIXML_SUCCESS ) {
1014  *_value = (float)d;
1015  }
1016  return result;
1017  }
1018 
1019  #ifdef TIXML_USE_STL
1020 
1028  template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const
1029  {
1030  const TiXmlAttribute* node = attributeSet.Find( name );
1031  if ( !node )
1032  return TIXML_NO_ATTRIBUTE;
1033 
1034  std::stringstream sstream( node->ValueStr() );
1035  sstream >> *outValue;
1036  if ( !sstream.fail() )
1037  return TIXML_SUCCESS;
1038  return TIXML_WRONG_TYPE;
1039  }
1040  /*
1041  This is - in theory - a bug fix for "QueryValueAtribute returns truncated std::string"
1042  but template specialization is hard to get working cross-compiler. Leaving the bug for now.
1043 
1044  // The above will fail for std::string because the space character is used as a seperator.
1045  // Specialize for strings. Bug [ 1695429 ] QueryValueAtribute returns truncated std::string
1046  template<> int QueryValueAttribute( const std::string& name, std::string* outValue ) const
1047  {
1048  const TiXmlAttribute* node = attributeSet.Find( name );
1049  if ( !node )
1050  return TIXML_NO_ATTRIBUTE;
1051  *outValue = node->ValueStr();
1052  return TIXML_SUCCESS;
1053  }
1054  */
1055  #endif
1056 
1060  void SetAttribute( const char* name, const char * _value );
1061 
1062  #ifdef TIXML_USE_STL
1063  const std::string* Attribute( const std::string& name ) const;
1064  const std::string* Attribute( const std::string& name, int* i ) const;
1065  const std::string* Attribute( const std::string& name, double* d ) const;
1066  int QueryIntAttribute( const std::string& name, int* _value ) const;
1067  int QueryDoubleAttribute( const std::string& name, double* _value ) const;
1068 
1070  void SetAttribute( const std::string& name, const std::string& _value );
1072  void SetAttribute( const std::string& name, int _value );
1073  #endif
1074 
1078  void SetAttribute( const char * name, int value );
1079 
1083  void SetDoubleAttribute( const char * name, double value );
1084 
1087  void RemoveAttribute( const char * name );
1088  #ifdef TIXML_USE_STL
1089  void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); }
1090  #endif
1091 
1092  const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); }
1093  TiXmlAttribute* FirstAttribute() { return attributeSet.First(); }
1094  const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); }
1095  TiXmlAttribute* LastAttribute() { return attributeSet.Last(); }
1096 
1129  const char* GetText() const;
1130 
1132  virtual TiXmlNode* Clone() const;
1133  // Print the Element to a FILE stream.
1134  virtual void Print( FILE* cfile, int depth ) const;
1135 
1136  /* Attribtue parsing starts: next char past '<'
1137  returns: next char past '>'
1138  */
1139  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1140 
1141  virtual const TiXmlElement* ToElement() const { return this; }
1142  virtual TiXmlElement* ToElement() { return this; }
1143 
1146  virtual bool Accept( TiXmlVisitor* visitor ) const;
1147 
1148 protected:
1149 
1150  void CopyTo( TiXmlElement* target ) const;
1151  void ClearThis(); // like clear, but initializes 'this' object as well
1152 
1153  // Used to be public [internal use]
1154  #ifdef TIXML_USE_STL
1155  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1156  #endif
1157  /* [internal use]
1158  Reads the "value" of the element -- another element, or text.
1159  This should terminate with the current end tag.
1160  */
1161  const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
1162 
1163 private:
1164 
1166 };
1167 
1168 
1171 class TiXmlComment : public TiXmlNode
1172 {
1173 public:
1175  TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {}
1177  TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) {
1178  SetValue( _value );
1179  }
1180  TiXmlComment( const TiXmlComment& );
1181  void operator=( const TiXmlComment& base );
1182 
1183  virtual ~TiXmlComment() {}
1184 
1186  virtual TiXmlNode* Clone() const;
1187  // Write this Comment to a FILE stream.
1188  virtual void Print( FILE* cfile, int depth ) const;
1189 
1190  /* Attribtue parsing starts: at the ! of the !--
1191  returns: next char past '>'
1192  */
1193  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1194 
1195  virtual const TiXmlComment* ToComment() const { return this; }
1196  virtual TiXmlComment* ToComment() { return this; }
1197 
1200  virtual bool Accept( TiXmlVisitor* visitor ) const;
1201 
1202 protected:
1203  void CopyTo( TiXmlComment* target ) const;
1204 
1205  // used to be public
1206  #ifdef TIXML_USE_STL
1207  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1208  #endif
1209 // virtual void StreamOut( TIXML_OSTREAM * out ) const;
1210 
1211 private:
1212 
1213 };
1214 
1215 
1221 class TiXmlText : public TiXmlNode
1222 {
1223  friend class TiXmlElement;
1224 public:
1229  TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT)
1230  {
1231  SetValue( initValue );
1232  cdata = false;
1233  }
1234  virtual ~TiXmlText() {}
1235 
1236  #ifdef TIXML_USE_STL
1237  TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT)
1239  {
1240  SetValue( initValue );
1241  cdata = false;
1242  }
1243  #endif
1244 
1245  TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT ) { copy.CopyTo( this ); }
1246  void operator=( const TiXmlText& base ) { base.CopyTo( this ); }
1247 
1248  // Write this text object to a FILE stream.
1249  virtual void Print( FILE* cfile, int depth ) const;
1250 
1252  bool CDATA() const { return cdata; }
1254  void SetCDATA( bool _cdata ) { cdata = _cdata; }
1255 
1256  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1257 
1258  virtual const TiXmlText* ToText() const { return this; }
1259  virtual TiXmlText* ToText() { return this; }
1260 
1263  virtual bool Accept( TiXmlVisitor* content ) const;
1264 
1265 protected :
1267  virtual TiXmlNode* Clone() const;
1268  void CopyTo( TiXmlText* target ) const;
1269 
1270  bool Blank() const; // returns true if all white space and new lines
1271  // [internal use]
1272  #ifdef TIXML_USE_STL
1273  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1274  #endif
1275 
1276 private:
1277  bool cdata; // true if this should be input and output as a CDATA style text element
1278 };
1279 
1280 
1295 {
1296 public:
1298  TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {}
1299 
1300 #ifdef TIXML_USE_STL
1301  TiXmlDeclaration( const std::string& _version,
1303  const std::string& _encoding,
1304  const std::string& _standalone );
1305 #endif
1306 
1308  TiXmlDeclaration( const char* _version,
1309  const char* _encoding,
1310  const char* _standalone );
1311 
1312  TiXmlDeclaration( const TiXmlDeclaration& copy );
1313  void operator=( const TiXmlDeclaration& copy );
1314 
1315  virtual ~TiXmlDeclaration() {}
1316 
1318  const char *Version() const { return version.c_str (); }
1320  const char *Encoding() const { return encoding.c_str (); }
1322  const char *Standalone() const { return standalone.c_str (); }
1323 
1325  virtual TiXmlNode* Clone() const;
1326  // Print this declaration to a FILE stream.
1327  virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
1328  virtual void Print( FILE* cfile, int depth ) const {
1329  Print( cfile, depth, 0 );
1330  }
1331 
1332  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1333 
1334  virtual const TiXmlDeclaration* ToDeclaration() const { return this; }
1335  virtual TiXmlDeclaration* ToDeclaration() { return this; }
1336 
1339  virtual bool Accept( TiXmlVisitor* visitor ) const;
1340 
1341 protected:
1342  void CopyTo( TiXmlDeclaration* target ) const;
1343  // used to be public
1344  #ifdef TIXML_USE_STL
1345  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1346  #endif
1347 
1348 private:
1349 
1353 };
1354 
1365 {
1366 public:
1368  TiXmlStylesheetReference() : TiXmlNode( TiXmlNode::STYLESHEETREFERENCE ) {}
1369 
1370 #ifdef TIXML_USE_STL
1371  TiXmlStylesheetReference( const std::string& _type,
1373  const std::string& _href );
1374 #endif
1375 
1377  TiXmlStylesheetReference( const char* _type,
1378  const char* _href );
1379 
1381  void operator=( const TiXmlStylesheetReference& copy );
1382 
1384 
1386  const char *Type() const { return type.c_str (); }
1388  const char *Href() const { return href.c_str (); }
1389 
1391  virtual TiXmlNode* Clone() const;
1392  // Print this declaration to a FILE stream.
1393  virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
1394  virtual void Print( FILE* cfile, int depth ) const {
1395  Print( cfile, depth, 0 );
1396  }
1397 
1398  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1399 
1400  virtual const TiXmlStylesheetReference* ToStylesheetReference() const { return this; }
1402 
1405  virtual bool Accept( TiXmlVisitor* visitor ) const;
1406 
1407 protected:
1408  void CopyTo( TiXmlStylesheetReference* target ) const;
1409  // used to be public
1410  #ifdef TIXML_USE_STL
1411  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1412  #endif
1413 
1414 private:
1415 
1418 };
1419 
1427 class TiXmlUnknown : public TiXmlNode
1428 {
1429 public:
1430  TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {}
1431  virtual ~TiXmlUnknown() {}
1432 
1433  TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN ) { copy.CopyTo( this ); }
1434  void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); }
1435 
1437  virtual TiXmlNode* Clone() const;
1438  // Print this Unknown to a FILE stream.
1439  virtual void Print( FILE* cfile, int depth ) const;
1440 
1441  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1442 
1443  virtual const TiXmlUnknown* ToUnknown() const { return this; }
1444  virtual TiXmlUnknown* ToUnknown() { return this; }
1445 
1448  virtual bool Accept( TiXmlVisitor* content ) const;
1449 
1450 protected:
1451  void CopyTo( TiXmlUnknown* target ) const;
1452 
1453  #ifdef TIXML_USE_STL
1454  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1455  #endif
1456 
1457 private:
1458 
1459 };
1460 
1461 
1466 class TiXmlDocument : public TiXmlNode
1467 {
1468 public:
1470  TiXmlDocument();
1472  TiXmlDocument( const char * documentName );
1473 
1474  #ifdef TIXML_USE_STL
1475  TiXmlDocument( const std::string& documentName );
1477  #endif
1478 
1479  TiXmlDocument( const TiXmlDocument& copy );
1480  void operator=( const TiXmlDocument& copy );
1481 
1482  virtual ~TiXmlDocument() {}
1483 
1488  bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1490  bool SaveFile() const;
1492  bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1494  bool SaveFile( const char * filename ) const;
1500  bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1502  bool SaveFile( FILE* ) const;
1503 
1504  #ifdef TIXML_USE_STL
1505  bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING )
1506  {
1507 // StringToBuffer f( filename );
1508 // return ( f.buffer && LoadFile( f.buffer, encoding ));
1509  return LoadFile( filename.c_str(), encoding );
1510  }
1511  bool SaveFile( const std::string& filename ) const
1512  {
1513 // StringToBuffer f( filename );
1514 // return ( f.buffer && SaveFile( f.buffer ));
1515  return SaveFile( filename.c_str() );
1516  }
1517  #endif
1518 
1523  virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1524 
1529  const TiXmlElement* RootElement() const { return FirstChildElement(); }
1530  TiXmlElement* RootElement() { return FirstChildElement(); }
1531 
1537  bool Error() const { return error; }
1538 
1540  const char * ErrorDesc() const { return errorDesc.c_str (); }
1541 
1545  int ErrorId() const { return errorId; }
1546 
1554  int ErrorRow() const { return errorLocation.row+1; }
1555  int ErrorCol() const { return errorLocation.col+1; }
1556 
1581  void SetTabSize( int _tabsize ) { tabsize = _tabsize; }
1582 
1583  int TabSize() const { return tabsize; }
1584 
1588  void ClearError() { error = false;
1589  errorId = 0;
1590  errorDesc = "";
1591  errorLocation.row = errorLocation.col = 0;
1592  //errorLocation.last = 0;
1593  }
1594 
1596  void Print() const { Print( stdout, 0 ); }
1597 
1598  /* Write the document to a string using formatted printing ("pretty print"). This
1599  will allocate a character array (new char[]) and return it as a pointer. The
1600  calling code pust call delete[] on the return char* to avoid a memory leak.
1601  */
1602  //char* PrintToMemory() const;
1603 
1605  virtual void Print( FILE* cfile, int depth = 0 ) const;
1606  // [internal use]
1607  void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding );
1608 
1609  virtual const TiXmlDocument* ToDocument() const { return this; }
1610  virtual TiXmlDocument* ToDocument() { return this; }
1611 
1614  virtual bool Accept( TiXmlVisitor* content ) const;
1615 
1616 protected :
1617  // [internal use]
1618  virtual TiXmlNode* Clone() const;
1619  #ifdef TIXML_USE_STL
1620  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1621  #endif
1622 
1623 private:
1624  void CopyTo( TiXmlDocument* target ) const;
1625 
1626  bool error;
1627  int errorId;
1629  int tabsize;
1631  bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write.
1632 };
1633 
1634 
1716 {
1717 public:
1719  TiXmlHandle( TiXmlNode* _node ) { this->node = _node; }
1721  TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; }
1722  TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; }
1723 
1725  TiXmlHandle FirstChild() const;
1727  TiXmlHandle FirstChild( const char * value ) const;
1729  TiXmlHandle FirstChildElement() const;
1731  TiXmlHandle FirstChildElement( const char * value ) const;
1732 
1736  TiXmlHandle Child( const char* value, int index ) const;
1740  TiXmlHandle Child( int index ) const;
1745  TiXmlHandle ChildElement( const char* value, int index ) const;
1750  TiXmlHandle ChildElement( int index ) const;
1751 
1752  #ifdef TIXML_USE_STL
1753  TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); }
1754  TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); }
1755 
1756  TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); }
1757  TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); }
1758  #endif
1759 
1762  TiXmlNode* ToNode() const { return node; }
1765  TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
1768  TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
1771  TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
1772 
1776  TiXmlNode* Node() const { return ToNode(); }
1780  TiXmlElement* Element() const { return ToElement(); }
1784  TiXmlText* Text() const { return ToText(); }
1788  TiXmlUnknown* Unknown() const { return ToUnknown(); }
1789 
1790 private:
1792 };
1793 
1794 
1815 {
1816 public:
1817  TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ),
1818  buffer(), indent( " " ), lineBreak( "\n" ) {}
1819 
1820  virtual bool VisitEnter( const TiXmlDocument& doc );
1821  virtual bool VisitExit( const TiXmlDocument& doc );
1822 
1823  virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute );
1824  virtual bool VisitExit( const TiXmlElement& element );
1825 
1826  virtual bool Visit( const TiXmlDeclaration& declaration );
1827  virtual bool Visit( const TiXmlText& text );
1828  virtual bool Visit( const TiXmlComment& comment );
1829  virtual bool Visit( const TiXmlUnknown& unknown );
1830  virtual bool Visit( const TiXmlStylesheetReference& stylesheet );
1831 
1835  void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; }
1837  const char* Indent() { return indent.c_str(); }
1842  void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; }
1844  const char* LineBreak() { return lineBreak.c_str(); }
1845 
1849  void SetStreamPrinting() { indent = "";
1850  lineBreak = "";
1851  }
1853  const char* CStr() { return buffer.c_str(); }
1855  size_t Size() { return buffer.size(); }
1856 
1857  #ifdef TIXML_USE_STL
1858  const std::string& Str() { return buffer; }
1860  #endif
1861 
1862 private:
1863  void DoIndent() {
1864  for( int i=0; i<depth; ++i )
1865  buffer += indent;
1866  }
1867  void DoLineBreak() {
1868  buffer += lineBreak;
1869  }
1870 
1871  int depth;
1876 };
1877 
1878 
1879 #ifdef _MSC_VER
1880 #pragma warning( pop )
1881 #endif
1882 
1883 #endif
1884 
void ClearError()
If you have handled the error, it can be reset with this call.
Definition: tinyxml.h:1588
TiXmlAttribute * LastAttribute()
Definition: tinyxml.h:1095
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1444
virtual const TiXmlStylesheetReference * ToStylesheetReference() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1400
TIXML_STRING encoding
Definition: tinyxml.h:1351
TiXmlAttribute * Next()
Definition: tinyxml.h:868
Always the top level node.
Definition: tinyxml.h:1466
TiXmlBase()
Definition: tinyxml.h:216
const char * Href() const
Href. Will return an empty string if none was found.
Definition: tinyxml.h:1388
int errorId
Definition: tinyxml.h:1627
TiXmlNode * Parent()
One step up the DOM.
Definition: tinyxml.h:535
TiXmlCursor()
Definition: tinyxml.h:110
const char * str
Definition: tinyxml.h:417
void SetTabSize(int _tabsize)
SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) to report the correct v...
Definition: tinyxml.h:1581
Definition: tinyxml.h:485
Definition: tinyxml.h:282
int ErrorId() const
Generally, you probably want the error string ( ErrorDesc() ).
Definition: tinyxml.h:1545
void operator=(const TiXmlText &base)
Definition: tinyxml.h:1246
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
Add a new node related to this.
Definition: tinyxml.cpp:183
static const char * ReadName(const char *p, TIXML_STRING *name, TiXmlEncoding encoding)
Definition: tinyxmlparser.cpp:401
TiXmlComment(const char *_value)
Construct a comment from text.
Definition: tinyxml.h:1177
Definition: tinyxml.h:289
Definition: tinyxml.h:283
TiXmlHandle operator=(const TiXmlHandle &ref)
Definition: tinyxml.h:1722
const TIXML_STRING & NameTStr() const
Definition: tinyxml.h:838
static void version(void)
Definition: tolua.c:58
static const char * GetChar(const char *p, char *_value, int *length, TiXmlEncoding encoding)
Definition: tinyxml.h:342
void SetCDATA(bool _cdata)
Turns on or off a CDATA representation of text.
Definition: tinyxml.h:1254
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1195
TIXML_STRING value
Definition: tinyxml.h:903
NodeType
The types of XML nodes supported by TinyXml.
Definition: tinyxml.h:477
static const char * SkipWhiteSpace(const char *, TiXmlEncoding encoding)
Definition: tinyxmlparser.cpp:314
const char * Version() const
Version. Will return an empty string if none was found.
Definition: tinyxml.h:1318
void CopyTo(TiXmlElement *target) const
Definition: tinyxml.cpp:823
int Type() const
Query the type (as an enumerated value, above) of this node.
Definition: tinyxml.h:700
virtual ~TiXmlDeclaration()
Definition: tinyxml.h:1315
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
Definition: tinyxmlparser.cpp:1058
const TiXmlNode * LastChild() const
Definition: tinyxml.h:547
virtual TiXmlStylesheetReference * ToStylesheetReference()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1401
bool Error() const
If an error occurs, Error will be set to true.
Definition: tinyxml.h:1537
int Column() const
See Row()
Definition: tinyxml.h:260
const TiXmlAttribute * First() const
Definition: tinyxml.h:930
const char * Standalone() const
Is this a standalone document?
Definition: tinyxml.h:1322
TiXmlNode * firstChild
Definition: tinyxml.h:776
Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.
Definition: tinyxml.h:1427
TiXmlNode * Node() const
Definition: tinyxml.h:1776
Definition: tinyxml.h:482
::std::string string
Definition: gtest-port.h:756
static void SetCondenseWhiteSpace(bool condense)
The world does not agree on whether white space should be kept or not.
Definition: tinyxml.h:236
A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thi...
Definition: tinyxml.h:1715
static bool IsWhiteSpace(char c)
Definition: tinyxml.h:305
TiXmlUnknown()
Definition: tinyxml.h:1430
size_t Size()
Return the length of the result string.
Definition: tinyxml.h:1855
TiXmlNode * node
Definition: tinyxml.h:1791
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
Definition: tinyxml.cpp:317
TiXmlHandle(TiXmlNode *_node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml.h:1719
virtual bool Accept(TiXmlVisitor *visitor) const
Walk the XML tree visiting this node and all of its children.
Definition: tinyxml.cpp:845
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
Definition: tinyxmlparser.cpp:88
virtual bool VisitEnter(const TiXmlElement &, const TiXmlAttribute *)
Visit an element.
Definition: tinyxml.h:147
TiXmlStylesheetReference()
Construct an empty declaration.
Definition: tinyxml.h:1368
TIXML_STRING value
Definition: tinyxml.h:779
TiXmlElement * FirstChildElement(const char *_value)
Definition: tinyxml.h:687
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1258
TiXmlText * Text() const
Definition: tinyxml.h:1784
const int TIXML_PATCH_VERSION
Definition: tinyxml.h:103
TIXML_STRING type
Definition: tinyxml.h:1416
void SetIndent(const char *_indent)
Set the indent characters for printing.
Definition: tinyxml.h:1835
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1259
TIXML_STRING version
Definition: tinyxml.h:1350
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:724
Definition: tinyxml.h:108
static int IsAlphaNum(unsigned char anyByte, TiXmlEncoding encoding)
Definition: tinyxmlparser.cpp:150
const char * Value() const
The meaning of &#39;value&#39; changes for the specific type of TiXmlNode.
Definition: tinyxml.h:503
const void * GetUserData() const
Get a pointer to arbitrary user data.
Definition: tinyxml.h:264
virtual ~TiXmlBase()
Definition: tinyxml.h:217
bool error
Definition: tinyxml.h:1626
TiXmlElement * Element() const
Definition: tinyxml.h:1780
TiXmlDocument * GetDocument()
Definition: tinyxml.h:706
std::ostream & operator<<(std::ostream &os, const Message &sb)
Definition: gtest-message.h:224
void Clear()
Definition: tinyxml.h:111
TiXmlElement * ToElement() const
Return the handle as a TiXmlElement.
Definition: tinyxml.h:1765
TiXmlPrinter()
Definition: tinyxml.h:1817
static bool IsWhiteSpace(int c)
Definition: tinyxml.h:309
TIXML_STRING errorDesc
Definition: tinyxml.h:1628
const char * Name() const
Return the name of this attribute.
Definition: tinyxml.h:829
Definition: tinyxml.h:175
virtual void Print(FILE *cfile, int depth) const
All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL ...
Definition: tinyxml.h:1328
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:721
static void error(char *o)
Definition: tolua.c:79
virtual TiXmlNode * Clone() const
Creates a new Element and returns it - the returned element is a copy.
Definition: tinyxml.cpp:859
void CopyTo(TiXmlText *target) const
Definition: tinyxml.cpp:1355
The parent class for everything in the Document Object Model.
Definition: tinyxml.h:438
TiXmlAttribute * First()
Definition: tinyxml.h:931
const TiXmlAttribute * LastAttribute() const
Access the last attribute in this element.
Definition: tinyxml.h:1094
const TiXmlNode * Parent() const
Definition: tinyxml.h:536
Definition: tinyxml.h:168
static const char * GetEntity(const char *in, char *value, int *length, TiXmlEncoding encoding)
Definition: tinyxmlparser.cpp:438
TIXML_STRING lineBreak
Definition: tinyxml.h:1875
bool operator>(const TiXmlAttribute &rhs) const
Definition: tinyxml.h:880
TiXmlComment()
Constructs an empty comment.
Definition: tinyxml.h:1175
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1609
TIXML_STRING standalone
Definition: tinyxml.h:1352
int QueryFloatAttribute(const char *name, float *_value) const
QueryFloatAttribute examines the attribute - see QueryIntAttribute().
Definition: tinyxml.h:1010
void SetStreamPrinting()
Switch over to "stream printing" which is the most dense formatting without linebreaks.
Definition: tinyxml.h:1849
TiXmlAttribute * Find(const char *_name)
Definition: tinyxml.h:936
virtual const TiXmlStylesheetReference * ToStylesheetReference() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:719
Definition: tinyxml.h:486
int ErrorCol() const
The column where the error occured. See ErrorRow()
Definition: tinyxml.h:1555
int ErrorRow() const
Returns the location (if known) of the error.
Definition: tinyxml.h:1554
TiXmlNode * lastChild
Definition: tinyxml.h:777
TiXmlUnknown * ToUnknown() const
Return the handle as a TiXmlUnknown.
Definition: tinyxml.h:1771
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
Definition: tinyxml.h:630
bool useMicrosoftBOM
Definition: tinyxml.h:1631
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
Replace a child of this node.
Definition: tinyxml.cpp:289
Definition: tinyxml.h:176
Definition: tinyxml.h:294
TiXmlText(const char *initValue)
Constructor for text element.
Definition: tinyxml.h:1229
virtual bool VisitExit(const TiXmlElement &)
Visit an element.
Definition: tinyxml.h:149
virtual bool Visit(const TiXmlComment &)
Visit a comment node.
Definition: tinyxml.h:158
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1165
TiXmlNode * prev
Definition: tinyxml.h:781
void SetName(const char *_name)
Set the name of this attribute.
Definition: tinyxml.h:853
const TiXmlEncoding TIXML_DEFAULT_ENCODING
Definition: tinyxml.h:180
TiXmlAttribute()
Construct an empty attribute.
Definition: tinyxml.h:803
virtual ~TiXmlText()
Definition: tinyxml.h:1234
TiXmlAttribute * next
Definition: tinyxml.h:905
Definition: tinyxml.h:281
TiXmlText(const TiXmlText &copy)
Definition: tinyxml.h:1245
TiXmlDocument * document
Definition: tinyxml.h:901
int col
Definition: tinyxml.h:114
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Parse the given null terminated block of xml data.
Definition: tinyxmlparser.cpp:704
An attribute is a name-value pair.
Definition: tinyxml.h:797
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1335
TiXmlNode(NodeType _type)
Definition: tinyxml.cpp:134
TIXML_STRING name
Definition: tinyxml.h:902
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:726
const int TIXML_MAJOR_VERSION
Definition: tinyxml.h:101
bool operator==(const TiXmlAttribute &rhs) const
Definition: tinyxml.h:878
virtual bool Visit(const TiXmlText &)
Visit a text node.
Definition: tinyxml.h:156
bool operator<(const TiXmlAttribute &rhs) const
Definition: tinyxml.h:879
const TiXmlAttribute * FirstAttribute() const
Access the first attribute in this element.
Definition: tinyxml.h:1092
virtual void Print(FILE *cfile, int depth) const
All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL ...
Definition: tinyxml.h:1394
void DoIndent()
Definition: tinyxml.h:1863
void DoLineBreak()
Definition: tinyxml.h:1867
TiXmlBase is a base class for every class in TinyXml.
Definition: tinyxml.h:208
TiXmlElement * NextSiblingElement(const char *_next)
Definition: tinyxml.h:670
An XML comment.
Definition: tinyxml.h:1171
TiXmlNode * next
Definition: tinyxml.h:782
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
Definition: tinyxml.h:142
Definition: tinyxmlparser.cpp:171
In correct XML the declaration is the first entry in the file.
Definition: tinyxml.h:1294
const TiXmlElement * NextSiblingElement() const
Convenience function to get through elements.
Definition: tinyxml.cpp:460
static const int utf8ByteTable[256]
Definition: tinyxml.h:268
TiXmlNode * FirstChild()
Definition: tinyxml.h:539
Definition: tinyxml.h:415
void operator=(const TiXmlAttributeSet &)
virtual bool Visit(const TiXmlUnknown &)
Visit an unknow node.
Definition: tinyxml.h:160
void operator=(const TiXmlElement &base)
Definition: tinyxml.cpp:529
TiXmlDeclaration()
Construct an empty declaration.
Definition: tinyxml.h:1298
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml.h:711
TiXmlEncoding
Definition: tinyxml.h:173
static const char * ReadText(const char *in, TIXML_STRING *text, bool ignoreWhiteSpace, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
Definition: tinyxmlparser.cpp:574
TiXmlElement * NextSiblingElement()
Definition: tinyxml.h:661
static void EncodeString(const TIXML_STRING &str, TIXML_STRING *out)
Expands entities in a string.
Definition: tinyxml.cpp:50
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1141
NodeType type
Definition: tinyxml.h:774
char chr
Definition: tinyxml.h:419
TiXmlAttribute sentinel
Definition: tinyxml.h:953
void * userData
Field containing a generic user pointer.
Definition: tinyxml.h:391
Definition: tinyxml.h:480
unsigned int strLength
Definition: tinyxml.h:418
void SetValue(const char *_value)
Set the value.
Definition: tinyxml.h:854
bool cdata
Definition: tinyxml.h:1277
bool IsAlpha(char ch)
Definition: gtest-port.h:1511
virtual void Print(FILE *cfile, int depth) const
All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL ...
Definition: tinyxml.h:888
A stylesheet reference looks like this:
Definition: tinyxml.h:1364
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
Add a new node related to this.
Definition: tinyxml.cpp:257
Definition: InputPrereqs.h:78
If you call the Accept() method, it requires being passed a TiXmlVisitor class to handle callbacks...
Definition: tinyxml.h:136
Definition: tinyxml.h:166
void operator=(const TiXmlDocument &copy)
Definition: tinyxml.cpp:916
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:717
static int ToLower(int v, TiXmlEncoding encoding)
Definition: tinyxml.h:397
void * GetUserData()
Get a pointer to arbitrary user data.
Definition: tinyxml.h:263
int depth
Definition: tinyxml.h:1871
const TIXML_STRING & ValueTStr() const
Definition: tinyxml.h:513
Definition: tinyxml.h:167
TIXML_STRING indent
Definition: tinyxml.h:1874
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1610
const char * CStr()
Return the result.
Definition: tinyxml.h:1853
int tabsize
Definition: tinyxml.h:1629
TiXmlNode * NextSibling(const char *_next)
Definition: tinyxml.h:652
TiXmlElement * RootElement()
Definition: tinyxml.h:1530
Definition: tinyxml.h:479
const char * Type() const
Type. Will return an empty string if none was found.
Definition: tinyxml.h:1386
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
Definition: tinyxml.h:647
virtual bool Visit(const TiXmlDeclaration &)
Visit a declaration.
Definition: tinyxml.h:152
int row
Definition: tinyxml.h:113
void CopyTo(TiXmlUnknown *target) const
Definition: tinyxml.cpp:1552
bool simpleTextPrint
Definition: tinyxml.h:1872
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:714
const char * Indent()
Query the indention string.
Definition: tinyxml.h:1837
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1334
void SetValue(const char *_value)
Changes the value of the node.
Definition: tinyxml.h:524
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
An alternate way to walk the children of a node.
Definition: tinyxml.cpp:363
XML text.
Definition: tinyxml.h:1221
const char * Encoding() const
Encoding. Will return an empty string if none was found.
Definition: tinyxml.h:1320
TiXmlAttribute * prev
Definition: tinyxml.h:904
void Print() const
Write the document to standard out using formatted printing ("pretty print").
Definition: tinyxml.h:1596
static bool IsWhiteSpaceCondensed()
Return the current white space setting.
Definition: tinyxml.h:239
virtual TiXmlStylesheetReference * ToStylesheetReference()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:727
TiXmlAttribute * Last()
Definition: tinyxml.h:933
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1443
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
Definition: tinyxmlparser.cpp:534
Definition: tinyxml.h:484
TiXmlAttribute * FirstAttribute()
Definition: tinyxml.h:1093
int TabSize() const
Definition: tinyxml.h:1583
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
Add a new node related to this.
Definition: tinyxml.cpp:225
virtual TiXmlComment * ToComment()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:723
virtual ~TiXmlStylesheetReference()
Definition: tinyxml.h:1383
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:713
Definition: tinyxml.h:296
virtual ~TiXmlVisitor()
Definition: tinyxml.h:139
Definition: tinyxml.h:483
virtual TiXmlComment * ToComment()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1196
void SetDocument(TiXmlDocument *doc)
Definition: tinyxml.h:895
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:718
Definition: tinyxml.h:921
Definition: tinyxml.h:295
TiXmlNode * parent
Definition: tinyxml.h:773
The element is a container class.
Definition: tinyxml.h:961
TiXmlElement * FirstChildElement()
Definition: tinyxml.h:681
int Row() const
Return the position, in the original source file, of this node or attribute.
Definition: tinyxml.h:259
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
Definition: tinyxml.h:1540
TiXmlNode * PreviousSibling(const char *_prev)
Definition: tinyxml.h:635
TiXmlNode * Identify(const char *start, TiXmlEncoding encoding)
Definition: tinyxmlparser.cpp:818
void SetLineBreak(const char *_lineBreak)
Set the line breaking string.
Definition: tinyxml.h:1842
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:551
static const char * errorString[TIXML_ERROR_STRING_COUNT]
Definition: tinyxml.h:386
virtual ~TiXmlComment()
Definition: tinyxml.h:1183
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:715
TiXmlUnknown(const TiXmlUnknown &copy)
Definition: tinyxml.h:1433
virtual bool VisitExit(const TiXmlDocument &)
Visit a document.
Definition: tinyxml.h:144
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:725
TiXmlNode * PreviousSibling()
Definition: tinyxml.h:631
static bool condenseWhiteSpace
Definition: tinyxml.h:428
const char * Value() const
Return the value of this attribute.
Definition: tinyxml.h:830
Definition: tinyxml.h:481
virtual ~TiXmlDocument()
Definition: tinyxml.h:1482
TiXmlCursor errorLocation
Definition: tinyxml.h:1630
const char * LineBreak()
Query the current line breaking string.
Definition: tinyxml.h:1844
TIXML_STRING href
Definition: tinyxml.h:1417
TiXmlNode * LastChild()
The last child of this node. Will be null if there are no children.
Definition: tinyxml.h:548
const TiXmlDocument * GetDocument() const
Return a pointer to the Document this node lives in.
Definition: tinyxml.cpp:490
Print to memory functionality.
Definition: tinyxml.h:1814
TiXmlCursor location
Definition: tinyxml.h:388
TiXmlNode * IterateChildren(const TiXmlNode *previous)
Definition: tinyxml.h:579
Definition: tinyxml.h:299
Definition: tinyxml.h:284
TIXML_STRING buffer
Definition: tinyxml.h:1873
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:716
void operator=(const TiXmlUnknown &copy)
Definition: tinyxml.h:1434
const TiXmlAttribute * Last() const
Definition: tinyxml.h:932
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
Definition: tinyxml.h:538
TiXmlNode * IterateChildren(const char *_value, const TiXmlNode *previous)
Definition: tinyxml.h:585
TiXmlUnknown * Unknown() const
Definition: tinyxml.h:1788
void SetUserData(void *user)
Set a pointer to arbitrary user data.
Definition: tinyxml.h:262
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:722
TiXmlHandle(const TiXmlHandle &ref)
Copy constructor.
Definition: tinyxml.h:1721
virtual void Print(FILE *cfile, int depth) const
All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL ...
Definition: tinyxml.cpp:770
virtual ~TiXmlUnknown()
Definition: tinyxml.h:1431
bool CDATA() const
Queries whether this represents text using a CDATA section.
Definition: tinyxml.h:1252
virtual bool Visit(const TiXmlStylesheetReference &)
Visit a stylesheet reference.
Definition: tinyxml.h:154
virtual ~TiXmlNode()
Definition: tinyxml.cpp:145
const TiXmlElement * RootElement() const
Get the root element – the only top level element – of the document.
Definition: tinyxml.h:1529
TiXmlNode * ToNode() const
Return the handle as a TiXmlNode.
Definition: tinyxml.h:1762
TiXmlNode * NextSibling()
Definition: tinyxml.h:648
#define TIXML_STRING
Definition: tinyxml.h:59
const int TIXML_MINOR_VERSION
Definition: tinyxml.h:102
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1142
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
Definition: tinyxml.cpp:430
TiXmlText * ToText() const
Return the handle as a TiXmlText.
Definition: tinyxml.h:1768
ORX_FORCEINLINE bool operator>>(std::istream &instream, ToType &output)
Fallback operator >>() (delegates to orxonox::ConverterFallback)
Definition: Convert.h:249
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
Add a new node related to this.
Definition: tinyxml.cpp:210
Definition: tinyxml.h:177
TiXmlAttribute * Previous()
Definition: tinyxml.h:874
TiXmlAttribute(const char *_name, const char *_value)
Construct an attribute with a name and value.
Definition: tinyxml.h:821