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 #if defined(TIXML_SNPRINTF) 115 TIXML_SNPRINTF( buf,
sizeof(buf),
"&#x%02X;", (
unsigned) ( c & 0xff ) );
117 sprintf( buf,
"&#x%02X;", (
unsigned) ( c & 0xff ) );
122 outString->append( buf, (
int)strlen( buf ) );
129 *outString += (char) c;
232 if ( !beforeThis || beforeThis->
parent !=
this ) {
247 node->
next = beforeThis;
249 if ( beforeThis->
prev )
258 beforeThis->
prev = node;
265 if ( !afterThis || afterThis->
parent !=
this ) {
280 node->
prev = afterThis;
282 if ( afterThis->
next )
291 afterThis->
next = node;
301 if ( replaceThis->
parent !=
this )
319 if ( replaceThis->
next )
324 if ( replaceThis->
prev )
341 if ( removeThis->
parent !=
this )
347 if ( removeThis->
next )
352 if ( removeThis->
prev )
366 if ( strcmp( node->
Value(), _value ) == 0 )
378 if ( strcmp( node->
Value(), _value ) == 0 )
393 assert( previous->
parent ==
this );
407 assert( previous->
parent ==
this );
416 for ( node =
next; node; node = node->
next )
418 if ( strcmp( node->
Value(), _value ) == 0 )
428 for ( node =
prev; node; node = node->
prev )
430 if ( strcmp( node->
Value(), _value ) == 0 )
447 attributeSet.Remove( node );
516 for( node =
this; node; node = node->
parent )
581 return node->
Value();
591 return &attrib->ValueStr();
600 const char* result = 0;
603 result = attrib->
Value();
616 const std::string* result = 0;
619 result = &attrib->ValueStr();
632 const char* result = 0;
635 result = attrib->
Value();
648 const std::string* result = 0;
651 result = &attrib->ValueStr();
678 *value = (unsigned)ival;
804 for ( i=0; i<depth; i++ ) {
805 fprintf( cfile,
" " );
808 fprintf( cfile,
"<%s",
value.c_str() );
813 fprintf( cfile,
" " );
814 attrib->Print( cfile, depth );
824 fprintf( cfile,
" />" );
828 fprintf( cfile,
">" );
830 fprintf( cfile,
"</%s>",
value.c_str() );
834 fprintf( cfile,
">" );
840 fprintf( cfile,
"\n" );
842 node->
Print( cfile, depth+1 );
844 fprintf( cfile,
"\n" );
845 for( i=0; i<depth; ++i ) {
846 fprintf( cfile,
" " );
848 fprintf( cfile,
"</%s>",
value.c_str() );
863 attribute = attribute->
Next() )
881 if ( !node->Accept( visitor ) )
906 return childText->
Value();
924 value = documentName;
934 value = documentName;
975 bool result =
LoadFile( file, encoding );
1000 fseek( file, 0, SEEK_END );
1001 length = ftell( file );
1002 fseek( file, 0, SEEK_SET );
1032 char* buf =
new char[ length+1 ];
1035 if ( fread( buf, length, 1, file ) != 1 ) {
1052 const char* p = buf;
1054 const char CR = 0x0d;
1055 const char LF = 0x0a;
1059 assert( p < (buf+length) );
1060 assert( q <= (buf+length) );
1074 assert( q <= (buf+length) );
1077 Parse( buf, 0, encoding );
1106 fputc( TIXML_UTF_LEAD_0, fp );
1107 fputc( TIXML_UTF_LEAD_1, fp );
1108 fputc( TIXML_UTF_LEAD_2, fp );
1111 return (ferror(fp) == 0);
1150 node->Print( cfile, depth );
1151 fprintf( cfile,
"\n" );
1162 if ( !node->Accept( visitor ) )
1217 if (
value.find (
'\"') == TIXML_STRING::npos) {
1219 fprintf (cfile,
"%s=\"%s\"", n.c_str(), v.c_str() );
1222 (*str) += n; (*str) +=
"=\""; (*str) += v; (*str) +=
"\"";
1227 fprintf (cfile,
"%s='%s'", n.c_str(), v.c_str() );
1230 (*str) += n; (*str) +=
"='"; (*str) += v; (*str) +=
"'";
1253 #if defined(TIXML_SNPRINTF) 1256 sprintf (buf,
"%d", _value);
1264 #if defined(TIXML_SNPRINTF) 1267 sprintf (buf,
"%g", _value);
1274 return atoi (
value.c_str ());
1279 return atof (
value.c_str ());
1300 for (
int i=0; i<depth; i++ )
1302 fprintf( cfile,
" " );
1304 fprintf( cfile,
"<!--%s-->",
value.c_str() );
1316 return visitor->
Visit( *
this );
1338 fprintf( cfile,
"\n" );
1339 for ( i=0; i<depth; i++ ) {
1340 fprintf( cfile,
" " );
1342 fprintf( cfile,
"<![CDATA[%s]]>\n",
value.c_str() );
1348 fprintf( cfile,
"%s", buffer.c_str() );
1356 target->
cdata = cdata;
1362 return visitor->
Visit( *
this );
1380 const char * _encoding,
1381 const char * _standalone )
1390 #ifdef TIXML_USE_STL 1392 const std::string& _encoding,
1393 const std::string& _standalone )
1420 if ( cfile ) fprintf( cfile,
"<?xml " );
1421 if ( str ) (*str) +=
"<?xml ";
1424 if ( cfile ) fprintf (cfile,
"version=\"%s\" ",
version.c_str ());
1425 if ( str ) { (*str) +=
"version=\""; (*str) +=
version; (*str) +=
"\" "; }
1428 if ( cfile ) fprintf (cfile,
"encoding=\"%s\" ",
encoding.c_str ());
1429 if ( str ) { (*str) +=
"encoding=\""; (*str) +=
encoding; (*str) +=
"\" "; }
1432 if ( cfile ) fprintf (cfile,
"standalone=\"%s\" ",
standalone.c_str ());
1433 if ( str ) { (*str) +=
"standalone=\""; (*str) +=
standalone; (*str) +=
"\" "; }
1435 if ( cfile ) fprintf( cfile,
"?>" );
1436 if ( str ) (*str) +=
"?>";
1452 return visitor->
Visit( *
this );
1470 for (
int i=0; i<depth; i++ )
1471 fprintf( cfile,
" " );
1472 fprintf( cfile,
"<%s>",
value.c_str() );
1484 return visitor->
Visit( *
this );
1502 sentinel.next = &sentinel;
1503 sentinel.prev = &sentinel;
1509 assert( sentinel.next == &sentinel );
1510 assert( sentinel.prev == &sentinel );
1516 #ifdef TIXML_USE_STL 1519 assert( !Find( addMe->
Name() ) );
1522 addMe->
next = &sentinel;
1526 sentinel.
prev = addMe;
1533 for( node = sentinel.
next; node != &sentinel; node = node->
next )
1535 if ( node == removeMe )
1548 #ifdef TIXML_USE_STL 1553 if ( node->name == name )
1576 if ( strcmp( node->name.c_str(), name ) == 0 )
1595 #ifdef TIXML_USE_STL 1599 tag.reserve( 8 * 1000 );
1600 base.StreamIn( &in, &tag );
1608 #ifdef TIXML_USE_STL 1609 std::ostream& operator<< (std::ostream & out,
const TiXmlNode & base)
1614 out << printer.Str();
1620 std::string& operator<< (std::string& out,
const TiXmlNode& base )
1625 out.append( printer.Str() );
1770 buffer += element.
Value();
1772 for(
const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->
Next() )
1775 attrib->Print( 0, 0, &buffer );
1790 simpleTextPrint =
true;
1812 if ( simpleTextPrint )
1814 simpleTextPrint =
false;
1821 buffer += element.
Value();
1834 buffer +=
"<![CDATA[";
1835 buffer += text.
Value();
1839 else if ( simpleTextPrint )
1860 declaration.
Print( 0, 0, &buffer );
1870 buffer += comment.
Value();
1881 buffer += unknown.
Value();
const TiXmlAttribute * First() const
virtual TiXmlNode * Clone() const
Creates a copy of this Declaration and returns it.
virtual bool Accept(TiXmlVisitor *visitor) const
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.
int IntValue() const
Return the value of this attribute, converted to an integer.
int QueryBoolAttribute(const char *name, bool *_value) const
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)
TiXmlAttribute * FindOrCreate(const char *_name)
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
const unsigned char TIXML_UTF_LEAD_2
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
void SetName(const char *_name)
Set the name of this attribute.
TiXmlDocument()
Create an empty document, that has no name.
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.
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
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.
const unsigned char TIXML_UTF_LEAD_1
TiXmlAttribute * Find(const char *_name) const
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().
FILE * TiXmlFOpen(const char *filename, const char *mode)
TiXmlElement(const char *in_value)
Construct an element.
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
const unsigned char TIXML_UTF_LEAD_0
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
std::istream & operator>>(std::istream &str, CSVRow &data)
void Add(TiXmlAttribute *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 ©)
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
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.
virtual bool VisitExit(const TiXmlDocument &)
Visit a document.
int QueryDoubleAttribute(const char *name, double *_value) const
QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
const char * Value() const
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
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.
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.
int QueryUnsignedAttribute(const char *name, unsigned *_value) const
QueryUnsignedAttribute examines the attribute - see QueryIntAttribute().
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.