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