36 bool TiXmlBase::condenseWhiteSpace =
true;
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 );
85 outString->append( entity[0].str, entity[0].strLength );
90 outString->append( entity[1].str, entity[1].strLength );
95 outString->append( entity[2].str, entity[2].strLength );
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;
230 if ( !beforeThis || beforeThis->
parent !=
this ) {
244 node->
next = beforeThis;
246 if ( beforeThis->
prev )
255 beforeThis->
prev = node;
262 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 )
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 )
563 while( attributeSet.
First() )
566 attributeSet.
Remove( node );
576 return node->
Value();
586 return &attrib->ValueStr();
598 result = attrib->
Value();
614 result = &attrib->ValueStr();
627 const char* result = 0;
630 result = attrib->
Value();
646 result = &attrib->ValueStr();
760 for ( i=0; i<
depth; i++ ) {
761 fprintf( cfile,
" " );
764 fprintf( cfile,
"<%s",
value.c_str() );
767 for ( attrib = attributeSet.
First(); attrib; attrib = attrib->
Next() )
769 fprintf( cfile,
" " );
770 attrib->Print( cfile, depth );
780 fprintf( cfile,
" />" );
784 fprintf( cfile,
">" );
786 fprintf( cfile,
"</%s>",
value.c_str() );
790 fprintf( cfile,
">" );
796 fprintf( cfile,
"\n" );
798 node->
Print( cfile, depth+1 );
800 fprintf( cfile,
"\n" );
801 for( i=0; i<
depth; ++
i ) {
802 fprintf( cfile,
" " );
804 fprintf( cfile,
"</%s>",
value.c_str() );
817 for( attribute = attributeSet.
First();
819 attribute = attribute->
Next() )
837 if ( !node->Accept( visitor ) )
862 return childText->
Value();
872 useMicrosoftBOM =
false;
879 useMicrosoftBOM =
false;
880 value = documentName;
889 useMicrosoftBOM =
false;
890 value = documentName;
930 bool result =
LoadFile( file, encoding );
956 length = ftell( file );
987 char*
buf =
new char[ length+1 ];
990 if ( fread( buf, length, 1, file ) != 1 ) {
1007 const char*
p =
buf;
1009 const char CR = 0x0d;
1010 const char LF = 0x0a;
1014 assert( p < (buf+length) );
1015 assert( q <= (buf+length) );
1029 assert( q <= (buf+length) );
1032 Parse( buf, 0, encoding );
1055 if ( useMicrosoftBOM )
1061 fputc( TIXML_UTF_LEAD_0, fp );
1062 fputc( TIXML_UTF_LEAD_1, fp );
1063 fputc( TIXML_UTF_LEAD_2, fp );
1066 return (ferror(fp) == 0);
1074 target->error = error;
1075 target->errorId = errorId;
1076 target->errorDesc = errorDesc;
1077 target->tabsize = tabsize;
1078 target->errorLocation = errorLocation;
1079 target->useMicrosoftBOM = useMicrosoftBOM;
1105 node->
Print( cfile, depth );
1106 fprintf( cfile,
"\n" );
1117 if ( !node->
Accept( visitor ) )
1129 if ( next->value.empty() && next->name.empty() )
1149 if ( prev->value.empty() && prev->name.empty() )
1172 if (
value.find (
'\"') == TIXML_STRING::npos) {
1174 fprintf (cfile,
"%s=\"%s\"", n.c_str(), v.c_str() );
1177 (*str) +=
n; (*str) +=
"=\""; (*str) +=
v; (*str) +=
"\"";
1182 fprintf (cfile,
"%s='%s'", n.c_str(), v.c_str() );
1185 (*str) +=
n; (*str) +=
"='"; (*str) +=
v; (*str) +=
"'";
1208 #if defined(TIXML_SNPRINTF)
1211 sprintf (buf,
"%d", _value);
1219 #if defined(TIXML_SNPRINTF)
1222 sprintf (buf,
"%g", _value);
1229 return atoi (
value.c_str ());
1234 return atof (
value.c_str ());
1254 for (
int i=0; i<
depth; i++ )
1256 fprintf( cfile,
" " );
1258 fprintf( cfile,
"<!--%s-->",
value.c_str() );
1270 return visitor->
Visit( *
this );
1292 fprintf( cfile,
"\n" );
1293 for ( i=0; i<
depth; i++ ) {
1294 fprintf( cfile,
" " );
1296 fprintf( cfile,
"<![CDATA[%s]]>\n",
value.c_str() );
1302 fprintf( cfile,
"%s", buffer.c_str() );
1310 target->cdata = cdata;
1316 return visitor->
Visit( *
this );
1334 const char * _encoding,
1335 const char * _standalone )
1339 encoding = _encoding;
1340 standalone = _standalone;
1344 #ifdef TIXML_USE_STL
1351 encoding = _encoding;
1352 standalone = _standalone;
1373 if ( cfile ) fprintf( cfile,
"<?xml " );
1374 if ( str ) (*str) +=
"<?xml ";
1376 if ( !version.empty() ) {
1377 if ( cfile ) fprintf (cfile,
"version=\"%s\" ", version.c_str ());
1378 if ( str ) { (*str) +=
"version=\""; (*str) += version; (*str) +=
"\" "; }
1380 if ( !encoding.empty() ) {
1381 if ( cfile ) fprintf (cfile,
"encoding=\"%s\" ", encoding.c_str ());
1382 if ( str ) { (*str) +=
"encoding=\""; (*str) += encoding; (*str) +=
"\" "; }
1384 if ( !standalone.empty() ) {
1385 if ( cfile ) fprintf (cfile,
"standalone=\"%s\" ", standalone.c_str ());
1386 if ( str ) { (*str) +=
"standalone=\""; (*str) += standalone; (*str) +=
"\" "; }
1388 if ( cfile ) fprintf( cfile,
"?>" );
1389 if ( str ) (*str) +=
"?>";
1397 target->version = version;
1398 target->encoding = encoding;
1399 target->standalone = standalone;
1405 return visitor->
Visit( *
this );
1423 for (
int i=0; i<
depth; i++ )
1424 fprintf( cfile,
" " );
1425 fprintf( cfile,
"<%s>",
value.c_str() );
1437 return visitor->
Visit( *
this );
1455 sentinel.next = &sentinel;
1456 sentinel.prev = &sentinel;
1462 assert( sentinel.next == &sentinel );
1463 assert( sentinel.prev == &sentinel );
1469 #ifdef TIXML_USE_STL
1475 addMe->next = &sentinel;
1476 addMe->prev = sentinel.prev;
1478 sentinel.prev->next = addMe;
1479 sentinel.prev = addMe;
1486 for( node = sentinel.next; node != &sentinel; node = node->next )
1488 if ( node == removeMe )
1490 node->prev->next = node->next;
1491 node->next->prev = node->prev;
1501 #ifdef TIXML_USE_STL
1506 if ( node->name == name )
1529 if ( strcmp( node->name.c_str(),
name ) == 0 )
1548 #ifdef TIXML_USE_STL
1552 tag.reserve( 8 * 1000 );
1553 base.StreamIn( &in, &tag );
1561 #ifdef TIXML_USE_STL
1567 out << printer.Str();
1578 out.append( printer.Str() );
1725 for(
const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->
Next() )
1743 simpleTextPrint =
true;
1765 if ( simpleTextPrint )
1767 simpleTextPrint =
false;
1792 else if ( simpleTextPrint )
EGLSurface EGLint attribute
TiXmlHandle FirstChildElement() const
Return a handle to the first child element.
void SetDoubleAttribute(const char *name, double value)
GLuint const GLfloat * val
virtual TiXmlNode * Clone() const
Creates a copy of this Declaration and returns it.
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
TiXmlAttribute * Find(const char *_name) const
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
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
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.
const unsigned char TIXML_UTF_LEAD_2
virtual bool Accept(TiXmlVisitor *visitor) const
void SetIntValue(int _value)
Set the value from an integer.
EGLImageKHR EGLint * name
std::istream & operator>>(std::istream &is, Zeni::String &str)
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.
return Display return Display Bool Bool int d
virtual TiXmlNode * Clone() const
Creates a copy of this Unknown and returns it.
const char * Value() const
TiXmlAttribute * FindOrCreate(const char *_name)
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
void Add(TiXmlAttribute *attribute)
EGLContext EGLenum target
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
virtual bool Accept(TiXmlVisitor *visitor) const
EGLContext EGLenum EGLClientBuffer buffer
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
TiXmlText(const char *initValue)
int QueryIntValue(int *_value) const
void SetName(const char *_name)
Set the name of this attribute.
const TiXmlEncoding TIXML_DEFAULT_ENCODING
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
TiXmlNode(NodeType _type)
void Clear()
Delete all the children of this node. Does not affect 'this'.
virtual bool Accept(TiXmlVisitor *content) const
const unsigned char TIXML_UTF_LEAD_1
virtual void Print(FILE *cfile, int depth, TIXML_STRING *str) const
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
const TiXmlElement * NextSiblingElement() const
TiXmlElement(const char *in_value)
Construct an element.
void operator=(const TiXmlElement &base)
TiXmlDeclaration()
Construct an empty declaration.
virtual TiXmlNode * Clone() const
[internal use] Creates a new Element and returns it.
FILE * TiXmlFOpen(const char *filename, const char *mode)
static void EncodeString(const TIXML_STRING &str, TIXML_STRING *out)
GLint GLenum GLsizei GLsizei GLsizei depth
virtual TiXmlNode * Clone() const
virtual bool Accept(TiXmlVisitor *visitor) const =0
const unsigned char TIXML_UTF_LEAD_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
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
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 TIXML_STRING & ValueTStr() const
std::ostream & operator<<(std::ostream &out, const Token &token)
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)
EGLSurface EGLint void ** value
void SetValue(const char *_value)
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
GLenum GLuint GLsizei const GLchar * buf
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)
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLcharARB ** string
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().
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.
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
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 void Print(FILE *cfile, int depth) 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.
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.