test
CMS 3D CMS Logo

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