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