GEAR  1.9.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
tinyxml.cc
1 /*
2 www.sourceforge.net/projects/tinyxml
3 Original code (2.0 and earlier )copyright (c) 2000-2002 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  F.Gaede, DESY : changed extension to .cc for use with gear
26  and include from "gearxml/tinyxml.h"
27  : put in namespace gear
28  : changed output format to scientific with precision 9: "%.9e"
29 
30  $Id: tinyxml.cc,v 1.2 2007-08-08 08:58:32 gaede Exp $
31 */
32 
33 
34 #include <ctype.h>
35 #include "gearxml/tinyxml.h"
36 
37 #ifdef TIXML_USE_STL
38 #include <sstream>
39 #endif
40 
41 
42 //fg: put in namespace gear
43 namespace gear {
44 
45 
46 
47 bool TiXmlBase::condenseWhiteSpace = true;
48 
49 void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_OSTREAM* stream )
50 {
51  TIXML_STRING buffer;
52  PutString( str, &buffer );
53  (*stream) << buffer;
54 }
55 
56 void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_STRING* outString )
57 {
58  int i=0;
59 
60  while( i<(int)str.length() )
61  {
62  unsigned char c = (unsigned char) str[i];
63 
64  if ( c == '&'
65  && i < ( (int)str.length() - 2 )
66  && str[i+1] == '#'
67  && str[i+2] == 'x' )
68  {
69  // Hexadecimal character reference.
70  // Pass through unchanged.
71  // &#xA9; -- copyright symbol, for example.
72  //
73  // The -1 is a bug fix from Rob Laveaux. It keeps
74  // an overflow from happening if there is no ';'.
75  // There are actually 2 ways to exit this loop -
76  // while fails (error case) and break (semicolon found).
77  // However, there is no mechanism (currently) for
78  // this function to return an error.
79  while ( i<(int)str.length()-1 )
80  {
81  outString->append( str.c_str() + i, 1 );
82  ++i;
83  if ( str[i] == ';' )
84  break;
85  }
86  }
87  else if ( c == '&' )
88  {
89  outString->append( entity[0].str, entity[0].strLength );
90  ++i;
91  }
92  else if ( c == '<' )
93  {
94  outString->append( entity[1].str, entity[1].strLength );
95  ++i;
96  }
97  else if ( c == '>' )
98  {
99  outString->append( entity[2].str, entity[2].strLength );
100  ++i;
101  }
102  else if ( c == '\"' )
103  {
104  outString->append( entity[3].str, entity[3].strLength );
105  ++i;
106  }
107  else if ( c == '\'' )
108  {
109  outString->append( entity[4].str, entity[4].strLength );
110  ++i;
111  }
112  else if ( c < 32 )
113  {
114  // Easy pass at non-alpha/numeric/symbol
115  // Below 32 is symbolic.
116  char buf[ 32 ];
117  sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) );
118  //*ME: warning C4267: convert 'size_t' to 'int'
119  //*ME: Int-Cast to make compiler happy ...
120  outString->append( buf, (int)strlen( buf ) );
121  ++i;
122  }
123  else
124  {
125  //char realc = (char) c;
126  //outString->append( &realc, 1 );
127  *outString += (char) c; // somewhat more efficient function call.
128  ++i;
129  }
130  }
131 }
132 
133 
134 // <-- Strange class for a bug fix. Search for STL_STRING_BUG
135 TiXmlBase::StringToBuffer::StringToBuffer( const TIXML_STRING& str )
136 {
137  buffer = new char[ str.length()+1 ];
138  if ( buffer )
139  {
140  strcpy( buffer, str.c_str() );
141  }
142 }
143 
144 
145 TiXmlBase::StringToBuffer::~StringToBuffer()
146 {
147  delete [] buffer;
148 }
149 // End strange bug fix. -->
150 
151 
152 TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase()
153 {
154  parent = 0;
155  type = _type;
156  firstChild = 0;
157  lastChild = 0;
158  prev = 0;
159  next = 0;
160 }
161 
162 
163 TiXmlNode::~TiXmlNode()
164 {
165  TiXmlNode* node = firstChild;
166  TiXmlNode* temp = 0;
167 
168  while ( node )
169  {
170  temp = node;
171  node = node->next;
172  delete temp;
173  }
174 }
175 
176 
177 void TiXmlNode::CopyTo( TiXmlNode* target ) const
178 {
179  target->SetValue (value.c_str() );
180  target->userData = userData;
181 }
182 
183 
185 {
186  TiXmlNode* node = firstChild;
187  TiXmlNode* temp = 0;
188 
189  while ( node )
190  {
191  temp = node;
192  node = node->next;
193  delete temp;
194  }
195 
196  firstChild = 0;
197  lastChild = 0;
198 }
199 
200 
202 {
203  node->parent = this;
204 
205  node->prev = lastChild;
206  node->next = 0;
207 
208  if ( lastChild )
209  lastChild->next = node;
210  else
211  firstChild = node; // it was an empty list.
212 
213  lastChild = node;
214  return node;
215 }
216 
217 
219 {
220  TiXmlNode* node = addThis.Clone();
221  if ( !node )
222  return 0;
223 
224  return LinkEndChild( node );
225 }
226 
227 
229 {
230  if ( !beforeThis || beforeThis->parent != this )
231  return 0;
232 
233  TiXmlNode* node = addThis.Clone();
234  if ( !node )
235  return 0;
236  node->parent = this;
237 
238  node->next = beforeThis;
239  node->prev = beforeThis->prev;
240  if ( beforeThis->prev )
241  {
242  beforeThis->prev->next = node;
243  }
244  else
245  {
246  assert( firstChild == beforeThis );
247  firstChild = node;
248  }
249  beforeThis->prev = node;
250  return node;
251 }
252 
253 
255 {
256  if ( !afterThis || afterThis->parent != this )
257  return 0;
258 
259  TiXmlNode* node = addThis.Clone();
260  if ( !node )
261  return 0;
262  node->parent = this;
263 
264  node->prev = afterThis;
265  node->next = afterThis->next;
266  if ( afterThis->next )
267  {
268  afterThis->next->prev = node;
269  }
270  else
271  {
272  assert( lastChild == afterThis );
273  lastChild = node;
274  }
275  afterThis->next = node;
276  return node;
277 }
278 
279 
280 TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis )
281 {
282  if ( replaceThis->parent != this )
283  return 0;
284 
285  TiXmlNode* node = withThis.Clone();
286  if ( !node )
287  return 0;
288 
289  node->next = replaceThis->next;
290  node->prev = replaceThis->prev;
291 
292  if ( replaceThis->next )
293  replaceThis->next->prev = node;
294  else
295  lastChild = node;
296 
297  if ( replaceThis->prev )
298  replaceThis->prev->next = node;
299  else
300  firstChild = node;
301 
302  delete replaceThis;
303  node->parent = this;
304  return node;
305 }
306 
307 
309 {
310  if ( removeThis->parent != this )
311  {
312  assert( 0 );
313  return false;
314  }
315 
316  if ( removeThis->next )
317  removeThis->next->prev = removeThis->prev;
318  else
319  lastChild = removeThis->prev;
320 
321  if ( removeThis->prev )
322  removeThis->prev->next = removeThis->next;
323  else
324  firstChild = removeThis->next;
325 
326  delete removeThis;
327  return true;
328 }
329 
330 const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const
331 {
332  const TiXmlNode* node;
333  for ( node = firstChild; node; node = node->next )
334  {
335  if ( node->SValue() == _value )
336  return node;
337  }
338  return 0;
339 }
340 
341 
342 TiXmlNode* TiXmlNode::FirstChild( const char * _value )
343 {
344  TiXmlNode* node;
345  for ( node = firstChild; node; node = node->next )
346  {
347  if ( node->SValue() == _value )
348  return node;
349  }
350  return 0;
351 }
352 
353 
354 const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const
355 {
356  const TiXmlNode* node;
357  for ( node = lastChild; node; node = node->prev )
358  {
359  if ( node->SValue() == _value )
360  return node;
361  }
362  return 0;
363 }
364 
365 TiXmlNode* TiXmlNode::LastChild( const char * _value )
366 {
367  TiXmlNode* node;
368  for ( node = lastChild; node; node = node->prev )
369  {
370  if ( node->SValue() == _value )
371  return node;
372  }
373  return 0;
374 }
375 
376 const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const
377 {
378  if ( !previous )
379  {
380  return FirstChild();
381  }
382  else
383  {
384  assert( previous->parent == this );
385  return previous->NextSibling();
386  }
387 }
388 
390 {
391  if ( !previous )
392  {
393  return FirstChild();
394  }
395  else
396  {
397  assert( previous->parent == this );
398  return previous->NextSibling();
399  }
400 }
401 
402 const 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 TiXmlNode* TiXmlNode::IterateChildren( const char * val, TiXmlNode* previous )
416 {
417  if ( !previous )
418  {
419  return FirstChild( val );
420  }
421  else
422  {
423  assert( previous->parent == this );
424  return previous->NextSibling( val );
425  }
426 }
427 
428 const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const
429 {
430  const TiXmlNode* node;
431  for ( node = next; node; node = node->next )
432  {
433  if ( node->SValue() == _value )
434  return node;
435  }
436  return 0;
437 }
438 
439 TiXmlNode* TiXmlNode::NextSibling( const char * _value )
440 {
441  TiXmlNode* node;
442  for ( node = next; node; node = node->next )
443  {
444  if ( node->SValue() == _value )
445  return node;
446  }
447  return 0;
448 }
449 
450 const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const
451 {
452  const TiXmlNode* node;
453  for ( node = prev; node; node = node->prev )
454  {
455  if ( node->SValue() == _value )
456  return node;
457  }
458  return 0;
459 }
460 
461 TiXmlNode* TiXmlNode::PreviousSibling( const char * _value )
462 {
463  TiXmlNode* node;
464  for ( node = prev; node; node = node->prev )
465  {
466  if ( node->SValue() == _value )
467  return node;
468  }
469  return 0;
470 }
471 
472 void TiXmlElement::RemoveAttribute( const char * name )
473 {
474  TiXmlAttribute* node = attributeSet.Find( name );
475  if ( node )
476  {
477  attributeSet.Remove( node );
478  delete node;
479  }
480 }
481 
483 {
484  const TiXmlNode* node;
485 
486  for ( node = FirstChild();
487  node;
488  node = node->NextSibling() )
489  {
490  if ( node->ToElement() )
491  return node->ToElement();
492  }
493  return 0;
494 }
495 
497 {
498  TiXmlNode* node;
499 
500  for ( node = FirstChild();
501  node;
502  node = node->NextSibling() )
503  {
504  if ( node->ToElement() )
505  return node->ToElement();
506  }
507  return 0;
508 }
509 
510 const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const
511 {
512  const TiXmlNode* node;
513 
514  for ( node = FirstChild( _value );
515  node;
516  node = node->NextSibling( _value ) )
517  {
518  if ( node->ToElement() )
519  return node->ToElement();
520  }
521  return 0;
522 }
523 
524 TiXmlElement* TiXmlNode::FirstChildElement( const char * _value )
525 {
526  TiXmlNode* node;
527 
528  for ( node = FirstChild( _value );
529  node;
530  node = node->NextSibling( _value ) )
531  {
532  if ( node->ToElement() )
533  return node->ToElement();
534  }
535  return 0;
536 }
537 
539 {
540  const TiXmlNode* node;
541 
542  for ( node = NextSibling();
543  node;
544  node = node->NextSibling() )
545  {
546  if ( node->ToElement() )
547  return node->ToElement();
548  }
549  return 0;
550 }
551 
553 {
554  TiXmlNode* node;
555 
556  for ( node = NextSibling();
557  node;
558  node = node->NextSibling() )
559  {
560  if ( node->ToElement() )
561  return node->ToElement();
562  }
563  return 0;
564 }
565 
566 const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const
567 {
568  const TiXmlNode* node;
569 
570  for ( node = NextSibling( _value );
571  node;
572  node = node->NextSibling( _value ) )
573  {
574  if ( node->ToElement() )
575  return node->ToElement();
576  }
577  return 0;
578 }
579 
580 TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value )
581 {
582  TiXmlNode* node;
583 
584  for ( node = NextSibling( _value );
585  node;
586  node = node->NextSibling( _value ) )
587  {
588  if ( node->ToElement() )
589  return node->ToElement();
590  }
591  return 0;
592 }
593 
594 
596 {
597  const TiXmlNode* node;
598 
599  for( node = this; node; node = node->parent )
600  {
601  if ( node->ToDocument() )
602  return node->ToDocument();
603  }
604  return 0;
605 }
606 
608 {
609  TiXmlNode* node;
610 
611  for( node = this; node; node = node->parent )
612  {
613  if ( node->ToDocument() )
614  return node->ToDocument();
615  }
616  return 0;
617 }
618 
619 TiXmlElement::TiXmlElement (const char * _value)
620  : TiXmlNode( TiXmlNode::ELEMENT )
621 {
622  firstChild = lastChild = 0;
623  value = _value;
624 }
625 
626 
627 #ifdef TIXML_USE_STL
628 TiXmlElement::TiXmlElement( const std::string& _value )
629  : TiXmlNode( TiXmlNode::ELEMENT )
630 {
631  firstChild = lastChild = 0;
632  value = _value;
633 }
634 #endif
635 
636 
637 TiXmlElement::TiXmlElement( const TiXmlElement& copy)
638  : TiXmlNode( TiXmlNode::ELEMENT )
639 {
640  firstChild = lastChild = 0;
641  copy.CopyTo( this );
642 }
643 
644 
645 TiXmlElement& TiXmlElement::operator=( const TiXmlElement& base )
646 {
647  ClearThis();
648  base.CopyTo( this );
649  return *this ;
650 }
651 
652 
653 TiXmlElement::~TiXmlElement()
654 {
655  ClearThis();
656 }
657 
658 
659 void TiXmlElement::ClearThis()
660 {
661  Clear();
662  while( attributeSet.First() )
663  {
664  TiXmlAttribute* node = attributeSet.First();
665  attributeSet.Remove( node );
666  delete node;
667  }
668 }
669 
670 
671 const char * TiXmlElement::Attribute( const char * name ) const
672 {
673  const TiXmlAttribute* node = attributeSet.Find( name );
674 
675  if ( node )
676  return node->Value();
677 
678  return 0;
679 }
680 
681 
682 const char * TiXmlElement::Attribute( const char * name, int* i ) const
683 {
684  const char * s = Attribute( name );
685  if ( i )
686  {
687  if ( s )
688  *i = atoi( s );
689  else
690  *i = 0;
691  }
692  return s;
693 }
694 
695 
696 const char * TiXmlElement::Attribute( const char * name, double* d ) const
697 {
698  const char * s = Attribute( name );
699  if ( d )
700  {
701  if ( s )
702  *d = atof( s );
703  else
704  *d = 0;
705  }
706  return s;
707 }
708 
709 
710 int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const
711 {
712  const TiXmlAttribute* node = attributeSet.Find( name );
713  if ( !node )
714  return TIXML_NO_ATTRIBUTE;
715 
716  return node->QueryIntValue( ival );
717 }
718 
719 
720 int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const
721 {
722  const TiXmlAttribute* node = attributeSet.Find( name );
723  if ( !node )
724  return TIXML_NO_ATTRIBUTE;
725 
726  return node->QueryDoubleValue( dval );
727 }
728 
729 
730 void TiXmlElement::SetAttribute( const char * name, int val )
731 {
732  char buf[64];
733  sprintf( buf, "%d", val );
734  SetAttribute( name, buf );
735 }
736 
737 
738 void TiXmlElement::SetDoubleAttribute( const char * name, double val )
739 {
740  char buf[256];
741  sprintf( buf, "%.9e", val );
742  SetAttribute( name, buf );
743 }
744 
745 
746 void TiXmlElement::SetAttribute( const char * name, const char * _value )
747 {
748  TiXmlAttribute* node = attributeSet.Find( name );
749  if ( node )
750  {
751  node->SetValue( _value );
752  return;
753  }
754 
755  TiXmlAttribute* attrib = new TiXmlAttribute( name, _value );
756  if ( attrib )
757  {
758  attributeSet.Add( attrib );
759  }
760  else
761  {
762  TiXmlDocument* document = GetDocument();
763  if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
764  }
765 }
766 
767 void TiXmlElement::Print( FILE* cfile, int depth ) const
768 {
769  int i;
770  for ( i=0; i<depth; i++ )
771  {
772  fprintf( cfile, " " );
773  }
774 
775  fprintf( cfile, "<%s", value.c_str() );
776 
777  const TiXmlAttribute* attrib;
778  for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
779  {
780  fprintf( cfile, " " );
781  attrib->Print( cfile, depth );
782  }
783 
784  // There are 3 different formatting approaches:
785  // 1) An element without children is printed as a <foo /> node
786  // 2) An element with only a text child is printed as <foo> text </foo>
787  // 3) An element with children is printed on multiple lines.
788  TiXmlNode* node;
789  if ( !firstChild )
790  {
791  fprintf( cfile, " />" );
792  }
793  else if ( firstChild == lastChild && firstChild->ToText() )
794  {
795  fprintf( cfile, ">" );
796  firstChild->Print( cfile, depth + 1 );
797  fprintf( cfile, "</%s>", value.c_str() );
798  }
799  else
800  {
801  fprintf( cfile, ">" );
802 
803  for ( node = firstChild; node; node=node->NextSibling() )
804  {
805  if ( !node->ToText() )
806  {
807  fprintf( cfile, "\n" );
808  }
809  node->Print( cfile, depth+1 );
810  }
811  fprintf( cfile, "\n" );
812  for( i=0; i<depth; ++i )
813  fprintf( cfile, " " );
814  fprintf( cfile, "</%s>", value.c_str() );
815  }
816 }
817 
818 void TiXmlElement::StreamOut( TIXML_OSTREAM * stream ) const
819 {
820  (*stream) << "<" << value;
821 
822  const TiXmlAttribute* attrib;
823  for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
824  {
825  (*stream) << " ";
826  attrib->StreamOut( stream );
827  }
828 
829  // If this node has children, give it a closing tag. Else
830  // make it an empty tag.
831  TiXmlNode* node;
832  if ( firstChild )
833  {
834  (*stream) << ">";
835 
836  for ( node = firstChild; node; node=node->NextSibling() )
837  {
838  node->StreamOut( stream );
839  }
840  (*stream) << "</" << value << ">";
841  }
842  else
843  {
844  (*stream) << " />";
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 
873 {
874  TiXmlElement* clone = new TiXmlElement( Value() );
875  if ( !clone )
876  return 0;
877 
878  CopyTo( clone );
879  return clone;
880 }
881 
882 
884 {
885  tabsize = 4;
886  ClearError();
887 }
888 
889 TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT )
890 {
891  tabsize = 4;
892  value = documentName;
893  ClearError();
894 }
895 
896 
897 #ifdef TIXML_USE_STL
898 TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT )
899 {
900  tabsize = 4;
901  value = documentName;
902  ClearError();
903 }
904 #endif
905 
906 
907 TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::DOCUMENT )
908 {
909  copy.CopyTo( this );
910 }
911 
912 
913 TiXmlDocument& TiXmlDocument::operator=( const TiXmlDocument& copy )
914 {
915  Clear();
916  copy.CopyTo( this );
917  return *this ;
918 }
919 
920 
921 bool TiXmlDocument::LoadFile( TiXmlEncoding encoding )
922 {
923  // See STL_STRING_BUG below.
924  StringToBuffer buf( value );
925 
926  if ( buf.buffer && LoadFile( buf.buffer, encoding ) )
927  return true;
928 
929  return false;
930 }
931 
932 
934 {
935  // See STL_STRING_BUG below.
936  StringToBuffer buf( value );
937 
938  if ( buf.buffer && SaveFile( buf.buffer ) )
939  return true;
940 
941  return false;
942 }
943 
944 bool TiXmlDocument::LoadFile( const char* filename, TiXmlEncoding encoding )
945 {
946  // Delete the existing data:
947  Clear();
948  location.Clear();
949 
950  // There was a really terrifying little bug here. The code:
951  // value = filename
952  // in the STL case, cause the assignment method of the std::string to
953  // be called. What is strange, is that the std::string had the same
954  // address as it's c_str() method, and so bad things happen. Looks
955  // like a bug in the Microsoft STL implementation.
956  // See STL_STRING_BUG above.
957  // Fixed with the StringToBuffer class.
958  value = filename;
959 
960  FILE* file = fopen( value.c_str (), "r" );
961 
962  if ( file )
963  {
964  // Get the file size, so we can pre-allocate the string. HUGE speed impact.
965  long length = 0;
966  fseek( file, 0, SEEK_END );
967  length = ftell( file );
968  fseek( file, 0, SEEK_SET );
969 
970  // Strange case, but good to handle up front.
971  if ( length == 0 )
972  {
973  fclose( file );
974  return false;
975  }
976 
977  // If we have a file, assume it is all one big XML file, and read it in.
978  // The document parser may decide the document ends sooner than the entire file, however.
979  TIXML_STRING data;
980  data.reserve( length );
981 
982  const int BUF_SIZE = 2048;
983  char buf[BUF_SIZE];
984 
985  while( fgets( buf, BUF_SIZE, file ) )
986  {
987  data += buf;
988  }
989  fclose( file );
990 
991  Parse( data.c_str(), 0, encoding );
992 
993  if ( Error() )
994  return false;
995  else
996  return true;
997  }
998  SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
999  return false;
1000 }
1001 
1002 bool TiXmlDocument::SaveFile( const char * filename ) const
1003 {
1004  // The old c stuff lives on...
1005  FILE* fp = fopen( filename, "w" );
1006  if ( fp )
1007  {
1008  Print( fp, 0 );
1009  fclose( fp );
1010  return true;
1011  }
1012  return false;
1013 }
1014 
1015 
1016 void TiXmlDocument::CopyTo( TiXmlDocument* target ) const
1017 {
1018  TiXmlNode::CopyTo( target );
1019 
1020  target->error = error;
1021  target->errorDesc = errorDesc.c_str ();
1022 
1023  TiXmlNode* node = 0;
1024  for ( node = firstChild; node; node = node->NextSibling() )
1025  {
1026  target->LinkEndChild( node->Clone() );
1027  }
1028 }
1029 
1030 
1032 {
1033  TiXmlDocument* clone = new TiXmlDocument();
1034  if ( !clone )
1035  return 0;
1036 
1037  CopyTo( clone );
1038  return clone;
1039 }
1040 
1041 
1042 void TiXmlDocument::Print( FILE* cfile, int depth ) const
1043 {
1044  const TiXmlNode* node;
1045  for ( node=FirstChild(); node; node=node->NextSibling() )
1046  {
1047  node->Print( cfile, depth );
1048  fprintf( cfile, "\n" );
1049  }
1050 }
1051 
1052 void TiXmlDocument::StreamOut( TIXML_OSTREAM * out ) const
1053 {
1054  const TiXmlNode* node;
1055  for ( node=FirstChild(); node; node=node->NextSibling() )
1056  {
1057  node->StreamOut( out );
1058 
1059  // Special rule for streams: stop after the root element.
1060  // The stream in code will only read one element, so don't
1061  // write more than one.
1062  if ( node->ToElement() )
1063  break;
1064  }
1065 }
1066 
1067 
1069 {
1070  // We are using knowledge of the sentinel. The sentinel
1071  // have a value or name.
1072  if ( next->value.empty() && next->name.empty() )
1073  return 0;
1074  return next;
1075 }
1076 
1078 {
1079  // We are using knowledge of the sentinel. The sentinel
1080  // have a value or name.
1081  if ( next->value.empty() && next->name.empty() )
1082  return 0;
1083  return next;
1084 }
1085 
1087 {
1088  // We are using knowledge of the sentinel. The sentinel
1089  // have a value or name.
1090  if ( prev->value.empty() && prev->name.empty() )
1091  return 0;
1092  return prev;
1093 }
1094 
1096 {
1097  // We are using knowledge of the sentinel. The sentinel
1098  // have a value or name.
1099  if ( prev->value.empty() && prev->name.empty() )
1100  return 0;
1101  return prev;
1102 }
1103 
1104 void TiXmlAttribute::Print( FILE* cfile, int /*depth*/ ) const
1105 {
1106  TIXML_STRING n, v;
1107 
1108  PutString( name, &n );
1109  PutString( value, &v );
1110 
1111  if (value.find ('\"') == TIXML_STRING::npos)
1112  fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() );
1113  else
1114  fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() );
1115 }
1116 
1117 
1118 void TiXmlAttribute::StreamOut( TIXML_OSTREAM * stream ) const
1119 {
1120  if (value.find( '\"' ) != TIXML_STRING::npos)
1121  {
1122  PutString( name, stream );
1123  (*stream) << "=" << "'";
1124  PutString( value, stream );
1125  (*stream) << "'";
1126  }
1127  else
1128  {
1129  PutString( name, stream );
1130  (*stream) << "=" << "\"";
1131  PutString( value, stream );
1132  (*stream) << "\"";
1133  }
1134 }
1135 
1136 int TiXmlAttribute::QueryIntValue( int* ival ) const
1137 {
1138  if ( sscanf( value.c_str(), "%d", ival ) == 1 )
1139  return TIXML_SUCCESS;
1140  return TIXML_WRONG_TYPE;
1141 }
1142 
1143 int TiXmlAttribute::QueryDoubleValue( double* dval ) const
1144 {
1145  if ( sscanf( value.c_str(), "%le", dval ) == 1 )
1146  return TIXML_SUCCESS;
1147  return TIXML_WRONG_TYPE;
1148 }
1149 
1151 {
1152  char buf [64];
1153  sprintf (buf, "%d", _value);
1154  SetValue (buf);
1155 }
1156 
1157 void TiXmlAttribute::SetDoubleValue( double _value )
1158 {
1159  char buf [256];
1160 //fg: sprintf (buf, "%lf", _value);
1161 // %lf is not ISO C++
1162  sprintf (buf, "%.9e", _value);
1163  SetValue (buf);
1164 }
1165 
1167 {
1168  return atoi (value.c_str ());
1169 }
1170 
1172 {
1173  return atof (value.c_str ());
1174 }
1175 
1176 
1177 TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::COMMENT )
1178 {
1179  copy.CopyTo( this );
1180 }
1181 
1182 
1183 TiXmlComment& TiXmlComment::operator=( const TiXmlComment& base )
1184 {
1185  Clear();
1186  base.CopyTo( this );
1187  return *this ;
1188 }
1189 
1190 
1191 void TiXmlComment::Print( FILE* cfile, int depth ) const
1192 {
1193  for ( int i=0; i<depth; i++ )
1194  {
1195  fputs( " ", cfile );
1196  }
1197  fprintf( cfile, "<!--%s-->", value.c_str() );
1198 }
1199 
1200 void TiXmlComment::StreamOut( TIXML_OSTREAM * stream ) const
1201 {
1202  (*stream) << "<!--";
1203  //PutString( value, stream );
1204  (*stream) << value;
1205  (*stream) << "-->";
1206 }
1207 
1208 
1209 void TiXmlComment::CopyTo( TiXmlComment* target ) const
1210 {
1211  TiXmlNode::CopyTo( target );
1212 }
1213 
1214 
1216 {
1217  TiXmlComment* clone = new TiXmlComment();
1218 
1219  if ( !clone )
1220  return 0;
1221 
1222  CopyTo( clone );
1223  return clone;
1224 }
1225 
1226 
1227 void TiXmlText::Print( FILE* cfile, int /*depth*/ ) const
1228 {
1229  TIXML_STRING buffer;
1230  PutString( value, &buffer );
1231  fprintf( cfile, "%s", buffer.c_str() );
1232 }
1233 
1234 
1235 void TiXmlText::StreamOut( TIXML_OSTREAM * stream ) const
1236 {
1237  PutString( value, stream );
1238 }
1239 
1240 
1241 void TiXmlText::CopyTo( TiXmlText* target ) const
1242 {
1243  TiXmlNode::CopyTo( target );
1244 }
1245 
1246 
1248 {
1249  TiXmlText* clone = 0;
1250  clone = new TiXmlText( "" );
1251 
1252  if ( !clone )
1253  return 0;
1254 
1255  CopyTo( clone );
1256  return clone;
1257 }
1258 
1259 
1260 TiXmlDeclaration::TiXmlDeclaration( const char * _version,
1261  const char * _encoding,
1262  const char * _standalone )
1263  : TiXmlNode( TiXmlNode::DECLARATION )
1264 {
1265  version = _version;
1266  encoding = _encoding;
1267  standalone = _standalone;
1268 }
1269 
1270 
1271 #ifdef TIXML_USE_STL
1272 TiXmlDeclaration::TiXmlDeclaration( const std::string& _version,
1273  const std::string& _encoding,
1274  const std::string& _standalone )
1275  : TiXmlNode( TiXmlNode::DECLARATION )
1276 {
1277  version = _version;
1278  encoding = _encoding;
1279  standalone = _standalone;
1280 }
1281 #endif
1282 
1283 
1284 TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy )
1285  : TiXmlNode( TiXmlNode::DECLARATION )
1286 {
1287  copy.CopyTo( this );
1288 }
1289 
1290 
1291 TiXmlDeclaration& TiXmlDeclaration::operator=( const TiXmlDeclaration& copy )
1292 {
1293  Clear();
1294  copy.CopyTo( this );
1295  return *this ;
1296 }
1297 
1298 
1299 void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/ ) const
1300 {
1301  fprintf (cfile, "<?xml ");
1302 
1303  if ( !version.empty() )
1304  fprintf (cfile, "version=\"%s\" ", version.c_str ());
1305  if ( !encoding.empty() )
1306  fprintf (cfile, "encoding=\"%s\" ", encoding.c_str ());
1307  if ( !standalone.empty() )
1308  fprintf (cfile, "standalone=\"%s\" ", standalone.c_str ());
1309  fprintf (cfile, "?>");
1310 }
1311 
1312 void TiXmlDeclaration::StreamOut( TIXML_OSTREAM * stream ) const
1313 {
1314  (*stream) << "<?xml ";
1315 
1316  if ( !version.empty() )
1317  {
1318  (*stream) << "version=\"";
1319  PutString( version, stream );
1320  (*stream) << "\" ";
1321  }
1322  if ( !encoding.empty() )
1323  {
1324  (*stream) << "encoding=\"";
1325  PutString( encoding, stream );
1326  (*stream ) << "\" ";
1327  }
1328  if ( !standalone.empty() )
1329  {
1330  (*stream) << "standalone=\"";
1331  PutString( standalone, stream );
1332  (*stream) << "\" ";
1333  }
1334  (*stream) << "?>";
1335 }
1336 
1337 
1338 void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const
1339 {
1340  TiXmlNode::CopyTo( target );
1341 
1342  target->version = version;
1343  target->encoding = encoding;
1344  target->standalone = standalone;
1345 }
1346 
1347 
1349 {
1350  TiXmlDeclaration* clone = new TiXmlDeclaration();
1351 
1352  if ( !clone )
1353  return 0;
1354 
1355  CopyTo( clone );
1356  return clone;
1357 }
1358 
1359 
1360 void TiXmlUnknown::Print( FILE* cfile, int depth ) const
1361 {
1362  for ( int i=0; i<depth; i++ )
1363  fprintf( cfile, " " );
1364  fprintf( cfile, "<%s>", value.c_str() );
1365 }
1366 
1367 
1368 void TiXmlUnknown::StreamOut( TIXML_OSTREAM * stream ) const
1369 {
1370  (*stream) << "<" << value << ">"; // Don't use entities here! It is unknown.
1371 }
1372 
1373 
1374 void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const
1375 {
1376  TiXmlNode::CopyTo( target );
1377 }
1378 
1379 
1381 {
1382  TiXmlUnknown* clone = new TiXmlUnknown();
1383 
1384  if ( !clone )
1385  return 0;
1386 
1387  CopyTo( clone );
1388  return clone;
1389 }
1390 
1391 
1392 TiXmlAttributeSet::TiXmlAttributeSet()
1393 {
1394  sentinel.next = &sentinel;
1395  sentinel.prev = &sentinel;
1396 }
1397 
1398 
1399 TiXmlAttributeSet::~TiXmlAttributeSet()
1400 {
1401  assert( sentinel.next == &sentinel );
1402  assert( sentinel.prev == &sentinel );
1403 }
1404 
1405 
1406 void TiXmlAttributeSet::Add( TiXmlAttribute* addMe )
1407 {
1408  assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set.
1409 
1410  addMe->next = &sentinel;
1411  addMe->prev = sentinel.prev;
1412 
1413  sentinel.prev->next = addMe;
1414  sentinel.prev = addMe;
1415 }
1416 
1417 void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe )
1418 {
1419  TiXmlAttribute* node;
1420 
1421  for( node = sentinel.next; node != &sentinel; node = node->next )
1422  {
1423  if ( node == removeMe )
1424  {
1425  node->prev->next = node->next;
1426  node->next->prev = node->prev;
1427  node->next = 0;
1428  node->prev = 0;
1429  return;
1430  }
1431  }
1432  assert( 0 ); // we tried to remove a non-linked attribute.
1433 }
1434 
1435 const TiXmlAttribute* TiXmlAttributeSet::Find( const char * name ) const
1436 {
1437  const TiXmlAttribute* node;
1438 
1439  for( node = sentinel.next; node != &sentinel; node = node->next )
1440  {
1441  if ( node->name == name )
1442  return node;
1443  }
1444  return 0;
1445 }
1446 
1447 TiXmlAttribute* TiXmlAttributeSet::Find( const char * name )
1448 {
1449  TiXmlAttribute* node;
1450 
1451  for( node = sentinel.next; node != &sentinel; node = node->next )
1452  {
1453  if ( node->name == name )
1454  return node;
1455  }
1456  return 0;
1457 }
1458 
1459 #ifdef TIXML_USE_STL
1460 TIXML_ISTREAM & operator >> (TIXML_ISTREAM & in, TiXmlNode & base)
1461 {
1462  TIXML_STRING tag;
1463  tag.reserve( 8 * 1000 );
1464  base.StreamIn( &in, &tag );
1465 
1466  base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING );
1467  return in;
1468 }
1469 #endif
1470 
1471 
1472 TIXML_OSTREAM & operator<< (TIXML_OSTREAM & out, const TiXmlNode & base)
1473 {
1474  base.StreamOut (& out);
1475  return out;
1476 }
1477 
1478 
1479 #ifdef TIXML_USE_STL
1480 std::string & operator<< (std::string& out, const TiXmlNode& base )
1481 {
1482  std::ostringstream os_stream( std::ostringstream::out );
1483  base.StreamOut( &os_stream );
1484 
1485  out.append( os_stream.str() );
1486  return out;
1487 }
1488 #endif
1489 
1490 
1492 {
1493  if ( node )
1494  {
1495  TiXmlNode* child = node->FirstChild();
1496  if ( child )
1497  return TiXmlHandle( child );
1498  }
1499  return TiXmlHandle( 0 );
1500 }
1501 
1502 
1503 TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const
1504 {
1505  if ( node )
1506  {
1507  TiXmlNode* child = node->FirstChild( value );
1508  if ( child )
1509  return TiXmlHandle( child );
1510  }
1511  return TiXmlHandle( 0 );
1512 }
1513 
1514 
1516 {
1517  if ( node )
1518  {
1519  TiXmlElement* child = node->FirstChildElement();
1520  if ( child )
1521  return TiXmlHandle( child );
1522  }
1523  return TiXmlHandle( 0 );
1524 }
1525 
1526 
1527 TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const
1528 {
1529  if ( node )
1530  {
1531  TiXmlElement* child = node->FirstChildElement( value );
1532  if ( child )
1533  return TiXmlHandle( child );
1534  }
1535  return TiXmlHandle( 0 );
1536 }
1537 
1538 
1540 {
1541  if ( node )
1542  {
1543  int i;
1544  TiXmlNode* child = node->FirstChild();
1545  for ( i=0;
1546  child && i<count;
1547  child = child->NextSibling(), ++i )
1548  {
1549  // nothing
1550  }
1551  if ( child )
1552  return TiXmlHandle( child );
1553  }
1554  return TiXmlHandle( 0 );
1555 }
1556 
1557 
1558 TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const
1559 {
1560  if ( node )
1561  {
1562  int i;
1563  TiXmlNode* child = node->FirstChild( value );
1564  for ( i=0;
1565  child && i<count;
1566  child = child->NextSibling( value ), ++i )
1567  {
1568  // nothing
1569  }
1570  if ( child )
1571  return TiXmlHandle( child );
1572  }
1573  return TiXmlHandle( 0 );
1574 }
1575 
1576 
1578 {
1579  if ( node )
1580  {
1581  int i;
1582  TiXmlElement* child = node->FirstChildElement();
1583  for ( i=0;
1584  child && i<count;
1585  child = child->NextSiblingElement(), ++i )
1586  {
1587  // nothing
1588  }
1589  if ( child )
1590  return TiXmlHandle( child );
1591  }
1592  return TiXmlHandle( 0 );
1593 }
1594 
1595 
1596 TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const
1597 {
1598  if ( node )
1599  {
1600  int i;
1601  TiXmlElement* child = node->FirstChildElement( value );
1602  for ( i=0;
1603  child && i<count;
1604  child = child->NextSiblingElement( value ), ++i )
1605  {
1606  // nothing
1607  }
1608  if ( child )
1609  return TiXmlHandle( child );
1610  }
1611  return TiXmlHandle( 0 );
1612 }
1613 
1614 } //fg: end namespace gear
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Parse the given null terminated block of xml data.
bool SaveFile() const
Save a file using the current document value. Returns true if successful.
Definition: tinyxml.cc:933
TiXmlDeclaration()
Construct an empty declaration.
Definition: tinyxml.h:1065
void SetDoubleValue(double value)
Set the value from a double.
Definition: tinyxml.cc:1157
void SetValue(const char *_value)
Set the value.
Definition: tinyxml.h:728
int IntValue() const
Return the value of this attribute, converted to an integer.
Definition: tinyxml.cc:1166
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:557
virtual TiXmlNode * Clone() const
Creates a new Element and returns it - the returned element is a copy.
Definition: tinyxml.cc:872
TiXmlElement(const char *in_value)
Construct an element.
Definition: tinyxml.cc:619
virtual void Print(FILE *cfile, int depth) const =0
All TinyXml classes can print themselves to a filestream.
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
Add a new node related to this.
Definition: tinyxml.cc:201
virtual TiXmlNode * Clone() const =0
Create an exact duplicate of this node and return it.
TiXmlComment()
Constructs an empty comment.
Definition: tinyxml.h:973
virtual void Print(FILE *cfile, int depth) const
Print this declaration to a FILE stream.
Definition: tinyxml.cc:1299
bool LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Load a file using the current document value.
Definition: tinyxml.cc:921
void Clear()
Delete all the children of this node. Does not affect &#39;this&#39;.
Definition: tinyxml.cc:184
In correct XML the declaration is the first entry in the file.
Definition: tinyxml.h:1061
An attribute is a name-value pair.
Definition: tinyxml.h:677
virtual TiXmlNode * Clone() const
Creates a copy of this Unknown and returns it.
Definition: tinyxml.cc:1380
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
Definition: tinyxml.h:562
virtual void Print(FILE *cfile, int depth) const
Write this text object to a FILE stream.
Definition: tinyxml.cc:1227
void SetIntValue(int value)
Set the value from an integer.
Definition: tinyxml.cc:1150
const char * Value() const
The meaning of &#39;value&#39; changes for the specific type of TiXmlNode.
Definition: tinyxml.h:437
A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thi...
Definition: tinyxml.h:1376
const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:616
virtual void Print(FILE *cfile, int depth) const
Print this Unknown to a FILE stream.
Definition: tinyxml.cc:1360
Always the top level node.
Definition: tinyxml.h:1154
double DoubleValue() const
Return the value of this attribute, converted to a double.
Definition: tinyxml.cc:1171
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
Add a new node related to this.
Definition: tinyxml.cc:228
virtual TiXmlNode * Clone() const
Returns a copy of this Comment.
Definition: tinyxml.cc:1215
int QueryDoubleAttribute(const char *name, double *value) const
QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
Definition: tinyxml.cc:720
Any tag that tinyXml doesn&#39;t recognize is saved as an unknown.
Definition: tinyxml.h:1121
The parent class for everything in the Document Object Model.
Definition: tinyxml.h:370
const char * Attribute(const char *name) const
Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists.
Definition: tinyxml.cc:671
TiXmlHandle ChildElement(const char *value, int index) const
Return a handle to the &quot;index&quot; child element with the given name.
Definition: tinyxml.cc:1596
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
Replace a child of this node.
Definition: tinyxml.cc:280
int QueryDoubleValue(double *value) const
QueryDoubleValue examines the value string. See QueryIntValue().
Definition: tinyxml.cc:1143
virtual TiXmlNode * Clone() const
Create an exact duplicate of this node and return it.
Definition: tinyxml.cc:1031
const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:617
void * userData
Field containing a generic user pointer.
Definition: tinyxml.h:323
int QueryIntAttribute(const char *name, int *value) const
QueryIntAttribute examines the attribute - it is an alternative to the Attribute() method with richer...
Definition: tinyxml.cc:710
virtual TiXmlNode * Clone() const
Creates a copy of this Declaration and returns it.
Definition: tinyxml.cc:1348
An XML comment.
Definition: tinyxml.h:969
The element is a container class.
Definition: tinyxml.h:827
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
Definition: tinyxml.h:547
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
Add a new node related to this.
Definition: tinyxml.cc:218
bool Error() const
If an error occurs, Error will be set to true.
Definition: tinyxml.h:1215
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
Definition: tinyxml.cc:308
void SetDoubleAttribute(const char *name, double value)
Sets an attribute of name to a given value.
Definition: tinyxml.cc:738
XML text.
Definition: tinyxml.h:1005
void RemoveAttribute(const char *name)
Deletes an attribute with the given name.
Definition: tinyxml.cc:472
TiXmlHandle(TiXmlNode *aNode)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml.h:1380
virtual void Print(FILE *cfile, int depth) const
All TinyXml classes can print themselves to a filestream.
Definition: tinyxml.cc:767
void ClearError()
If you have handled the error, it can be reset with this call.
Definition: tinyxml.h:1262
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
Definition: tinyxml.h:466
TiXmlHandle Child(const char *value, int index) const
Return a handle to the &quot;index&quot; child with the given name.
Definition: tinyxml.cc:1558
const char * Value() const
Return the value of this attribute.
Definition: tinyxml.h:710
TiXmlDocument()
Create an empty document, that has no name.
Definition: tinyxml.cc:883
virtual TiXmlNode * Clone() const
[internal use] Creates a new Element and returns it.
Definition: tinyxml.cc:1247
const TiXmlElement * NextSiblingElement() const
Convenience function to get through elements.
Definition: tinyxml.cc:538
virtual void Print(FILE *cfile, int depth) const
Write this Comment to a FILE stream.
Definition: tinyxml.cc:1191
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
Add a new node related to this.
Definition: tinyxml.cc:254
TiXmlHandle FirstChildElement() const
Return a handle to the first child element.
Definition: tinyxml.cc:1515
int QueryIntValue(int *value) const
QueryIntValue examines the value string.
Definition: tinyxml.cc:1136
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
An alternate way to walk the children of a node.
Definition: tinyxml.cc:376
const TiXmlText * ToText() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:620
void SetAttribute(const char *name, const char *value)
Sets an attribute of name to a given value.
Definition: tinyxml.cc:746
virtual void Print(FILE *cfile, int depth) const
All TinyXml classes can print themselves to a filestream.
Definition: tinyxml.cc:1104
const TiXmlDocument * GetDocument() const
Return a pointer to the Document this node lives in.
Definition: tinyxml.cc:595
void Print() const
Dump the document to standard out.
Definition: tinyxml.h:1270
const TiXmlAttribute * Next() const
Get the next sibling attribute in the DOM. Returns null at end.
Definition: tinyxml.cc:1068
TiXmlText(const char *initValue)
Constructor.
Definition: tinyxml.h:1010
TiXmlHandle FirstChild() const
Return a handle to the first child node.
Definition: tinyxml.cc:1491
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
Definition: tinyxml.cc:482
const TiXmlAttribute * Previous() const
Get the previous sibling attribute in the DOM. Returns null at beginning.
Definition: tinyxml.cc:1086