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


rtt
Author(s): RTT Developers
autogenerated on Fri Oct 25 2019 03:59:44