34 FILE*
TiXmlFOpen(
const char* filename,
const char* mode );
39 FILE*
TiXmlFOpen(
const char* filename,
const char* mode )
41 #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) 43 errno_t err = fopen_s( &fp, filename, mode );
48 return fopen( filename, mode );
56 while( i<(
int)str.length() )
58 unsigned char c = (
unsigned char) str[i];
61 && i < ( (
int)str.length() - 2 )
75 while ( i<(
int)str.length()-1 )
77 outString->append( str.c_str() + i, 1 );
100 outString->append(
entity[3].str,
entity[3].strLength );
103 else if ( c ==
'\'' )
105 outString->append(
entity[4].str,
entity[4].strLength );
114 TIXML_SNPRINTF( buf,
sizeof(buf),
"&#x%02X;", (
unsigned) ( c & 0xff ) );
118 outString->append( buf, (
int)strlen( buf ) );
125 *outString += (char) c;
228 if ( !beforeThis || beforeThis->
parent !=
this ) {
243 node->
next = beforeThis;
245 if ( beforeThis->
prev )
254 beforeThis->
prev = node;
261 if ( !afterThis || afterThis->
parent !=
this ) {
276 node->
prev = afterThis;
278 if ( afterThis->
next )
287 afterThis->
next = node;
297 if ( replaceThis->
parent !=
this )
315 if ( replaceThis->
next )
320 if ( replaceThis->
prev )
337 if ( removeThis->
parent !=
this )
343 if ( removeThis->
next )
348 if ( removeThis->
prev )
362 if ( strcmp( node->
Value(), _value ) == 0 )
374 if ( strcmp( node->
Value(), _value ) == 0 )
389 assert( previous->
parent ==
this );
403 assert( previous->
parent ==
this );
412 for ( node =
next; node; node = node->
next )
414 if ( strcmp( node->
Value(), _value ) == 0 )
424 for ( node =
prev; node; node = node->
prev )
426 if ( strcmp( node->
Value(), _value ) == 0 )
443 attributeSet.Remove( node );
512 for( node =
this; node; node = node->
parent )
577 return node->
Value();
596 const char* result = 0;
599 result = attrib->
Value();
612 const std::string* result = 0;
628 const char* result = 0;
631 result = attrib->
Value();
644 const std::string* result = 0;
674 *value_ = (unsigned)ival;
800 for ( i=0; i<depth; i++ ) {
801 fprintf( cfile,
" " );
804 fprintf( cfile,
"<%s",
value.c_str() );
809 fprintf( cfile,
" " );
810 attrib->Print( cfile, depth );
820 fprintf( cfile,
" />" );
824 fprintf( cfile,
">" );
826 fprintf( cfile,
"</%s>",
value.c_str() );
830 fprintf( cfile,
">" );
836 fprintf( cfile,
"\n" );
838 node->
Print( cfile, depth+1 );
840 fprintf( cfile,
"\n" );
841 for( i=0; i<depth; ++i ) {
842 fprintf( cfile,
" " );
844 fprintf( cfile,
"</%s>",
value.c_str() );
859 attribute = attribute->
Next() )
877 if ( !node->Accept( visitor ) )
902 return childText->
Value();
920 value = documentName;
930 value = documentName;
971 bool result =
LoadFile( file, encoding );
996 fseek( file, 0, SEEK_END );
997 length = ftell( file );
998 fseek( file, 0, SEEK_SET );
1028 char* buf =
new char[ length+1 ];
1031 if ( fread( buf, length, 1, file ) != 1 ) {
1048 const char* p = buf;
1050 const char CR = 0x0d;
1051 const char LF = 0x0a;
1055 assert( p < (buf+length) );
1056 assert( q <= (buf+length) );
1070 assert( q <= (buf+length) );
1073 Parse( buf, 0, encoding );
1102 fputc( TIXML_UTF_LEAD_0, fp );
1103 fputc( TIXML_UTF_LEAD_1, fp );
1104 fputc( TIXML_UTF_LEAD_2, fp );
1107 return (ferror(fp) == 0);
1146 node->Print( cfile, depth );
1147 fprintf( cfile,
"\n" );
1158 if ( !node->Accept( visitor ) )
1213 if (
value.find (
'\"') == TIXML_STRING::npos) {
1215 fprintf (cfile,
"%s=\"%s\"", n.c_str(), v.c_str() );
1218 (*str) += n; (*str) +=
"=\""; (*str) += v; (*str) +=
"\"";
1223 fprintf (cfile,
"%s='%s'", n.c_str(), v.c_str() );
1226 (*str) += n; (*str) +=
"='"; (*str) += v; (*str) +=
"'";
1262 return atoi (
value.c_str ());
1267 return atof (
value.c_str ());
1288 for (
int i=0; i<depth; i++ )
1290 fprintf( cfile,
" " );
1292 fprintf( cfile,
"<!--%s-->",
value.c_str() );
1304 return visitor->
Visit( *
this );
1326 fprintf( cfile,
"\n" );
1327 for ( i=0; i<depth; i++ ) {
1328 fprintf( cfile,
" " );
1330 fprintf( cfile,
"<![CDATA[%s]]>\n",
value.c_str() );
1336 fprintf( cfile,
"%s", buffer.c_str() );
1344 target->
cdata = cdata;
1350 return visitor->
Visit( *
this );
1368 const char * _encoding,
1369 const char * _standalone )
1378 #ifdef TIXML_USE_STL 1380 const std::string& _encoding,
1381 const std::string& _standalone )
1408 if ( cfile ) fprintf( cfile,
"<?xml " );
1409 if ( str ) (*str) +=
"<?xml ";
1412 if ( cfile ) fprintf (cfile,
"version=\"%s\" ",
version.c_str ());
1413 if ( str ) { (*str) +=
"version=\""; (*str) +=
version; (*str) +=
"\" "; }
1416 if ( cfile ) fprintf (cfile,
"encoding=\"%s\" ",
encoding.c_str ());
1417 if ( str ) { (*str) +=
"encoding=\""; (*str) +=
encoding; (*str) +=
"\" "; }
1420 if ( cfile ) fprintf (cfile,
"standalone=\"%s\" ",
standalone.c_str ());
1421 if ( str ) { (*str) +=
"standalone=\""; (*str) +=
standalone; (*str) +=
"\" "; }
1423 if ( cfile ) fprintf( cfile,
"?>" );
1424 if ( str ) (*str) +=
"?>";
1440 return visitor->
Visit( *
this );
1458 for (
int i=0; i<depth; i++ )
1459 fprintf( cfile,
" " );
1460 fprintf( cfile,
"<%s>",
value.c_str() );
1472 return visitor->
Visit( *
this );
1490 sentinel.next = &sentinel;
1491 sentinel.prev = &sentinel;
1497 assert( sentinel.next == &sentinel );
1498 assert( sentinel.prev == &sentinel );
1504 #ifdef TIXML_USE_STL 1507 assert( !Find( addMe->
Name() ) );
1510 addMe->
next = &sentinel;
1514 sentinel.
prev = addMe;
1521 for( node = sentinel.
next; node != &sentinel; node = node->
next )
1523 if ( node == removeMe )
1536 #ifdef TIXML_USE_STL 1541 if ( node->name == name )
1564 if ( strcmp( node->name.c_str(),
name ) == 0 )
1583 #ifdef TIXML_USE_STL 1587 tag.reserve( 8 * 1000 );
1596 #ifdef TIXML_USE_STL 1602 out << printer.
Str();
1613 out.append( printer.
Str() );
1758 buffer += element.
Value();
1760 for(
const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->
Next() )
1763 attrib->Print( 0, 0, &buffer );
1778 simpleTextPrint =
true;
1800 if ( simpleTextPrint )
1802 simpleTextPrint =
false;
1809 buffer += element.
Value();
1822 buffer +=
"<![CDATA[";
1823 buffer += text.
Value();
1827 else if ( simpleTextPrint )
1848 declaration.
Print( 0, 0, &buffer );
1858 buffer += comment.
Value();
1869 buffer += unknown.
Value();
int QueryIntValue(int *_value) const
int QueryBoolAttribute(const char *name, bool *_value) const
friend std::ostream & operator<<(std::ostream &out, const TiXmlNode &base)
const TiXmlNode * LastChild() const
virtual void Print(FILE *cfile, int depth) const
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)=0
const char * Name() const
Return the name of this attribute.
int QueryDoubleAttribute(const char *name, double *_value) const
QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
int QueryDoubleValue(double *_value) const
QueryDoubleValue examines the value string. See QueryIntValue().
TiXmlElement & operator=(const TiXmlElement &base)
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
void CopyTo(TiXmlDocument *target) const
TiXmlAttribute * FindOrCreate(const char *_name)
TiXmlHandle ChildElement(const char *value, int index) const
const char * GetText() const
virtual bool Accept(TiXmlVisitor *content) const
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlNode * Clone() const
Creates a copy of this Unknown and returns it.
const unsigned char TIXML_UTF_LEAD_2
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
size_t count(InputIterator first, InputIterator last, T const &item)
bool CDATA() const
Queries whether this represents text using a CDATA section.
void SetName(const char *_name)
Set the name of this attribute.
TiXmlDocument()
Create an empty document, that has no name.
virtual bool Accept(TiXmlVisitor *visitor) const
void CopyTo(TiXmlElement *target) const
TiXmlAttribute * Find(const char *_name) const
void CopyTo(TiXmlUnknown *target) const
friend std::istream & operator>>(std::istream &in, TiXmlNode &base)
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 TIXML_STRING & ValueTStr() const
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
void CopyTo(TiXmlDeclaration *target) const
static bool condenseWhiteSpace
const std::string & ValueStr() const
Return the value of this attribute.
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
int QueryUnsignedAttribute(const char *name, unsigned *_value) const
QueryUnsignedAttribute examines the attribute - see QueryIntAttribute().
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
bool SaveFile() const
Save a file using the current document value. Returns true if successful.
TiXmlHandle Child(const char *value, int index) const
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
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 TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
const char * Value() const
Return the value of this attribute.
TiXmlAttributeSet attributeSet
int QueryIntAttribute(const char *name, int *_value) const
const TiXmlEncoding TIXML_DEFAULT_ENCODING
void SetDoubleAttribute(const std::string &name, double value)
int IntValue() const
Return the value of this attribute, converted to an integer.
virtual TiXmlNode * Clone() const
Creates a copy of this Declaration and returns it.
virtual TiXmlNode * Clone() const
[internal use] Creates a new Element and returns it.
const char * Value() const
void CopyTo(TiXmlText *target) const
const unsigned char TIXML_UTF_LEAD_1
void RemoveAttribute(const char *name)
void SetAttribute(const char *name, const char *_value)
virtual void Print(FILE *cfile, int depth) const
double DoubleValue() const
Return the value of this attribute, converted to a double.
const TiXmlElement * NextSiblingElement() const
TiXmlHandle FirstChild() const
Return a handle to the first child node.
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0
FILE * TiXmlFOpen(const char *filename, const char *mode)
TiXmlElement(const char *in_value)
Construct an element.
const unsigned char TIXML_UTF_LEAD_0
static Entity entity[NUM_ENTITY]
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
void CopyTo(TiXmlNode *target) const
void Add(TiXmlAttribute *attribute)
const TiXmlAttribute * Next() const
Get the next sibling attribute in the DOM. Returns null at end.
const TiXmlDocument * GetDocument() const
TiXmlDeclaration & operator=(const TiXmlDeclaration ©)
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
virtual bool VisitEnter(const TiXmlDocument &doc)
Visit a document.
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
virtual TiXmlNode * Clone() const
Creates a new Element and returns it - the returned element is a copy.
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
TiXmlNode(NodeType _type)
static void EncodeString(const TIXML_STRING &str, TIXML_STRING *out)
const TiXmlAttribute * First() const
void SetIntValue(int _value)
Set the value from an integer.
virtual bool VisitExit(const TiXmlDocument &)
Visit a document.
virtual TiXmlNode * Clone() const
const char * Attribute(const char *name) const
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
TiXmlDocument & operator=(const TiXmlDocument ©)
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
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 TiXmlAttribute * Previous() const
Get the previous sibling attribute in the DOM. Returns null at beginning.
const std::string & Str()
Return the result.
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
virtual bool Accept(TiXmlVisitor *content) const
virtual bool Accept(TiXmlVisitor *visitor) const
TiXmlHandle FirstChildElement() const
Return a handle to the first child element.
TiXmlDeclaration()
Construct an empty declaration.
virtual void Print(FILE *cfile, int depth) const =0
virtual TiXmlNode * Clone() const =0
virtual void Print(FILE *cfile, int depth, TIXML_STRING *str) const
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
virtual bool Visit(const TiXmlDeclaration &declaration)
Visit a declaration.
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
TiXmlCursor errorLocation
virtual bool Accept(TiXmlVisitor *content) const
virtual void Print(FILE *cfile, int depth) const
virtual bool Visit(const TiXmlDeclaration &)
Visit a declaration.