46 while( i<(
int)str.length() )
48 unsigned char c = (
unsigned char) str[i];
51 && i < ( (
int)str.length() - 2 )
65 while ( i<(
int)str.length()-1 )
67 outString->append( str.c_str() + i, 1 );
104 #if defined(TIXML_SNPRINTF)
105 TIXML_SNPRINTF( buf,
sizeof(buf),
"&#x%02X;", (
unsigned) ( c & 0xff ) );
107 sprintf( buf,
"&#x%02X;", (
unsigned) ( c & 0xff ) );
112 outString->append( buf, (
int)strlen( buf ) );
119 *outString += (char) c;
215 if ( !beforeThis || beforeThis->
parent !=
this ) {
229 node->
next = beforeThis;
231 if ( beforeThis->
prev )
240 beforeThis->
prev = node;
247 if ( !afterThis || afterThis->
parent !=
this ) {
261 node->
prev = afterThis;
263 if ( afterThis->
next )
272 afterThis->
next = node;
279 if ( replaceThis->
parent !=
this )
289 if ( replaceThis->
next )
294 if ( replaceThis->
prev )
307 if ( removeThis->
parent !=
this )
313 if ( removeThis->
next )
318 if ( removeThis->
prev )
332 if ( strcmp( node->
Value(), _value ) == 0 )
344 if ( strcmp( node->
Value(), _value ) == 0 )
359 assert( previous->
parent ==
this );
373 assert( previous->
parent ==
this );
382 for ( node =
next; node; node = node->
next )
384 if ( strcmp( node->
Value(), _value ) == 0 )
394 for ( node =
prev; node; node = node->
prev )
396 if ( strcmp( node->
Value(), _value ) == 0 )
511 for( node =
this; node; node = node->
parent )
585 return node->
Value();
624 *i = atoi( s->c_str() );
654 const std::string* s =
Attribute( name );
658 *d = atof( s->c_str() );
712 #if defined(TIXML_SNPRINTF)
713 TIXML_SNPRINTF( buf,
sizeof(buf),
"%d", val );
715 sprintf( buf,
"%d", val );
724 std::ostringstream oss;
734 #if defined(TIXML_SNPRINTF)
735 TIXML_SNPRINTF( buf,
sizeof(buf),
"%f", val );
737 sprintf( buf,
"%f", val );
749 const char* _name = cname;
750 const char* _value = cvalue;
801 for ( i=0; i<depth; i++ ) {
802 fprintf( cfile,
" " );
805 fprintf( cfile,
"<%s",
value.c_str() );
810 fprintf( cfile,
" " );
811 attrib->Print( cfile, depth );
821 fprintf( cfile,
" />" );
825 fprintf( cfile,
">" );
827 fprintf( cfile,
"</%s>",
value.c_str() );
831 fprintf( cfile,
">" );
837 fprintf( cfile,
"\n" );
839 node->
Print( cfile, depth+1 );
841 fprintf( cfile,
"\n" );
842 for( i=0; i<depth; ++i ) {
843 fprintf( cfile,
" " );
845 fprintf( cfile,
"</%s>",
value.c_str() );
860 attribute = attribute->
Next() )
878 if ( !node->Accept( visitor ) )
903 return childText->
Value();
921 value = documentName;
931 value = documentName;
984 FILE* file = fopen(
value.c_str (),
"rb" );
988 bool result =
LoadFile( file, encoding );
1013 fseek( file, 0, SEEK_END );
1014 length = ftell( file );
1015 fseek( file, 0, SEEK_SET );
1027 data.reserve( length );
1050 char* buf =
new char[ length+1 ];
1053 if ( fread( buf, length, 1, file ) != 1 ) {
1059 const char* lastPos = buf;
1060 const char* p = buf;
1064 assert( p < (buf+length) );
1068 data.append( lastPos, (p-lastPos+1) );
1071 assert( p <= (buf+length) );
1073 else if ( *p == 0xd ) {
1076 if ( (p-lastPos) > 0 ) {
1077 data.append( lastPos, p-lastPos );
1081 if ( *(p+1) == 0xa ) {
1085 assert( p <= (buf+length) );
1091 assert( p <= (buf+length) );
1100 data.append( lastPos, p-lastPos );
1105 Parse( data.c_str(), 0, encoding );
1117 FILE* fp = fopen( filename,
"w" );
1136 fputc( TIXML_UTF_LEAD_0, fp );
1137 fputc( TIXML_UTF_LEAD_1, fp );
1138 fputc( TIXML_UTF_LEAD_2, fp );
1141 return (ferror(fp) == 0);
1176 node->
Print( cfile, depth );
1177 fprintf( cfile,
"\n" );
1188 if ( !node->Accept( visitor ) )
1243 if (
value.find (
'\"') == TIXML_STRING::npos) {
1245 fprintf (cfile,
"%s=\"%s\"", n.c_str(), v.c_str() );
1248 (*str) += n; (*str) +=
"=\""; (*str) +=
v; (*str) +=
"\"";
1253 fprintf (cfile,
"%s='%s'", n.c_str(), v.c_str() );
1256 (*str) += n; (*str) +=
"='"; (*str) +=
v; (*str) +=
"'";
1264 if ( sscanf(
value.c_str(),
"%d", ival ) == 1 )
1271 if ( sscanf(
value.c_str(),
"%lf", dval ) == 1 )
1279 #if defined(TIXML_SNPRINTF)
1280 TIXML_SNPRINTF(buf,
sizeof(buf),
"%d", _value);
1282 sprintf (buf,
"%d", _value);
1290 #if defined(TIXML_SNPRINTF)
1291 TIXML_SNPRINTF( buf,
sizeof(buf),
"%f", _value);
1293 sprintf (buf,
"%f", _value);
1300 return atoi (
value.c_str ());
1305 return atof (
value.c_str ());
1325 for (
int i=0; i<depth; i++ )
1327 fprintf( cfile,
" " );
1329 fprintf( cfile,
"<!--%s-->",
value.c_str() );
1341 return visitor->
Visit( *
this );
1363 fprintf( cfile,
"\n" );
1364 for ( i=0; i<depth; i++ ) {
1365 fprintf( cfile,
" " );
1367 fprintf( cfile,
"<![CDATA[%s]]>\n",
value.c_str() );
1373 fprintf( cfile,
"%s", buffer.c_str() );
1387 return visitor->
Visit( *
this );
1405 const char * _encoding,
1406 const char * _standalone )
1415 #ifdef TIXML_USE_STL
1417 const std::string& _encoding,
1418 const std::string& _standalone )
1444 if ( cfile ) fprintf( cfile,
"<?xml " );
1445 if ( str ) (*str) +=
"<?xml ";
1448 if ( cfile ) fprintf (cfile,
"version=\"%s\" ",
version.c_str ());
1449 if ( str ) { (*str) +=
"version=\""; (*str) +=
version; (*str) +=
"\" "; }
1452 if ( cfile ) fprintf (cfile,
"encoding=\"%s\" ",
encoding.c_str ());
1453 if ( str ) { (*str) +=
"encoding=\""; (*str) +=
encoding; (*str) +=
"\" "; }
1456 if ( cfile ) fprintf (cfile,
"standalone=\"%s\" ",
standalone.c_str ());
1457 if ( str ) { (*str) +=
"standalone=\""; (*str) +=
standalone; (*str) +=
"\" "; }
1459 if ( cfile ) fprintf( cfile,
"?>" );
1460 if ( str ) (*str) +=
"?>";
1476 return visitor->
Visit( *
this );
1494 for (
int i=0; i<depth; i++ )
1495 fprintf( cfile,
" " );
1496 fprintf( cfile,
"<%s>",
value.c_str() );
1508 return visitor->
Visit( *
this );
1540 #ifdef TIXML_USE_STL
1559 if ( node == removeMe )
1572 #ifdef TIXML_USE_STL
1577 if ( node->
name == name )
1601 if ( strcmp( node->
name.c_str(), name ) == 0 )
1619 #ifdef TIXML_USE_STL
1620 std::istream& operator>> (std::istream & in,
TiXmlNode & base)
1623 tag.reserve( 8 * 1000 );
1632 #ifdef TIXML_USE_STL
1638 out << printer.
Str();
1649 out.append( printer.
Str() );
1672 TiXmlNode* child = node->FirstChild( value );
1696 TiXmlElement* child = node->FirstChildElement( value );
1728 TiXmlNode* child = node->FirstChild( value );
1766 TiXmlElement* child = node->FirstChildElement( value );
1796 for(
const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->
Next() )
TinyXML class. See http://www.grinninglizard.com/tinyxml.
TiXmlHandle FirstChildElement() const
Return a handle to the first child element.
void SetDoubleAttribute(const char *name, double value)
virtual TiXmlNode * Clone() const
Creates a copy of this Declaration and returns it.
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
static void PutString(const TIXML_STRING &str, TIXML_STRING *out)
const std::string & ValueStr() const
Return the value of this attribute.
void CopyTo(TiXmlElement *target) const
int QueryDoubleAttribute(const char *name, double *_value) const
QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
const TiXmlNode * LastChild() const
virtual TiXmlNode * Clone() const =0
const TiXmlAttribute * First() const
TinyXML class. See http://www.grinninglizard.com/tinyxml.
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
TinyXML class. See http://www.grinninglizard.com/tinyxml.
bool SaveFile() const
Save a file using the current document value. Returns true if successful.
void SetDoubleValue(double _value)
Set the value from a double.
void RemoveAttribute(const char *name)
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
TiXmlHandle(TiXmlNode *_node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
virtual bool Accept(TiXmlVisitor *visitor) const
const std::string & Str()
Return the result.
void SetIntValue(int _value)
Set the value from an integer.
void CopyTo(TiXmlDeclaration *target) const
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0
void operator=(const TiXmlDeclaration ©)
TiXmlDocument()
Create an empty document, that has no name.
virtual TiXmlNode * Clone() const
Creates a copy of this Unknown and returns it.
const char * Value() const
int IntValue() const
Return the value of this attribute, converted to an integer.
int QueryIntAttribute(const char *name, int *_value) const
const char * Name() const
Return the name of this attribute.
const TiXmlAttribute * Previous() const
Get the previous sibling attribute in the DOM. Returns null at beginning.
virtual TiXmlNode * Clone() const
Creates a new Element and returns it - the returned element is a copy.
void CopyTo(TiXmlText *target) const
TinyXML class. See http://www.grinninglizard.com/tinyxml.
void Add(TiXmlAttribute *attribute)
ostream & operator<<(ostream &s, const Delta &data)
print Conditions object
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
virtual bool Accept(TiXmlVisitor *visitor) const
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
TiXmlText(const char *initValue)
int QueryIntValue(int *_value) const
TiXmlAttributeSet attributeSet
const TiXmlEncoding TIXML_DEFAULT_ENCODING
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
TinyXML class. See http://www.grinninglizard.com/tinyxml.
TiXmlNode(NodeType _type)
void Clear()
Delete all the children of this node. Does not affect 'this'.
virtual bool Accept(TiXmlVisitor *content) const
virtual void Print(FILE *cfile, int depth, TIXML_STRING *str) const
TinyXML class. See http://www.grinninglizard.com/tinyxml.
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
TinyXML class. See http://www.grinninglizard.com/tinyxml.
const TiXmlElement * NextSiblingElement() const
TiXmlElement(const char *in_value)
Construct an element.
void operator=(const TiXmlElement &base)
TiXmlDeclaration()
Construct an empty declaration.
const unsigned char TIXML_UTF_LEAD_2
virtual TiXmlNode * Clone() const
[internal use] Creates a new Element and returns it.
static Entity entity[NUM_ENTITY]
virtual TiXmlNode * Clone() const
virtual bool Accept(TiXmlVisitor *visitor) const =0
void * userData
Field containing a generic user pointer.
const char * Attribute(const char *name) const
void SetValue(const char *_value)
Set the value.
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
virtual void Print(FILE *cfile, int depth) const
virtual bool Accept(TiXmlVisitor *content) const
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)=0
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
TinyXML class. See http://www.grinninglizard.com/tinyxml.
void operator=(const TiXmlDocument ©)
virtual const TiXmlText * ToText() 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 bool Visit(const TiXmlDeclaration &)
Visit a declaration.
void CopyTo(TiXmlUnknown *target) const
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
void SetAttribute(const char *name, const char *_value)
void SetValue(const char *_value)
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
TinyXML class. See http://www.grinninglizard.com/tinyxml.
const unsigned char TIXML_UTF_LEAD_0
const char * GetText() const
virtual void Print(FILE *cfile, int depth) const
virtual void Print(FILE *cfile, int depth) const =0
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
const unsigned char TIXML_UTF_LEAD_1
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
virtual bool Accept(TiXmlVisitor *content) const
int QueryDoubleValue(double *_value) const
QueryDoubleValue examines the value string. See QueryIntValue().
TinyXML class. See http://www.grinninglizard.com/tinyxml.
bool LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
TiXmlHandle FirstChild() const
Return a handle to the first child node.
virtual bool VisitExit(const TiXmlDocument &doc)
Visit a document.
TiXmlHandle Child(const char *value, int index) const
virtual bool VisitExit(const TiXmlDocument &)
Visit a document.
static bool condenseWhiteSpace
void Remove(TiXmlAttribute *attribute)
const char * Value() const
Return the value of this attribute.
const TiXmlAttribute * Next() const
Get the next sibling attribute in the DOM. Returns null at end.
const TiXmlDocument * GetDocument() const
virtual void Print(FILE *cfile, int depth) const
TinyXML class. See http://www.grinninglizard.com/tinyxml.
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
const TiXmlElement * PreviousSiblingElement() const
virtual bool VisitEnter(const TiXmlDocument &doc)
Visit a document.
virtual void Print(FILE *cfile, int depth) const
const TiXmlAttribute * Find(const char *_name) const
double DoubleValue() const
Return the value of this attribute, converted to a double.
bool CDATA() const
Queries whether this represents text using a CDATA section.
void CopyTo(TiXmlDocument *target) const
TiXmlHandle ChildElement(const char *value, int index) const
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
void CopyTo(TiXmlNode *target) const
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
virtual bool Visit(const TiXmlDeclaration &declaration)
Visit a declaration.