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