MADARA  3.0.6
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 ********* MODIFICATIONS **********
25 Author: James Edmondson
26 Changes:
27 
28 * classes are available through dllexports on Windows
29 * we use STL instead of the provided string class
30 */
31 
32 
33 #ifndef TINYXML_INCLUDED
34 #define TINYXML_INCLUDED
35 
36 #ifndef _MADARA_NO_XML_
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 #include "madara/MADARA_export.h"
50 
51 // Help out windows:
52 #if defined( _DEBUG ) && !defined( DEBUG )
53 #define DEBUG
54 #endif
55 
56 // always use STL because MADARA uses STL
57 #ifndef TIXML_USE_STL
58  #define TIXML_USE_STL
59 #endif
60 
61 #ifdef TIXML_USE_STL
62  #include <string>
63  #include <iostream>
64  #include <sstream>
65  #define TIXML_STRING std::string
66 #endif
67 
68 // Deprecated library function hell. Compilers want to use the
69 // new safe versions. This probably doesn't fully address the problem,
70 // but it gets closer. There are too many compilers for me to fully
71 // test. If you get compilation troubles, undefine TIXML_SAFE
72 #define TIXML_SAFE
73 
74 #ifdef TIXML_SAFE
75  #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
76  // Microsoft visual studio, version 2005 and higher.
77  #define TIXML_SNPRINTF _snprintf_s
78  #define TIXML_SSCANF sscanf_s
79  #elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
80  // Microsoft visual studio, version 6 and higher.
81  //#pragma message( "Using _sn* functions." )
82  #define TIXML_SNPRINTF _snprintf
83  #define TIXML_SSCANF sscanf
84  #elif defined(__GNUC__) && (__GNUC__ >= 3 )
85  // GCC version 3 and higher.s
86  //#warning( "Using sn* functions." )
87  #define TIXML_SNPRINTF snprintf
88  #define TIXML_SSCANF sscanf
89  #else
90  #define TIXML_SNPRINTF snprintf
91  #define TIXML_SSCANF sscanf
92  #endif
93 #endif
94 
95 class TiXmlDocument;
96 class TiXmlElement;
97 class TiXmlComment;
98 class TiXmlUnknown;
99 class TiXmlAttribute;
100 class TiXmlText;
101 class TiXmlDeclaration;
102 class TiXmlParsingData;
103 class TiXmlVisitor;
104 
105 const int TIXML_MAJOR_VERSION = 2;
106 const int TIXML_MINOR_VERSION = 6;
107 const int TIXML_PATCH_VERSION = 1;
108 
113 {
118 
122  void Clear() { row = col = -1; }
123 
124  int row;
125  int col;
126 };
127 
128 
148 class MADARA_Export TiXmlVisitor
149 {
150 public:
151  virtual ~TiXmlVisitor() {}
152 
154  virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; }
156  virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; }
157 
159  virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; }
161  virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; }
162 
164  virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; }
166  virtual bool Visit( const TiXmlText& /*text*/ ) { return true; }
168  virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; }
170  virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; }
171 };
172 
174 enum
175 {
179 };
180 
181 
184 {
188 };
189 
191 
214 class MADARA_Export TiXmlBase
215 {
216  friend class TiXmlNode;
217  friend class TiXmlElement;
218  friend class TiXmlDocument;
219 
220 public:
221  TiXmlBase() : userData(0) {}
222  virtual ~TiXmlBase() {}
223 
233  virtual void Print( FILE* cfile, int depth ) const = 0;
234 
241  static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; }
242 
244  static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; }
245 
264  int Row() const { return location.row + 1; }
265  int Column() const { return location.col + 1; }
266 
267  void SetUserData( void * user ) { userData = user; }
268  void * GetUserData() { return userData; }
269  const void * GetUserData() const { return userData; }
270 
271  // Table that returs, for a given lead byte, the total number of bytes
272  // in the UTF-8 sequence.
273  static const int utf8ByteTable[256];
274 
275  virtual const char* Parse( const char* p,
276  TiXmlParsingData* data,
277  TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
278 
282  static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out );
283 
284  enum
285  {
302 
304  };
305 
306 protected:
307 
308  static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
309 
310  inline static bool IsWhiteSpace( char c )
311  {
312  return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
313  }
314  inline static bool IsWhiteSpace( int c )
315  {
316  if ( c < 256 )
317  return IsWhiteSpace( (char) c );
318  return false; // Again, only truly correct for English/Latin...but usually works.
319  }
320 
321  #ifdef TIXML_USE_STL
322  static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag );
323  static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag );
324  #endif
325 
326  /* Reads an XML name into the string provided. Returns
327  a pointer just past the last character of the name,
328  or 0 if the function has an error.
329  */
330  static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding );
331 
332  /* Reads text. Returns a pointer past the given end tag.
333  Wickedly complex options, but it keeps the (sensitive) code in one place.
334  */
335  static const char* ReadText( const char* in, // where to start
336  TIXML_STRING* text, // the string read
337  bool ignoreWhiteSpace, // whether to keep the white space
338  const char* endTag, // what ends this text
339  bool ignoreCase, // whether to ignore case in the end tag
340  TiXmlEncoding encoding ); // the current encoding
341 
342  // If an entity has been found, transform it into a character.
343  static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding );
344 
345  // Get a character, while interpreting entities.
346  // The length can be from 0 to 4 bytes.
347  inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding )
348  {
349  assert( p );
350  if ( encoding == TIXML_ENCODING_UTF8 )
351  {
352  *length = utf8ByteTable[ *((const unsigned char*)p) ];
353  assert( *length >= 0 && *length < 5 );
354  }
355  else
356  {
357  *length = 1;
358  }
359 
360  if ( *length == 1 )
361  {
362  if ( *p == '&' )
363  return GetEntity( p, _value, length, encoding );
364  *_value = *p;
365  return p+1;
366  }
367  else if ( *length )
368  {
369  //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe),
370  // and the null terminator isn't needed
371  for( int i=0; p[i] && i<*length; ++i ) {
372  _value[i] = p[i];
373  }
374  return p + (*length);
375  }
376  else
377  {
378  // Not valid text.
379  return 0;
380  }
381  }
382 
383  // Return true if the next characters in the stream are any of the endTag sequences.
384  // Ignore case only works for english, and should only be relied on when comparing
385  // to English words: StringEqual( p, "version", true ) is fine.
386  static bool StringEqual( const char* p,
387  const char* endTag,
388  bool ignoreCase,
389  TiXmlEncoding encoding );
390 
391  static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
392 
394 
396  void * userData;
397 
398  // None of these methods are reliable for any language except English.
399  // Good for approximation, not great for accuracy.
400  static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding );
401  static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding );
402  inline static int ToLower( int v, TiXmlEncoding encoding )
403  {
404  if ( encoding == TIXML_ENCODING_UTF8 )
405  {
406  if ( v < 128 ) return tolower( v );
407  return v;
408  }
409  else
410  {
411  return tolower( v );
412  }
413  }
414  static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
415 
416 private:
417  TiXmlBase( const TiXmlBase& ); // not implemented.
418  void operator=( const TiXmlBase& base ); // not allowed.
419 
423  struct Entity
424  {
425  const char* str;
426  unsigned int strLength;
427  char chr;
428  };
429  enum
430  {
431  NUM_ENTITY = 5,
432  MAX_ENTITY_LENGTH = 6
433 
434  };
435  static Entity entity[ NUM_ENTITY ];
436  static bool condenseWhiteSpace;
437 };
438 
439 
446 class MADARA_Export TiXmlNode : public TiXmlBase
447 {
448  friend class TiXmlDocument;
449  friend class TiXmlElement;
450 
451 public:
452  #ifdef TIXML_USE_STL
453 
457  friend std::istream& operator >> (std::istream& in, TiXmlNode& base);
458 
475  friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
476 
478  friend std::string& operator<< (std::string& out, const TiXmlNode& base );
479 
480  #endif
481 
485  enum NodeType
486  {
494  };
495 
496  virtual ~TiXmlNode();
497 
510  const char *Value() const { return value.c_str (); }
511 
512  #ifdef TIXML_USE_STL
513 
517  const std::string& ValueStr() const { return value; }
518  #endif
519 
520  const TIXML_STRING& ValueTStr() const { return value; }
521 
531  void SetValue(const char * _value) { value = _value;}
532 
533  #ifdef TIXML_USE_STL
534  void SetValue( const std::string& _value ) { value = _value; }
536  #endif
537 
539  void Clear();
540 
542  TiXmlNode* Parent() { return parent; }
543  const TiXmlNode* Parent() const { return parent; }
544 
545  const TiXmlNode* FirstChild() const { return firstChild; }
547  const TiXmlNode* FirstChild( const char * value ) const;
548  TiXmlNode* FirstChild( const char * _value ) {
550  // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe)
551  // call the method, cast the return back to non-const.
552  return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value ));
553  }
554  const TiXmlNode* LastChild() const { return lastChild; }
556 
557  const TiXmlNode* LastChild( const char * value ) const;
558  TiXmlNode* LastChild( const char * _value ) {
559  return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value ));
560  }
561 
562  #ifdef TIXML_USE_STL
563  const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); }
564  TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); }
565  const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); }
566  TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); }
567  #endif
568 
585  const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const;
586  TiXmlNode* IterateChildren( const TiXmlNode* previous ) {
587  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) );
588  }
589 
591  const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const;
592  TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) {
593  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) );
594  }
595 
596  #ifdef TIXML_USE_STL
597  const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); }
598  TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); }
599  #endif
600 
604  TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
605 
606 
616  TiXmlNode* LinkEndChild( TiXmlNode* addThis );
617 
621  TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
622 
626  TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis );
627 
631  TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
632 
634  bool RemoveChild( TiXmlNode* removeThis );
635 
637  const TiXmlNode* PreviousSibling() const { return prev; }
639 
641  const TiXmlNode* PreviousSibling( const char * ) const;
642  TiXmlNode* PreviousSibling( const char *_prev ) {
643  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) );
644  }
645 
646  #ifdef TIXML_USE_STL
647  const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); }
648  TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); }
649  const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); }
650  TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); }
651  #endif
652 
654  const TiXmlNode* NextSibling() const { return next; }
655  TiXmlNode* NextSibling() { return next; }
656 
658  const TiXmlNode* NextSibling( const char * ) const;
659  TiXmlNode* NextSibling( const char* _next ) {
660  return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) );
661  }
662 
667  const TiXmlElement* NextSiblingElement() const;
669  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() );
670  }
671 
676  const TiXmlElement* NextSiblingElement( const char * ) const;
677  TiXmlElement* NextSiblingElement( const char *_next ) {
678  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) );
679  }
680 
681  #ifdef TIXML_USE_STL
682  const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); }
683  TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); }
684  #endif
685 
687  const TiXmlElement* FirstChildElement() const;
689  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() );
690  }
691 
693  const TiXmlElement* FirstChildElement( const char * _value ) const;
694  TiXmlElement* FirstChildElement( const char * _value ) {
695  return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) );
696  }
697 
698  #ifdef TIXML_USE_STL
699  const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); }
700  TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); }
701  #endif
702 
707  int Type() const { return type; }
708 
712  const TiXmlDocument* GetDocument() const;
714  return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() );
715  }
716 
718  bool NoChildren() const { return !firstChild; }
719 
720  virtual const TiXmlDocument* ToDocument() const { return 0; }
721  virtual const TiXmlElement* ToElement() const { return 0; }
722  virtual const TiXmlComment* ToComment() const { return 0; }
723  virtual const TiXmlUnknown* ToUnknown() const { return 0; }
724  virtual const TiXmlText* ToText() const { return 0; }
725  virtual const TiXmlDeclaration* ToDeclaration() const { return 0; }
726 
727  virtual TiXmlDocument* ToDocument() { return 0; }
728  virtual TiXmlElement* ToElement() { return 0; }
729  virtual TiXmlComment* ToComment() { return 0; }
730  virtual TiXmlUnknown* ToUnknown() { return 0; }
731  virtual TiXmlText* ToText() { return 0; }
732  virtual TiXmlDeclaration* ToDeclaration() { return 0; }
733 
737  virtual TiXmlNode* Clone() const = 0;
738 
761  virtual bool Accept( TiXmlVisitor* visitor ) const = 0;
762 
763 protected:
764  TiXmlNode( NodeType _type );
765 
766  // Copy to the allocated object. Shared functionality between Clone, Copy constructor,
767  // and the assignment operator.
768  void CopyTo( TiXmlNode* target ) const;
769 
770  #ifdef TIXML_USE_STL
771  // The real work of the input operator.
772  virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0;
773  #endif
774 
775  // Figure out what is at *p, and parse it. Returns null if it is not an xml node.
776  TiXmlNode* Identify( const char* start, TiXmlEncoding encoding );
777 
780 
783 
785 
788 
789 private:
790  TiXmlNode( const TiXmlNode& ); // not implemented.
791  void operator=( const TiXmlNode& base ); // not allowed.
792 };
793 
794 
802 class MADARA_Export TiXmlAttribute : public TiXmlBase
803 {
804  friend class TiXmlAttributeSet;
805 
806 public:
809  {
810  document = 0;
811  prev = next = 0;
812  }
813 
814  #ifdef TIXML_USE_STL
815  TiXmlAttribute( const std::string& _name, const std::string& _value )
817  {
818  name = _name;
819  value = _value;
820  document = 0;
821  prev = next = 0;
822  }
823  #endif
824 
826  TiXmlAttribute( const char * _name, const char * _value )
827  {
828  name = _name;
829  value = _value;
830  document = 0;
831  prev = next = 0;
832  }
833 
834  const char* Name() const { return name.c_str(); }
835  const char* Value() const { return value.c_str(); }
836  #ifdef TIXML_USE_STL
837  const std::string& ValueStr() const { return value; }
838  #endif
839  int IntValue() const;
840  double DoubleValue() const;
841 
842  // Get the tinyxml string representation
843  const TIXML_STRING& NameTStr() const { return name; }
844 
854  int QueryIntValue( int* _value ) const;
856  int QueryDoubleValue( double* _value ) const;
857 
858  void SetName( const char* _name ) { name = _name; }
859  void SetValue( const char* _value ) { value = _value; }
860 
861  void SetIntValue( int _value );
862  void SetDoubleValue( double _value );
863 
864  #ifdef TIXML_USE_STL
865  void SetName( const std::string& _name ) { name = _name; }
868  void SetValue( const std::string& _value ) { value = _value; }
869  #endif
870 
872  const TiXmlAttribute* Next() const;
874  return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() );
875  }
876 
878  const TiXmlAttribute* Previous() const;
880  return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() );
881  }
882 
883  bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
884  bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; }
885  bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; }
886 
887  /* Attribute parsing starts: first letter of the name
888  returns: the next char after the value end quote
889  */
890  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
891 
892  // Prints this Attribute to a FILE stream.
893  virtual void Print( FILE* cfile, int depth ) const {
894  Print( cfile, depth, 0 );
895  }
896  void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
897 
898  // [internal use]
899  // Set the document pointer so the attribute can report errors.
900  void SetDocument( TiXmlDocument* doc ) { document = doc; }
901 
902 private:
903  TiXmlAttribute( const TiXmlAttribute& ); // not implemented.
904  void operator=( const TiXmlAttribute& base ); // not allowed.
905 
906  TiXmlDocument* document; // A pointer back to a document, for error reporting.
911 };
912 
913 
927 class MADARA_Export TiXmlAttributeSet
928 {
929 public:
932 
933  void Add( TiXmlAttribute* attribute );
934  void Remove( TiXmlAttribute* attribute );
935 
936  const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
937  TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
938  const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
939  TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
940 
941  TiXmlAttribute* Find( const char* _name ) const;
942  TiXmlAttribute* FindOrCreate( const char* _name );
943 
944 # ifdef TIXML_USE_STL
945  TiXmlAttribute* Find( const std::string& _name ) const;
946  TiXmlAttribute* FindOrCreate( const std::string& _name );
947 # endif
948 
949 
950 private:
951  //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
952  //*ME: this class must be also use a hidden/disabled copy-constructor !!!
953  TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed
954  void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute)
955 
957 };
958 
959 
964 class MADARA_Export TiXmlElement : public TiXmlNode
965 {
966 public:
968  TiXmlElement (const char * in_value);
969 
970  #ifdef TIXML_USE_STL
971  TiXmlElement( const std::string& _value );
973  #endif
974 
975  TiXmlElement( const TiXmlElement& );
976 
977  void operator=( const TiXmlElement& base );
978 
979  virtual ~TiXmlElement();
980 
984  const char* Attribute( const char* name ) const;
985 
992  const char* Attribute( const char* name, int* i ) const;
993 
1000  const char* Attribute( const char* name, double* d ) const;
1001 
1009  int QueryIntAttribute( const char* name, int* _value ) const;
1011  int QueryDoubleAttribute( const char* name, double* _value ) const;
1013  int QueryFloatAttribute( const char* name, float* _value ) const {
1014  double d;
1015  int result = QueryDoubleAttribute( name, &d );
1016  if ( result == TIXML_SUCCESS ) {
1017  *_value = (float)d;
1018  }
1019  return result;
1020  }
1021 
1022  #ifdef TIXML_USE_STL
1023  int QueryStringAttribute( const char* name, std::string* _value ) const {
1025  const char* cstr = Attribute( name );
1026  if ( cstr ) {
1027  *_value = std::string( cstr );
1028  return TIXML_SUCCESS;
1029  }
1030  return TIXML_NO_ATTRIBUTE;
1031  }
1032 
1041  template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const
1042  {
1043  const TiXmlAttribute* node = attributeSet.Find( name );
1044  if ( !node )
1045  return TIXML_NO_ATTRIBUTE;
1046 
1047  std::stringstream sstream( node->ValueStr() );
1048  sstream >> *outValue;
1049  if ( !sstream.fail() )
1050  return TIXML_SUCCESS;
1051  return TIXML_WRONG_TYPE;
1052  }
1053 
1054  int QueryValueAttribute( const std::string& name, std::string* outValue ) const
1055  {
1056  const TiXmlAttribute* node = attributeSet.Find( name );
1057  if ( !node )
1058  return TIXML_NO_ATTRIBUTE;
1059  *outValue = node->ValueStr();
1060  return TIXML_SUCCESS;
1061  }
1062  #endif
1063 
1067  void SetAttribute( const char* name, const char * _value );
1068 
1069  #ifdef TIXML_USE_STL
1070  const std::string* Attribute( const std::string& name ) const;
1071  const std::string* Attribute( const std::string& name, int* i ) const;
1072  const std::string* Attribute( const std::string& name, double* d ) const;
1073  int QueryIntAttribute( const std::string& name, int* _value ) const;
1074  int QueryDoubleAttribute( const std::string& name, double* _value ) const;
1075 
1077  void SetAttribute( const std::string& name, const std::string& _value );
1079  void SetAttribute( const std::string& name, int _value );
1081  void SetDoubleAttribute( const std::string& name, double value );
1082  #endif
1083 
1087  void SetAttribute( const char * name, int value );
1088 
1092  void SetDoubleAttribute( const char * name, double value );
1093 
1096  void RemoveAttribute( const char * name );
1097  #ifdef TIXML_USE_STL
1098  void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); }
1099  #endif
1100 
1101  const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); }
1102  TiXmlAttribute* FirstAttribute() { return attributeSet.First(); }
1103  const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); }
1104  TiXmlAttribute* LastAttribute() { return attributeSet.Last(); }
1105 
1138  const char* GetText() const;
1139 
1141  virtual TiXmlNode* Clone() const;
1142  // Print the Element to a FILE stream.
1143  virtual void Print( FILE* cfile, int depth ) const;
1144 
1145  /* Attribtue parsing starts: next char past '<'
1146  returns: next char past '>'
1147  */
1148  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1149 
1150  virtual const TiXmlElement* ToElement() const { return this; }
1151  virtual TiXmlElement* ToElement() { return this; }
1152 
1155  virtual bool Accept( TiXmlVisitor* visitor ) const;
1156 
1157 protected:
1158 
1159  void CopyTo( TiXmlElement* target ) const;
1160  void ClearThis(); // like clear, but initializes 'this' object as well
1161 
1162  // Used to be public [internal use]
1163  #ifdef TIXML_USE_STL
1164  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1165  #endif
1166  /* [internal use]
1167  Reads the "value" of the element -- another element, or text.
1168  This should terminate with the current end tag.
1169  */
1170  const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
1171 
1172 private:
1174 };
1175 
1176 
1180 class MADARA_Export TiXmlComment : public TiXmlNode
1181 {
1182 public:
1184  TiXmlComment() : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {}
1186  TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {
1187  SetValue( _value );
1188  }
1189  TiXmlComment( const TiXmlComment& );
1190  void operator=( const TiXmlComment& base );
1191 
1192  virtual ~TiXmlComment() {}
1193 
1195  virtual TiXmlNode* Clone() const;
1196  // Write this Comment to a FILE stream.
1197  virtual void Print( FILE* cfile, int depth ) const;
1198 
1199  /* Attribtue parsing starts: at the ! of the !--
1200  returns: next char past '>'
1201  */
1202  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1203 
1204  virtual const TiXmlComment* ToComment() const { return this; }
1205  virtual TiXmlComment* ToComment() { return this; }
1206 
1209  virtual bool Accept( TiXmlVisitor* visitor ) const;
1210 
1211 protected:
1212  void CopyTo( TiXmlComment* target ) const;
1213 
1214  // used to be public
1215  #ifdef TIXML_USE_STL
1216  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1217  #endif
1218 // virtual void StreamOut( TIXML_OSTREAM * out ) const;
1219 
1220 private:
1221 
1222 };
1223 
1224 
1230 class MADARA_Export TiXmlText : public TiXmlNode
1231 {
1232  friend class TiXmlElement;
1233 public:
1238  TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT)
1239  {
1240  SetValue( initValue );
1241  cdata = false;
1242  }
1243  virtual ~TiXmlText() {}
1244 
1245  #ifdef TIXML_USE_STL
1246  TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT)
1248  {
1249  SetValue( initValue );
1250  cdata = false;
1251  }
1252  #endif
1253 
1254  TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TINYXML_TEXT ) { copy.CopyTo( this ); }
1255  void operator=( const TiXmlText& base ) { base.CopyTo( this ); }
1256 
1257  // Write this text object to a FILE stream.
1258  virtual void Print( FILE* cfile, int depth ) const;
1259 
1261  bool CDATA() const { return cdata; }
1263  void SetCDATA( bool _cdata ) { cdata = _cdata; }
1264 
1265  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1266 
1267  virtual const TiXmlText* ToText() const { return this; }
1268  virtual TiXmlText* ToText() { return this; }
1269 
1272  virtual bool Accept( TiXmlVisitor* content ) const;
1273 
1274 protected :
1276  virtual TiXmlNode* Clone() const;
1277  void CopyTo( TiXmlText* target ) const;
1278 
1279  bool Blank() const; // returns true if all white space and new lines
1280  // [internal use]
1281  #ifdef TIXML_USE_STL
1282  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1283  #endif
1284 
1285 private:
1286  bool cdata; // true if this should be input and output as a CDATA style text element
1287 };
1288 
1289 
1303 class MADARA_Export TiXmlDeclaration : public TiXmlNode
1304 {
1305 public:
1307  TiXmlDeclaration() : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) {}
1308 
1309 #ifdef TIXML_USE_STL
1310  TiXmlDeclaration( const std::string& _version,
1312  const std::string& _encoding,
1313  const std::string& _standalone );
1314 #endif
1315 
1317  TiXmlDeclaration( const char* _version,
1318  const char* _encoding,
1319  const char* _standalone );
1320 
1321  TiXmlDeclaration( const TiXmlDeclaration& copy );
1322  void operator=( const TiXmlDeclaration& copy );
1323 
1324  virtual ~TiXmlDeclaration() {}
1325 
1327  const char *Version() const { return version.c_str (); }
1329  const char *Encoding() const { return encoding.c_str (); }
1331  const char *Standalone() const { return standalone.c_str (); }
1332 
1334  virtual TiXmlNode* Clone() const;
1335  // Print this declaration to a FILE stream.
1336  virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
1337  virtual void Print( FILE* cfile, int depth ) const {
1338  Print( cfile, depth, 0 );
1339  }
1340 
1341  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1342 
1343  virtual const TiXmlDeclaration* ToDeclaration() const { return this; }
1344  virtual TiXmlDeclaration* ToDeclaration() { return this; }
1345 
1348  virtual bool Accept( TiXmlVisitor* visitor ) const;
1349 
1350 protected:
1351  void CopyTo( TiXmlDeclaration* target ) const;
1352  // used to be public
1353  #ifdef TIXML_USE_STL
1354  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1355  #endif
1356 
1357 private:
1358 
1362 };
1363 
1364 
1372 class MADARA_Export TiXmlUnknown : public TiXmlNode
1373 {
1374 public:
1375  TiXmlUnknown() : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) {}
1376  virtual ~TiXmlUnknown() {}
1377 
1378  TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) { copy.CopyTo( this ); }
1379  void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); }
1380 
1382  virtual TiXmlNode* Clone() const;
1383  // Print this Unknown to a FILE stream.
1384  virtual void Print( FILE* cfile, int depth ) const;
1385 
1386  virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1387 
1388  virtual const TiXmlUnknown* ToUnknown() const { return this; }
1389  virtual TiXmlUnknown* ToUnknown() { return this; }
1390 
1393  virtual bool Accept( TiXmlVisitor* content ) const;
1394 
1395 protected:
1396  void CopyTo( TiXmlUnknown* target ) const;
1397 
1398  #ifdef TIXML_USE_STL
1399  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1400  #endif
1401 
1402 private:
1403 
1404 };
1405 
1406 
1411 class MADARA_Export TiXmlDocument : public TiXmlNode
1412 {
1413 public:
1415  TiXmlDocument();
1417  TiXmlDocument( const char * documentName );
1418 
1419  #ifdef TIXML_USE_STL
1420  TiXmlDocument( const std::string& documentName );
1422  #endif
1423 
1424  TiXmlDocument( const TiXmlDocument& copy );
1425  void operator=( const TiXmlDocument& copy );
1426 
1427  virtual ~TiXmlDocument() {}
1428 
1433  bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1435  bool SaveFile() const;
1437  bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1439  bool SaveFile( const char * filename ) const;
1445  bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1447  bool SaveFile( FILE* ) const;
1448 
1449  #ifdef TIXML_USE_STL
1450 
1456  bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING )
1457  {
1458  return LoadFile( filename.c_str(), encoding );
1459  }
1460 
1466  bool SaveFile( const std::string& filename ) const
1467  {
1468  return SaveFile( filename.c_str() );
1469  }
1470  #endif
1471 
1476  virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1477 
1482  const TiXmlElement* RootElement() const { return FirstChildElement(); }
1484 
1490  bool Error() const { return error; }
1491 
1493  const char * ErrorDesc() const { return errorDesc.c_str (); }
1494 
1498  int ErrorId() const { return errorId; }
1499 
1507  int ErrorRow() const { return errorLocation.row+1; }
1508  int ErrorCol() const { return errorLocation.col+1; }
1509 
1534  void SetTabSize( int _tabsize ) { tabsize = _tabsize; }
1535 
1536  int TabSize() const { return tabsize; }
1537 
1541  void ClearError() { error = false;
1542  errorId = 0;
1543  errorDesc = "";
1544  errorLocation.row = errorLocation.col = 0;
1545  //errorLocation.last = 0;
1546  }
1547 
1549  void Print() const { Print( stdout, 0 ); }
1550 
1551  /* Write the document to a string using formatted printing ("pretty print"). This
1552  will allocate a character array (new char[]) and return it as a pointer. The
1553  calling code pust call delete[] on the return char* to avoid a memory leak.
1554  */
1555  //char* PrintToMemory() const;
1556 
1558  virtual void Print( FILE* cfile, int depth = 0 ) const;
1559  // [internal use]
1560  void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding );
1561 
1562  virtual const TiXmlDocument* ToDocument() const { return this; }
1563  virtual TiXmlDocument* ToDocument() { return this; }
1564 
1567  virtual bool Accept( TiXmlVisitor* content ) const;
1568 
1569 protected :
1570  // [internal use]
1571  virtual TiXmlNode* Clone() const;
1572  #ifdef TIXML_USE_STL
1573  virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
1574  #endif
1575 
1576 private:
1577  void CopyTo( TiXmlDocument* target ) const;
1578 
1579  bool error;
1580  int errorId;
1582  int tabsize;
1584  bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write.
1585 };
1586 
1587 
1668 class MADARA_Export TiXmlHandle
1669 {
1670 public:
1672  TiXmlHandle( TiXmlNode* _node ) { this->node = _node; }
1674  TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; }
1675  TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; }
1676 
1678  TiXmlHandle FirstChild() const;
1680  TiXmlHandle FirstChild( const char * value ) const;
1682  TiXmlHandle FirstChildElement() const;
1684  TiXmlHandle FirstChildElement( const char * value ) const;
1685 
1689  TiXmlHandle Child( const char* value, int index ) const;
1693  TiXmlHandle Child( int index ) const;
1698  TiXmlHandle ChildElement( const char* value, int index ) const;
1703  TiXmlHandle ChildElement( int index ) const;
1704 
1705  #ifdef TIXML_USE_STL
1706  TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); }
1707  TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); }
1708 
1709  TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); }
1710  TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); }
1711  #endif
1712 
1715  TiXmlNode* ToNode() const { return node; }
1718  TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
1721  TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
1724  TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
1725 
1729  TiXmlNode* Node() const { return ToNode(); }
1733  TiXmlElement* Element() const { return ToElement(); }
1737  TiXmlText* Text() const { return ToText(); }
1741  TiXmlUnknown* Unknown() const { return ToUnknown(); }
1742 
1743 private:
1745 };
1746 
1747 
1767 class MADARA_Export TiXmlPrinter : public TiXmlVisitor
1768 {
1769 public:
1770  TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ),
1771  buffer(), indent( " " ), lineBreak( "\n" ) {}
1772 
1773  virtual bool VisitEnter( const TiXmlDocument& doc );
1774  virtual bool VisitExit( const TiXmlDocument& doc );
1775 
1776  virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute );
1777  virtual bool VisitExit( const TiXmlElement& element );
1778 
1779  virtual bool Visit( const TiXmlDeclaration& declaration );
1780  virtual bool Visit( const TiXmlText& text );
1781  virtual bool Visit( const TiXmlComment& comment );
1782  virtual bool Visit( const TiXmlUnknown& unknown );
1783 
1787  void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; }
1789  const char* Indent() { return indent.c_str(); }
1794  void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; }
1796  const char* LineBreak() { return lineBreak.c_str(); }
1797 
1801  void SetStreamPrinting() { indent = "";
1802  lineBreak = "";
1803  }
1805  const char* CStr() { return buffer.c_str(); }
1807  size_t Size() { return buffer.size(); }
1808 
1809  #ifdef TIXML_USE_STL
1810  const std::string& Str() { return buffer; }
1812  #endif
1813 
1814 private:
1815  void DoIndent() {
1816  for( int i=0; i<depth; ++i )
1817  buffer += indent;
1818  }
1819  void DoLineBreak() {
1820  buffer += lineBreak;
1821  }
1822 
1823  int depth;
1828 };
1829 
1830 
1831 #ifdef _MSC_VER
1832 #pragma warning( pop )
1833 #endif
1834 
1835 #endif // _MADARA_NO_XML_
1836 
1837 #endif
1838 
virtual ~TiXmlVisitor()
Definition: tinyxml.h:151
virtual void StreamIn(std::istream *in, std::string *tag)
static const int utf8ByteTable[256]
Definition: tinyxml.h:273
TiXmlHandle Child(const std::string &_value, int index) const
Definition: tinyxml.h:1709
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1204
TiXmlAttribute sentinel
Definition: tinyxml.h:956
const TiXmlAttribute * First() const
Definition: tinyxml.h:936
void DoLineBreak()
Definition: tinyxml.h:1819
TiXmlNode * LastChild(const char *_value)
The last child of this node matching 'value'. Will be null if there are no children.
Definition: tinyxml.h:558
std::string errorDesc
Definition: tinyxml.h:1581
An attribute is a name-value pair.
Definition: tinyxml.h:802
TiXmlHandle(TiXmlNode *_node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml.h:1672
TiXmlUnknown * Unknown() const
Definition: tinyxml.h:1741
TiXmlNode * FirstChild(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:564
int col
0 based.
Definition: tinyxml.h:125
virtual bool Accept(TiXmlVisitor *visitor) const
Walk the XML tree visiting this node and all of its children.
Definition: tinyxml.cpp:833
void SetUserData(void *user)
Set a pointer to arbitrary user data.
Definition: tinyxml.h:267
Implements the interface to the "Visitor pattern" (see the Accept() method.) If you call the Accept()...
Definition: tinyxml.h:148
A class used to manage a group of attributes.
Definition: tinyxml.h:927
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1562
const std::string & ValueTStr() const
Definition: tinyxml.h:520
TiXmlUnknown(const TiXmlUnknown &copy)
Definition: tinyxml.h:1378
const TiXmlNode * Parent() const
Definition: tinyxml.h:543
const std::string & ValueStr() const
Return Value() as a std::string.
Definition: tinyxml.h:517
const TiXmlElement * RootElement() const
Get the root element – the only top level element – of the document.
Definition: tinyxml.h:1482
TiXmlComment()
Constructs an empty comment.
Definition: tinyxml.h:1184
void SetLineBreak(const char *_lineBreak)
Set the line breaking string.
Definition: tinyxml.h:1794
TiXmlElement * NextSiblingElement()
Definition: tinyxml.h:668
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1150
static bool StreamWhiteSpace(std::istream *in, std::string *tag)
TiXmlHandle(const TiXmlHandle &ref)
Copy constructor.
Definition: tinyxml.h:1674
void operator=(const TiXmlNode &base)
TiXmlNode * PreviousSibling(const char *_prev)
Definition: tinyxml.h:642
TiXmlNode * LastChild()
The last child of this node. Will be null if there are no children.
Definition: tinyxml.h:555
const char * LineBreak()
Query the current line breaking string.
Definition: tinyxml.h:1796
virtual TiXmlNode * Clone() const
Creates a new Element and returns it - the returned element is a copy.
Definition: tinyxml.cpp:847
bool Error() const
If an error occurs, Error will be set to true.
Definition: tinyxml.h:1490
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:728
virtual bool Visit(const TiXmlUnknown &)
Visit an unknow node.
Definition: tinyxml.h:170
TiXmlAttribute(const char *_name, const char *_value)
Construct an attribute with a name and value.
Definition: tinyxml.h:826
TiXmlNode * prev
Definition: tinyxml.h:786
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1267
void CopyTo(TiXmlUnknown *target) const
Definition: tinyxml.cpp:1431
const void * GetUserData() const
Get a pointer to arbitrary user data.
Definition: tinyxml.h:269
int Type() const
Query the type (as an enumerated value, above) of this node.
Definition: tinyxml.h:707
static int ToLower(int v, TiXmlEncoding encoding)
Definition: tinyxml.h:402
TiXmlNode * IterateChildren(const std::string &_value, const TiXmlNode *previous)
STL std::string form.
Definition: tinyxml.h:598
const TiXmlElement * FirstChildElement(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:699
TiXmlNode * IterateChildren(const char *_value, const TiXmlNode *previous)
Definition: tinyxml.h:592
TiXmlNode * firstChild
Definition: tinyxml.h:781
static int IsAlphaNum(unsigned char anyByte, TiXmlEncoding encoding)
Internal structure for tracking location of items in the XML file.
Definition: tinyxml.h:112
void operator=(const TiXmlUnknown &copy)
Definition: tinyxml.h:1379
int TabSize() const
Definition: tinyxml.h:1536
static void EncodeString(const std::string &str, std::string *out)
Expands entities in a string.
Definition: tinyxml.cpp:54
TiXmlDocument * document
Definition: tinyxml.h:906
int ErrorId() const
Generally, you probably want the error string ( ErrorDesc() ).
Definition: tinyxml.h:1498
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:1337
TiXmlElement * NextSiblingElement(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:683
TiXmlAttribute * FirstAttribute()
Definition: tinyxml.h:1102
TiXmlElement * FirstChildElement(const char *_value)
Definition: tinyxml.h:694
void operator=(const TiXmlDocument &copy)
Definition: tinyxml.cpp:904
void SetValue(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:868
TiXmlAttribute * Next()
Definition: tinyxml.h:873
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
Replace a child of this node.
Definition: tinyxml.cpp:294
bool SaveFile(const std::string &filename) const
Saves a XML structure to file.
Definition: tinyxml.h:1466
const TiXmlAttribute * LastAttribute() const
Access the last attribute in this element.
Definition: tinyxml.h:1103
virtual bool VisitExit(const TiXmlElement &)
Visit an element.
Definition: tinyxml.h:161
void SetName(const char *_name)
Set the name of this attribute.
Definition: tinyxml.h:858
TiXmlNode * NextSibling()
Definition: tinyxml.h:655
void SetTabSize(int _tabsize)
SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) to report the correct v...
Definition: tinyxml.h:1534
void DoIndent()
Definition: tinyxml.h:1815
TiXmlAttribute()
Construct an empty attribute.
Definition: tinyxml.h:808
const int TIXML_PATCH_VERSION
Definition: tinyxml.h:107
const char * Standalone() const
Is this a standalone document?
Definition: tinyxml.h:1331
TiXmlElement * ToElement() const
Return the handle as a TiXmlElement.
Definition: tinyxml.h:1718
TiXmlElement * NextSiblingElement(const char *_next)
Definition: tinyxml.h:677
std::string value
Definition: tinyxml.h:784
virtual ~TiXmlText()
Definition: tinyxml.h:1243
TiXmlElement * FirstChildElement()
Definition: tinyxml.h:688
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:727
void ClearError()
If you have handled the error, it can be reset with this call.
Definition: tinyxml.h:1541
const char * Value() const
Return the value of this attribute.
Definition: tinyxml.h:835
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:722
void Clear()
Sets row and column to -1.
Definition: tinyxml.h:122
virtual TiXmlComment * ToComment()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1205
virtual ~TiXmlComment()
Definition: tinyxml.h:1192
static const char * errorString[TIXML_ERROR_STRING_COUNT]
Definition: tinyxml.h:391
void SetValue(const char *_value)
Changes the value of the node.
Definition: tinyxml.h:531
int ErrorCol() const
The column where the error occured. See ErrorRow()
Definition: tinyxml.h:1508
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
Add a new node related to this.
Definition: tinyxml.cpp:215
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
const std::string & NameTStr() const
Definition: tinyxml.h:843
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1151
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
Add a new node related to this.
Definition: tinyxml.cpp:230
static bool condenseWhiteSpace
Definition: tinyxml.h:436
virtual ~TiXmlDocument()
Definition: tinyxml.h:1427
TiXmlNode * PreviousSibling()
Definition: tinyxml.h:638
NodeType
The types of XML nodes supported by TinyXml.
Definition: tinyxml.h:485
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:725
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
Definition: tinyxml.h:154
TiXmlHandle ChildElement(const std::string &_value, int index) const
Definition: tinyxml.h:1710
const char * Encoding() const
Encoding. Will return an empty string if none was found.
Definition: tinyxml.h:1329
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
Add a new node related to this.
Definition: tinyxml.cpp:188
const TiXmlNode * LastChild() const
Definition: tinyxml.h:554
const char * Name() const
Return the name of this attribute.
Definition: tinyxml.h:834
void * userData
Field containing a generic user pointer.
Definition: tinyxml.h:396
virtual bool Accept(TiXmlVisitor *visitor) const =0
Accept a hierchical visit the nodes in the TinyXML DOM.
TiXmlAttribute * prev
Definition: tinyxml.h:909
TiXmlDocument * GetDocument()
Definition: tinyxml.h:713
void Print() const
Write the document to standard out using formatted printing ("pretty print").
Definition: tinyxml.h:1549
const char * str
Definition: tinyxml.h:425
In correct XML the declaration is the first entry in the file.
Definition: tinyxml.h:1303
bool cdata
Definition: tinyxml.h:1286
const TiXmlAttribute * Last() const
Definition: tinyxml.h:938
static bool IsWhiteSpace(char c)
Definition: tinyxml.h:310
std::istream & operator>>(std::istream &in, TiXmlNode &base)
Definition: tinyxml.cpp:1551
TiXmlCursor()
Constructor.
Definition: tinyxml.h:117
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1173
Any tag that tinyXml doesn't recognize is saved as an unknown.
Definition: tinyxml.h:1372
virtual bool Visit(const TiXmlText &)
Visit a text node.
Definition: tinyxml.h:166
const TiXmlEncoding TIXML_DEFAULT_ENCODING
Definition: tinyxml.h:190
Internal entity struct for holding string elements.
Definition: tinyxml.h:423
int ErrorRow() const
Returns the location (if known) of the error.
Definition: tinyxml.h:1507
const char * Version() const
Version. Will return an empty string if none was found.
Definition: tinyxml.h:1327
std::string buffer
Definition: tinyxml.h:1825
TiXmlNode * NextSibling(const char *_next)
Definition: tinyxml.h:659
TiXmlNode * FirstChild()
Definition: tinyxml.h:546
TiXmlAttribute * next
Definition: tinyxml.h:910
int Column() const
See Row()
Definition: tinyxml.h:265
static bool IsWhiteSpaceCondensed()
Return the current white space setting.
Definition: tinyxml.h:244
TiXmlText(const TiXmlText &copy)
Definition: tinyxml.h:1254
TiXmlCursor location
Definition: tinyxml.h:393
const int TIXML_MAJOR_VERSION
Definition: tinyxml.h:105
static const char * ReadName(const char *p, std::string *name, TiXmlEncoding encoding)
void SetIndent(const char *_indent)
Set the indent characters for printing.
Definition: tinyxml.h:1787
virtual ~TiXmlUnknown()
Definition: tinyxml.h:1376
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
Definition: tinyxml.h:545
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
Definition: tinyxml.h:1493
bool LoadFile(const std::string &filename, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Loads a XML file.
Definition: tinyxml.h:1456
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1388
std::ostream & operator<<(std::ostream &stream, const madara::knowledge::KnowledgeRecord &rhs)
output stream buffering
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1563
TiXmlAttribute * Last()
Definition: tinyxml.h:939
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:893
void SetCDATA(bool _cdata)
Turns on or off a CDATA representation of text.
Definition: tinyxml.h:1263
const char * Indent()
Query the indention string.
Definition: tinyxml.h:1789
TiXmlElement * FirstChildElement(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:700
virtual void StreamIn(std::istream *in, std::string *tag)=0
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1344
Always the top level node.
Definition: tinyxml.h:1411
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
Definition: tinyxml.cpp:450
TiXmlEncoding
Used by the parsing routines.
Definition: tinyxml.h:183
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0
friend class TiXmlNode
Definition: tinyxml.h:216
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1343
int row
0 based.
Definition: tinyxml.h:124
const TiXmlNode * LastChild(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:565
int QueryFloatAttribute(const char *name, float *_value) const
QueryFloatAttribute examines the attribute - see QueryIntAttribute().
Definition: tinyxml.h:1013
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
Definition: tinyxml.h:637
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:649
static const char * SkipWhiteSpace(const char *, TiXmlEncoding encoding)
friend class TiXmlElement
Definition: tinyxml.h:449
TiXmlNode * Identify(const char *start, TiXmlEncoding encoding)
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
Add a new node related to this.
Definition: tinyxml.cpp:262
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:732
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:721
const std::string & ValueStr() const
Return the value of this attribute.
Definition: tinyxml.h:837
const TiXmlDocument * GetDocument() const
Return a pointer to the Document this node lives in.
Definition: tinyxml.cpp:510
TiXmlNode * node
Definition: tinyxml.h:1744
bool CDATA() const
Queries whether this represents text using a CDATA section.
Definition: tinyxml.h:1261
std::string version
Definition: tinyxml.h:1359
A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thi...
Definition: tinyxml.h:1668
static bool IsWhiteSpace(int c)
Definition: tinyxml.h:314
virtual TiXmlComment * ToComment()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:729
bool operator>(const TiXmlAttribute &rhs) const
Definition: tinyxml.h:885
const TiXmlNode * IterateChildren(const std::string &_value, const TiXmlNode *previous) const
STL std::string form.
Definition: tinyxml.h:597
static const char * GetEntity(const char *in, char *value, int *length, TiXmlEncoding encoding)
TiXmlText * Text() const
Definition: tinyxml.h:1737
TiXmlNode * Node() const
Definition: tinyxml.h:1729
void operator=(const TiXmlBase &base)
TiXmlNode * ToNode() const
Return the handle as a TiXmlNode.
Definition: tinyxml.h:1715
static void SetCondenseWhiteSpace(bool condense)
The world does not agree on whether white space should be kept or not.
Definition: tinyxml.h:241
bool operator<(const TiXmlAttribute &rhs) const
Definition: tinyxml.h:884
TiXmlBase is a base class for every class in TinyXml.
Definition: tinyxml.h:214
const TiXmlElement * NextSiblingElement() const
Convenience function to get through elements.
Definition: tinyxml.cpp:480
TiXmlNode * Parent()
One step up the DOM.
Definition: tinyxml.h:542
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:730
std::string value
Definition: tinyxml.h:908
bool operator==(const TiXmlAttribute &rhs) const
Definition: tinyxml.h:883
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:723
std::string encoding
Definition: tinyxml.h:1360
TiXmlComment(const char *_value)
Construct a comment from text.
Definition: tinyxml.h:1186
virtual ~TiXmlBase()
Definition: tinyxml.h:222
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
static bool StreamTo(std::istream *in, int character, std::string *tag)
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Parse the given null terminated block of xml data.
TiXmlHandle operator=(const TiXmlHandle &ref)
Definition: tinyxml.h:1675
TiXmlNode * parent
Definition: tinyxml.h:778
std::string standalone
Definition: tinyxml.h:1361
TiXmlNode * IterateChildren(const TiXmlNode *previous)
Definition: tinyxml.h:586
int Row() const
Return the position, in the original source file, of this node or attribute.
Definition: tinyxml.h:264
TiXmlHandle FirstChild(const std::string &_value) const
Definition: tinyxml.h:1706
TiXmlAttribute * Previous()
Definition: tinyxml.h:879
TiXmlElement * Element() const
Definition: tinyxml.h:1733
TiXmlElement * RootElement()
Definition: tinyxml.h:1483
int QueryValueAttribute(const std::string &name, T *outValue) const
Template form of the attribute query which will try to read the attribute into the specified type...
Definition: tinyxml.h:1041
void * GetUserData()
Get a pointer to arbitrary user data.
Definition: tinyxml.h:268
The parent class for everything in the Document Object Model.
Definition: tinyxml.h:446
INTERNAL USE: holds parsing data for tabs, cursors, etc.
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:724
void CopyTo(TiXmlNode *target) const
Definition: tinyxml.cpp:163
TiXmlNode * LastChild(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:566
size_t Size()
Return the length of the result string.
Definition: tinyxml.h:1807
Print to memory functionality.
Definition: tinyxml.h:1767
TiXmlNode * PreviousSibling(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:648
XML text.
Definition: tinyxml.h:1230
std::string indent
Definition: tinyxml.h:1826
const TiXmlNode * FirstChild(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:563
TiXmlNode * next
Definition: tinyxml.h:787
friend class TiXmlDocument
Definition: tinyxml.h:448
virtual bool VisitExit(const TiXmlDocument &)
Visit a document.
Definition: tinyxml.h:156
virtual bool Visit(const TiXmlComment &)
Visit a comment node.
Definition: tinyxml.h:168
static const char * GetChar(const char *p, char *_value, int *length, TiXmlEncoding encoding)
Definition: tinyxml.h:347
void operator=(const TiXmlText &base)
Definition: tinyxml.h:1255
TiXmlText(const char *initValue)
Constructor for text element.
Definition: tinyxml.h:1238
bool useMicrosoftBOM
Definition: tinyxml.h:1584
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
An alternate way to walk the children of a node.
Definition: tinyxml.cpp:383
const char * Value() const
The meaning of 'value' changes for the specific type of TiXmlNode.
Definition: tinyxml.h:510
TiXmlNode * NextSibling(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:650
int QueryValueAttribute(const std::string &name, std::string *outValue) const
Definition: tinyxml.h:1054
void CopyTo(TiXmlText *target) const
Definition: tinyxml.cpp:1309
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml.h:718
void CopyTo(TiXmlElement *target) const
Definition: tinyxml.cpp:811
const TiXmlAttribute * FirstAttribute() const
Access the first attribute in this element.
Definition: tinyxml.h:1101
unsigned int strLength
Definition: tinyxml.h:426
NodeType type
Definition: tinyxml.h:779
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
Definition: tinyxml.cpp:333
std::string name
Definition: tinyxml.h:907
void RemoveAttribute(const std::string &name)
STL std::string form.
Definition: tinyxml.h:1098
An XML comment.
Definition: tinyxml.h:1180
void SetDocument(TiXmlDocument *doc)
Definition: tinyxml.h:900
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1389
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:720
void Clear()
Delete all the children of this node. Does not affect 'this'.
Definition: tinyxml.cpp:171
TiXmlHandle FirstChildElement(const std::string &_value) const
Definition: tinyxml.h:1707
void SetValue(const char *_value)
Set the value.
Definition: tinyxml.h:859
virtual ~TiXmlDeclaration()
Definition: tinyxml.h:1324
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
Definition: tinyxml.h:654
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:1268
TiXmlAttribute * LastAttribute()
Definition: tinyxml.h:1104
TiXmlNode * lastChild
Definition: tinyxml.h:782
TiXmlText * ToText() const
Return the handle as a TiXmlText.
Definition: tinyxml.h:1721
TiXmlDeclaration()
Construct an empty declaration.
Definition: tinyxml.h:1307
void SetStreamPrinting()
Switch over to "stream printing" which is the most dense formatting without linebreaks.
Definition: tinyxml.h:1801
static int IsAlpha(unsigned char anyByte, TiXmlEncoding encoding)
TiXmlAttribute * First()
Definition: tinyxml.h:937
virtual void Print(FILE *cfile, int depth) const =0
All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL ...
std::string lineBreak
Definition: tinyxml.h:1827
static const char * ReadText(const char *in, std::string *text, bool ignoreWhiteSpace, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
virtual ~TiXmlNode()
Definition: tinyxml.cpp:149
virtual TiXmlNode * Clone() const =0
Create an exact duplicate of this node and return it.
const TiXmlElement * NextSiblingElement(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:682
TiXmlUnknown * ToUnknown() const
Return the handle as a TiXmlUnknown.
Definition: tinyxml.h:1724
const TiXmlNode * PreviousSibling(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:647
const char * CStr()
Return the result.
Definition: tinyxml.h:1805
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:731
#define TIXML_STRING
Definition: tinyxml.h:65
const int TIXML_MINOR_VERSION
Definition: tinyxml.h:106
The element is a container class.
Definition: tinyxml.h:964
bool simpleTextPrint
Definition: tinyxml.h:1824
TiXmlCursor errorLocation
Definition: tinyxml.h:1583
virtual bool VisitEnter(const TiXmlElement &, const TiXmlAttribute *)
Visit an element.
Definition: tinyxml.h:159
TiXmlBase()
Definition: tinyxml.h:221
virtual bool Visit(const TiXmlDeclaration &)
Visit a declaration.
Definition: tinyxml.h:164