42 #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
44 errno_t err = fopen_s( &fp, filename, mode );
49 return fopen( filename, mode );
57 while( i<(
int)str.length() )
59 unsigned char c = (
unsigned char) str[i];
62 && i < ( (
int)str.length() - 2 )
76 while ( i<(
int)str.length()-1 )
78 outString->append( str.c_str() +
i, 1 );
101 outString->append(
entity[3].str,
entity[3].strLength );
104 else if ( c ==
'\'' )
106 outString->append(
entity[4].str,
entity[4].strLength );
115 #if defined(TIXML_SNPRINTF)
116 TIXML_SNPRINTF( buf,
sizeof(buf),
"&#x%02X;", (
unsigned) ( c & 0xff ) );
118 sprintf( buf,
"&#x%02X;", (
unsigned) ( c & 0xff ) );
123 outString->append( buf, (
int)strlen( buf ) );
130 *outString += (char) c;
230 if ( !beforeThis || beforeThis->
parent !=
this ) {
244 node->
next = beforeThis;
246 if ( beforeThis->
prev )
262 if ( !afterThis || afterThis->
parent !=
this ) {
276 node->
prev = afterThis;
278 if ( afterThis->
next )
294 if ( replaceThis->
parent !=
this )
304 if ( replaceThis->
next )
309 if ( replaceThis->
prev )
322 if ( removeThis->
parent !=
this )
328 if ( removeThis->
next )
333 if ( removeThis->
prev )
347 if ( strcmp( node->
Value(), _value ) == 0 )
359 if ( strcmp( node->
Value(), _value ) == 0 )
374 assert( previous->
parent ==
this );
388 assert( previous->
parent ==
this );
399 if ( strcmp( node->
Value(), _value ) == 0 )
411 if ( strcmp( node->
Value(), _value ) == 0 )
561 return node->
Value();
600 *i = atoi( s->c_str() );
634 *d = atof( s->c_str() );
688 #if defined(TIXML_SNPRINTF)
689 TIXML_SNPRINTF( buf,
sizeof(buf),
"%d", val );
691 sprintf( buf,
"%d", val );
700 std::ostringstream oss;
710 #if defined(TIXML_SNPRINTF)
711 TIXML_SNPRINTF( buf,
sizeof(buf),
"%f", val );
713 sprintf( buf,
"%f", val );
725 const char* _name = cname;
726 const char* _value = cvalue;
777 for ( i=0; i<depth; i++ ) {
778 fprintf( cfile,
" " );
781 fprintf( cfile,
"<%s",
value.c_str() );
786 fprintf( cfile,
" " );
787 attrib->Print( cfile, depth );
797 fprintf( cfile,
" />" );
801 fprintf( cfile,
">" );
803 fprintf( cfile,
"</%s>",
value.c_str() );
807 fprintf( cfile,
">" );
813 fprintf( cfile,
"\n" );
815 node->
Print( cfile, depth+1 );
817 fprintf( cfile,
"\n" );
818 for( i=0; i<depth; ++
i ) {
819 fprintf( cfile,
" " );
821 fprintf( cfile,
"</%s>",
value.c_str() );
836 attribute = attribute->
Next() )
854 if ( !
node->Accept( visitor ) )
879 return childText->
Value();
897 value = documentName;
907 value = documentName;
989 fseek( file, 0, SEEK_END );
990 length = ftell( file );
991 fseek( file, 0, SEEK_SET );
1003 data.reserve( length );
1026 char* buf =
new char[ length+1 ];
1029 if ( fread( buf, length, 1, file ) != 1 ) {
1035 const char* lastPos = buf;
1036 const char*
p = buf;
1040 assert( p < (buf+length) );
1044 data.append( lastPos, (p-lastPos+1) );
1047 assert( p <= (buf+length) );
1049 else if ( *p == 0xd ) {
1052 if ( (p-lastPos) > 0 ) {
1053 data.append( lastPos, p-lastPos );
1057 if ( *(p+1) == 0xa ) {
1061 assert( p <= (buf+length) );
1067 assert( p <= (buf+length) );
1076 data.append( lastPos, p-lastPos );
1081 Parse( data.c_str(), 0, encoding );
1112 fputc( TIXML_UTF_LEAD_0, fp );
1113 fputc( TIXML_UTF_LEAD_1, fp );
1114 fputc( TIXML_UTF_LEAD_2, fp );
1117 return (ferror(fp) == 0);
1156 node->Print( cfile, depth );
1157 fprintf( cfile,
"\n" );
1168 if ( !
node->Accept( visitor ) )
1223 if (
value.find (
'\"') == TIXML_STRING::npos) {
1225 fprintf (cfile,
"%s=\"%s\"", n.c_str(), v.c_str() );
1228 (*str) +=
n; (*str) +=
"=\""; (*str) +=
v; (*str) +=
"\"";
1233 fprintf (cfile,
"%s='%s'", n.c_str(), v.c_str() );
1236 (*str) +=
n; (*str) +=
"='"; (*str) +=
v; (*str) +=
"'";
1259 #if defined(TIXML_SNPRINTF)
1260 TIXML_SNPRINTF(buf,
sizeof(buf),
"%d", _value);
1262 sprintf (buf,
"%d", _value);
1270 #if defined(TIXML_SNPRINTF)
1271 TIXML_SNPRINTF( buf,
sizeof(buf),
"%f", _value);
1273 sprintf (buf,
"%f", _value);
1280 return atoi (
value.c_str ());
1285 return atof (
value.c_str ());
1305 for (
int i=0;
i<depth;
i++ )
1307 fprintf( cfile,
" " );
1309 fprintf( cfile,
"<!--%s-->",
value.c_str() );
1321 return visitor->
Visit( *
this );
1343 fprintf( cfile,
"\n" );
1344 for ( i=0; i<depth; i++ ) {
1345 fprintf( cfile,
" " );
1347 fprintf( cfile,
"<![CDATA[%s]]>\n",
value.c_str() );
1353 fprintf( cfile,
"%s", buffer.c_str() );
1367 return visitor->
Visit( *
this );
1385 const char * _encoding,
1386 const char * _standalone )
1395 #ifdef TIXML_USE_STL
1397 const std::string& _encoding,
1398 const std::string& _standalone )
1424 if ( cfile ) fprintf( cfile,
"<?xml " );
1425 if ( str ) (*str) +=
"<?xml ";
1428 if ( cfile ) fprintf (cfile,
"version=\"%s\" ",
version.c_str ());
1429 if ( str ) { (*str) +=
"version=\""; (*str) +=
version; (*str) +=
"\" "; }
1432 if ( cfile ) fprintf (cfile,
"encoding=\"%s\" ",
encoding.c_str ());
1433 if ( str ) { (*str) +=
"encoding=\""; (*str) +=
encoding; (*str) +=
"\" "; }
1436 if ( cfile ) fprintf (cfile,
"standalone=\"%s\" ",
standalone.c_str ());
1437 if ( str ) { (*str) +=
"standalone=\""; (*str) +=
standalone; (*str) +=
"\" "; }
1439 if ( cfile ) fprintf( cfile,
"?>" );
1440 if ( str ) (*str) +=
"?>";
1456 return visitor->
Visit( *
this );
1474 for (
int i=0;
i<depth;
i++ )
1475 fprintf( cfile,
" " );
1476 fprintf( cfile,
"<%s>",
value.c_str() );
1488 return visitor->
Visit( *
this );
1520 #ifdef TIXML_USE_STL
1539 if ( node == removeMe )
1552 #ifdef TIXML_USE_STL
1557 if (
node->name == name )
1581 if ( strcmp(
node->name.c_str(),
name ) == 0 )
1599 #ifdef TIXML_USE_STL
1603 tag.reserve( 8 * 1000 );
1612 #ifdef TIXML_USE_STL
1618 out << printer.
Str();
1629 out.append( printer.
Str() );
1776 for(
const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->
Next() )
1779 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
void SetDoubleAttribute(const char *name, double value)
virtual void Print(FILE *cfile, int depth) const
void operator=(const TiXmlDeclaration ©)
virtual TiXmlNode * Clone() const
[internal use] Creates a new Element and returns it.
void operator=(const TiXmlDocument ©)
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
virtual bool VisitEnter(const TiXmlDocument &doc)
Visit a document.
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
void operator=(const TiXmlElement &base)
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)
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
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.
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.