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