41 #include <boost/lexical_cast.hpp>
48 #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
50 errno_t err = fopen_s( &fp, filename, mode );
55 return fopen( filename, mode );
63 while( i<(
int)str.length() )
65 unsigned char c = (
unsigned char) str[i];
68 && i < ( (
int)str.length() - 2 )
82 while ( i<(
int)str.length()-1 )
84 outString->append( str.c_str() +
i, 1 );
102 outString->append(
entity[2].str,
entity[2].strLength );
105 else if ( c ==
'\"' )
107 outString->append(
entity[3].str,
entity[3].strLength );
110 else if ( c ==
'\'' )
112 outString->append(
entity[4].str,
entity[4].strLength );
121 #if defined(TIXML_SNPRINTF)
122 TIXML_SNPRINTF( buf,
sizeof(buf),
"&#x%02X;", (
unsigned) ( c & 0xff ) );
124 snprintf( buf,
sizeof(buf),
"&#x%02X;", (
unsigned) ( c & 0xff ) );
129 outString->append( buf, (
int)strlen( buf ) );
136 *outString += (
char) c;
236 if ( !beforeThis || beforeThis->
parent !=
this ) {
250 node->
next = beforeThis;
252 if ( beforeThis->
prev )
268 if ( !afterThis || afterThis->
parent !=
this ) {
282 node->
prev = afterThis;
284 if ( afterThis->
next )
300 if ( replaceThis->
parent !=
this )
310 if ( replaceThis->
next )
315 if ( replaceThis->
prev )
328 if ( removeThis->
parent !=
this )
334 if ( removeThis->
next )
339 if ( removeThis->
prev )
353 if ( strcmp( node->
Value(), _value ) == 0 )
365 if ( strcmp( node->
Value(), _value ) == 0 )
380 assert( previous->
parent ==
this );
394 assert( previous->
parent ==
this );
405 if ( strcmp( node->
Value(), _value ) == 0 )
417 if ( strcmp( node->
Value(), _value ) == 0 )
568 return node->
Value();
607 *i = atoi( s->c_str() );
641 *d = atof( s->c_str() );
695 #if defined(TIXML_SNPRINTF)
696 TIXML_SNPRINTF( buf,
sizeof(buf),
"%d", val );
698 snprintf( buf,
sizeof(buf),
"%d", val );
707 std::ostringstream oss;
717 #if defined(TIXML_SNPRINTF)
718 TIXML_SNPRINTF( buf,
sizeof(buf),
"%f", val );
720 snprintf( buf,
sizeof(buf),
"%f", val );
732 const char* _name = cname;
733 const char* _value = cvalue;
784 for ( i=0; i<depth; i++ ) {
785 fprintf( cfile,
" " );
788 fprintf( cfile,
"<%s",
value.c_str() );
793 fprintf( cfile,
" " );
794 attrib->Print( cfile, depth );
804 fprintf( cfile,
" />" );
808 fprintf( cfile,
">" );
810 fprintf( cfile,
"</%s>",
value.c_str() );
814 fprintf( cfile,
">" );
820 fprintf( cfile,
"\n" );
822 node->
Print( cfile, depth+1 );
824 fprintf( cfile,
"\n" );
825 for( i=0; i<depth; ++
i ) {
826 fprintf( cfile,
" " );
828 fprintf( cfile,
"</%s>",
value.c_str() );
843 attribute = attribute->
Next() )
861 if ( !
node->Accept( visitor ) )
886 return childText->
Value();
904 value = documentName;
914 value = documentName;
997 fseek( file, 0, SEEK_END );
998 length = ftell( file );
999 fseek( file, 0, SEEK_SET );
1011 data.reserve( length );
1034 char* buf =
new char[ length+1 ];
1037 if ( fread( buf, length, 1, file ) != 1 ) {
1043 const char* lastPos = buf;
1044 const char*
p = buf;
1048 assert( p < (buf+length) );
1052 data.append( lastPos, (p-lastPos+1) );
1055 assert( p <= (buf+length) );
1057 else if ( *p == 0xd ) {
1060 if ( (p-lastPos) > 0 ) {
1061 data.append( lastPos, p-lastPos );
1065 if ( *(p+1) == 0xa ) {
1069 assert( p <= (buf+length) );
1075 assert( p <= (buf+length) );
1084 data.append( lastPos, p-lastPos );
1089 Parse( data.c_str(), 0, encoding );
1120 fputc( TIXML_UTF_LEAD_0, fp );
1121 fputc( TIXML_UTF_LEAD_1, fp );
1122 fputc( TIXML_UTF_LEAD_2, fp );
1125 return (ferror(fp) == 0);
1164 node->Print( cfile, depth );
1165 fprintf( cfile,
"\n" );
1176 if ( !
node->Accept( visitor ) )
1231 if (
value.find (
'\"') == TIXML_STRING::npos) {
1233 fprintf (cfile,
"%s=\"%s\"", n.c_str(), v.c_str() );
1236 (*str) +=
n; (*str) +=
"=\""; (*str) +=
v; (*str) +=
"\"";
1241 fprintf (cfile,
"%s='%s'", n.c_str(), v.c_str() );
1244 (*str) +=
n; (*str) +=
"='"; (*str) +=
v; (*str) +=
"'";
1253 *ival = boost::lexical_cast<
int>(
value);
1254 }
catch(boost::bad_lexical_cast
const&) {
1263 *dval = boost::lexical_cast<
double>(
value);
1264 }
catch(boost::bad_lexical_cast
const&) {
1273 #if defined(TIXML_SNPRINTF)
1274 TIXML_SNPRINTF(buf,
sizeof(buf),
"%d", _value);
1276 snprintf (buf,
sizeof(buf),
"%d", _value);
1284 #if defined(TIXML_SNPRINTF)
1285 TIXML_SNPRINTF( buf,
sizeof(buf),
"%f", _value);
1287 snprintf (buf,
sizeof(buf),
"%f", _value);
1294 return atoi (
value.c_str ());
1299 return atof (
value.c_str ());
1320 for (
int i=0;
i<depth;
i++ )
1322 fprintf( cfile,
" " );
1324 fprintf( cfile,
"<!--%s-->",
value.c_str() );
1336 return visitor->
Visit( *
this );
1358 fprintf( cfile,
"\n" );
1359 for ( i=0; i<depth; i++ ) {
1360 fprintf( cfile,
" " );
1362 fprintf( cfile,
"<![CDATA[%s]]>\n",
value.c_str() );
1368 fprintf( cfile,
"%s", buffer.c_str() );
1382 return visitor->
Visit( *
this );
1400 const char * _encoding,
1401 const char * _standalone )
1410 #ifdef TIXML_USE_STL
1440 if ( cfile ) fprintf( cfile,
"<?xml " );
1441 if ( str ) (*str) +=
"<?xml ";
1444 if ( cfile ) fprintf (cfile,
"version=\"%s\" ",
version.c_str ());
1445 if ( str ) { (*str) +=
"version=\""; (*str) +=
version; (*str) +=
"\" "; }
1448 if ( cfile ) fprintf (cfile,
"encoding=\"%s\" ",
encoding.c_str ());
1449 if ( str ) { (*str) +=
"encoding=\""; (*str) +=
encoding; (*str) +=
"\" "; }
1452 if ( cfile ) fprintf (cfile,
"standalone=\"%s\" ",
standalone.c_str ());
1453 if ( str ) { (*str) +=
"standalone=\""; (*str) +=
standalone; (*str) +=
"\" "; }
1455 if ( cfile ) fprintf( cfile,
"?>" );
1456 if ( str ) (*str) +=
"?>";
1472 return visitor->
Visit( *
this );
1490 for (
int i=0;
i<depth;
i++ )
1491 fprintf( cfile,
" " );
1492 fprintf( cfile,
"<%s>",
value.c_str() );
1504 return visitor->
Visit( *
this );
1536 #ifdef TIXML_USE_STL
1555 if ( node == removeMe )
1568 #ifdef TIXML_USE_STL
1573 if (
node->name == name )
1597 if ( strcmp(
node->name.c_str(),
name ) == 0 )
1615 #ifdef TIXML_USE_STL
1619 tag.reserve( 8 * 1000 );
1628 #ifdef TIXML_USE_STL
1634 out << printer.
Str();
1645 out.append( printer.
Str() );
1792 for(
const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->
Next() )
1795 attrib->Print( 0, 0, &
buffer );
const TiXmlAttribute * First() const
TiXmlHandle(TiXmlNode *_node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
virtual TiXmlNode * Clone() const
Creates a copy of this Declaration and returns it.
virtual bool Accept(TiXmlVisitor *visitor) const
const unsigned char TIXML_UTF_LEAD_2
const TIXML_STRING & ValueTStr() const
virtual TiXmlNode * Clone() const
Creates a new Element and returns it - the returned element is a copy.
double DoubleValue() const
Return the value of this attribute, converted to a double.
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)=0
int IntValue() const
Return the value of this attribute, converted to an integer.
TiXmlHandle FirstChild() const
Return a handle to the first child node.
void CopyTo(TiXmlUnknown *target) const
void CopyTo(TiXmlDocument *target) const
TiXmlElement & operator=(const TiXmlElement &base)
void SetDoubleAttribute(const char *name, double value)
virtual void Print(FILE *cfile, int depth) const
virtual TiXmlNode * Clone() const
[internal use] Creates a new Element and returns it.
virtual void Print(FILE *cfile, int depth, TIXML_STRING *str) const
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
TiXmlDocument()
Create an empty document, that has no name.
std::ostream & operator<<(std::ostream &out, const ALILine &li)
const char * Value() const
Return the value of this attribute.
int QueryIntValue(int *_value) const
virtual void Print(FILE *cfile, int depth) const
bool LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
void SetValue(const char *_value)
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
virtual bool VisitExit(const TiXmlDocument &doc)
Visit a document.
const unsigned char TIXML_UTF_LEAD_0
FILE * TiXmlFOpen(const char *filename, const char *mode)
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
static bool condenseWhiteSpace
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
TiXmlHandle FirstChildElement() const
Return a handle to the first child element.
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
const TiXmlNode * LastChild() const
const char * Name() const
Return the name of this attribute.
void SetDoubleValue(double _value)
Set the value from a double.
void * userData
Field containing a generic user pointer.
virtual bool Accept(TiXmlVisitor *visitor) const =0
const unsigned char TIXML_UTF_LEAD_1
TiXmlAttributeSet attributeSet
const TiXmlEncoding TIXML_DEFAULT_ENCODING
TiXmlHandle ChildElement(const char *value, int index) const
virtual bool Accept(TiXmlVisitor *content) const
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
const TiXmlAttribute * Next() const
Get the next sibling attribute in the DOM. Returns null at end.
void RemoveAttribute(const char *name)
virtual TiXmlNode * Clone() const
void SetAttribute(const char *name, const char *_value)
virtual void Print(FILE *cfile, int depth) const
virtual void Print(FILE *cfile, int depth) const
bool SaveFile() const
Save a file using the current document value. Returns true if successful.
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0
int QueryDoubleValue(double *_value) const
QueryDoubleValue examines the value string. See QueryIntValue().
TiXmlElement(const char *in_value)
Construct an element.
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
const TiXmlAttribute * Find(const char *_name) const
static Entity entity[NUM_ENTITY]
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
TiXmlHandle Child(const char *value, int index) const
void Add(TiXmlAttribute *attribute)
const std::string & ValueStr() const
Return the value of this attribute.
const TiXmlDocument * GetDocument() const
bool CDATA() const
Queries whether this represents text using a CDATA section.
const TiXmlAttribute * Previous() const
Get the previous sibling attribute in the DOM. Returns null at beginning.
const TiXmlElement * NextSiblingElement() const
TiXmlDeclaration & operator=(const TiXmlDeclaration ©)
virtual bool VisitEnter(const TiXmlDocument &doc)
Visit a document.
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
int QueryIntAttribute(const char *name, int *_value) const
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
virtual bool Accept(TiXmlVisitor *content) const
TiXmlNode(NodeType _type)
static void EncodeString(const TIXML_STRING &str, TIXML_STRING *out)
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
void CopyTo(TiXmlNode *target) const
void SetIntValue(int _value)
Set the value from an integer.
virtual TiXmlNode * Clone() const
Creates a copy of this Unknown and returns it.
std::istream & operator>>(std::istream &input, CLHEP::HepGenMatrix &matrix)
char data[epos_bytes_allocation]
virtual bool VisitExit(const TiXmlDocument &)
Visit a document.
int QueryDoubleAttribute(const char *name, double *_value) const
QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
TiXmlText(const char *initValue)
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
const char * Value() const
TiXmlDocument & operator=(const TiXmlDocument ©)
void CopyTo(TiXmlText *target) const
void CopyTo(TiXmlElement *target) const
virtual bool Accept(TiXmlVisitor *visitor) const
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
volatile std::atomic< bool > shutdown_flag false
const char * GetText() const
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
void Remove(TiXmlAttribute *attribute)
void Clear()
Delete all the children of this node. Does not affect 'this'.
void SetValue(const char *_value)
Set the value.
const std::string & Str()
Return the result.
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
TiXmlDeclaration()
Construct an empty declaration.
const char * Attribute(const char *name) const
virtual void Print(FILE *cfile, int depth) const =0
virtual bool Accept(TiXmlVisitor *content) const
virtual TiXmlNode * Clone() const =0
virtual bool Visit(const TiXmlDeclaration &declaration)
Visit a declaration.
void CopyTo(TiXmlDeclaration *target) const
TiXmlCursor errorLocation
virtual bool Visit(const TiXmlDeclaration &)
Visit a declaration.