Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
tinyxml.cc
Go to the documentation of this file.
1/*
2www.sourceforge.net/projects/tinyxml
3Original code by 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#include <ctype.h>
26
27#ifdef TIXML_USE_STL
28#include <sstream>
29#include <iostream>
30#endif
31
32#include "Xml/tinyxml.h" // Altered path
33
34namespace pandora // Added namespace
35{
36
37FILE* TiXmlFOpen( const char* filename, const char* mode );
38
40
41// Microsoft compiler security
42FILE* TiXmlFOpen( const char* filename, const char* mode )
43{
44 #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
45 FILE* fp = 0;
46 errno_t err = fopen_s( &fp, filename, mode );
47 if ( !err && fp )
48 return fp;
49 return 0;
50 #else
51 return fopen( filename, mode );
52 #endif
53}
54
56{
57 int i=0;
58
59 while( i<(int)str.length() )
60 {
61 unsigned char c = (unsigned char) str[i];
62
63 if ( c == '&'
64 && i < ( (int)str.length() - 2 )
65 && str[i+1] == '#'
66 && str[i+2] == 'x' )
67 {
68 // Hexadecimal character reference.
69 // Pass through unchanged.
70 // &#xA9; -- copyright symbol, for example.
71 //
72 // The -1 is a bug fix from Rob Laveaux. It keeps
73 // an overflow from happening if there is no ';'.
74 // There are actually 2 ways to exit this loop -
75 // while fails (error case) and break (semicolon found).
76 // However, there is no mechanism (currently) for
77 // this function to return an error.
78 while ( i<(int)str.length()-1 )
79 {
80 outString->append( str.c_str() + i, 1 );
81 ++i;
82 if ( str[i] == ';' )
83 break;
84 }
85 }
86 else if ( c == '&' )
87 {
88 outString->append( entity[0].str, entity[0].strLength );
89 ++i;
90 }
91 else if ( c == '<' )
92 {
93 outString->append( entity[1].str, entity[1].strLength );
94 ++i;
95 }
96 else if ( c == '>' )
97 {
98 outString->append( entity[2].str, entity[2].strLength );
99 ++i;
100 }
101 else if ( c == '\"' )
102 {
103 outString->append( entity[3].str, entity[3].strLength );
104 ++i;
105 }
106 else if ( c == '\'' )
107 {
108 outString->append( entity[4].str, entity[4].strLength );
109 ++i;
110 }
111 else if ( c < 32 )
112 {
113 // Easy pass at non-alpha/numeric/symbol
114 // Below 32 is symbolic.
115 char buf[ 32 ];
116
117 #if defined(TIXML_SNPRINTF)
118 TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) );
119 #else
120 sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) );
121 #endif
122
123 //*ME: warning C4267: convert 'size_t' to 'int'
124 //*ME: Int-Cast to make compiler happy ...
125 outString->append( buf, (int)strlen( buf ) );
126 ++i;
127 }
128 else
129 {
130 //char realc = (char) c;
131 //outString->append( &realc, 1 );
132 *outString += (char) c; // somewhat more efficient function call.
133 ++i;
134 }
135 }
136}
137
138
140{
141 parent = 0;
142 type = _type;
143 firstChild = 0;
144 lastChild = 0;
145 prev = 0;
146 next = 0;
147}
148
149
151{
152 TiXmlNode* node = firstChild;
153 TiXmlNode* temp = 0;
154
155 while ( node )
156 {
157 temp = node;
158 node = node->next;
159 delete temp;
160 }
161}
162
163
164void TiXmlNode::CopyTo( TiXmlNode* target ) const
165{
166 target->SetValue (value.c_str() );
167 target->userData = userData;
168 target->location = location;
169}
170
171
173{
174 TiXmlNode* node = firstChild;
175 TiXmlNode* temp = 0;
176
177 while ( node )
178 {
179 temp = node;
180 node = node->next;
181 delete temp;
182 }
183
184 firstChild = 0;
185 lastChild = 0;
186}
187
188
190{
191 assert( node->parent == 0 || node->parent == this );
192 assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() );
193
194 if ( node->Type() == TiXmlNode::TINYXML_DOCUMENT )
195 {
196 delete node;
197 if ( GetDocument() )
199 return 0;
200 }
201
202 node->parent = this;
203
204 node->prev = lastChild;
205 node->next = 0;
206
207 if ( lastChild )
208 lastChild->next = node;
209 else
210 firstChild = node; // it was an empty list.
211
212 lastChild = node;
213 return node;
214}
215
216
218{
219 if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT )
220 {
221 if ( GetDocument() )
223 return 0;
224 }
225 TiXmlNode* node = addThis.Clone();
226 if ( !node )
227 return 0;
228
229 return LinkEndChild( node );
230}
231
232
234{
235 if ( !beforeThis || beforeThis->parent != this ) {
236 return 0;
237 }
238 if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT )
239 {
240 if ( GetDocument() )
242 return 0;
243 }
244
245 TiXmlNode* node = addThis.Clone();
246 if ( !node )
247 return 0;
248 node->parent = this;
249
250 node->next = beforeThis;
251 node->prev = beforeThis->prev;
252 if ( beforeThis->prev )
253 {
254 beforeThis->prev->next = node;
255 }
256 else
257 {
258 assert( firstChild == beforeThis );
259 firstChild = node;
260 }
261 beforeThis->prev = node;
262 return node;
263}
264
265
267{
268 if ( !afterThis || afterThis->parent != this ) {
269 return 0;
270 }
271 if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT )
272 {
273 if ( GetDocument() )
275 return 0;
276 }
277
278 TiXmlNode* node = addThis.Clone();
279 if ( !node )
280 return 0;
281 node->parent = this;
282
283 node->prev = afterThis;
284 node->next = afterThis->next;
285 if ( afterThis->next )
286 {
287 afterThis->next->prev = node;
288 }
289 else
290 {
291 assert( lastChild == afterThis );
292 lastChild = node;
293 }
294 afterThis->next = node;
295 return node;
296}
297
298
299TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis )
300{
301 if ( !replaceThis )
302 return 0;
303
304 if ( replaceThis->parent != this )
305 return 0;
306
307 if ( withThis.ToDocument() ) {
308 // A document can never be a child. Thanks to Noam.
309 TiXmlDocument* document = GetDocument();
310 if ( document )
312 return 0;
313 }
314
315 TiXmlNode* node = withThis.Clone();
316 if ( !node )
317 return 0;
318
319 node->next = replaceThis->next;
320 node->prev = replaceThis->prev;
321
322 if ( replaceThis->next )
323 replaceThis->next->prev = node;
324 else
325 lastChild = node;
326
327 if ( replaceThis->prev )
328 replaceThis->prev->next = node;
329 else
330 firstChild = node;
331
332 delete replaceThis;
333 node->parent = this;
334 return node;
335}
336
337
339{
340 if ( !removeThis ) {
341 return false;
342 }
343
344 if ( removeThis->parent != this )
345 {
346 assert( 0 );
347 return false;
348 }
349
350 if ( removeThis->next )
351 removeThis->next->prev = removeThis->prev;
352 else
353 lastChild = removeThis->prev;
354
355 if ( removeThis->prev )
356 removeThis->prev->next = removeThis->next;
357 else
358 firstChild = removeThis->next;
359
360 delete removeThis;
361 return true;
362}
363
364const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const
365{
366 const TiXmlNode* node;
367 for ( node = firstChild; node; node = node->next )
368 {
369 if ( strcmp( node->Value(), _value ) == 0 )
370 return node;
371 }
372 return 0;
373}
374
375
376const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const
377{
378 const TiXmlNode* node;
379 for ( node = lastChild; node; node = node->prev )
380 {
381 if ( strcmp( node->Value(), _value ) == 0 )
382 return node;
383 }
384 return 0;
385}
386
387
388const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const
389{
390 if ( !previous )
391 {
392 return FirstChild();
393 }
394 else
395 {
396 assert( previous->parent == this );
397 return previous->NextSibling();
398 }
399}
400
401
402const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const
403{
404 if ( !previous )
405 {
406 return FirstChild( val );
407 }
408 else
409 {
410 assert( previous->parent == this );
411 return previous->NextSibling( val );
412 }
413}
414
415
416const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const
417{
418 const TiXmlNode* node;
419 for ( node = next; node; node = node->next )
420 {
421 if ( strcmp( node->Value(), _value ) == 0 )
422 return node;
423 }
424 return 0;
425}
426
427
428const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const
429{
430 const TiXmlNode* node;
431 for ( node = prev; node; node = node->prev )
432 {
433 if ( strcmp( node->Value(), _value ) == 0 )
434 return node;
435 }
436 return 0;
437}
438
439
440void TiXmlElement::RemoveAttribute( const char * name )
441{
442 #ifdef TIXML_USE_STL
443 TIXML_STRING str( name );
444 TiXmlAttribute* node = attributeSet.Find( str );
445 #else
446 TiXmlAttribute* node = attributeSet.Find( name );
447 #endif
448 if ( node )
449 {
450 attributeSet.Remove( node );
451 delete node;
452 }
453}
454
456{
457 const TiXmlNode* node;
458
459 for ( node = FirstChild();
460 node;
461 node = node->NextSibling() )
462 {
463 if ( node->ToElement() )
464 return node->ToElement();
465 }
466 return 0;
467}
468
469
470const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const
471{
472 const TiXmlNode* node;
473
474 for ( node = FirstChild( _value );
475 node;
476 node = node->NextSibling( _value ) )
477 {
478 if ( node->ToElement() )
479 return node->ToElement();
480 }
481 return 0;
482}
483
484
486{
487 const TiXmlNode* node;
488
489 for ( node = NextSibling();
490 node;
491 node = node->NextSibling() )
492 {
493 if ( node->ToElement() )
494 return node->ToElement();
495 }
496 return 0;
497}
498
499
500const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const
501{
502 const TiXmlNode* node;
503
504 for ( node = NextSibling( _value );
505 node;
506 node = node->NextSibling( _value ) )
507 {
508 if ( node->ToElement() )
509 return node->ToElement();
510 }
511 return 0;
512}
513
514
516{
517 const TiXmlNode* node;
518
519 for( node = this; node; node = node->parent )
520 {
521 if ( node->ToDocument() )
522 return node->ToDocument();
523 }
524 return 0;
525}
526
527
528TiXmlElement::TiXmlElement (const char * _value)
529 : TiXmlNode( TiXmlNode::TINYXML_ELEMENT )
530{
531 firstChild = lastChild = 0;
532 value = _value;
533}
534
535
536#ifdef TIXML_USE_STL
537TiXmlElement::TiXmlElement( const std::string& _value )
538 : TiXmlNode( TiXmlNode::TINYXML_ELEMENT )
539{
540 firstChild = lastChild = 0;
541 value = _value;
542}
543#endif
544
545
547 : TiXmlNode( TiXmlNode::TINYXML_ELEMENT )
548{
549 firstChild = lastChild = 0;
550 copy.CopyTo( this );
551}
552
553
555{
556 ClearThis();
557 base.CopyTo( this );
558 return *this;
559}
560
561
566
567
569{
570 Clear();
571 while( attributeSet.First() )
572 {
574 attributeSet.Remove( node );
575 delete node;
576 }
577}
578
579
580const char* TiXmlElement::Attribute( const char* name ) const
581{
582 const TiXmlAttribute* node = attributeSet.Find( name );
583 if ( node )
584 return node->Value();
585 return 0;
586}
587
588
589#ifdef TIXML_USE_STL
590const std::string* TiXmlElement::Attribute( const std::string& name ) const
591{
592 const TiXmlAttribute* attrib = attributeSet.Find( name );
593 if ( attrib )
594 return &attrib->ValueStr();
595 return 0;
596}
597#endif
598
599
600const char* TiXmlElement::Attribute( const char* name, int* i ) const
601{
602 const TiXmlAttribute* attrib = attributeSet.Find( name );
603 const char* result = 0;
604
605 if ( attrib ) {
606 result = attrib->Value();
607 if ( i ) {
608 attrib->QueryIntValue( i );
609 }
610 }
611 return result;
612}
613
614
615#ifdef TIXML_USE_STL
616const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const
617{
618 const TiXmlAttribute* attrib = attributeSet.Find( name );
619 const std::string* result = 0;
620
621 if ( attrib ) {
622 result = &attrib->ValueStr();
623 if ( i ) {
624 attrib->QueryIntValue( i );
625 }
626 }
627 return result;
628}
629#endif
630
631
632const char* TiXmlElement::Attribute( const char* name, double* d ) const
633{
634 const TiXmlAttribute* attrib = attributeSet.Find( name );
635 const char* result = 0;
636
637 if ( attrib ) {
638 result = attrib->Value();
639 if ( d ) {
640 attrib->QueryDoubleValue( d );
641 }
642 }
643 return result;
644}
645
646
647#ifdef TIXML_USE_STL
648const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const
649{
650 const TiXmlAttribute* attrib = attributeSet.Find( name );
651 const std::string* result = 0;
652
653 if ( attrib ) {
654 result = &attrib->ValueStr();
655 if ( d ) {
656 attrib->QueryDoubleValue( d );
657 }
658 }
659 return result;
660}
661#endif
662
663
664int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const
665{
666 const TiXmlAttribute* attrib = attributeSet.Find( name );
667 if ( !attrib )
668 return TIXML_NO_ATTRIBUTE;
669 return attrib->QueryIntValue( ival );
670}
671
672
673int TiXmlElement::QueryUnsignedAttribute( const char* name, unsigned* thisValue ) const // Renamed argument: value -> thisValue
674{
675 const TiXmlAttribute* node = attributeSet.Find( name );
676 if ( !node )
677 return TIXML_NO_ATTRIBUTE;
678
679 int ival = 0;
680 int result = node->QueryIntValue( &ival );
681 *thisValue = (unsigned)ival;
682 return result;
683}
684
685
686int TiXmlElement::QueryBoolAttribute( const char* name, bool* bval ) const
687{
688 const TiXmlAttribute* node = attributeSet.Find( name );
689 if ( !node )
690 return TIXML_NO_ATTRIBUTE;
691
692 int result = TIXML_WRONG_TYPE;
693 if ( StringEqual( node->Value(), "true", true, TIXML_ENCODING_UNKNOWN )
694 || StringEqual( node->Value(), "yes", true, TIXML_ENCODING_UNKNOWN )
695 || StringEqual( node->Value(), "1", true, TIXML_ENCODING_UNKNOWN ) )
696 {
697 *bval = true;
698 result = TIXML_SUCCESS;
699 }
700 else if ( StringEqual( node->Value(), "false", true, TIXML_ENCODING_UNKNOWN )
701 || StringEqual( node->Value(), "no", true, TIXML_ENCODING_UNKNOWN )
702 || StringEqual( node->Value(), "0", true, TIXML_ENCODING_UNKNOWN ) )
703 {
704 *bval = false;
705 result = TIXML_SUCCESS;
706 }
707 return result;
708}
709
710
711
712#ifdef TIXML_USE_STL
713int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const
714{
715 const TiXmlAttribute* attrib = attributeSet.Find( name );
716 if ( !attrib )
717 return TIXML_NO_ATTRIBUTE;
718 return attrib->QueryIntValue( ival );
719}
720#endif
721
722
723int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const
724{
725 const TiXmlAttribute* attrib = attributeSet.Find( name );
726 if ( !attrib )
727 return TIXML_NO_ATTRIBUTE;
728 return attrib->QueryDoubleValue( dval );
729}
730
731
732#ifdef TIXML_USE_STL
733int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const
734{
735 const TiXmlAttribute* attrib = attributeSet.Find( name );
736 if ( !attrib )
737 return TIXML_NO_ATTRIBUTE;
738 return attrib->QueryDoubleValue( dval );
739}
740#endif
741
742
743void TiXmlElement::SetAttribute( const char * name, int val )
744{
745 TiXmlAttribute* attrib = attributeSet.FindOrCreate( name );
746 if ( attrib ) {
747 attrib->SetIntValue( val );
748 }
749}
750
751
752#ifdef TIXML_USE_STL
753void TiXmlElement::SetAttribute( const std::string& name, int val )
754{
755 TiXmlAttribute* attrib = attributeSet.FindOrCreate( name );
756 if ( attrib ) {
757 attrib->SetIntValue( val );
758 }
759}
760#endif
761
762
763void TiXmlElement::SetDoubleAttribute( const char * name, double val )
764{
765 TiXmlAttribute* attrib = attributeSet.FindOrCreate( name );
766 if ( attrib ) {
767 attrib->SetDoubleValue( val );
768 }
769}
770
771
772#ifdef TIXML_USE_STL
773void TiXmlElement::SetDoubleAttribute( const std::string& name, double val )
774{
775 TiXmlAttribute* attrib = attributeSet.FindOrCreate( name );
776 if ( attrib ) {
777 attrib->SetDoubleValue( val );
778 }
779}
780#endif
781
782
783void TiXmlElement::SetAttribute( const char * cname, const char * cvalue )
784{
785 TiXmlAttribute* attrib = attributeSet.FindOrCreate( cname );
786 if ( attrib ) {
787 attrib->SetValue( cvalue );
788 }
789}
790
791
792#ifdef TIXML_USE_STL
793void TiXmlElement::SetAttribute( const std::string& _name, const std::string& _value )
794{
795 TiXmlAttribute* attrib = attributeSet.FindOrCreate( _name );
796 if ( attrib ) {
797 attrib->SetValue( _value );
798 }
799}
800#endif
801
802
803void TiXmlElement::Print( FILE* cfile, int depth ) const
804{
805 int i;
806 assert( cfile );
807 for ( i=0; i<depth; i++ ) {
808 fprintf( cfile, " " );
809 }
810
811 fprintf( cfile, "<%s", value.c_str() );
812
813 const TiXmlAttribute* attrib;
814 for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
815 {
816 fprintf( cfile, " " );
817 attrib->Print( cfile, depth );
818 }
819
820 // There are 3 different formatting approaches:
821 // 1) An element without children is printed as a <foo /> node
822 // 2) An element with only a text child is printed as <foo> text </foo>
823 // 3) An element with children is printed on multiple lines.
824 TiXmlNode* node;
825 if ( !firstChild )
826 {
827 fprintf( cfile, " />" );
828 }
829 else if ( firstChild == lastChild && firstChild->ToText() )
830 {
831 fprintf( cfile, ">" );
832 firstChild->Print( cfile, depth + 1 );
833 fprintf( cfile, "</%s>", value.c_str() );
834 }
835 else
836 {
837 fprintf( cfile, ">" );
838
839 for ( node = firstChild; node; node=node->NextSibling() )
840 {
841 if ( !node->ToText() )
842 {
843 fprintf( cfile, "\n" );
844 }
845 node->Print( cfile, depth+1 );
846 }
847 fprintf( cfile, "\n" );
848 for( i=0; i<depth; ++i ) {
849 fprintf( cfile, " " );
850 }
851 fprintf( cfile, "</%s>", value.c_str() );
852 }
853}
854
855
857{
858 // superclass:
859 TiXmlNode::CopyTo( target );
860
861 // Element class:
862 // Clone the attributes, then clone the children.
863 const TiXmlAttribute* attribute = 0;
864 for( attribute = attributeSet.First();
865 attribute;
866 attribute = attribute->Next() )
867 {
868 target->SetAttribute( attribute->Name(), attribute->Value() );
869 }
870
871 TiXmlNode* node = 0;
872 for ( node = firstChild; node; node = node->NextSibling() )
873 {
874 target->LinkEndChild( node->Clone() );
875 }
876}
877
878bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const
879{
880 if ( visitor->VisitEnter( *this, attributeSet.First() ) )
881 {
882 for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
883 {
884 if ( !node->Accept( visitor ) )
885 break;
886 }
887 }
888 return visitor->VisitExit( *this );
889}
890
891
893{
894 TiXmlElement* clone = new TiXmlElement( Value() );
895 if ( !clone )
896 return 0;
897
898 CopyTo( clone );
899 return clone;
900}
901
902
903const char* TiXmlElement::GetText() const
904{
905 const TiXmlNode* child = this->FirstChild();
906 if ( child ) {
907 const TiXmlText* childText = child->ToText();
908 if ( childText ) {
909 return childText->Value();
910 }
911 }
912 return 0;
913}
914
915
917{
918 tabsize = 4;
919 useMicrosoftBOM = false;
920 ClearError();
921}
922
923TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT )
924{
925 tabsize = 4;
926 useMicrosoftBOM = false;
927 value = documentName;
928 ClearError();
929}
930
931
932#ifdef TIXML_USE_STL
933TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT )
934{
935 tabsize = 4;
936 useMicrosoftBOM = false;
937 value = documentName;
938 ClearError();
939}
940#endif
941
942
944{
945 copy.CopyTo( this );
946}
947
948
950{
951 Clear();
952 copy.CopyTo( this );
953 return *this;
954}
955
956
958{
959 return LoadFile( Value(), encoding );
960}
961
962
964{
965 return SaveFile( Value() );
966}
967
968bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding )
969{
970 TIXML_STRING filename( _filename );
971 value = filename;
972
973 // reading in binary mode so that tinyxml can normalize the EOL
974 FILE* file = TiXmlFOpen( value.c_str (), "rb" );
975
976 if ( file )
977 {
978 bool result = LoadFile( file, encoding );
979 fclose( file );
980 return result;
981 }
982 else
983 {
985 return false;
986 }
987}
988
989bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding )
990{
991 if ( !file )
992 {
994 return false;
995 }
996
997 // Delete the existing data:
998 Clear();
999 location.Clear();
1000
1001 // Get the file size, so we can pre-allocate the string. HUGE speed impact.
1002 long length = 0;
1003 fseek( file, 0, SEEK_END );
1004 length = ftell( file );
1005 fseek( file, 0, SEEK_SET );
1006
1007 // Strange case, but good to handle up front.
1008 if ( length <= 0 )
1009 {
1011 return false;
1012 }
1013
1014 // Subtle bug here. TinyXml did use fgets. But from the XML spec:
1015 // 2.11 End-of-Line Handling
1016 // <snip>
1017 // <quote>
1018 // ...the XML processor MUST behave as if it normalized all line breaks in external
1019 // parsed entities (including the document entity) on input, before parsing, by translating
1020 // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to
1021 // a single #xA character.
1022 // </quote>
1023 //
1024 // It is not clear fgets does that, and certainly isn't clear it works cross platform.
1025 // Generally, you expect fgets to translate from the convention of the OS to the c/unix
1026 // convention, and not work generally.
1027
1028 /*
1029 while( fgets( buf, sizeof(buf), file ) )
1030 {
1031 data += buf;
1032 }
1033 */
1034
1035 char* buf = new char[ length+1 ];
1036 buf[0] = 0;
1037
1038 if ( fread( buf, length, 1, file ) != 1 ) {
1039 delete [] buf;
1041 return false;
1042 }
1043
1044 // Process the buffer in place to normalize new lines. (See comment above.)
1045 // Copies from the 'p' to 'q' pointer, where p can advance faster if
1046 // a newline-carriage return is hit.
1047 //
1048 // Wikipedia:
1049 // Systems based on ASCII or a compatible character set use either LF (Line feed, '\n', 0x0A, 10 in decimal) or
1050 // CR (Carriage return, '\r', 0x0D, 13 in decimal) individually, or CR followed by LF (CR+LF, 0x0D 0x0A)...
1051 // * LF: Multics, Unix and Unix-like systems (GNU/Linux, AIX, Xenix, Mac OS X, FreeBSD, etc.), BeOS, Amiga, RISC OS, and others
1052 // * CR+LF: DEC RT-11 and most other early non-Unix, non-IBM OSes, CP/M, MP/M, DOS, OS/2, Microsoft Windows, Symbian OS
1053 // * CR: Commodore 8-bit machines, Apple II family, Mac OS up to version 9 and OS-9
1054
1055 const char* p = buf; // the read head
1056 char* q = buf; // the write head
1057 const char CR = 0x0d;
1058 const char LF = 0x0a;
1059
1060 buf[length] = 0;
1061 while( *p ) {
1062 assert( p < (buf+length) );
1063 assert( q <= (buf+length) );
1064 assert( q <= p );
1065
1066 if ( *p == CR ) {
1067 *q++ = LF;
1068 p++;
1069 if ( *p == LF ) { // check for CR+LF (and skip LF)
1070 p++;
1071 }
1072 }
1073 else {
1074 *q++ = *p++;
1075 }
1076 }
1077 assert( q <= (buf+length) );
1078 *q = 0;
1079
1080 Parse( buf, 0, encoding );
1081
1082 delete [] buf;
1083 return !Error();
1084}
1085
1086
1087bool TiXmlDocument::SaveFile( const char * filename ) const
1088{
1089 // The old c stuff lives on...
1090 FILE* fp = TiXmlFOpen( filename, "w" );
1091 if ( fp )
1092 {
1093 bool result = SaveFile( fp );
1094 fclose( fp );
1095 return result;
1096 }
1097 return false;
1098}
1099
1100
1101bool TiXmlDocument::SaveFile( FILE* fp ) const
1102{
1103 if ( useMicrosoftBOM )
1104 {
1105 const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
1106 const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
1107 const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
1108
1109 fputc( TIXML_UTF_LEAD_0, fp );
1110 fputc( TIXML_UTF_LEAD_1, fp );
1111 fputc( TIXML_UTF_LEAD_2, fp );
1112 }
1113 Print( fp, 0 );
1114 return (ferror(fp) == 0);
1115}
1116
1117
1119{
1120 TiXmlNode::CopyTo( target );
1121
1122 target->error = error;
1123 target->errorId = errorId;
1124 target->errorDesc = errorDesc;
1125 target->tabsize = tabsize;
1126 target->errorLocation = errorLocation;
1128
1129 TiXmlNode* node = 0;
1130 for ( node = firstChild; node; node = node->NextSibling() )
1131 {
1132 target->LinkEndChild( node->Clone() );
1133 }
1134}
1135
1136
1138{
1139 TiXmlDocument* clone = new TiXmlDocument();
1140 if ( !clone )
1141 return 0;
1142
1143 CopyTo( clone );
1144 return clone;
1145}
1146
1147
1148void TiXmlDocument::Print( FILE* cfile, int depth ) const
1149{
1150 assert( cfile );
1151 for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
1152 {
1153 node->Print( cfile, depth );
1154 fprintf( cfile, "\n" );
1155 }
1156}
1157
1158
1160{
1161 if ( visitor->VisitEnter( *this ) )
1162 {
1163 for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
1164 {
1165 if ( !node->Accept( visitor ) )
1166 break;
1167 }
1168 }
1169 return visitor->VisitExit( *this );
1170}
1171
1172
1174{
1175 // We are using knowledge of the sentinel. The sentinel
1176 // have a value or name.
1177 if ( next->value.empty() && next->name.empty() )
1178 return 0;
1179 return next;
1180}
1181
1182/*
1183TiXmlAttribute* TiXmlAttribute::Next()
1184{
1185 // We are using knowledge of the sentinel. The sentinel
1186 // have a value or name.
1187 if ( next->value.empty() && next->name.empty() )
1188 return 0;
1189 return next;
1190}
1191*/
1192
1194{
1195 // We are using knowledge of the sentinel. The sentinel
1196 // have a value or name.
1197 if ( prev->value.empty() && prev->name.empty() )
1198 return 0;
1199 return prev;
1200}
1201
1202/*
1203TiXmlAttribute* TiXmlAttribute::Previous()
1204{
1205 // We are using knowledge of the sentinel. The sentinel
1206 // have a value or name.
1207 if ( prev->value.empty() && prev->name.empty() )
1208 return 0;
1209 return prev;
1210}
1211*/
1212
1213void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const
1214{
1215 TIXML_STRING n, v;
1216
1217 EncodeString( name, &n );
1218 EncodeString( value, &v );
1219
1220 if (value.find ('\"') == TIXML_STRING::npos) {
1221 if ( cfile ) {
1222 fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() );
1223 }
1224 if ( str ) {
1225 (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\"";
1226 }
1227 }
1228 else {
1229 if ( cfile ) {
1230 fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() );
1231 }
1232 if ( str ) {
1233 (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'";
1234 }
1235 }
1236}
1237
1238
1239int TiXmlAttribute::QueryIntValue( int* ival ) const
1240{
1241 if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 )
1242 return TIXML_SUCCESS;
1243 return TIXML_WRONG_TYPE;
1244}
1245
1246int TiXmlAttribute::QueryDoubleValue( double* dval ) const
1247{
1248 if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 )
1249 return TIXML_SUCCESS;
1250 return TIXML_WRONG_TYPE;
1251}
1252
1254{
1255 char buf [64];
1256 #if defined(TIXML_SNPRINTF)
1257 TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value);
1258 #else
1259 sprintf (buf, "%d", _value);
1260 #endif
1261 SetValue (buf);
1262}
1263
1265{
1266 char buf [256];
1267 #if defined(TIXML_SNPRINTF)
1268 TIXML_SNPRINTF( buf, sizeof(buf), "%g", _value);
1269 #else
1270 sprintf (buf, "%g", _value);
1271 #endif
1272 SetValue (buf);
1273}
1274
1276{
1277 return atoi (value.c_str ());
1278}
1279
1281{
1282 return atof (value.c_str ());
1283}
1284
1285
1287{
1288 copy.CopyTo( this );
1289}
1290
1291
1293{
1294 Clear();
1295 base.CopyTo( this );
1296 return *this;
1297}
1298
1299
1300void TiXmlComment::Print( FILE* cfile, int depth ) const
1301{
1302 assert( cfile );
1303 for ( int i=0; i<depth; i++ )
1304 {
1305 fprintf( cfile, " " );
1306 }
1307 fprintf( cfile, "<!--%s-->", value.c_str() );
1308}
1309
1310
1312{
1313 TiXmlNode::CopyTo( target );
1314}
1315
1316
1318{
1319 return visitor->Visit( *this );
1320}
1321
1322
1324{
1325 TiXmlComment* clone = new TiXmlComment();
1326
1327 if ( !clone )
1328 return 0;
1329
1330 CopyTo( clone );
1331 return clone;
1332}
1333
1334
1335void TiXmlText::Print( FILE* cfile, int depth ) const
1336{
1337 assert( cfile );
1338 if ( cdata )
1339 {
1340 int i;
1341 fprintf( cfile, "\n" );
1342 for ( i=0; i<depth; i++ ) {
1343 fprintf( cfile, " " );
1344 }
1345 fprintf( cfile, "<![CDATA[%s]]>\n", value.c_str() ); // unformatted output
1346 }
1347 else
1348 {
1349 TIXML_STRING buffer;
1350 EncodeString( value, &buffer );
1351 fprintf( cfile, "%s", buffer.c_str() );
1352 }
1353}
1354
1355
1356void TiXmlText::CopyTo( TiXmlText* target ) const
1357{
1358 TiXmlNode::CopyTo( target );
1359 target->cdata = cdata;
1360}
1361
1362
1363bool TiXmlText::Accept( TiXmlVisitor* visitor ) const
1364{
1365 return visitor->Visit( *this );
1366}
1367
1368
1370{
1371 TiXmlText* clone = 0;
1372 clone = new TiXmlText( "" );
1373
1374 if ( !clone )
1375 return 0;
1376
1377 CopyTo( clone );
1378 return clone;
1379}
1380
1381
1383 const char * _encoding,
1384 const char * _standalone )
1385 : TiXmlNode( TiXmlNode::TINYXML_DECLARATION )
1386{
1387 version = _version;
1388 encoding = _encoding;
1389 standalone = _standalone;
1390}
1391
1392
1393#ifdef TIXML_USE_STL
1394TiXmlDeclaration::TiXmlDeclaration( const std::string& _version,
1395 const std::string& _encoding,
1396 const std::string& _standalone )
1397 : TiXmlNode( TiXmlNode::TINYXML_DECLARATION )
1398{
1399 version = _version;
1400 encoding = _encoding;
1401 standalone = _standalone;
1402}
1403#endif
1404
1405
1407 : TiXmlNode( TiXmlNode::TINYXML_DECLARATION )
1408{
1409 copy.CopyTo( this );
1410}
1411
1412
1414{
1415 Clear();
1416 copy.CopyTo( this );
1417 return *this;
1418}
1419
1420
1421void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const
1422{
1423 if ( cfile ) fprintf( cfile, "<?xml " );
1424 if ( str ) (*str) += "<?xml ";
1425
1426 if ( !version.empty() ) {
1427 if ( cfile ) fprintf (cfile, "version=\"%s\" ", version.c_str ());
1428 if ( str ) { (*str) += "version=\""; (*str) += version; (*str) += "\" "; }
1429 }
1430 if ( !encoding.empty() ) {
1431 if ( cfile ) fprintf (cfile, "encoding=\"%s\" ", encoding.c_str ());
1432 if ( str ) { (*str) += "encoding=\""; (*str) += encoding; (*str) += "\" "; }
1433 }
1434 if ( !standalone.empty() ) {
1435 if ( cfile ) fprintf (cfile, "standalone=\"%s\" ", standalone.c_str ());
1436 if ( str ) { (*str) += "standalone=\""; (*str) += standalone; (*str) += "\" "; }
1437 }
1438 if ( cfile ) fprintf( cfile, "?>" );
1439 if ( str ) (*str) += "?>";
1440}
1441
1442
1444{
1445 TiXmlNode::CopyTo( target );
1446
1447 target->version = version;
1448 target->encoding = encoding;
1449 target->standalone = standalone;
1450}
1451
1452
1454{
1455 return visitor->Visit( *this );
1456}
1457
1458
1460{
1461 TiXmlDeclaration* clone = new TiXmlDeclaration();
1462
1463 if ( !clone )
1464 return 0;
1465
1466 CopyTo( clone );
1467 return clone;
1468}
1469
1470
1471void TiXmlUnknown::Print( FILE* cfile, int depth ) const
1472{
1473 for ( int i=0; i<depth; i++ )
1474 fprintf( cfile, " " );
1475 fprintf( cfile, "<%s>", value.c_str() );
1476}
1477
1478
1480{
1481 TiXmlNode::CopyTo( target );
1482}
1483
1484
1486{
1487 return visitor->Visit( *this );
1488}
1489
1490
1492{
1493 TiXmlUnknown* clone = new TiXmlUnknown();
1494
1495 if ( !clone )
1496 return 0;
1497
1498 CopyTo( clone );
1499 return clone;
1500}
1501
1502
1508
1509
1511{
1512 assert( sentinel.next == &sentinel );
1513 assert( sentinel.prev == &sentinel );
1514}
1515
1516
1518{
1519 #ifdef TIXML_USE_STL
1520 assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set.
1521 #else
1522 assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set.
1523 #endif
1524
1525 addMe->next = &sentinel;
1526 addMe->prev = sentinel.prev;
1527
1528 sentinel.prev->next = addMe;
1529 sentinel.prev = addMe;
1530}
1531
1533{
1534 TiXmlAttribute* node;
1535
1536 for( node = sentinel.next; node != &sentinel; node = node->next )
1537 {
1538 if ( node == removeMe )
1539 {
1540 node->prev->next = node->next;
1541 node->next->prev = node->prev;
1542 node->next = 0;
1543 node->prev = 0;
1544 return;
1545 }
1546 }
1547 assert( 0 ); // we tried to remove a non-linked attribute.
1548}
1549
1550
1551#ifdef TIXML_USE_STL
1552TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const
1553{
1554 for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
1555 {
1556 if ( node->name == name )
1557 return node;
1558 }
1559 return 0;
1560}
1561
1562TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const std::string& _name )
1563{
1564 TiXmlAttribute* attrib = Find( _name );
1565 if ( !attrib ) {
1566 attrib = new TiXmlAttribute();
1567 Add( attrib );
1568 attrib->SetName( _name );
1569 }
1570 return attrib;
1571}
1572#endif
1573
1574
1575TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const
1576{
1577 for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
1578 {
1579 if ( strcmp( node->name.c_str(), name ) == 0 )
1580 return node;
1581 }
1582 return 0;
1583}
1584
1585
1587{
1588 TiXmlAttribute* attrib = Find( _name );
1589 if ( !attrib ) {
1590 attrib = new TiXmlAttribute();
1591 Add( attrib );
1592 attrib->SetName( _name );
1593 }
1594 return attrib;
1595}
1596
1597
1598#ifdef TIXML_USE_STL
1599std::istream& operator>> (std::istream & in, TiXmlNode & base)
1600{
1601 TIXML_STRING tag;
1602 tag.reserve( 8 * 1000 );
1603 base.StreamIn( &in, &tag );
1604
1605 base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING );
1606 return in;
1607}
1608#endif
1609
1610
1611#ifdef TIXML_USE_STL
1612std::ostream& operator<< (std::ostream & out, const TiXmlNode & base)
1613{
1614 TiXmlPrinter printer;
1615 printer.SetStreamPrinting();
1616 base.Accept( &printer );
1617 out << printer.Str();
1618
1619 return out;
1620}
1621
1622
1623std::string& operator<< (std::string& out, const TiXmlNode& base )
1624{
1625 TiXmlPrinter printer;
1626 printer.SetStreamPrinting();
1627 base.Accept( &printer );
1628 out.append( printer.Str() );
1629
1630 return out;
1631}
1632#endif
1633
1634
1636{
1637 if ( node )
1638 {
1639 TiXmlNode* child = node->FirstChild();
1640 if ( child )
1641 return TiXmlHandle( child );
1642 }
1643 return TiXmlHandle( 0 );
1644}
1645
1646
1647TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const
1648{
1649 if ( node )
1650 {
1651 TiXmlNode* child = node->FirstChild( value );
1652 if ( child )
1653 return TiXmlHandle( child );
1654 }
1655 return TiXmlHandle( 0 );
1656}
1657
1658
1660{
1661 if ( node )
1662 {
1664 if ( child )
1665 return TiXmlHandle( child );
1666 }
1667 return TiXmlHandle( 0 );
1668}
1669
1670
1672{
1673 if ( node )
1674 {
1675 TiXmlElement* child = node->FirstChildElement( value );
1676 if ( child )
1677 return TiXmlHandle( child );
1678 }
1679 return TiXmlHandle( 0 );
1680}
1681
1682
1684{
1685 if ( node )
1686 {
1687 int i;
1688 TiXmlNode* child = node->FirstChild();
1689 for ( i=0;
1690 child && i<count;
1691 child = child->NextSibling(), ++i )
1692 {
1693 // nothing
1694 }
1695 if ( child )
1696 return TiXmlHandle( child );
1697 }
1698 return TiXmlHandle( 0 );
1699}
1700
1701
1702TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const
1703{
1704 if ( node )
1705 {
1706 int i;
1707 TiXmlNode* child = node->FirstChild( value );
1708 for ( i=0;
1709 child && i<count;
1710 child = child->NextSibling( value ), ++i )
1711 {
1712 // nothing
1713 }
1714 if ( child )
1715 return TiXmlHandle( child );
1716 }
1717 return TiXmlHandle( 0 );
1718}
1719
1720
1722{
1723 if ( node )
1724 {
1725 int i;
1727 for ( i=0;
1728 child && i<count;
1729 child = child->NextSiblingElement(), ++i )
1730 {
1731 // nothing
1732 }
1733 if ( child )
1734 return TiXmlHandle( child );
1735 }
1736 return TiXmlHandle( 0 );
1737}
1738
1739
1740TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const
1741{
1742 if ( node )
1743 {
1744 int i;
1745 TiXmlElement* child = node->FirstChildElement( value );
1746 for ( i=0;
1747 child && i<count;
1748 child = child->NextSiblingElement( value ), ++i )
1749 {
1750 // nothing
1751 }
1752 if ( child )
1753 return TiXmlHandle( child );
1754 }
1755 return TiXmlHandle( 0 );
1756}
1757
1758
1760{
1761 return true;
1762}
1763
1765{
1766 return true;
1767}
1768
1769bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute )
1770{
1771 DoIndent();
1772 buffer += "<";
1773 buffer += element.Value();
1774
1775 for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() )
1776 {
1777 buffer += " ";
1778 attrib->Print( 0, 0, &buffer );
1779 }
1780
1781 if ( !element.FirstChild() )
1782 {
1783 buffer += " />";
1784 DoLineBreak();
1785 }
1786 else
1787 {
1788 buffer += ">";
1789 if ( element.FirstChild()->ToText()
1790 && element.LastChild() == element.FirstChild()
1791 && element.FirstChild()->ToText()->CDATA() == false )
1792 {
1793 simpleTextPrint = true;
1794 // no DoLineBreak()!
1795 }
1796 else
1797 {
1798 DoLineBreak();
1799 }
1800 }
1801 ++depth;
1802 return true;
1803}
1804
1805
1807{
1808 --depth;
1809 if ( !element.FirstChild() )
1810 {
1811 // nothing.
1812 }
1813 else
1814 {
1815 if ( simpleTextPrint )
1816 {
1817 simpleTextPrint = false;
1818 }
1819 else
1820 {
1821 DoIndent();
1822 }
1823 buffer += "</";
1824 buffer += element.Value();
1825 buffer += ">";
1826 DoLineBreak();
1827 }
1828 return true;
1829}
1830
1831
1833{
1834 if ( text.CDATA() )
1835 {
1836 DoIndent();
1837 buffer += "<![CDATA[";
1838 buffer += text.Value();
1839 buffer += "]]>";
1840 DoLineBreak();
1841 }
1842 else if ( simpleTextPrint )
1843 {
1844 TIXML_STRING str;
1845 TiXmlBase::EncodeString( text.ValueTStr(), &str );
1846 buffer += str;
1847 }
1848 else
1849 {
1850 DoIndent();
1851 TIXML_STRING str;
1852 TiXmlBase::EncodeString( text.ValueTStr(), &str );
1853 buffer += str;
1854 DoLineBreak();
1855 }
1856 return true;
1857}
1858
1859
1860bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration )
1861{
1862 DoIndent();
1863 declaration.Print( 0, 0, &buffer );
1864 DoLineBreak();
1865 return true;
1866}
1867
1868
1869bool TiXmlPrinter::Visit( const TiXmlComment& comment )
1870{
1871 DoIndent();
1872 buffer += "<!--";
1873 buffer += comment.Value();
1874 buffer += "-->";
1875 DoLineBreak();
1876 return true;
1877}
1878
1879
1880bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown )
1881{
1882 DoIndent();
1883 buffer += "<";
1884 buffer += unknown.Value();
1885 buffer += ">";
1886 DoLineBreak();
1887 return true;
1888}
1889
1890} // Added namespace pandora
const char * Name() const
Return the name of this attribute.
Definition tinyxml.h:818
int QueryIntValue(int *_value) const
Definition tinyxml.cc:1239
double DoubleValue() const
Return the value of this attribute, converted to a double.
Definition tinyxml.cc:1280
const char * Value() const
Return the value of this attribute.
Definition tinyxml.h:819
TIXML_STRING name
Definition tinyxml.h:891
void SetValue(const char *_value)
Set the value.
Definition tinyxml.h:843
TiXmlAttribute * prev
Definition tinyxml.h:893
virtual void Print(FILE *cfile, int depth) const
Definition tinyxml.h:877
const TiXmlAttribute * Previous() const
Get the previous sibling attribute in the DOM. Returns null at beginning.
Definition tinyxml.cc:1193
void SetName(const char *_name)
Set the name of this attribute.
Definition tinyxml.h:842
int QueryDoubleValue(double *_value) const
QueryDoubleValue examines the value string. See QueryIntValue().
Definition tinyxml.cc:1246
void SetIntValue(int _value)
Set the value from an integer.
Definition tinyxml.cc:1253
void SetDoubleValue(double _value)
Set the value from a double.
Definition tinyxml.cc:1264
const TiXmlAttribute * Next() const
Get the next sibling attribute in the DOM. Returns null at end.
Definition tinyxml.cc:1173
TiXmlAttribute * next
Definition tinyxml.h:894
int IntValue() const
Return the value of this attribute, converted to an integer.
Definition tinyxml.cc:1275
TIXML_STRING value
Definition tinyxml.h:892
const std::string & ValueStr() const
Return the value of this attribute.
Definition tinyxml.h:821
TiXmlAttribute * FindOrCreate(const char *_name)
Definition tinyxml.cc:1586
const TiXmlAttribute * First() const
Definition tinyxml.h:919
TiXmlAttribute * Find(const char *_name) const
Definition tinyxml.cc:1575
TiXmlAttribute sentinel
Definition tinyxml.h:939
void Add(TiXmlAttribute *attribute)
Definition tinyxml.cc:1517
void Remove(TiXmlAttribute *attribute)
Definition tinyxml.cc:1532
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0
friend class TiXmlNode
Definition tinyxml.h:203
static Entity entity[NUM_ENTITY]
Definition tinyxml.h:419
static bool condenseWhiteSpace
Definition tinyxml.h:420
@ TIXML_ERROR_DOCUMENT_TOP_ONLY
Definition tinyxml.h:288
static void EncodeString(const TIXML_STRING &str, TIXML_STRING *out)
Definition tinyxml.cc:55
friend class TiXmlElement
Definition tinyxml.h:204
void * userData
Field containing a generic user pointer.
Definition tinyxml.h:383
virtual void Print(FILE *cfile, int depth) const =0
TiXmlCursor location
Definition tinyxml.h:380
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
void CopyTo(TiXmlComment *target) const
Definition tinyxml.cc:1311
TiXmlComment & operator=(const TiXmlComment &base)
Definition tinyxml.cc:1292
virtual TiXmlNode * Clone() const
Returns a copy of this Comment.
Definition tinyxml.cc:1323
virtual bool Accept(TiXmlVisitor *visitor) const
Definition tinyxml.cc:1317
TiXmlComment()
Constructs an empty comment.
Definition tinyxml.h:1173
virtual void Print(FILE *cfile, int depth) const
Definition tinyxml.cc:1300
TiXmlDeclaration()
Construct an empty declaration.
Definition tinyxml.h:1296
void CopyTo(TiXmlDeclaration *target) const
Definition tinyxml.cc:1443
virtual void Print(FILE *cfile, int depth, TIXML_STRING *str) const
Definition tinyxml.cc:1421
TIXML_STRING standalone
Definition tinyxml.h:1350
TiXmlDeclaration & operator=(const TiXmlDeclaration &copy)
Definition tinyxml.cc:1413
virtual bool Accept(TiXmlVisitor *visitor) const
Definition tinyxml.cc:1453
virtual TiXmlNode * Clone() const
Creates a copy of this Declaration and returns it.
Definition tinyxml.cc:1459
virtual TiXmlNode * Clone() const
Definition tinyxml.cc:1137
virtual bool Accept(TiXmlVisitor *content) const
Definition tinyxml.cc:1159
TIXML_STRING errorDesc
Definition tinyxml.h:1558
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
TiXmlDocument & operator=(const TiXmlDocument &copy)
Definition tinyxml.cc:949
void CopyTo(TiXmlDocument *target) const
Definition tinyxml.cc:1118
TiXmlCursor errorLocation
Definition tinyxml.h:1560
TiXmlDocument()
Create an empty document, that has no name.
Definition tinyxml.cc:916
bool SaveFile() const
Save a file using the current document value. Returns true if successful.
Definition tinyxml.cc:963
bool Error() const
Definition tinyxml.h:1467
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
void Print() const
Definition tinyxml.h:1526
bool LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Definition tinyxml.cc:957
void CopyTo(TiXmlElement *target) const
Definition tinyxml.cc:856
virtual ~TiXmlElement()
Definition tinyxml.cc:562
TiXmlElement & operator=(const TiXmlElement &base)
Definition tinyxml.cc:554
int QueryDoubleAttribute(const char *name, double *_value) const
QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
Definition tinyxml.cc:723
virtual bool Accept(TiXmlVisitor *visitor) const
Definition tinyxml.cc:878
int QueryUnsignedAttribute(const char *name, unsigned *_value) const
QueryUnsignedAttribute examines the attribute - see QueryIntAttribute().
Definition tinyxml.cc:673
const char * Attribute(const char *name) const
Definition tinyxml.cc:580
void SetAttribute(const char *name, const char *_value)
Definition tinyxml.cc:783
void SetDoubleAttribute(const std::string &name, double value)
virtual TiXmlNode * Clone() const
Creates a new Element and returns it - the returned element is a copy.
Definition tinyxml.cc:892
virtual void Print(FILE *cfile, int depth) const
Definition tinyxml.cc:803
TiXmlAttributeSet attributeSet
Definition tinyxml.h:1163
const char * GetText() const
Definition tinyxml.cc:903
int QueryIntAttribute(const char *name, int *_value) const
Definition tinyxml.cc:664
int QueryBoolAttribute(const char *name, bool *_value) const
Definition tinyxml.cc:686
void RemoveAttribute(const char *name)
Definition tinyxml.cc:440
TiXmlHandle FirstChildElement() const
Return a handle to the first child element.
Definition tinyxml.cc:1659
TiXmlHandle FirstChild() const
Return a handle to the first child node.
Definition tinyxml.cc:1635
TiXmlHandle Child(const char *value, int index) const
Definition tinyxml.cc:1702
TiXmlNode * node
Definition tinyxml.h:1721
TiXmlHandle ChildElement(const char *value, int index) const
Definition tinyxml.cc:1740
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)=0
const TiXmlNode * LastChild() const
Definition tinyxml.h:538
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
Definition tinyxml.h:529
TiXmlNode * lastChild
Definition tinyxml.h:766
void Clear()
Delete all the children of this node. Does not affect 'this'.
Definition tinyxml.cc:172
virtual TiXmlNode * Clone() const =0
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
Definition tinyxml.h:705
TiXmlNode * prev
Definition tinyxml.h:770
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
Definition tinyxml.h:638
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
Definition tinyxml.h:704
virtual ~TiXmlNode()
Definition tinyxml.cc:150
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
Definition tinyxml.cc:338
int Type() const
Definition tinyxml.h:691
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
Definition tinyxml.cc:217
void SetValue(const char *_value)
Definition tinyxml.h:515
TiXmlNode * next
Definition tinyxml.h:771
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
Definition tinyxml.h:621
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
Definition tinyxml.h:708
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
Definition tinyxml.cc:189
const TiXmlElement * NextSiblingElement() const
Definition tinyxml.cc:485
void CopyTo(TiXmlNode *target) const
Definition tinyxml.cc:164
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
Definition tinyxml.cc:299
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
Definition tinyxml.cc:388
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
Definition tinyxml.cc:233
TiXmlNode * parent
Definition tinyxml.h:762
friend class TiXmlElement
Definition tinyxml.h:433
const char * Value() const
Definition tinyxml.h:494
TiXmlNode * firstChild
Definition tinyxml.h:765
const TiXmlDocument * GetDocument() const
Definition tinyxml.cc:515
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
Definition tinyxml.cc:266
const TIXML_STRING & ValueTStr() const
Definition tinyxml.h:504
TIXML_STRING value
Definition tinyxml.h:768
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
Definition tinyxml.h:633
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
Definition tinyxml.cc:455
virtual bool VisitEnter(const TiXmlDocument &doc)
Visit a document.
Definition tinyxml.cc:1759
TIXML_STRING buffer
Definition tinyxml.h:1802
virtual bool Visit(const TiXmlDeclaration &declaration)
Visit a declaration.
Definition tinyxml.cc:1860
virtual bool VisitExit(const TiXmlDocument &doc)
Visit a document.
Definition tinyxml.cc:1764
bool CDATA() const
Queries whether this represents text using a CDATA section.
Definition tinyxml.h:1250
virtual TiXmlNode * Clone() const
[internal use] Creates a new Element and returns it.
Definition tinyxml.cc:1369
virtual bool Accept(TiXmlVisitor *content) const
Definition tinyxml.cc:1363
virtual void Print(FILE *cfile, int depth) const
Definition tinyxml.cc:1335
void CopyTo(TiXmlText *target) const
Definition tinyxml.cc:1356
virtual void Print(FILE *cfile, int depth) const
Definition tinyxml.cc:1471
virtual bool Accept(TiXmlVisitor *content) const
Definition tinyxml.cc:1485
void CopyTo(TiXmlUnknown *target) const
Definition tinyxml.cc:1479
virtual TiXmlNode * Clone() const
Creates a copy of this Unknown and returns it.
Definition tinyxml.cc:1491
virtual bool Visit(const TiXmlDeclaration &)
Visit a declaration.
Definition tinyxml.h:151
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
Definition tinyxml.h:141
virtual bool VisitExit(const TiXmlDocument &)
Visit a document.
Definition tinyxml.h:143
std::ostream & operator<<(std::ostream &stream, const CartesianVector &cartesianVector)
Operator to dump cartesian vector properties to an ostream.
const unsigned char TIXML_UTF_LEAD_0
@ TIXML_WRONG_TYPE
Definition tinyxml.h:165
@ TIXML_SUCCESS
Definition tinyxml.h:163
@ TIXML_NO_ATTRIBUTE
Definition tinyxml.h:164
TiXmlEncoding
Definition tinyxml.h:171
@ TIXML_ENCODING_UNKNOWN
Definition tinyxml.h:172
FILE * TiXmlFOpen(const char *filename, const char *mode)
Definition tinyxml.cc:42
const unsigned char TIXML_UTF_LEAD_1
const TiXmlEncoding TIXML_DEFAULT_ENCODING
Definition tinyxml.h:177
const unsigned char TIXML_UTF_LEAD_2
#define TIXML_STRING
Definition tinyxml.h:54
#define TIXML_SSCANF
Definition tinyxml.h:83
#define TIXML_SNPRINTF
Definition tinyxml.h:82