37FILE*
TiXmlFOpen(
const char* filename,
const char* mode );
42FILE*
TiXmlFOpen(
const char* filename,
const char* mode )
44 #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
46 errno_t err = fopen_s( &fp, filename, mode );
51 return fopen( filename, mode );
59 while( i<(
int)str.length() )
61 unsigned char c = (
unsigned char) str[i];
64 && i < ( (
int)str.length() - 2 )
78 while ( i<(
int)str.length()-1 )
80 outString->append( str.c_str() + i, 1 );
101 else if ( c ==
'\"' )
103 outString->append(
entity[3].str,
entity[3].strLength );
106 else if ( c ==
'\'' )
108 outString->append(
entity[4].str,
entity[4].strLength );
117 #if defined(TIXML_SNPRINTF)
118 TIXML_SNPRINTF( buf,
sizeof(buf),
"&#x%02X;", (
unsigned) ( c & 0xff ) );
120 sprintf( buf,
"&#x%02X;", (
unsigned) ( c & 0xff ) );
125 outString->append( buf, (
int)strlen( buf ) );
132 *outString += (char) c;
235 if ( !beforeThis || beforeThis->
parent !=
this ) {
250 node->
next = beforeThis;
252 if ( beforeThis->
prev )
261 beforeThis->
prev = node;
268 if ( !afterThis || afterThis->
parent !=
this ) {
283 node->
prev = afterThis;
285 if ( afterThis->
next )
294 afterThis->
next = node;
304 if ( replaceThis->
parent !=
this )
322 if ( replaceThis->
next )
327 if ( replaceThis->
prev )
344 if ( removeThis->
parent !=
this )
350 if ( removeThis->
next )
355 if ( removeThis->
prev )
369 if ( strcmp( node->
Value(), _value ) == 0 )
381 if ( strcmp( node->
Value(), _value ) == 0 )
396 assert( previous->
parent ==
this );
410 assert( previous->
parent ==
this );
419 for ( node =
next; node; node = node->
next )
421 if ( strcmp( node->
Value(), _value ) == 0 )
431 for ( node =
prev; node; node = node->
prev )
433 if ( strcmp( node->
Value(), _value ) == 0 )
519 for( node =
this; node; node = node->
parent )
584 return node->
Value();
603 const char* result = 0;
606 result = attrib->
Value();
619 const std::string* result = 0;
635 const char* result = 0;
638 result = attrib->
Value();
651 const std::string* result = 0;
681 *thisValue = (unsigned)ival;
807 for ( i=0; i<depth; i++ ) {
808 fprintf( cfile,
" " );
811 fprintf( cfile,
"<%s",
value.c_str() );
816 fprintf( cfile,
" " );
817 attrib->
Print( cfile, depth );
827 fprintf( cfile,
" />" );
831 fprintf( cfile,
">" );
833 fprintf( cfile,
"</%s>",
value.c_str() );
837 fprintf( cfile,
">" );
843 fprintf( cfile,
"\n" );
845 node->
Print( cfile, depth+1 );
847 fprintf( cfile,
"\n" );
848 for( i=0; i<depth; ++i ) {
849 fprintf( cfile,
" " );
851 fprintf( cfile,
"</%s>",
value.c_str() );
866 attribute = attribute->
Next() )
884 if ( !node->Accept( visitor ) )
909 return childText->
Value();
927 value = documentName;
937 value = documentName;
978 bool result =
LoadFile( file, encoding );
1003 fseek( file, 0, SEEK_END );
1004 length = ftell( file );
1005 fseek( file, 0, SEEK_SET );
1035 char* buf =
new char[ length+1 ];
1038 if ( fread( buf, length, 1, file ) != 1 ) {
1055 const char* p = buf;
1057 const char CR = 0x0d;
1058 const char LF = 0x0a;
1062 assert( p < (buf+length) );
1063 assert( q <= (buf+length) );
1077 assert( q <= (buf+length) );
1080 Parse( buf, 0, encoding );
1114 return (ferror(fp) == 0);
1153 node->Print( cfile, depth );
1154 fprintf( cfile,
"\n" );
1165 if ( !node->Accept( visitor ) )
1220 if (
value.find (
'\"') == TIXML_STRING::npos) {
1222 fprintf (cfile,
"%s=\"%s\"", n.c_str(), v.c_str() );
1225 (*str) += n; (*str) +=
"=\""; (*str) += v; (*str) +=
"\"";
1230 fprintf (cfile,
"%s='%s'", n.c_str(), v.c_str() );
1233 (*str) += n; (*str) +=
"='"; (*str) += v; (*str) +=
"'";
1256 #if defined(TIXML_SNPRINTF)
1259 sprintf (buf,
"%d", _value);
1267 #if defined(TIXML_SNPRINTF)
1270 sprintf (buf,
"%g", _value);
1277 return atoi (
value.c_str ());
1282 return atof (
value.c_str ());
1303 for (
int i=0; i<depth; i++ )
1305 fprintf( cfile,
" " );
1307 fprintf( cfile,
"<!--%s-->",
value.c_str() );
1319 return visitor->
Visit( *
this );
1341 fprintf( cfile,
"\n" );
1342 for ( i=0; i<depth; i++ ) {
1343 fprintf( cfile,
" " );
1345 fprintf( cfile,
"<![CDATA[%s]]>\n",
value.c_str() );
1351 fprintf( cfile,
"%s", buffer.c_str() );
1365 return visitor->
Visit( *
this );
1383 const char * _encoding,
1384 const char * _standalone )
1395 const std::string& _encoding,
1396 const std::string& _standalone )
1423 if ( cfile ) fprintf( cfile,
"<?xml " );
1424 if ( str ) (*str) +=
"<?xml ";
1427 if ( cfile ) fprintf (cfile,
"version=\"%s\" ",
version.c_str ());
1428 if ( str ) { (*str) +=
"version=\""; (*str) +=
version; (*str) +=
"\" "; }
1431 if ( cfile ) fprintf (cfile,
"encoding=\"%s\" ",
encoding.c_str ());
1432 if ( str ) { (*str) +=
"encoding=\""; (*str) +=
encoding; (*str) +=
"\" "; }
1435 if ( cfile ) fprintf (cfile,
"standalone=\"%s\" ",
standalone.c_str ());
1436 if ( str ) { (*str) +=
"standalone=\""; (*str) +=
standalone; (*str) +=
"\" "; }
1438 if ( cfile ) fprintf( cfile,
"?>" );
1439 if ( str ) (*str) +=
"?>";
1455 return visitor->
Visit( *
this );
1473 for (
int i=0; i<depth; i++ )
1474 fprintf( cfile,
" " );
1475 fprintf( cfile,
"<%s>",
value.c_str() );
1487 return visitor->
Visit( *
this );
1519 #ifdef TIXML_USE_STL
1538 if ( node == removeMe )
1556 if ( node->name == name )
1564 TiXmlAttribute* attrib =
Find( _name );
1566 attrib =
new TiXmlAttribute();
1568 attrib->SetName( _name );
1579 if ( strcmp( node->name.c_str(), name ) == 0 )
1599std::istream& operator>> (std::istream & in,
TiXmlNode & base)
1602 tag.reserve( 8 * 1000 );
1612std::ostream&
operator<< (std::ostream & out,
const TiXmlNode & base)
1614 TiXmlPrinter printer;
1615 printer.SetStreamPrinting();
1616 base.Accept( &printer );
1617 out << printer.Str();
1623std::string&
operator<< (std::string& out,
const TiXmlNode& base )
1625 TiXmlPrinter printer;
1626 printer.SetStreamPrinting();
1627 base.Accept( &printer );
1628 out.append( printer.Str() );
1775 for(
const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->
Next() )
1778 attrib->Print( 0, 0, &
buffer );
const char * Name() const
Return the name of this attribute.
int QueryIntValue(int *_value) const
double DoubleValue() const
Return the value of this attribute, converted to a double.
const char * Value() const
Return the value of this attribute.
void SetValue(const char *_value)
Set the value.
virtual void Print(FILE *cfile, int depth) const
const TiXmlAttribute * Previous() const
Get the previous sibling attribute in the DOM. Returns null at beginning.
void SetName(const char *_name)
Set the name of this attribute.
int QueryDoubleValue(double *_value) const
QueryDoubleValue examines the value string. See QueryIntValue().
void SetIntValue(int _value)
Set the value from an integer.
void SetDoubleValue(double _value)
Set the value from a double.
const TiXmlAttribute * Next() const
Get the next sibling attribute in the DOM. Returns null at end.
int IntValue() const
Return the value of this attribute, converted to an integer.
const std::string & ValueStr() const
Return the value of this attribute.
TiXmlAttribute * FindOrCreate(const char *_name)
const TiXmlAttribute * First() const
TiXmlAttribute * Find(const char *_name) const
void Add(TiXmlAttribute *attribute)
void Remove(TiXmlAttribute *attribute)
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0
static Entity entity[NUM_ENTITY]
static bool condenseWhiteSpace
@ TIXML_ERROR_DOCUMENT_TOP_ONLY
@ TIXML_ERROR_DOCUMENT_EMPTY
@ TIXML_ERROR_OPENING_FILE
static void EncodeString(const TIXML_STRING &str, TIXML_STRING *out)
friend class TiXmlElement
void * userData
Field containing a generic user pointer.
virtual void Print(FILE *cfile, int depth) const =0
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
TiXmlDeclaration()
Construct an empty declaration.
void CopyTo(TiXmlDeclaration *target) const
virtual void Print(FILE *cfile, int depth, TIXML_STRING *str) const
TiXmlDeclaration & operator=(const TiXmlDeclaration ©)
virtual bool Accept(TiXmlVisitor *visitor) const
virtual TiXmlNode * Clone() const
Creates a copy of this Declaration and returns it.
virtual TiXmlNode * Clone() const
virtual bool Accept(TiXmlVisitor *content) const
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
TiXmlDocument & operator=(const TiXmlDocument ©)
void CopyTo(TiXmlDocument *target) const
TiXmlCursor errorLocation
TiXmlDocument()
Create an empty document, that has no name.
bool SaveFile() const
Save a file using the current document value. Returns true if successful.
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
bool LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
void CopyTo(TiXmlElement *target) const
TiXmlElement & operator=(const TiXmlElement &base)
int QueryDoubleAttribute(const char *name, double *_value) const
QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
virtual bool Accept(TiXmlVisitor *visitor) const
int QueryUnsignedAttribute(const char *name, unsigned *_value) const
QueryUnsignedAttribute examines the attribute - see QueryIntAttribute().
const char * Attribute(const char *name) const
void SetAttribute(const char *name, const char *_value)
void SetDoubleAttribute(const std::string &name, double value)
virtual TiXmlNode * Clone() const
Creates a new Element and returns it - the returned element is a copy.
virtual void Print(FILE *cfile, int depth) const
TiXmlAttributeSet attributeSet
const char * GetText() const
int QueryIntAttribute(const char *name, int *_value) const
int QueryBoolAttribute(const char *name, bool *_value) const
void RemoveAttribute(const char *name)
TiXmlHandle FirstChildElement() const
Return a handle to the first child element.
TiXmlHandle FirstChild() const
Return a handle to the first child node.
TiXmlHandle Child(const char *value, int index) const
TiXmlHandle ChildElement(const char *value, int index) const
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)=0
const TiXmlNode * LastChild() const
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
void Clear()
Delete all the children of this node. Does not affect 'this'.
virtual TiXmlNode * Clone() const =0
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
const TiXmlNode * NextSibling() 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.
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
void SetValue(const char *_value)
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
const TiXmlElement * NextSiblingElement() const
void CopyTo(TiXmlNode *target) const
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
friend class TiXmlElement
const char * Value() const
const TiXmlDocument * GetDocument() const
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
const TIXML_STRING & ValueTStr() const
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
virtual bool VisitEnter(const TiXmlDocument &doc)
Visit a document.
virtual bool Visit(const TiXmlDeclaration &declaration)
Visit a declaration.
virtual bool VisitExit(const TiXmlDocument &doc)
Visit a document.
bool CDATA() const
Queries whether this represents text using a CDATA section.
virtual TiXmlNode * Clone() const
[internal use] Creates a new Element and returns it.
virtual bool Accept(TiXmlVisitor *content) const
virtual void Print(FILE *cfile, int depth) const
void CopyTo(TiXmlText *target) const
virtual void Print(FILE *cfile, int depth) const
virtual bool Accept(TiXmlVisitor *content) const
void CopyTo(TiXmlUnknown *target) const
virtual TiXmlNode * Clone() const
Creates a copy of this Unknown and returns it.
virtual bool Visit(const TiXmlDeclaration &)
Visit a declaration.
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
virtual bool VisitExit(const TiXmlDocument &)
Visit a document.
std::ostream & operator<<(std::ostream &stream, const CartesianVector &cartesianVector)
Operator to dump cartesian vector properties to an ostream.
const unsigned char TIXML_UTF_LEAD_0
FILE * TiXmlFOpen(const char *filename, const char *mode)
const unsigned char TIXML_UTF_LEAD_1
const TiXmlEncoding TIXML_DEFAULT_ENCODING
const unsigned char TIXML_UTF_LEAD_2