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


inertial_sense_ros
Author(s):
autogenerated on Sat Sep 19 2020 03:19:05