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