Nebula
Loading...
Searching...
No Matches
tinyxml.h
Go to the documentation of this file.
1/*
2www.sourceforge.net/projects/tinyxml
3Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com)
4
5This software is provided 'as-is', without any express or implied
6warranty. In no event will the authors be held liable for any
7damages arising from the use of this software.
8
9Permission is granted to anyone to use this software for any
10purpose, including commercial applications, and to alter it and
11redistribute it freely, subject to the following restrictions:
12
131. The origin of this software must not be misrepresented; you must
14not claim that you wrote the original software. If you use this
15software in a product, an acknowledgment in the product documentation
16would be appreciated but is not required.
17
182. Altered source versions must be plainly marked as such, and
19must not be misrepresented as being the original software.
20
213. This notice may not be removed or altered from any source
22distribution.
23*/
24
25
26#ifndef TINYXML_INCLUDED
27#define TINYXML_INCLUDED
28
29#ifdef _MSC_VER
30#pragma warning( disable : 4530 )
31#pragma warning( disable : 4786 )
32#pragma warning( disable : 4996 )
33#endif
35#include <ctype.h>
36#include <stdio.h>
37#include <stdlib.h>
38#include <string.h>
39#include <assert.h>
40#include "io/stream.h"
41#include "io/textwriter.h"
43// Help out windows:
44#if defined( _DEBUG ) && !defined( DEBUG )
45#define DEBUG
46#endif
47
48#ifdef TIXML_USE_STL
49 #include <string>
50 #include <iostream>
51 #define TIXML_STRING std::string
52 #define TIXML_ISTREAM std::istream
53 #define TIXML_OSTREAM std::ostream
54#else
55 #include "tinystr.h"
56 #define TIXML_STRING TiXmlString
57 #define TIXML_OSTREAM TiXmlOutStream
58#endif
59
60// Deprecated library function hell. Compilers want to use the
61// new safe versions. This probably doesn't fully address the problem,
62// but it gets closer. There are too many compilers for me to fully
63// test. If you get compilation troubles, undefine TIXML_SAFE
64
65#define TIXML_SAFE // TinyXml isn't fully buffer overrun protected, safe code. This is work in progress.
66#ifdef TIXML_SAFE
67 #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
68 // Microsoft visual studio, version 2005 and higher.
69 #define TIXML_SNPRINTF _snprintf_s
70 #define TIXML_SNSCANF _snscanf_s
71 #elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
72 // Microsoft visual studio, version 6 and higher.
73 //#pragma message( "Using _sn* functions." )
74 #define TIXML_SNPRINTF _snprintf
75 #define TIXML_SNSCANF _snscanf
76 #elif defined(__GNUC__) && (__GNUC__ >= 3 )
77 // GCC version 3 and higher.s
78 //#warning( "Using sn* functions." )
79 #define TIXML_SNPRINTF snprintf
80 #define TIXML_SNSCANF snscanf
81 #endif
82#endif
83
84class TiXmlDocument;
85class TiXmlElement;
86class TiXmlComment;
87class TiXmlUnknown;
88class TiXmlAttribute;
89class TiXmlText;
92
93const int TIXML_MAJOR_VERSION = 2;
94const int TIXML_MINOR_VERSION = 4;
95const int TIXML_PATCH_VERSION = 3;
96
97/* Internal structure for tracking location of items
98 in the XML file.
99*/
101{
103 void Clear() { row = col = -1; }
104
105 int row; // 0 based.
106 int col; // 0 based.
107};
108
109
110// Only used by Attribute::Query functions
111enum
112{
117
118
119// Used by the parsing routines.
126
128
152{
153 friend class TiXmlNode;
154 friend class TiXmlElement;
155 friend class TiXmlDocument;
156
157public:
159 virtual ~TiXmlBase() {}
160
166 virtual void Print(const Ptr<IO::TextWriter>& textWriter, int depth ) const = 0;
167
174 static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; }
175
178
197 int Row() const { return location.row + 1; }
198 int Column() const { return location.col + 1; }
199
200 void SetUserData( void* user ) { userData = user; }
201 void* GetUserData() { return userData; }
202
203 // Table that returs, for a given lead byte, the total number of bytes
204 // in the UTF-8 sequence.
205 static const int utf8ByteTable[256];
206
207 virtual const char* Parse( const char* p,
208 TiXmlParsingData* data,
209 TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
210
211 enum
212 {
229
231 };
232
233protected:
234
235 // See STL_STRING_BUG
236 // Utility class to overcome a bug.
238 {
239 public:
240 StringToBuffer( const TIXML_STRING& str );
242 char* buffer;
243 };
244
245 static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
246 inline static bool IsWhiteSpace( char c )
247 {
248 return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
249 }
250 inline static bool IsWhiteSpace( int c )
251 {
252 if ( c < 256 )
253 return IsWhiteSpace( (char) c );
254 return false; // Again, only truly correct for English/Latin...but usually works.
255 }
256
257 virtual void StreamOut (TIXML_OSTREAM *) const = 0;
258
259 #ifdef TIXML_USE_STL
260 static bool StreamWhiteSpace( TIXML_ISTREAM * in, TIXML_STRING * tag );
261 static bool StreamTo( TIXML_ISTREAM * in, int character, TIXML_STRING * tag );
262 #endif
263
264 /* Reads an XML name into the string provided. Returns
265 a pointer just past the last character of the name,
266 or 0 if the function has an error.
267 */
268 static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding );
269
270 /* Reads text. Returns a pointer past the given end tag.
271 Wickedly complex options, but it keeps the (sensitive) code in one place.
272 */
273 static const char* ReadText( const char* in, // where to start
274 TIXML_STRING* text, // the string read
275 bool ignoreWhiteSpace, // whether to keep the white space
276 const char* endTag, // what ends this text
277 bool ignoreCase, // whether to ignore case in the end tag
278 TiXmlEncoding encoding ); // the current encoding
279
280 // If an entity has been found, transform it into a character.
281 static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding );
282
283 // Get a character, while interpreting entities.
284 // The length can be from 0 to 4 bytes.
285 inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding )
286 {
287 assert( p );
288 if ( encoding == TIXML_ENCODING_UTF8 )
289 {
290 *length = utf8ByteTable[ *((unsigned char*)p) ];
291 assert( *length >= 0 && *length < 5 );
292 }
293 else
294 {
295 *length = 1;
296 }
297
298 if ( *length == 1 )
299 {
300 if ( *p == '&' )
301 return GetEntity( p, _value, length, encoding );
302 *_value = *p;
303 return p+1;
304 }
305 else if ( *length )
306 {
307 //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe),
308 // and the null terminator isn't needed
309 for( int i=0; p[i] && i<*length; ++i ) {
310 _value[i] = p[i];
311 }
312 return p + (*length);
313 }
314 else
315 {
316 // Not valid text.
317 return 0;
318 }
319 }
320
321 // Puts a string to a stream, expanding entities as it goes.
322 // Note this should not contian the '<', '>', etc, or they will be transformed into entities!
323 static void PutString( const TIXML_STRING& str, TIXML_OSTREAM* out );
324
325 static void PutString( const TIXML_STRING& str, TIXML_STRING* out );
326
327 // Return true if the next characters in the stream are any of the endTag sequences.
328 // Ignore case only works for english, and should only be relied on when comparing
329 // to English words: StringEqual( p, "version", true ) is fine.
330 static bool StringEqual( const char* p,
331 const char* endTag,
332 bool ignoreCase,
333 TiXmlEncoding encoding );
334
335 static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
336
338
340 void* userData;
341
342 // None of these methods are reliable for any language except English.
343 // Good for approximation, not great for accuracy.
344 static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding );
345 static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding );
346 inline static int ToLower( int v, TiXmlEncoding encoding )
347 {
348 if ( encoding == TIXML_ENCODING_UTF8 )
349 {
350 if ( v < 128 ) return tolower( v );
351 return v;
352 }
353 else
354 {
355 return tolower( v );
356 }
357 }
358 static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
359
360private:
361 TiXmlBase( const TiXmlBase& ); // not implemented.
362 void operator=( const TiXmlBase& base ); // not allowed.
363
364 struct Entity
365 {
366 const char* str;
367 unsigned int strLength;
368 char chr;
369 };
370 enum
371 {
374
375 };
376 static Entity entity[ NUM_ENTITY ];
378};
379
380
387class TiXmlNode : public TiXmlBase
388{
389 friend class TiXmlDocument;
390 friend class TiXmlElement;
391
392public:
393 #ifdef TIXML_USE_STL
394
398 friend std::istream& operator >> (std::istream& in, TiXmlNode& base);
399
416 friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
417
419 friend std::string& operator<< (std::string& out, const TiXmlNode& base );
420
421 #else
422 // Used internally, not part of the public API.
423 friend TIXML_OSTREAM& operator<< (TIXML_OSTREAM& out, const TiXmlNode& base);
424 #endif
425
439
440 virtual ~TiXmlNode();
441
454 const char *Value() const { return value.c_str (); }
455
456 #ifdef TIXML_USE_STL
461 const std::string& ValueStr() const { return value; }
462 #endif
463
473 void SetValue(const char * _value) { value = _value;}
474
475 #ifdef TIXML_USE_STL
477 void SetValue( const std::string& _value ) { value = _value; }
478 #endif
479
481 void Clear();
482
484 TiXmlNode* Parent() { return parent; }
485 const TiXmlNode* Parent() const { return parent; }
486
487 const TiXmlNode* FirstChild() const { return firstChild; }
489 const TiXmlNode* FirstChild( const char * value ) const;
490 TiXmlNode* FirstChild( const char * value );
491
492 const TiXmlNode* LastChild() const { return lastChild; }
494 const TiXmlNode* LastChild( const char * value ) const;
495 TiXmlNode* LastChild( const char * value );
496
497 #ifdef TIXML_USE_STL
498 const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); }
499 TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); }
500 const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); }
501 TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); }
502 #endif
503
520 const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const;
521 TiXmlNode* IterateChildren( TiXmlNode* previous );
522
524 const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const;
525 TiXmlNode* IterateChildren( const char * value, TiXmlNode* previous );
526
527 #ifdef TIXML_USE_STL
528 const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); }
529 TiXmlNode* IterateChildren( const std::string& _value, TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); }
530 #endif
531
535 TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
536
537
547 TiXmlNode* LinkEndChild( TiXmlNode* addThis );
548
552 TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
553
557 TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis );
558
562 TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
563
565 bool RemoveChild( TiXmlNode* removeThis );
566
568 const TiXmlNode* PreviousSibling() const { return prev; }
570
572 const TiXmlNode* PreviousSibling( const char * ) const;
573 TiXmlNode* PreviousSibling( const char * );
574
575 #ifdef TIXML_USE_STL
576 const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); }
577 TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); }
578 const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); }
579 TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); }
580 #endif
581
583 const TiXmlNode* NextSibling() const { return next; }
585
587 const TiXmlNode* NextSibling( const char * ) const;
588 TiXmlNode* NextSibling( const char * );
589
594 const TiXmlElement* NextSiblingElement() const;
596
601 const TiXmlElement* NextSiblingElement( const char * ) const;
602 TiXmlElement* NextSiblingElement( const char * );
603
604 #ifdef TIXML_USE_STL
605 const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); }
606 TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); }
607 #endif
608
610 const TiXmlElement* FirstChildElement() const;
612
614 const TiXmlElement* FirstChildElement( const char * value ) const;
615 TiXmlElement* FirstChildElement( const char * value );
616
617 #ifdef TIXML_USE_STL
618 const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); }
619 TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); }
620 #endif
621
626 int Type() const { return type; }
627
631 const TiXmlDocument* GetDocument() const;
633
635 bool NoChildren() const { return !firstChild; }
636
637 virtual const TiXmlDocument* ToDocument() const { return 0; }
638 virtual const TiXmlElement* ToElement() const { return 0; }
639 virtual const TiXmlComment* ToComment() const { return 0; }
640 virtual const TiXmlUnknown* ToUnknown() const { return 0; }
641 virtual const TiXmlText* ToText() const { return 0; }
642 virtual const TiXmlDeclaration* ToDeclaration() const { return 0; }
643
644 virtual TiXmlDocument* ToDocument() { return 0; }
645 virtual TiXmlElement* ToElement() { return 0; }
646 virtual TiXmlComment* ToComment() { return 0; }
647 virtual TiXmlUnknown* ToUnknown() { return 0; }
648 virtual TiXmlText* ToText() { return 0; }
649 virtual TiXmlDeclaration* ToDeclaration() { return 0; }
650
654 virtual TiXmlNode* Clone() const = 0;
655
656protected:
657 TiXmlNode( NodeType _type );
658
659 // Copy to the allocated object. Shared functionality between Clone, Copy constructor,
660 // and the assignment operator.
661 void CopyTo( TiXmlNode* target ) const;
662
663 #ifdef TIXML_USE_STL
664 // The real work of the input operator.
665 virtual void StreamIn( TIXML_ISTREAM* in, TIXML_STRING* tag ) = 0;
666 #endif
667
668 // Figure out what is at *p, and parse it. Returns null if it is not an xml node.
669 TiXmlNode* Identify( const char* start, TiXmlEncoding encoding );
670
673
676
678
681
682private:
683 TiXmlNode( const TiXmlNode& ); // not implemented.
684 void operator=( const TiXmlNode& base ); // not allowed.
685};
686
687
696{
697 friend class TiXmlAttributeSet;
698
699public:
702 {
703 document = 0;
704 prev = next = 0;
705 }
706
707 #ifdef TIXML_USE_STL
709 TiXmlAttribute( const std::string& _name, const std::string& _value )
710 {
711 name = _name;
712 value = _value;
713 document = 0;
714 prev = next = 0;
715 }
716 #endif
717
719 TiXmlAttribute( const char * _name, const char * _value )
720 {
721 name = _name;
722 value = _value;
723 document = 0;
724 prev = next = 0;
725 }
726
727 const char* Name() const { return name.c_str (); }
728 const char* Value() const { return value.c_str (); }
729 int IntValue() const;
730 double DoubleValue() const;
731
732 // Get the tinyxml string representation
733 const TIXML_STRING& NameTStr() const { return name; }
734
744 int QueryIntValue( int* _value ) const;
746 int QueryDoubleValue( double* _value ) const;
747
748 void SetName( const char* _name ) { name = _name; }
749 void SetValue( const char* _value ) { value = _value; }
750
751 void SetIntValue( int _value );
752 void SetDoubleValue( double _value );
753
754 #ifdef TIXML_USE_STL
756 void SetName( const std::string& _name ) { name = _name; }
758 void SetValue( const std::string& _value ) { value = _value; }
759 #endif
760
762 const TiXmlAttribute* Next() const;
765 const TiXmlAttribute* Previous() const;
767
768 bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
769 bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; }
770 bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; }
771
772 /* Attribute parsing starts: first letter of the name
773 returns: the next char after the value end quote
774 */
775 virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
776
777 // Prints this Attribute to a FILE stream.
778 virtual void Print(const Ptr<IO::TextWriter>& textWriter, int depth) const;
779
780 virtual void StreamOut( TIXML_OSTREAM * out ) const;
781 // [internal use]
782 // Set the document pointer so the attribute can report errors.
783 void SetDocument( TiXmlDocument* doc ) { document = doc; }
784
785private:
786 TiXmlAttribute( const TiXmlAttribute& ); // not implemented.
787 void operator=( const TiXmlAttribute& base ); // not allowed.
788
789 TiXmlDocument* document; // A pointer back to a document, for error reporting.
794};
795
796
797/* A class used to manage a group of attributes.
798 It is only used internally, both by the ELEMENT and the DECLARATION.
799
800 The set can be changed transparent to the Element and Declaration
801 classes that use it, but NOT transparent to the Attribute
802 which has to implement a next() and previous() method. Which makes
803 it a bit problematic and prevents the use of STL.
804
805 This version is implemented with circular lists because:
806 - I like circular lists
807 - it demonstrates some independence from the (typical) doubly linked list.
808*/
810{
811public:
814
815 void Add( TiXmlAttribute* attribute );
816 void Remove( TiXmlAttribute* attribute );
817
818 const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
820 const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
821 TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
822
823 const TiXmlAttribute* Find( const TIXML_STRING& name ) const;
824 TiXmlAttribute* Find( const TIXML_STRING& name );
825
826private:
827 //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
828 //*ME: this class must be also use a hidden/disabled copy-constructor !!!
829 TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed
830 void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute)
831
833};
834
835
841{
842public:
844 TiXmlElement (const char * in_value);
845
846 #ifdef TIXML_USE_STL
848 TiXmlElement( const std::string& _value );
849 #endif
850
851 TiXmlElement( const TiXmlElement& );
852
853 void operator=( const TiXmlElement& base );
854
855 virtual ~TiXmlElement();
856
860 const char* Attribute( const char* name ) const;
861
868 const char* Attribute( const char* name, int* i ) const;
869
876 const char* Attribute( const char* name, double* d ) const;
877
885 int QueryIntAttribute( const char* name, int* _value ) const;
887 int QueryDoubleAttribute( const char* name, double* _value ) const;
889 int QueryFloatAttribute( const char* name, float* _value ) const {
890 double d;
891 int result = QueryDoubleAttribute( name, &d );
892 if ( result == TIXML_SUCCESS ) {
893 *_value = (float)d;
894 }
895 return result;
896 }
897
901 void SetAttribute( const char* name, const char * _value );
902
903 #ifdef TIXML_USE_STL
904 const char* Attribute( const std::string& name ) const { return Attribute( name.c_str() ); }
905 const char* Attribute( const std::string& name, int* i ) const { return Attribute( name.c_str(), i ); }
906 const char* Attribute( const std::string& name, double* d ) const { return Attribute( name.c_str(), d ); }
907 int QueryIntAttribute( const std::string& name, int* _value ) const { return QueryIntAttribute( name.c_str(), _value ); }
908 int QueryDoubleAttribute( const std::string& name, double* _value ) const { return QueryDoubleAttribute( name.c_str(), _value ); }
909
911 void SetAttribute( const std::string& name, const std::string& _value );
913 void SetAttribute( const std::string& name, int _value );
914 #endif
915
919 void SetAttribute( const char * name, int value );
920
924 void SetDoubleAttribute( const char * name, double value );
925
928 void RemoveAttribute( const char * name );
929 #ifdef TIXML_USE_STL
930 void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); }
931 #endif
932
933 const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); }
935 const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); }
937
970 const char* GetText() const;
971
973 virtual TiXmlNode* Clone() const;
974 // Print the Element to a FILE stream.
975 virtual void Print(const Ptr<IO::TextWriter>& textWriter, int depth) const;
976
977 /* Attribtue parsing starts: next char past '<'
978 returns: next char past '>'
979 */
980 virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
981
982 virtual const TiXmlElement* ToElement() const { return this; }
983 virtual TiXmlElement* ToElement() { return this; }
984
985protected:
986
987 void CopyTo( TiXmlElement* target ) const;
988 void ClearThis(); // like clear, but initializes 'this' object as well
989
990 // Used to be public [internal use]
991 #ifdef TIXML_USE_STL
992 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
993 #endif
994 virtual void StreamOut( TIXML_OSTREAM * out ) const;
995
996 /* [internal use]
997 Reads the "value" of the element -- another element, or text.
998 This should terminate with the current end tag.
999 */
1000 const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
1001
1002private:
1003
1005};
1006
1007
1011{
1012public:
1015 TiXmlComment( const TiXmlComment& );
1016 void operator=( const TiXmlComment& base );
1017
1018 virtual ~TiXmlComment() {}
1019
1021 virtual TiXmlNode* Clone() const;
1023 virtual void Print(const Ptr<IO::TextWriter>& textWriter, int depth) const;
1024
1025 /* Attribtue parsing starts: at the ! of the !--
1026 returns: next char past '>'
1027 */
1028 virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1029
1030 virtual const TiXmlComment* ToComment() const { return this; }
1031 virtual TiXmlComment* ToComment() { return this; }
1032
1033protected:
1034 void CopyTo( TiXmlComment* target ) const;
1035
1036 // used to be public
1037 #ifdef TIXML_USE_STL
1038 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
1039 #endif
1040 virtual void StreamOut( TIXML_OSTREAM * out ) const;
1041
1042private:
1043
1044};
1045
1046
1052class TiXmlText : public TiXmlNode
1053{
1054 friend class TiXmlElement;
1055public:
1060 TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT)
1061 {
1062 SetValue( initValue );
1063 cdata = false;
1064 }
1065 virtual ~TiXmlText() {}
1066
1067 #ifdef TIXML_USE_STL
1069 TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT)
1070 {
1071 SetValue( initValue );
1072 cdata = false;
1073 }
1074 #endif
1075
1076 TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT ) { copy.CopyTo( this ); }
1077 void operator=( const TiXmlText& base ) { base.CopyTo( this ); }
1078
1080 virtual void Print(const Ptr<IO::TextWriter>& textWriter, int depth) const;
1081
1083 bool CDATA() { return cdata; }
1085 void SetCDATA( bool _cdata ) { cdata = _cdata; }
1086
1088 bool Raw() { return raw; }
1090 void SetRaw( bool _raw ) { raw = _raw; }
1091
1092 virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1093
1094 virtual const TiXmlText* ToText() const { return this; }
1095 virtual TiXmlText* ToText() { return this; }
1096
1097protected :
1099 virtual TiXmlNode* Clone() const;
1100 void CopyTo( TiXmlText* target ) const;
1101
1102 virtual void StreamOut ( TIXML_OSTREAM * out ) const;
1103 bool Blank() const; // returns true if all white space and new lines
1104 // [internal use]
1105 #ifdef TIXML_USE_STL
1106 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
1107 #endif
1108
1109private:
1110 bool cdata; // true if this should be input and output as a CDATA style text element
1111 bool raw; // true if this text node should not prase the text information and just output it as raw
1112};
1113
1114
1129{
1130public:
1133
1134#ifdef TIXML_USE_STL
1136 TiXmlDeclaration( const std::string& _version,
1137 const std::string& _encoding,
1138 const std::string& _standalone );
1139#endif
1140
1142 TiXmlDeclaration( const char* _version,
1143 const char* _encoding,
1144 const char* _standalone );
1145
1146 TiXmlDeclaration( const TiXmlDeclaration& copy );
1147 void operator=( const TiXmlDeclaration& copy );
1148
1150
1152 const char *Version() const { return version.c_str (); }
1154 const char *Encoding() const { return encoding.c_str (); }
1156 const char *Standalone() const { return standalone.c_str (); }
1157
1159 virtual TiXmlNode* Clone() const;
1161 virtual void Print(const Ptr<IO::TextWriter>& textWriter, int depth) const;
1162
1163 virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1164
1165 virtual const TiXmlDeclaration* ToDeclaration() const { return this; }
1166 virtual TiXmlDeclaration* ToDeclaration() { return this; }
1167
1168protected:
1169 void CopyTo( TiXmlDeclaration* target ) const;
1170 // used to be public
1171 #ifdef TIXML_USE_STL
1172 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
1173 #endif
1174 virtual void StreamOut ( TIXML_OSTREAM * out) const;
1175
1176private:
1177
1181};
1182
1183
1192{
1193public:
1195 virtual ~TiXmlUnknown() {}
1196
1197 TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN ) { copy.CopyTo( this ); }
1198 void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); }
1199
1201 virtual TiXmlNode* Clone() const;
1203 virtual void Print(const Ptr<IO::TextWriter>& textWriter, int depth) const;
1204
1205 virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
1206
1207 virtual const TiXmlUnknown* ToUnknown() const { return this; }
1208 virtual TiXmlUnknown* ToUnknown() { return this; }
1209
1210protected:
1211 void CopyTo( TiXmlUnknown* target ) const;
1212
1213 #ifdef TIXML_USE_STL
1214 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
1215 #endif
1216 virtual void StreamOut ( TIXML_OSTREAM * out ) const;
1217
1218private:
1219
1220};
1221
1222
1228{
1229public:
1231 TiXmlDocument();
1232
1233 TiXmlDocument( const TiXmlDocument& copy );
1234 void operator=( const TiXmlDocument& copy );
1235
1236 virtual ~TiXmlDocument() {}
1237
1243 bool LoadStream(const Ptr<IO::Stream>& stream, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1245 bool SaveStream(const Ptr<IO::Stream>& stream) const;
1246
1247 #ifdef TIXML_USE_STL
1248 bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING )
1249 {
1250 StringToBuffer f( filename );
1251 return ( f.buffer && LoadFile( f.buffer, encoding ));
1252 }
1253 bool SaveFile( const std::string& filename ) const
1254 {
1255 StringToBuffer f( filename );
1256 return ( f.buffer && SaveFile( f.buffer ));
1257 }
1258 #endif
1259
1264 virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
1265
1270 const TiXmlElement* RootElement() const { return FirstChildElement(); }
1272
1278 bool Error() const { return error; }
1279
1281 const char * ErrorDesc() const { return errorDesc.c_str (); }
1282
1286 int ErrorId() const { return errorId; }
1287
1295 int ErrorRow() { return errorLocation.row+1; }
1296 int ErrorCol() { return errorLocation.col+1; }
1297
1322 void SetTabSize( int _tabsize ) { tabsize = _tabsize; }
1323
1324 int TabSize() const { return tabsize; }
1325
1329 void ClearError() { error = false;
1330 errorId = 0;
1331 errorDesc = "";
1333 //errorLocation.last = 0;
1334 }
1335
1337 virtual void Print(const Ptr<IO::TextWriter>& textWriter, int depth = 0) const;
1338 // [internal use]
1339 void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding );
1340
1341 virtual const TiXmlDocument* ToDocument() const { return this; }
1342 virtual TiXmlDocument* ToDocument() { return this; }
1343
1344protected :
1345 virtual void StreamOut ( TIXML_OSTREAM * out) const;
1346 // [internal use]
1347 virtual TiXmlNode* Clone() const;
1348 #ifdef TIXML_USE_STL
1349 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
1350 #endif
1351
1352private:
1353 void CopyTo( TiXmlDocument* target ) const;
1354
1355 bool error;
1360 bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write.
1361};
1362
1363
1445{
1446public:
1448 TiXmlHandle( TiXmlNode* _node ) { this->node = _node; }
1450 TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; }
1451 TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; }
1452
1454 TiXmlHandle FirstChild() const;
1456 TiXmlHandle FirstChild( const char * value ) const;
1460 TiXmlHandle FirstChildElement( const char * value ) const;
1461
1465 TiXmlHandle Child( const char* value, int index ) const;
1469 TiXmlHandle Child( int index ) const;
1474 TiXmlHandle ChildElement( const char* value, int index ) const;
1479 TiXmlHandle ChildElement( int index ) const;
1480
1481 #ifdef TIXML_USE_STL
1482 TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); }
1483 TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); }
1484
1485 TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); }
1486 TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); }
1487 #endif
1488
1490 TiXmlNode* Node() const { return node; }
1492 TiXmlElement* Element() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
1494 TiXmlText* Text() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
1496 TiXmlUnknown* Unknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
1497
1498private:
1500};
1501
1502#endif
1503
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition ptr.h:38
An attribute is a name-value pair.
Definition tinyxml.h:696
void SetDoubleValue(double _value)
Set the value from a double.
Definition tinyxml.cc:1240
const char * Value() const
Return the value of this attribute.
Definition tinyxml.h:728
void SetValue(const char *_value)
Set the value.
Definition tinyxml.h:749
const TIXML_STRING & NameTStr() const
Definition tinyxml.h:733
bool operator==(const TiXmlAttribute &rhs) const
Definition tinyxml.h:768
bool operator>(const TiXmlAttribute &rhs) const
Definition tinyxml.h:770
int QueryIntValue(int *_value) const
QueryIntValue examines the value string.
Definition tinyxml.cc:1215
int QueryDoubleValue(double *_value) const
QueryDoubleValue examines the value string. See QueryIntValue().
Definition tinyxml.cc:1222
TiXmlAttribute(const char *_name, const char *_value)
Construct an attribute with a name and value.
Definition tinyxml.h:719
void SetIntValue(int _value)
Set the value from an integer.
Definition tinyxml.cc:1229
bool operator<(const TiXmlAttribute &rhs) const
Definition tinyxml.h:769
const char * Name() const
Return the name of this attribute.
Definition tinyxml.h:727
void operator=(const TiXmlAttribute &base)
double DoubleValue() const
Return the value of this attribute, converted to a double.
Definition tinyxml.cc:1256
TiXmlAttribute()
Construct an empty attribute.
Definition tinyxml.h:701
TiXmlAttribute * prev
Definition tinyxml.h:792
void SetName(const char *_name)
Set the name of this attribute.
Definition tinyxml.h:748
virtual void Print(const Ptr< IO::TextWriter > &textWriter, int depth) const
All TinyXml classes can print themselves to a filestream.
Definition tinyxml.cc:1183
void SetDocument(TiXmlDocument *doc)
Definition tinyxml.h:783
int IntValue() const
Return the value of this attribute, converted to an integer.
Definition tinyxml.cc:1251
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
Definition tinyxmlparser.cc:1326
TiXmlDocument * document
Definition tinyxml.h:789
virtual void StreamOut(TIXML_OSTREAM *out) const
Definition tinyxml.cc:1197
TiXmlAttribute * next
Definition tinyxml.h:793
TIXML_STRING value
Definition tinyxml.h:791
TiXmlAttribute(const TiXmlAttribute &)
const TiXmlAttribute * Next() const
Get the next sibling attribute in the DOM. Returns null at end.
Definition tinyxml.cc:1147
const TiXmlAttribute * Previous() const
Get the previous sibling attribute in the DOM. Returns null at beginning.
Definition tinyxml.cc:1165
TIXML_STRING name
Definition tinyxml.h:790
Definition tinyxml.h:810
TiXmlAttribute sentinel
Definition tinyxml.h:832
TiXmlAttributeSet()
Definition tinyxml.cc:1504
TiXmlAttribute * First()
Definition tinyxml.h:819
TiXmlAttribute * Last()
Definition tinyxml.h:821
void Add(TiXmlAttribute *attribute)
Definition tinyxml.cc:1518
void Remove(TiXmlAttribute *attribute)
Definition tinyxml.cc:1529
void operator=(const TiXmlAttributeSet &)
const TiXmlAttribute * First() const
Definition tinyxml.h:818
TiXmlAttributeSet(const TiXmlAttributeSet &)
const TiXmlAttribute * Last() const
Definition tinyxml.h:820
~TiXmlAttributeSet()
Definition tinyxml.cc:1511
const TiXmlAttribute * Find(const TIXML_STRING &name) const
Definition tinyxml.cc:1547
Definition tinyxml.h:238
char * buffer
Definition tinyxml.h:242
~StringToBuffer()
Definition tinyxml.cc:138
StringToBuffer(const TIXML_STRING &str)
Definition tinyxml.cc:128
TiXmlBase is a base class for every class in TinyXml.
Definition tinyxml.h:152
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
Definition tinyxmlparser.cc:87
TiXmlCursor location
Definition tinyxml.h:337
static void SetCondenseWhiteSpace(bool condense)
The world does not agree on whether white space should be kept or not.
Definition tinyxml.h:174
void operator=(const TiXmlBase &base)
static const char * ReadName(const char *p, TIXML_STRING *name, TiXmlEncoding encoding)
Definition tinyxmlparser.cc:397
friend class TiXmlNode
Definition tinyxml.h:153
virtual void StreamOut(TIXML_OSTREAM *) const =0
static int IsAlphaNum(unsigned char anyByte, TiXmlEncoding encoding)
Definition tinyxmlparser.cc:149
static bool IsWhiteSpace(int c)
Definition tinyxml.h:250
void * GetUserData()
Definition tinyxml.h:201
static bool condenseWhiteSpace
Definition tinyxml.h:377
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
Definition tinyxmlparser.cc:521
static void PutString(const TIXML_STRING &str, TIXML_OSTREAM *out)
Definition tinyxml.cc:36
static const char * GetChar(const char *p, char *_value, int *length, TiXmlEncoding encoding)
Definition tinyxml.h:285
TiXmlBase(const TiXmlBase &)
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0
virtual void Print(const Ptr< IO::TextWriter > &textWriter, int depth) const =0
All TinyXml classes can print themselves to a filestream.
static int ToLower(int v, TiXmlEncoding encoding)
Definition tinyxml.h:346
static const char * errorString[TIXML_ERROR_STRING_COUNT]
Definition tinyxml.h:34
static const char * ReadText(const char *in, TIXML_STRING *text, bool ignoreWhiteSpace, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
Definition tinyxmlparser.cc:561
@ NUM_ENTITY
Definition tinyxml.h:372
@ MAX_ENTITY_LENGTH
Definition tinyxml.h:373
static Entity entity[NUM_ENTITY]
Definition tinyxml.h:42
void * userData
Field containing a generic user pointer.
Definition tinyxml.h:340
static const char * SkipWhiteSpace(const char *, TiXmlEncoding encoding)
Definition tinyxmlparser.cc:313
static const char * GetEntity(const char *in, char *value, int *length, TiXmlEncoding encoding)
Definition tinyxmlparser.cc:427
TiXmlBase()
Definition tinyxml.h:158
void SetUserData(void *user)
Definition tinyxml.h:200
static const int utf8ByteTable[256]
Definition tinyxml.h:65
int Row() const
Return the position, in the original source file, of this node or attribute.
Definition tinyxml.h:197
virtual ~TiXmlBase()
Definition tinyxml.h:159
int Column() const
See Row()
Definition tinyxml.h:198
static bool IsWhiteSpaceCondensed()
Return the current white space setting.
Definition tinyxml.h:177
static int IsAlpha(unsigned char anyByte, TiXmlEncoding encoding)
Definition tinyxmlparser.cc:128
static bool IsWhiteSpace(char c)
Definition tinyxml.h:246
@ TIXML_ERROR_STRING_COUNT
Definition tinyxml.h:230
@ TIXML_ERROR_READING_END_TAG
Definition tinyxml.h:222
@ TIXML_ERROR_PARSING_UNKNOWN
Definition tinyxml.h:223
@ TIXML_ERROR_PARSING_DECLARATION
Definition tinyxml.h:225
@ TIXML_ERROR_PARSING_ELEMENT
Definition tinyxml.h:217
@ TIXML_ERROR_PARSING_EMPTY
Definition tinyxml.h:221
@ TIXML_ERROR_READING_ATTRIBUTES
Definition tinyxml.h:220
@ TIXML_ERROR_PARSING_COMMENT
Definition tinyxml.h:224
@ TIXML_NO_ERROR
Definition tinyxml.h:213
@ TIXML_ERROR_OUT_OF_MEMORY
Definition tinyxml.h:216
@ TIXML_ERROR_PARSING_CDATA
Definition tinyxml.h:228
@ TIXML_ERROR_DOCUMENT_EMPTY
Definition tinyxml.h:226
@ TIXML_ERROR_OPENING_FILE
Definition tinyxml.h:215
@ TIXML_ERROR
Definition tinyxml.h:214
@ TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME
Definition tinyxml.h:218
@ TIXML_ERROR_EMBEDDED_NULL
Definition tinyxml.h:227
@ TIXML_ERROR_READING_ELEMENT_VALUE
Definition tinyxml.h:219
An XML comment.
Definition tinyxml.h:1011
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null not of the requested type.
Definition tinyxml.h:1030
virtual TiXmlNode * Clone() const
Returns a copy of this Comment.
Definition tinyxml.cc:1299
virtual ~TiXmlComment()
Definition tinyxml.h:1018
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
Definition tinyxmlparser.cc:1300
virtual void StreamOut(TIXML_OSTREAM *out) const
Definition tinyxml.cc:1284
void operator=(const TiXmlComment &base)
Definition tinyxml.cc:1268
virtual void Print(const Ptr< IO::TextWriter > &textWriter, int depth) const
Write this Comment to a FILE stream.
Definition tinyxml.cc:1275
TiXmlComment()
Constructs an empty comment.
Definition tinyxml.h:1014
void CopyTo(TiXmlComment *target) const
Definition tinyxml.cc:1293
virtual TiXmlComment * ToComment()
Cast to a more defined type. Will return null not of the requested type.
Definition tinyxml.h:1031
In correct XML the declaration is the first entry in the file.
Definition tinyxml.h:1129
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null not of the requested type.
Definition tinyxml.h:1166
void operator=(const TiXmlDeclaration &copy)
Definition tinyxml.cc:1405
const char * Standalone() const
Is this a standalone document?
Definition tinyxml.h:1156
void CopyTo(TiXmlDeclaration *target) const
Definition tinyxml.cc:1450
TIXML_STRING encoding
Definition tinyxml.h:1179
virtual TiXmlNode * Clone() const
Creates a copy of this Declaration and returns it.
Definition tinyxml.cc:1460
TIXML_STRING standalone
Definition tinyxml.h:1180
const char * Encoding() const
Encoding. Will return an empty string if none was found.
Definition tinyxml.h:1154
virtual void StreamOut(TIXML_OSTREAM *out) const
Definition tinyxml.cc:1424
virtual void Print(const Ptr< IO::TextWriter > &textWriter, int depth) const
Print this declaration to a FILE stream.
Definition tinyxml.cc:1412
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
Definition tinyxmlparser.cc:1514
TiXmlDeclaration()
Construct an empty declaration.
Definition tinyxml.h:1132
const char * Version() const
Version. Will return an empty string if none was found.
Definition tinyxml.h:1152
TIXML_STRING version
Definition tinyxml.h:1178
virtual ~TiXmlDeclaration()
Definition tinyxml.h:1149
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null not of the requested type.
Definition tinyxml.h:1165
Always the top level node.
Definition tinyxml.h:1228
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
Definition tinyxml.h:1281
int ErrorRow()
Returns the location (if known) of the error.
Definition tinyxml.h:1295
virtual ~TiXmlDocument()
Definition tinyxml.h:1236
bool error
Definition tinyxml.h:1355
TIXML_STRING errorDesc
Definition tinyxml.h:1357
virtual void Print(const Ptr< IO::TextWriter > &textWriter, int depth=0) const
Print this Document to a FILE stream.
Definition tinyxml.cc:1121
bool Error() const
If an error occurs, Error will be set to true.
Definition tinyxml.h:1278
virtual TiXmlNode * Clone() const
Create an exact duplicate of this node and return it.
Definition tinyxml.cc:1110
bool useMicrosoftBOM
Definition tinyxml.h:1360
void SetTabSize(int _tabsize)
SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) to report the correct v...
Definition tinyxml.h:1322
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null not of the requested type.
Definition tinyxml.h:1342
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
Definition tinyxmlparser.cc:783
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null not of the requested type.
Definition tinyxml.h:1341
bool LoadStream(const Ptr< IO::Stream > &stream, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Load a file using the given FILE*.
Definition tinyxml.cc:962
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.cc:689
int TabSize() const
Definition tinyxml.h:1324
virtual void StreamOut(TIXML_OSTREAM *out) const
Definition tinyxml.cc:1131
TiXmlDocument()
Create an empty document, that has no name.
Definition tinyxml.cc:942
TiXmlCursor errorLocation
Definition tinyxml.h:1359
void CopyTo(TiXmlDocument *target) const
Definition tinyxml.cc:1095
void operator=(const TiXmlDocument &copy)
Definition tinyxml.cc:955
const TiXmlElement * RootElement() const
Get the root element – the only top level element – of the document.
Definition tinyxml.h:1270
TiXmlElement * RootElement()
Definition tinyxml.h:1271
int ErrorId() const
Generally, you probably want the error string ( ErrorDesc() ).
Definition tinyxml.h:1286
void ClearError()
If you have handled the error, it can be reset with this call.
Definition tinyxml.h:1329
int errorId
Definition tinyxml.h:1356
int ErrorCol()
The column where the error occured. See ErrorRow()
Definition tinyxml.h:1296
int tabsize
Definition tinyxml.h:1358
bool SaveStream(const Ptr< IO::Stream > &stream) const
Save a file using the given FILE*. Returns true if successful.
Definition tinyxml.cc:1072
The element is a container class.
Definition tinyxml.h:841
TiXmlAttribute * FirstAttribute()
Definition tinyxml.h:934
void SetDoubleAttribute(const char *name, double value)
Sets an attribute of name to a given value.
Definition tinyxml.cc:751
int QueryFloatAttribute(const char *name, float *_value) const
QueryFloatAttribute examines the attribute - see QueryIntAttribute().
Definition tinyxml.h:889
void ClearThis()
Definition tinyxml.cc:655
void RemoveAttribute(const char *name)
Deletes an attribute with the given name.
Definition tinyxml.cc:468
TiXmlAttributeSet attributeSet
Definition tinyxml.h:1004
int QueryIntAttribute(const char *name, int *_value) const
QueryIntAttribute examines the attribute - it is an alternative to the Attribute() method with richer...
Definition tinyxml.cc:707
const char * Attribute(const char *name) const
Given an attribute name, Attribute() returns the value for the attribute of that name,...
Definition tinyxml.cc:667
TiXmlAttribute * LastAttribute()
Definition tinyxml.h:936
virtual TiXmlNode * Clone() const
Creates a new Element and returns it - the returned element is a copy.
Definition tinyxml.cc:918
virtual ~TiXmlElement()
Definition tinyxml.cc:649
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
Definition tinyxml.h:982
void CopyTo(TiXmlElement *target) const
Definition tinyxml.cc:895
void SetAttribute(const char *name, const char *_value)
Sets an attribute of name to a given value.
Definition tinyxml.cc:763
const char * ReadValue(const char *in, TiXmlParsingData *prevData, TiXmlEncoding encoding)
Definition tinyxmlparser.cc:1142
const TiXmlAttribute * FirstAttribute() const
Access the first attribute in this element.
Definition tinyxml.h:933
virtual void StreamOut(TIXML_OSTREAM *out) const
Definition tinyxml.cc:864
const TiXmlAttribute * LastAttribute() const
Access the last attribute in this element.
Definition tinyxml.h:935
int QueryDoubleAttribute(const char *name, double *_value) const
QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
Definition tinyxml.cc:718
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null not of the requested type.
Definition tinyxml.h:983
const char * GetText() const
Convenience function for easy access to the text inside an element.
Definition tinyxml.cc:929
void operator=(const TiXmlElement &base)
Definition tinyxml.cc:642
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
Definition tinyxmlparser.cc:1022
virtual void Print(const Ptr< IO::TextWriter > &textWriter, int depth) const
All TinyXml classes can print themselves to a filestream.
Definition tinyxml.cc:812
A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thi...
Definition tinyxml.h:1445
TiXmlHandle(const TiXmlHandle &ref)
Copy constructor.
Definition tinyxml.h:1450
TiXmlText * Text() const
Return the handle as a TiXmlText. This may return null.
Definition tinyxml.h:1494
TiXmlHandle Child(const char *value, int index) const
Return a handle to the "index" child with the given name.
Definition tinyxml.cc:1670
TiXmlUnknown * Unknown() const
Return the handle as a TiXmlUnknown. This may return null;.
Definition tinyxml.h:1496
TiXmlHandle(TiXmlNode *_node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition tinyxml.h:1448
TiXmlNode * node
Definition tinyxml.h:1499
TiXmlElement * Element() const
Return the handle as a TiXmlElement. This may return null.
Definition tinyxml.h:1492
TiXmlHandle operator=(const TiXmlHandle &ref)
Definition tinyxml.h:1451
TiXmlHandle FirstChildElement() const
Return a handle to the first child element.
Definition tinyxml.cc:1627
TiXmlNode * Node() const
Return the handle as a TiXmlNode. This may return null.
Definition tinyxml.h:1490
TiXmlHandle FirstChild() const
Return a handle to the first child node.
Definition tinyxml.cc:1603
TiXmlHandle ChildElement(const char *value, int index) const
Return a handle to the "index" child element with the given name.
Definition tinyxml.cc:1708
The parent class for everything in the Document Object Model.
Definition tinyxml.h:388
virtual ~TiXmlNode()
Definition tinyxml.cc:156
int Type() const
Query the type (as an enumerated value, above) of this node.
Definition tinyxml.h:626
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null if not of the requested type.
Definition tinyxml.h:639
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
Definition tinyxml.cc:479
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
Add a new node related to this.
Definition tinyxml.cc:194
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
Definition tinyxml.h:641
NodeType type
Definition tinyxml.h:672
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
Add a new node related to this.
Definition tinyxml.cc:250
void SetValue(const char *_value)
Changes the value of the node.
Definition tinyxml.h:473
TiXmlNode * next
Definition tinyxml.h:680
const TiXmlNode * Parent() const
Definition tinyxml.h:485
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
Definition tinyxml.h:568
const char * Value() const
The meaning of 'value' changes for the specific type of TiXmlNode.
Definition tinyxml.h:454
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
Definition tinyxml.h:583
TiXmlNode * LastChild()
The last child of this node. Will be null if there are no children.
Definition tinyxml.h:493
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
Replace a child of this node.
Definition tinyxml.cc:276
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null if not of the requested type.
Definition tinyxml.h:642
TiXmlNode * lastChild
Definition tinyxml.h:675
TiXmlNode(const TiXmlNode &)
TiXmlNode * parent
Definition tinyxml.h:671
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
An alternate way to walk the children of a node.
Definition tinyxml.cc:372
virtual TiXmlComment * ToComment()
Cast to a more defined type. Will return null if not of the requested type.
Definition tinyxml.h:646
void Clear()
Delete all the children of this node. Does not affect 'this'.
Definition tinyxml.cc:177
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
Add a new node related to this.
Definition tinyxml.cc:224
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null if not of the requested type.
Definition tinyxml.h:644
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
Definition tinyxml.h:637
NodeType
The types of XML nodes supported by TinyXml.
Definition tinyxml.h:430
@ DOCUMENT
Definition tinyxml.h:431
@ TEXT
Definition tinyxml.h:435
@ COMMENT
Definition tinyxml.h:433
@ TYPECOUNT
Definition tinyxml.h:437
@ ELEMENT
Definition tinyxml.h:432
@ DECLARATION
Definition tinyxml.h:436
@ UNKNOWN
Definition tinyxml.h:434
virtual TiXmlNode * Clone() const =0
Create an exact duplicate of this node and return it.
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null if not of the requested type.
Definition tinyxml.h:649
TiXmlNode * FirstChild()
Definition tinyxml.h:488
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null if not of the requested type.
Definition tinyxml.h:648
const TiXmlNode * LastChild() const
Definition tinyxml.h:492
TiXmlNode * Parent()
One step up the DOM.
Definition tinyxml.h:484
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null if not of the requested type.
Definition tinyxml.h:640
TiXmlNode * prev
Definition tinyxml.h:679
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null if not of the requested type.
Definition tinyxml.h:647
void operator=(const TiXmlNode &base)
void CopyTo(TiXmlNode *target) const
Definition tinyxml.cc:170
friend class TiXmlElement
Definition tinyxml.h:390
bool NoChildren() const
Returns true if this node has no children.
Definition tinyxml.h:635
friend TIXML_OSTREAM & operator<<(TIXML_OSTREAM &out, const TiXmlNode &base)
Definition tinyxml.cc:1584
TiXmlNode * Identify(const char *start, TiXmlEncoding encoding)
Definition tinyxmlparser.cc:803
const TiXmlElement * NextSiblingElement() const
Convenience function to get through elements.
Definition tinyxml.cc:535
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null if not of the requested type.
Definition tinyxml.h:645
TiXmlNode * PreviousSibling()
Definition tinyxml.h:569
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
Definition tinyxml.h:638
const TiXmlDocument * GetDocument() const
Return a pointer to the Document this node lives in.
Definition tinyxml.cc:592
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
Definition tinyxml.cc:304
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
Definition tinyxml.h:487
TIXML_STRING value
Definition tinyxml.h:677
TiXmlNode * NextSibling()
Definition tinyxml.h:584
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
Add a new node related to this.
Definition tinyxml.cc:214
TiXmlNode * firstChild
Definition tinyxml.h:674
Definition tinyxmlparser.cc:171
XML text.
Definition tinyxml.h:1053
bool Blank() const
Definition tinyxmlparser.cc:1573
bool cdata
Definition tinyxml.h:1110
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null not of the requested type.
Definition tinyxml.h:1095
void CopyTo(TiXmlText *target) const
Definition tinyxml.cc:1353
bool CDATA()
Queries whether this represents text using a CDATA section.
Definition tinyxml.h:1083
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null not of the requested type.
Definition tinyxml.h:1094
virtual ~TiXmlText()
Definition tinyxml.h:1065
TiXmlText(const TiXmlText &copy)
Definition tinyxml.h:1076
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
Definition tinyxmlparser.cc:1440
void SetRaw(bool _raw)
Turns on or off a raw representation of text.
Definition tinyxml.h:1090
virtual TiXmlNode * Clone() const
[internal use] Creates a new Element and returns it.
Definition tinyxml.cc:1361
void SetCDATA(bool _cdata)
Turns on or off a CDATA representation of text.
Definition tinyxml.h:1085
virtual void Print(const Ptr< IO::TextWriter > &textWriter, int depth) const
Write this text object to a FILE stream.
Definition tinyxml.cc:1311
virtual void StreamOut(TIXML_OSTREAM *out) const
Definition tinyxml.cc:1340
bool Raw()
Queries whether the text in this node is raw, meaning that it shouldn't be treated by any encoding.
Definition tinyxml.h:1088
bool raw
Definition tinyxml.h:1111
void operator=(const TiXmlText &base)
Definition tinyxml.h:1077
TiXmlText(const char *initValue)
Constructor for text element.
Definition tinyxml.h:1060
Any tag that tinyXml doesn't recognize is saved as an unknown.
Definition tinyxml.h:1192
virtual TiXmlNode * Clone() const
Creates a copy of this Unknown and returns it.
Definition tinyxml.cc:1492
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null not of the requested type.
Definition tinyxml.h:1208
void operator=(const TiXmlUnknown &copy)
Definition tinyxml.h:1198
virtual void Print(const Ptr< IO::TextWriter > &textWriter, int depth) const
Print this Unknown to a FILE stream.
Definition tinyxml.cc:1472
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null not of the requested type.
Definition tinyxml.h:1207
TiXmlUnknown()
Definition tinyxml.h:1194
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
Definition tinyxmlparser.cc:1239
virtual void StreamOut(TIXML_OSTREAM *out) const
Definition tinyxml.cc:1480
TiXmlUnknown(const TiXmlUnknown &copy)
Definition tinyxml.h:1197
virtual ~TiXmlUnknown()
Definition tinyxml.h:1195
void CopyTo(TiXmlUnknown *target) const
Definition tinyxml.cc:1486
bool SaveFile(Util::String const &title, const IO::URI &start, std::initializer_list< const char * >const &filters, Util::String &path)
Save file dialog.
Definition filedialog.cc:67
Definition tinyxml.h:365
unsigned int strLength
Definition tinyxml.h:367
char chr
Definition tinyxml.h:368
const char * str
Definition tinyxml.h:366
Definition tinyxml.h:101
void Clear()
Definition tinyxml.h:103
int col
Definition tinyxml.h:106
int row
Definition tinyxml.h:105
TiXmlCursor()
Definition tinyxml.h:102
const int TIXML_PATCH_VERSION
Definition tinyxml.h:95
const int TIXML_MAJOR_VERSION
Definition tinyxml.h:93
const int TIXML_MINOR_VERSION
Definition tinyxml.h:94
#define TIXML_OSTREAM
Definition tinyxml.h:57
TiXmlEncoding
Definition tinyxml.h:121
@ TIXML_ENCODING_UNKNOWN
Definition tinyxml.h:122
@ TIXML_ENCODING_LEGACY
Definition tinyxml.h:124
@ TIXML_ENCODING_UTF8
Definition tinyxml.h:123
#define TIXML_STRING
Definition tinyxml.h:56
@ TIXML_WRONG_TYPE
Definition tinyxml.h:115
@ TIXML_SUCCESS
Definition tinyxml.h:113
@ TIXML_NO_ATTRIBUTE
Definition tinyxml.h:114
const TiXmlEncoding TIXML_DEFAULT_ENCODING
Definition tinyxml.h:127