Updating tinyxml to 2.6.1 (fixes small xml issues).
This commit is contained in:
Vendored
+2
-2
@@ -413,7 +413,7 @@ relate to the DOM.
|
|||||||
TiXmlDeclaration class. It will be the first child of the
|
TiXmlDeclaration class. It will be the first child of the
|
||||||
document node.
|
document node.
|
||||||
|
|
||||||
This is the only directive/special tag parsed by by TinyXML.
|
This is the only directive/special tag parsed by TinyXML.
|
||||||
Generally directive tags are stored in TiXmlUnknown so the
|
Generally directive tags are stored in TiXmlUnknown so the
|
||||||
commands wont be lost when it is saved back to disk.
|
commands wont be lost when it is saved back to disk.
|
||||||
|
|
||||||
@@ -499,7 +499,7 @@ distribution.
|
|||||||
<h2> References </h2>
|
<h2> References </h2>
|
||||||
|
|
||||||
The World Wide Web Consortium is the definitive standard body for
|
The World Wide Web Consortium is the definitive standard body for
|
||||||
XML, and there web pages contain huge amounts of information.
|
XML, and their web pages contain huge amounts of information.
|
||||||
|
|
||||||
The definitive spec: <a href="http://www.w3.org/TR/2004/REC-xml-20040204/">
|
The definitive spec: <a href="http://www.w3.org/TR/2004/REC-xml-20040204/">
|
||||||
http://www.w3.org/TR/2004/REC-xml-20040204/</a>
|
http://www.w3.org/TR/2004/REC-xml-20040204/</a>
|
||||||
|
|||||||
Vendored
+1
-1
@@ -36,7 +36,7 @@ const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_
|
|||||||
|
|
||||||
|
|
||||||
// Null rep.
|
// Null rep.
|
||||||
TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, '\0' };
|
TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } };
|
||||||
|
|
||||||
|
|
||||||
void TiXmlString::reserve (size_type cap)
|
void TiXmlString::reserve (size_type cap)
|
||||||
|
|||||||
Vendored
+202
-229
@@ -31,10 +31,25 @@ distribution.
|
|||||||
|
|
||||||
#include "tinyxml.h"
|
#include "tinyxml.h"
|
||||||
|
|
||||||
|
FILE* TiXmlFOpen( const char* filename, const char* mode );
|
||||||
|
|
||||||
bool TiXmlBase::condenseWhiteSpace = true;
|
bool TiXmlBase::condenseWhiteSpace = true;
|
||||||
|
|
||||||
void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_STRING* outString )
|
// Microsoft compiler security
|
||||||
|
FILE* TiXmlFOpen( const char* filename, const char* mode )
|
||||||
|
{
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
|
||||||
|
FILE* fp = 0;
|
||||||
|
errno_t err = fopen_s( &fp, filename, mode );
|
||||||
|
if ( !err && fp )
|
||||||
|
return fp;
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
return fopen( filename, mode );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString )
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
|
|
||||||
@@ -147,6 +162,7 @@ void TiXmlNode::CopyTo( TiXmlNode* target ) const
|
|||||||
{
|
{
|
||||||
target->SetValue (value.c_str() );
|
target->SetValue (value.c_str() );
|
||||||
target->userData = userData;
|
target->userData = userData;
|
||||||
|
target->location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -172,7 +188,7 @@ TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node )
|
|||||||
assert( node->parent == 0 || node->parent == this );
|
assert( node->parent == 0 || node->parent == this );
|
||||||
assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() );
|
assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() );
|
||||||
|
|
||||||
if ( node->Type() == TiXmlNode::DOCUMENT )
|
if ( node->Type() == TiXmlNode::TINYXML_DOCUMENT )
|
||||||
{
|
{
|
||||||
delete node;
|
delete node;
|
||||||
if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
||||||
@@ -196,7 +212,7 @@ TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node )
|
|||||||
|
|
||||||
TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis )
|
TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis )
|
||||||
{
|
{
|
||||||
if ( addThis.Type() == TiXmlNode::DOCUMENT )
|
if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT )
|
||||||
{
|
{
|
||||||
if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
||||||
return 0;
|
return 0;
|
||||||
@@ -214,7 +230,7 @@ TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode&
|
|||||||
if ( !beforeThis || beforeThis->parent != this ) {
|
if ( !beforeThis || beforeThis->parent != this ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ( addThis.Type() == TiXmlNode::DOCUMENT )
|
if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT )
|
||||||
{
|
{
|
||||||
if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
||||||
return 0;
|
return 0;
|
||||||
@@ -246,7 +262,7 @@ TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& a
|
|||||||
if ( !afterThis || afterThis->parent != this ) {
|
if ( !afterThis || afterThis->parent != this ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ( addThis.Type() == TiXmlNode::DOCUMENT )
|
if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT )
|
||||||
{
|
{
|
||||||
if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
||||||
return 0;
|
return 0;
|
||||||
@@ -275,9 +291,20 @@ TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& a
|
|||||||
|
|
||||||
TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis )
|
TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis )
|
||||||
{
|
{
|
||||||
|
if ( !replaceThis )
|
||||||
|
return 0;
|
||||||
|
|
||||||
if ( replaceThis->parent != this )
|
if ( replaceThis->parent != this )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if ( withThis.ToDocument() ) {
|
||||||
|
// A document can never be a child. Thanks to Noam.
|
||||||
|
TiXmlDocument* document = GetDocument();
|
||||||
|
if ( document )
|
||||||
|
document->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
TiXmlNode* node = withThis.Clone();
|
TiXmlNode* node = withThis.Clone();
|
||||||
if ( !node )
|
if ( !node )
|
||||||
return 0;
|
return 0;
|
||||||
@@ -303,6 +330,10 @@ TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& wit
|
|||||||
|
|
||||||
bool TiXmlNode::RemoveChild( TiXmlNode* removeThis )
|
bool TiXmlNode::RemoveChild( TiXmlNode* removeThis )
|
||||||
{
|
{
|
||||||
|
if ( !removeThis ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( removeThis->parent != this )
|
if ( removeThis->parent != this )
|
||||||
{
|
{
|
||||||
assert( 0 );
|
assert( 0 );
|
||||||
@@ -488,7 +519,7 @@ const TiXmlDocument* TiXmlNode::GetDocument() const
|
|||||||
|
|
||||||
|
|
||||||
TiXmlElement::TiXmlElement (const char * _value)
|
TiXmlElement::TiXmlElement (const char * _value)
|
||||||
: TiXmlNode( TiXmlNode::ELEMENT )
|
: TiXmlNode( TiXmlNode::TINYXML_ELEMENT )
|
||||||
{
|
{
|
||||||
firstChild = lastChild = 0;
|
firstChild = lastChild = 0;
|
||||||
value = _value;
|
value = _value;
|
||||||
@@ -497,7 +528,7 @@ TiXmlElement::TiXmlElement (const char * _value)
|
|||||||
|
|
||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
TiXmlElement::TiXmlElement( const std::string& _value )
|
TiXmlElement::TiXmlElement( const std::string& _value )
|
||||||
: TiXmlNode( TiXmlNode::ELEMENT )
|
: TiXmlNode( TiXmlNode::TINYXML_ELEMENT )
|
||||||
{
|
{
|
||||||
firstChild = lastChild = 0;
|
firstChild = lastChild = 0;
|
||||||
value = _value;
|
value = _value;
|
||||||
@@ -506,7 +537,7 @@ TiXmlElement::TiXmlElement( const std::string& _value )
|
|||||||
|
|
||||||
|
|
||||||
TiXmlElement::TiXmlElement( const TiXmlElement& copy)
|
TiXmlElement::TiXmlElement( const TiXmlElement& copy)
|
||||||
: TiXmlNode( TiXmlNode::ELEMENT )
|
: TiXmlNode( TiXmlNode::TINYXML_ELEMENT )
|
||||||
{
|
{
|
||||||
firstChild = lastChild = 0;
|
firstChild = lastChild = 0;
|
||||||
copy.CopyTo( this );
|
copy.CopyTo( this );
|
||||||
@@ -550,9 +581,9 @@ const char* TiXmlElement::Attribute( const char* name ) const
|
|||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
const std::string* TiXmlElement::Attribute( const std::string& name ) const
|
const std::string* TiXmlElement::Attribute( const std::string& name ) const
|
||||||
{
|
{
|
||||||
const TiXmlAttribute* node = attributeSet.Find( name );
|
const TiXmlAttribute* attrib = attributeSet.Find( name );
|
||||||
if ( node )
|
if ( attrib )
|
||||||
return &node->ValueStr();
|
return &attrib->ValueStr();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -560,195 +591,163 @@ const std::string* TiXmlElement::Attribute( const std::string& name ) const
|
|||||||
|
|
||||||
const char* TiXmlElement::Attribute( const char* name, int* i ) const
|
const char* TiXmlElement::Attribute( const char* name, int* i ) const
|
||||||
{
|
{
|
||||||
const char* s = Attribute( name );
|
const TiXmlAttribute* attrib = attributeSet.Find( name );
|
||||||
if ( i )
|
const char* result = 0;
|
||||||
{
|
|
||||||
if ( s ) {
|
if ( attrib ) {
|
||||||
*i = atoi( s );
|
result = attrib->Value();
|
||||||
}
|
if ( i ) {
|
||||||
else {
|
attrib->QueryIntValue( i );
|
||||||
*i = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const
|
const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const
|
||||||
{
|
{
|
||||||
const std::string* s = Attribute( name );
|
const TiXmlAttribute* attrib = attributeSet.Find( name );
|
||||||
if ( i )
|
const std::string* result = 0;
|
||||||
{
|
|
||||||
if ( s ) {
|
if ( attrib ) {
|
||||||
*i = atoi( s->c_str() );
|
result = &attrib->ValueStr();
|
||||||
}
|
if ( i ) {
|
||||||
else {
|
attrib->QueryIntValue( i );
|
||||||
*i = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
const char* TiXmlElement::Attribute( const char* name, double* d ) const
|
const char* TiXmlElement::Attribute( const char* name, double* d ) const
|
||||||
{
|
{
|
||||||
const char* s = Attribute( name );
|
const TiXmlAttribute* attrib = attributeSet.Find( name );
|
||||||
if ( d )
|
const char* result = 0;
|
||||||
{
|
|
||||||
if ( s ) {
|
if ( attrib ) {
|
||||||
*d = atof( s );
|
result = attrib->Value();
|
||||||
}
|
if ( d ) {
|
||||||
else {
|
attrib->QueryDoubleValue( d );
|
||||||
*d = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const
|
const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const
|
||||||
{
|
{
|
||||||
const std::string* s = Attribute( name );
|
const TiXmlAttribute* attrib = attributeSet.Find( name );
|
||||||
if ( d )
|
const std::string* result = 0;
|
||||||
{
|
|
||||||
if ( s ) {
|
if ( attrib ) {
|
||||||
*d = atof( s->c_str() );
|
result = &attrib->ValueStr();
|
||||||
}
|
if ( d ) {
|
||||||
else {
|
attrib->QueryDoubleValue( d );
|
||||||
*d = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const
|
int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const
|
||||||
{
|
{
|
||||||
const TiXmlAttribute* node = attributeSet.Find( name );
|
const TiXmlAttribute* attrib = attributeSet.Find( name );
|
||||||
if ( !node )
|
if ( !attrib )
|
||||||
return TIXML_NO_ATTRIBUTE;
|
return TIXML_NO_ATTRIBUTE;
|
||||||
return node->QueryIntValue( ival );
|
return attrib->QueryIntValue( ival );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const
|
int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const
|
||||||
{
|
{
|
||||||
const TiXmlAttribute* node = attributeSet.Find( name );
|
const TiXmlAttribute* attrib = attributeSet.Find( name );
|
||||||
if ( !node )
|
if ( !attrib )
|
||||||
return TIXML_NO_ATTRIBUTE;
|
return TIXML_NO_ATTRIBUTE;
|
||||||
return node->QueryIntValue( ival );
|
return attrib->QueryIntValue( ival );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const
|
int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const
|
||||||
{
|
{
|
||||||
const TiXmlAttribute* node = attributeSet.Find( name );
|
const TiXmlAttribute* attrib = attributeSet.Find( name );
|
||||||
if ( !node )
|
if ( !attrib )
|
||||||
return TIXML_NO_ATTRIBUTE;
|
return TIXML_NO_ATTRIBUTE;
|
||||||
return node->QueryDoubleValue( dval );
|
return attrib->QueryDoubleValue( dval );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const
|
int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const
|
||||||
{
|
{
|
||||||
const TiXmlAttribute* node = attributeSet.Find( name );
|
const TiXmlAttribute* attrib = attributeSet.Find( name );
|
||||||
if ( !node )
|
if ( !attrib )
|
||||||
return TIXML_NO_ATTRIBUTE;
|
return TIXML_NO_ATTRIBUTE;
|
||||||
return node->QueryDoubleValue( dval );
|
return attrib->QueryDoubleValue( dval );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void TiXmlElement::SetAttribute( const char * name, int val )
|
void TiXmlElement::SetAttribute( const char * name, int val )
|
||||||
{
|
{
|
||||||
char buf[64];
|
TiXmlAttribute* attrib = attributeSet.FindOrCreate( name );
|
||||||
#if defined(TIXML_SNPRINTF)
|
if ( attrib ) {
|
||||||
TIXML_SNPRINTF( buf, sizeof(buf), "%d", val );
|
attrib->SetIntValue( val );
|
||||||
#else
|
}
|
||||||
sprintf( buf, "%d", val );
|
|
||||||
#endif
|
|
||||||
SetAttribute( name, buf );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
void TiXmlElement::SetAttribute( const std::string& name, int val )
|
void TiXmlElement::SetAttribute( const std::string& name, int val )
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
TiXmlAttribute* attrib = attributeSet.FindOrCreate( name );
|
||||||
oss << val;
|
if ( attrib ) {
|
||||||
SetAttribute( name, oss.str() );
|
attrib->SetIntValue( val );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void TiXmlElement::SetDoubleAttribute( const char * name, double val )
|
void TiXmlElement::SetDoubleAttribute( const char * name, double val )
|
||||||
{
|
{
|
||||||
char buf[256];
|
TiXmlAttribute* attrib = attributeSet.FindOrCreate( name );
|
||||||
#if defined(TIXML_SNPRINTF)
|
if ( attrib ) {
|
||||||
TIXML_SNPRINTF( buf, sizeof(buf), "%f", val );
|
attrib->SetDoubleValue( val );
|
||||||
#else
|
|
||||||
sprintf( buf, "%f", val );
|
|
||||||
#endif
|
|
||||||
SetAttribute( name, buf );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void TiXmlElement::SetAttribute( const char * cname, const char * cvalue )
|
|
||||||
{
|
|
||||||
#ifdef TIXML_USE_STL
|
|
||||||
TIXML_STRING _name( cname );
|
|
||||||
TIXML_STRING _value( cvalue );
|
|
||||||
#else
|
|
||||||
const char* _name = cname;
|
|
||||||
const char* _value = cvalue;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TiXmlAttribute* node = attributeSet.Find( _name );
|
|
||||||
if ( node )
|
|
||||||
{
|
|
||||||
node->SetValue( _value );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue );
|
|
||||||
if ( attrib )
|
|
||||||
{
|
|
||||||
attributeSet.Add( attrib );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TiXmlDocument* document = GetDocument();
|
|
||||||
if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
void TiXmlElement::SetAttribute( const std::string& name, const std::string& _value )
|
void TiXmlElement::SetDoubleAttribute( const std::string& name, double val )
|
||||||
{
|
{
|
||||||
TiXmlAttribute* node = attributeSet.Find( name );
|
TiXmlAttribute* attrib = attributeSet.FindOrCreate( name );
|
||||||
if ( node )
|
if ( attrib ) {
|
||||||
{
|
attrib->SetDoubleValue( val );
|
||||||
node->SetValue( _value );
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TiXmlAttribute* attrib = new TiXmlAttribute( name, _value );
|
|
||||||
if ( attrib )
|
void TiXmlElement::SetAttribute( const char * cname, const char * cvalue )
|
||||||
{
|
{
|
||||||
attributeSet.Add( attrib );
|
TiXmlAttribute* attrib = attributeSet.FindOrCreate( cname );
|
||||||
|
if ( attrib ) {
|
||||||
|
attrib->SetValue( cvalue );
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
TiXmlDocument* document = GetDocument();
|
|
||||||
if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
#ifdef TIXML_USE_STL
|
||||||
|
void TiXmlElement::SetAttribute( const std::string& _name, const std::string& _value )
|
||||||
|
{
|
||||||
|
TiXmlAttribute* attrib = attributeSet.FindOrCreate( _name );
|
||||||
|
if ( attrib ) {
|
||||||
|
attrib->SetValue( _value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -867,14 +866,14 @@ const char* TiXmlElement::GetText() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT )
|
TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT )
|
||||||
{
|
{
|
||||||
tabsize = 4;
|
tabsize = 4;
|
||||||
useMicrosoftBOM = false;
|
useMicrosoftBOM = false;
|
||||||
ClearError();
|
ClearError();
|
||||||
}
|
}
|
||||||
|
|
||||||
TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT )
|
TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT )
|
||||||
{
|
{
|
||||||
tabsize = 4;
|
tabsize = 4;
|
||||||
useMicrosoftBOM = false;
|
useMicrosoftBOM = false;
|
||||||
@@ -884,7 +883,7 @@ TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode
|
|||||||
|
|
||||||
|
|
||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT )
|
TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT )
|
||||||
{
|
{
|
||||||
tabsize = 4;
|
tabsize = 4;
|
||||||
useMicrosoftBOM = false;
|
useMicrosoftBOM = false;
|
||||||
@@ -894,7 +893,7 @@ TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiX
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::DOCUMENT )
|
TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT )
|
||||||
{
|
{
|
||||||
copy.CopyTo( this );
|
copy.CopyTo( this );
|
||||||
}
|
}
|
||||||
@@ -909,39 +908,22 @@ void TiXmlDocument::operator=( const TiXmlDocument& copy )
|
|||||||
|
|
||||||
bool TiXmlDocument::LoadFile( TiXmlEncoding encoding )
|
bool TiXmlDocument::LoadFile( TiXmlEncoding encoding )
|
||||||
{
|
{
|
||||||
// See STL_STRING_BUG below.
|
|
||||||
//StringToBuffer buf( value );
|
|
||||||
|
|
||||||
return LoadFile( Value(), encoding );
|
return LoadFile( Value(), encoding );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TiXmlDocument::SaveFile() const
|
bool TiXmlDocument::SaveFile() const
|
||||||
{
|
{
|
||||||
// See STL_STRING_BUG below.
|
|
||||||
// StringToBuffer buf( value );
|
|
||||||
//
|
|
||||||
// if ( buf.buffer && SaveFile( buf.buffer ) )
|
|
||||||
// return true;
|
|
||||||
//
|
|
||||||
// return false;
|
|
||||||
return SaveFile( Value() );
|
return SaveFile( Value() );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding )
|
bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding )
|
||||||
{
|
{
|
||||||
// There was a really terrifying little bug here. The code:
|
|
||||||
// value = filename
|
|
||||||
// in the STL case, cause the assignment method of the std::string to
|
|
||||||
// be called. What is strange, is that the std::string had the same
|
|
||||||
// address as it's c_str() method, and so bad things happen. Looks
|
|
||||||
// like a bug in the Microsoft STL implementation.
|
|
||||||
// Add an extra string to avoid the crash.
|
|
||||||
TIXML_STRING filename( _filename );
|
TIXML_STRING filename( _filename );
|
||||||
value = filename;
|
value = filename;
|
||||||
|
|
||||||
// reading in binary mode so that tinyxml can normalize the EOL
|
// reading in binary mode so that tinyxml can normalize the EOL
|
||||||
FILE* file = fopen( value.c_str (), "rb" );
|
FILE* file = TiXmlFOpen( value.c_str (), "rb" );
|
||||||
|
|
||||||
if ( file )
|
if ( file )
|
||||||
{
|
{
|
||||||
@@ -975,17 +957,12 @@ bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding )
|
|||||||
fseek( file, 0, SEEK_SET );
|
fseek( file, 0, SEEK_SET );
|
||||||
|
|
||||||
// Strange case, but good to handle up front.
|
// Strange case, but good to handle up front.
|
||||||
if ( length == 0 )
|
if ( length <= 0 )
|
||||||
{
|
{
|
||||||
SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a file, assume it is all one big XML file, and read it in.
|
|
||||||
// The document parser may decide the document ends sooner than the entire file, however.
|
|
||||||
TIXML_STRING data;
|
|
||||||
data.reserve( length );
|
|
||||||
|
|
||||||
// Subtle bug here. TinyXml did use fgets. But from the XML spec:
|
// Subtle bug here. TinyXml did use fgets. But from the XML spec:
|
||||||
// 2.11 End-of-Line Handling
|
// 2.11 End-of-Line Handling
|
||||||
// <snip>
|
// <snip>
|
||||||
@@ -1016,65 +993,53 @@ bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* lastPos = buf;
|
// Process the buffer in place to normalize new lines. (See comment above.)
|
||||||
const char* p = buf;
|
// Copies from the 'p' to 'q' pointer, where p can advance faster if
|
||||||
|
// a newline-carriage return is hit.
|
||||||
|
//
|
||||||
|
// Wikipedia:
|
||||||
|
// Systems based on ASCII or a compatible character set use either LF (Line feed, '\n', 0x0A, 10 in decimal) or
|
||||||
|
// CR (Carriage return, '\r', 0x0D, 13 in decimal) individually, or CR followed by LF (CR+LF, 0x0D 0x0A)...
|
||||||
|
// * LF: Multics, Unix and Unix-like systems (GNU/Linux, AIX, Xenix, Mac OS X, FreeBSD, etc.), BeOS, Amiga, RISC OS, and others
|
||||||
|
// * CR+LF: DEC RT-11 and most other early non-Unix, non-IBM OSes, CP/M, MP/M, DOS, OS/2, Microsoft Windows, Symbian OS
|
||||||
|
// * CR: Commodore 8-bit machines, Apple II family, Mac OS up to version 9 and OS-9
|
||||||
|
|
||||||
|
const char* p = buf; // the read head
|
||||||
|
char* q = buf; // the write head
|
||||||
|
const char CR = 0x0d;
|
||||||
|
const char LF = 0x0a;
|
||||||
|
|
||||||
buf[length] = 0;
|
buf[length] = 0;
|
||||||
while( *p ) {
|
while( *p ) {
|
||||||
assert( p < (buf+length) );
|
assert( p < (buf+length) );
|
||||||
if ( *p == 0xa ) {
|
assert( q <= (buf+length) );
|
||||||
// Newline character. No special rules for this. Append all the characters
|
assert( q <= p );
|
||||||
// since the last string, and include the newline.
|
|
||||||
data.append( lastPos, (p-lastPos+1) ); // append, include the newline
|
|
||||||
++p; // move past the newline
|
|
||||||
lastPos = p; // and point to the new buffer (may be 0)
|
|
||||||
assert( p <= (buf+length) );
|
|
||||||
}
|
|
||||||
else if ( *p == 0xd ) {
|
|
||||||
// Carriage return. Append what we have so far, then
|
|
||||||
// handle moving forward in the buffer.
|
|
||||||
if ( (p-lastPos) > 0 ) {
|
|
||||||
data.append( lastPos, p-lastPos ); // do not add the CR
|
|
||||||
}
|
|
||||||
data += (char)0xa; // a proper newline
|
|
||||||
|
|
||||||
if ( *(p+1) == 0xa ) {
|
if ( *p == CR ) {
|
||||||
// Carriage return - new line sequence
|
*q++ = LF;
|
||||||
p += 2;
|
p++;
|
||||||
lastPos = p;
|
if ( *p == LF ) { // check for CR+LF (and skip LF)
|
||||||
assert( p <= (buf+length) );
|
p++;
|
||||||
}
|
|
||||||
else {
|
|
||||||
// it was followed by something else...that is presumably characters again.
|
|
||||||
++p;
|
|
||||||
lastPos = p;
|
|
||||||
assert( p <= (buf+length) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
++p;
|
*q++ = *p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Handle any left over characters.
|
assert( q <= (buf+length) );
|
||||||
if ( p-lastPos ) {
|
*q = 0;
|
||||||
data.append( lastPos, p-lastPos );
|
|
||||||
}
|
Parse( buf, 0, encoding );
|
||||||
|
|
||||||
delete [] buf;
|
delete [] buf;
|
||||||
buf = 0;
|
return !Error();
|
||||||
|
|
||||||
Parse( data.c_str(), 0, encoding );
|
|
||||||
|
|
||||||
if ( Error() )
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TiXmlDocument::SaveFile( const char * filename ) const
|
bool TiXmlDocument::SaveFile( const char * filename ) const
|
||||||
{
|
{
|
||||||
// The old c stuff lives on...
|
// The old c stuff lives on...
|
||||||
FILE* fp = fopen( filename, "w" );
|
FILE* fp = TiXmlFOpen( filename, "w" );
|
||||||
if ( fp )
|
if ( fp )
|
||||||
{
|
{
|
||||||
bool result = SaveFile( fp );
|
bool result = SaveFile( fp );
|
||||||
@@ -1107,7 +1072,11 @@ void TiXmlDocument::CopyTo( TiXmlDocument* target ) const
|
|||||||
TiXmlNode::CopyTo( target );
|
TiXmlNode::CopyTo( target );
|
||||||
|
|
||||||
target->error = error;
|
target->error = error;
|
||||||
target->errorDesc = errorDesc.c_str ();
|
target->errorId = errorId;
|
||||||
|
target->errorDesc = errorDesc;
|
||||||
|
target->tabsize = tabsize;
|
||||||
|
target->errorLocation = errorLocation;
|
||||||
|
target->useMicrosoftBOM = useMicrosoftBOM;
|
||||||
|
|
||||||
TiXmlNode* node = 0;
|
TiXmlNode* node = 0;
|
||||||
for ( node = firstChild; node; node = node->NextSibling() )
|
for ( node = firstChild; node; node = node->NextSibling() )
|
||||||
@@ -1197,8 +1166,8 @@ void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) cons
|
|||||||
{
|
{
|
||||||
TIXML_STRING n, v;
|
TIXML_STRING n, v;
|
||||||
|
|
||||||
PutString( name, &n );
|
EncodeString( name, &n );
|
||||||
PutString( value, &v );
|
EncodeString( value, &v );
|
||||||
|
|
||||||
if (value.find ('\"') == TIXML_STRING::npos) {
|
if (value.find ('\"') == TIXML_STRING::npos) {
|
||||||
if ( cfile ) {
|
if ( cfile ) {
|
||||||
@@ -1221,14 +1190,14 @@ void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) cons
|
|||||||
|
|
||||||
int TiXmlAttribute::QueryIntValue( int* ival ) const
|
int TiXmlAttribute::QueryIntValue( int* ival ) const
|
||||||
{
|
{
|
||||||
if ( sscanf( value.c_str(), "%d", ival ) == 1 )
|
if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 )
|
||||||
return TIXML_SUCCESS;
|
return TIXML_SUCCESS;
|
||||||
return TIXML_WRONG_TYPE;
|
return TIXML_WRONG_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TiXmlAttribute::QueryDoubleValue( double* dval ) const
|
int TiXmlAttribute::QueryDoubleValue( double* dval ) const
|
||||||
{
|
{
|
||||||
if ( sscanf( value.c_str(), "%lf", dval ) == 1 )
|
if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 )
|
||||||
return TIXML_SUCCESS;
|
return TIXML_SUCCESS;
|
||||||
return TIXML_WRONG_TYPE;
|
return TIXML_WRONG_TYPE;
|
||||||
}
|
}
|
||||||
@@ -1248,9 +1217,9 @@ void TiXmlAttribute::SetDoubleValue( double _value )
|
|||||||
{
|
{
|
||||||
char buf [256];
|
char buf [256];
|
||||||
#if defined(TIXML_SNPRINTF)
|
#if defined(TIXML_SNPRINTF)
|
||||||
TIXML_SNPRINTF( buf, sizeof(buf), "%lf", _value);
|
TIXML_SNPRINTF( buf, sizeof(buf), "%g", _value);
|
||||||
#else
|
#else
|
||||||
sprintf (buf, "%lf", _value);
|
sprintf (buf, "%g", _value);
|
||||||
#endif
|
#endif
|
||||||
SetValue (buf);
|
SetValue (buf);
|
||||||
}
|
}
|
||||||
@@ -1266,7 +1235,7 @@ double TiXmlAttribute::DoubleValue() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::COMMENT )
|
TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT )
|
||||||
{
|
{
|
||||||
copy.CopyTo( this );
|
copy.CopyTo( this );
|
||||||
}
|
}
|
||||||
@@ -1329,7 +1298,7 @@ void TiXmlText::Print( FILE* cfile, int depth ) const
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
TIXML_STRING buffer;
|
TIXML_STRING buffer;
|
||||||
PutString( value, &buffer );
|
EncodeString( value, &buffer );
|
||||||
fprintf( cfile, "%s", buffer.c_str() );
|
fprintf( cfile, "%s", buffer.c_str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1364,7 +1333,7 @@ TiXmlNode* TiXmlText::Clone() const
|
|||||||
TiXmlDeclaration::TiXmlDeclaration( const char * _version,
|
TiXmlDeclaration::TiXmlDeclaration( const char * _version,
|
||||||
const char * _encoding,
|
const char * _encoding,
|
||||||
const char * _standalone )
|
const char * _standalone )
|
||||||
: TiXmlNode( TiXmlNode::DECLARATION )
|
: TiXmlNode( TiXmlNode::TINYXML_DECLARATION )
|
||||||
{
|
{
|
||||||
version = _version;
|
version = _version;
|
||||||
encoding = _encoding;
|
encoding = _encoding;
|
||||||
@@ -1376,7 +1345,7 @@ TiXmlDeclaration::TiXmlDeclaration( const char * _version,
|
|||||||
TiXmlDeclaration::TiXmlDeclaration( const std::string& _version,
|
TiXmlDeclaration::TiXmlDeclaration( const std::string& _version,
|
||||||
const std::string& _encoding,
|
const std::string& _encoding,
|
||||||
const std::string& _standalone )
|
const std::string& _standalone )
|
||||||
: TiXmlNode( TiXmlNode::DECLARATION )
|
: TiXmlNode( TiXmlNode::TINYXML_DECLARATION )
|
||||||
{
|
{
|
||||||
version = _version;
|
version = _version;
|
||||||
encoding = _encoding;
|
encoding = _encoding;
|
||||||
@@ -1386,7 +1355,7 @@ TiXmlDeclaration::TiXmlDeclaration( const std::string& _version,
|
|||||||
|
|
||||||
|
|
||||||
TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy )
|
TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy )
|
||||||
: TiXmlNode( TiXmlNode::DECLARATION )
|
: TiXmlNode( TiXmlNode::TINYXML_DECLARATION )
|
||||||
{
|
{
|
||||||
copy.CopyTo( this );
|
copy.CopyTo( this );
|
||||||
}
|
}
|
||||||
@@ -1530,18 +1499,7 @@ void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe )
|
|||||||
|
|
||||||
|
|
||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
const TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const
|
TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const
|
||||||
{
|
|
||||||
for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
|
|
||||||
{
|
|
||||||
if ( node->name == name )
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name )
|
|
||||||
{
|
{
|
||||||
for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
|
for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
|
||||||
{
|
{
|
||||||
@@ -1550,22 +1508,21 @@ TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name )
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const std::string& _name )
|
||||||
|
{
|
||||||
|
TiXmlAttribute* attrib = Find( _name );
|
||||||
|
if ( !attrib ) {
|
||||||
|
attrib = new TiXmlAttribute();
|
||||||
|
Add( attrib );
|
||||||
|
attrib->SetName( _name );
|
||||||
|
}
|
||||||
|
return attrib;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
const TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const
|
TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const
|
||||||
{
|
|
||||||
for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
|
|
||||||
{
|
|
||||||
if ( strcmp( node->name.c_str(), name ) == 0 )
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
TiXmlAttribute* TiXmlAttributeSet::Find( const char* name )
|
|
||||||
{
|
{
|
||||||
for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
|
for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
|
||||||
{
|
{
|
||||||
@@ -1574,7 +1531,19 @@ TiXmlAttribute* TiXmlAttributeSet::Find( const char* name )
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const char* _name )
|
||||||
|
{
|
||||||
|
TiXmlAttribute* attrib = Find( _name );
|
||||||
|
if ( !attrib ) {
|
||||||
|
attrib = new TiXmlAttribute();
|
||||||
|
Add( attrib );
|
||||||
|
attrib->SetName( _name );
|
||||||
|
}
|
||||||
|
return attrib;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
std::istream& operator>> (std::istream & in, TiXmlNode & base)
|
std::istream& operator>> (std::istream & in, TiXmlNode & base)
|
||||||
@@ -1822,12 +1791,16 @@ bool TiXmlPrinter::Visit( const TiXmlText& text )
|
|||||||
}
|
}
|
||||||
else if ( simpleTextPrint )
|
else if ( simpleTextPrint )
|
||||||
{
|
{
|
||||||
buffer += text.Value();
|
TIXML_STRING str;
|
||||||
|
TiXmlBase::EncodeString( text.ValueTStr(), &str );
|
||||||
|
buffer += str;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DoIndent();
|
DoIndent();
|
||||||
buffer += text.Value();
|
TIXML_STRING str;
|
||||||
|
TiXmlBase::EncodeString( text.ValueTStr(), &str );
|
||||||
|
buffer += str;
|
||||||
DoLineBreak();
|
DoLineBreak();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Vendored
+78
-51
@@ -20,6 +20,10 @@ must not be misrepresented as being the original software.
|
|||||||
|
|
||||||
3. This notice may not be removed or altered from any source
|
3. This notice may not be removed or altered from any source
|
||||||
distribution.
|
distribution.
|
||||||
|
|
||||||
|
THIS IS A MODIFIED SOURCE VERSION, IT INCLUDES THE DEFAULT
|
||||||
|
DEFINE FOR TIXML_USE_STL!
|
||||||
|
|
||||||
*/
|
*/
|
||||||
#define TIXML_USE_STL
|
#define TIXML_USE_STL
|
||||||
|
|
||||||
@@ -63,17 +67,20 @@ distribution.
|
|||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
|
||||||
// Microsoft visual studio, version 2005 and higher.
|
// Microsoft visual studio, version 2005 and higher.
|
||||||
#define TIXML_SNPRINTF _snprintf_s
|
#define TIXML_SNPRINTF _snprintf_s
|
||||||
#define TIXML_SNSCANF _snscanf_s
|
#define TIXML_SSCANF sscanf_s
|
||||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
|
#elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
|
||||||
// Microsoft visual studio, version 6 and higher.
|
// Microsoft visual studio, version 6 and higher.
|
||||||
//#pragma message( "Using _sn* functions." )
|
//#pragma message( "Using _sn* functions." )
|
||||||
#define TIXML_SNPRINTF _snprintf
|
#define TIXML_SNPRINTF _snprintf
|
||||||
#define TIXML_SNSCANF _snscanf
|
#define TIXML_SSCANF sscanf
|
||||||
#elif defined(__GNUC__) && (__GNUC__ >= 3 )
|
#elif defined(__GNUC__) && (__GNUC__ >= 3 )
|
||||||
// GCC version 3 and higher.s
|
// GCC version 3 and higher.s
|
||||||
//#warning( "Using sn* functions." )
|
//#warning( "Using sn* functions." )
|
||||||
#define TIXML_SNPRINTF snprintf
|
#define TIXML_SNPRINTF snprintf
|
||||||
#define TIXML_SNSCANF snscanf
|
#define TIXML_SSCANF sscanf
|
||||||
|
#else
|
||||||
|
#define TIXML_SNPRINTF snprintf
|
||||||
|
#define TIXML_SSCANF sscanf
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -87,8 +94,8 @@ class TiXmlDeclaration;
|
|||||||
class TiXmlParsingData;
|
class TiXmlParsingData;
|
||||||
|
|
||||||
const int TIXML_MAJOR_VERSION = 2;
|
const int TIXML_MAJOR_VERSION = 2;
|
||||||
const int TIXML_MINOR_VERSION = 5;
|
const int TIXML_MINOR_VERSION = 6;
|
||||||
const int TIXML_PATCH_VERSION = 2;
|
const int TIXML_PATCH_VERSION = 1;
|
||||||
|
|
||||||
/* Internal structure for tracking location of items
|
/* Internal structure for tracking location of items
|
||||||
in the XML file.
|
in the XML file.
|
||||||
@@ -104,10 +111,11 @@ struct TiXmlCursor
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Implements the interface to the "Visitor pattern" (see the Accept() method.)
|
||||||
If you call the Accept() method, it requires being passed a TiXmlVisitor
|
If you call the Accept() method, it requires being passed a TiXmlVisitor
|
||||||
class to handle callbacks. For nodes that contain other nodes (Document, Element)
|
class to handle callbacks. For nodes that contain other nodes (Document, Element)
|
||||||
you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves
|
you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves
|
||||||
are simple called with Visit().
|
are simply called with Visit().
|
||||||
|
|
||||||
If you return 'true' from a Visit method, recursive parsing will continue. If you return
|
If you return 'true' from a Visit method, recursive parsing will continue. If you return
|
||||||
false, <b>no children of this node or its sibilings</b> will be Visited.
|
false, <b>no children of this node or its sibilings</b> will be Visited.
|
||||||
@@ -127,23 +135,23 @@ public:
|
|||||||
virtual ~TiXmlVisitor() {}
|
virtual ~TiXmlVisitor() {}
|
||||||
|
|
||||||
/// Visit a document.
|
/// Visit a document.
|
||||||
virtual bool VisitEnter( const TiXmlDocument& ) { return true; }
|
virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; }
|
||||||
/// Visit a document.
|
/// Visit a document.
|
||||||
virtual bool VisitExit( const TiXmlDocument& ) { return true; }
|
virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; }
|
||||||
|
|
||||||
/// Visit an element.
|
/// Visit an element.
|
||||||
virtual bool VisitEnter( const TiXmlElement&, const TiXmlAttribute* ) { return true; }
|
virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; }
|
||||||
/// Visit an element.
|
/// Visit an element.
|
||||||
virtual bool VisitExit( const TiXmlElement& ) { return true; }
|
virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; }
|
||||||
|
|
||||||
/// Visit a declaration
|
/// Visit a declaration
|
||||||
virtual bool Visit( const TiXmlDeclaration& ) { return true; }
|
virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; }
|
||||||
/// Visit a text node
|
/// Visit a text node
|
||||||
virtual bool Visit( const TiXmlText& ) { return true; }
|
virtual bool Visit( const TiXmlText& /*text*/ ) { return true; }
|
||||||
/// Visit a comment node
|
/// Visit a comment node
|
||||||
virtual bool Visit( const TiXmlComment& ) { return true; }
|
virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; }
|
||||||
/// Visit an unknow node
|
/// Visit an unknow node
|
||||||
virtual bool Visit( const TiXmlUnknown& ) { return true; }
|
virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Only used by Attribute::Query functions
|
// Only used by Attribute::Query functions
|
||||||
@@ -252,12 +260,16 @@ public:
|
|||||||
TiXmlParsingData* data,
|
TiXmlParsingData* data,
|
||||||
TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
|
TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
|
||||||
|
|
||||||
|
/** Expands entities in a string. Note this should not contian the tag's '<', '>', etc,
|
||||||
|
or they will be transformed into entities!
|
||||||
|
*/
|
||||||
|
static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out );
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
TIXML_NO_ERROR = 0,
|
TIXML_NO_ERROR = 0,
|
||||||
TIXML_ERROR,
|
TIXML_ERROR,
|
||||||
TIXML_ERROR_OPENING_FILE,
|
TIXML_ERROR_OPENING_FILE,
|
||||||
TIXML_ERROR_OUT_OF_MEMORY,
|
|
||||||
TIXML_ERROR_PARSING_ELEMENT,
|
TIXML_ERROR_PARSING_ELEMENT,
|
||||||
TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
|
TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
|
||||||
TIXML_ERROR_READING_ELEMENT_VALUE,
|
TIXML_ERROR_READING_ELEMENT_VALUE,
|
||||||
@@ -278,6 +290,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
|
static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
|
||||||
|
|
||||||
inline static bool IsWhiteSpace( char c )
|
inline static bool IsWhiteSpace( char c )
|
||||||
{
|
{
|
||||||
return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
|
return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
|
||||||
@@ -351,10 +364,6 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Puts a string to a stream, expanding entities as it goes.
|
|
||||||
// Note this should not contian the '<', '>', etc, or they will be transformed into entities!
|
|
||||||
static void PutString( const TIXML_STRING& str, TIXML_STRING* out );
|
|
||||||
|
|
||||||
// Return true if the next characters in the stream are any of the endTag sequences.
|
// Return true if the next characters in the stream are any of the endTag sequences.
|
||||||
// Ignore case only works for english, and should only be relied on when comparing
|
// Ignore case only works for english, and should only be relied on when comparing
|
||||||
// to English words: StringEqual( p, "version", true ) is fine.
|
// to English words: StringEqual( p, "version", true ) is fine.
|
||||||
@@ -456,13 +465,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
enum NodeType
|
enum NodeType
|
||||||
{
|
{
|
||||||
DOCUMENT,
|
TINYXML_DOCUMENT,
|
||||||
ELEMENT,
|
TINYXML_ELEMENT,
|
||||||
COMMENT,
|
TINYXML_COMMENT,
|
||||||
UNKNOWN,
|
TINYXML_UNKNOWN,
|
||||||
TEXT,
|
TINYXML_TEXT,
|
||||||
DECLARATION,
|
TINYXML_DECLARATION,
|
||||||
TYPECOUNT
|
TINYXML_TYPECOUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~TiXmlNode();
|
virtual ~TiXmlNode();
|
||||||
@@ -489,6 +498,8 @@ public:
|
|||||||
const std::string& ValueStr() const { return value; }
|
const std::string& ValueStr() const { return value; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const TIXML_STRING& ValueTStr() const { return value; }
|
||||||
|
|
||||||
/** Changes the value of the node. Defined as:
|
/** Changes the value of the node. Defined as:
|
||||||
@verbatim
|
@verbatim
|
||||||
Document: filename of the xml file
|
Document: filename of the xml file
|
||||||
@@ -512,8 +523,8 @@ public:
|
|||||||
TiXmlNode* Parent() { return parent; }
|
TiXmlNode* Parent() { return parent; }
|
||||||
const TiXmlNode* Parent() const { return parent; }
|
const TiXmlNode* Parent() const { return parent; }
|
||||||
|
|
||||||
const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children.
|
const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children.
|
||||||
TiXmlNode* FirstChild() { return firstChild; }
|
TiXmlNode* FirstChild() { return firstChild; }
|
||||||
const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found.
|
const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found.
|
||||||
/// The first child of this node with the matching 'value'. Will be null if none found.
|
/// The first child of this node with the matching 'value'. Will be null if none found.
|
||||||
TiXmlNode* FirstChild( const char * _value ) {
|
TiXmlNode* FirstChild( const char * _value ) {
|
||||||
@@ -907,17 +918,14 @@ public:
|
|||||||
const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
|
const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
|
||||||
TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
|
TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
|
||||||
|
|
||||||
const TiXmlAttribute* Find( const char* _name ) const;
|
TiXmlAttribute* Find( const char* _name ) const;
|
||||||
TiXmlAttribute* Find( const char* _name ) {
|
TiXmlAttribute* FindOrCreate( const char* _name );
|
||||||
return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
|
|
||||||
}
|
# ifdef TIXML_USE_STL
|
||||||
#ifdef TIXML_USE_STL
|
TiXmlAttribute* Find( const std::string& _name ) const;
|
||||||
const TiXmlAttribute* Find( const std::string& _name ) const;
|
TiXmlAttribute* FindOrCreate( const std::string& _name );
|
||||||
TiXmlAttribute* Find( const std::string& _name ) {
|
# endif
|
||||||
return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
|
//*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
|
||||||
@@ -990,11 +998,24 @@ public:
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
|
/// QueryStringAttribute examines the attribute - see QueryIntAttribute().
|
||||||
|
int QueryStringAttribute( const char* name, std::string* _value ) const {
|
||||||
|
const char* cstr = Attribute( name );
|
||||||
|
if ( cstr ) {
|
||||||
|
*_value = std::string( cstr );
|
||||||
|
return TIXML_SUCCESS;
|
||||||
|
}
|
||||||
|
return TIXML_NO_ATTRIBUTE;
|
||||||
|
}
|
||||||
|
|
||||||
/** Template form of the attribute query which will try to read the
|
/** Template form of the attribute query which will try to read the
|
||||||
attribute into the specified type. Very easy, very powerful, but
|
attribute into the specified type. Very easy, very powerful, but
|
||||||
be careful to make sure to call this with the correct type.
|
be careful to make sure to call this with the correct type.
|
||||||
|
|
||||||
|
NOTE: This method doesn't work correctly for 'string' types that contain spaces.
|
||||||
|
|
||||||
@return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE
|
@return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE
|
||||||
*/
|
*/
|
||||||
template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const
|
template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const
|
||||||
@@ -1009,6 +1030,15 @@ public:
|
|||||||
return TIXML_SUCCESS;
|
return TIXML_SUCCESS;
|
||||||
return TIXML_WRONG_TYPE;
|
return TIXML_WRONG_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int QueryValueAttribute( const std::string& name, std::string* outValue ) const
|
||||||
|
{
|
||||||
|
const TiXmlAttribute* node = attributeSet.Find( name );
|
||||||
|
if ( !node )
|
||||||
|
return TIXML_NO_ATTRIBUTE;
|
||||||
|
*outValue = node->ValueStr();
|
||||||
|
return TIXML_SUCCESS;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Sets an attribute of name to a given value. The attribute
|
/** Sets an attribute of name to a given value. The attribute
|
||||||
@@ -1027,6 +1057,8 @@ public:
|
|||||||
void SetAttribute( const std::string& name, const std::string& _value );
|
void SetAttribute( const std::string& name, const std::string& _value );
|
||||||
///< STL std::string form.
|
///< STL std::string form.
|
||||||
void SetAttribute( const std::string& name, int _value );
|
void SetAttribute( const std::string& name, int _value );
|
||||||
|
///< STL std::string form.
|
||||||
|
void SetDoubleAttribute( const std::string& name, double value );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Sets an attribute of name to a given value. The attribute
|
/** Sets an attribute of name to a given value. The attribute
|
||||||
@@ -1118,7 +1150,6 @@ protected:
|
|||||||
const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
|
const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
TiXmlAttributeSet attributeSet;
|
TiXmlAttributeSet attributeSet;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1129,9 +1160,9 @@ class TiXmlComment : public TiXmlNode
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Constructs an empty comment.
|
/// Constructs an empty comment.
|
||||||
TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {}
|
TiXmlComment() : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {}
|
||||||
/// Construct a comment from text.
|
/// Construct a comment from text.
|
||||||
TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) {
|
TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {
|
||||||
SetValue( _value );
|
SetValue( _value );
|
||||||
}
|
}
|
||||||
TiXmlComment( const TiXmlComment& );
|
TiXmlComment( const TiXmlComment& );
|
||||||
@@ -1183,7 +1214,7 @@ public:
|
|||||||
normal, encoded text. If you want it be output as a CDATA text
|
normal, encoded text. If you want it be output as a CDATA text
|
||||||
element, set the parameter _cdata to 'true'
|
element, set the parameter _cdata to 'true'
|
||||||
*/
|
*/
|
||||||
TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT)
|
TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT)
|
||||||
{
|
{
|
||||||
SetValue( initValue );
|
SetValue( initValue );
|
||||||
cdata = false;
|
cdata = false;
|
||||||
@@ -1192,14 +1223,14 @@ public:
|
|||||||
|
|
||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT)
|
TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT)
|
||||||
{
|
{
|
||||||
SetValue( initValue );
|
SetValue( initValue );
|
||||||
cdata = false;
|
cdata = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT ) { copy.CopyTo( this ); }
|
TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TINYXML_TEXT ) { copy.CopyTo( this ); }
|
||||||
void operator=( const TiXmlText& base ) { base.CopyTo( this ); }
|
void operator=( const TiXmlText& base ) { base.CopyTo( this ); }
|
||||||
|
|
||||||
// Write this text object to a FILE stream.
|
// Write this text object to a FILE stream.
|
||||||
@@ -1252,7 +1283,7 @@ class TiXmlDeclaration : public TiXmlNode
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Construct an empty declaration.
|
/// Construct an empty declaration.
|
||||||
TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {}
|
TiXmlDeclaration() : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) {}
|
||||||
|
|
||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
@@ -1320,10 +1351,10 @@ private:
|
|||||||
class TiXmlUnknown : public TiXmlNode
|
class TiXmlUnknown : public TiXmlNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {}
|
TiXmlUnknown() : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) {}
|
||||||
virtual ~TiXmlUnknown() {}
|
virtual ~TiXmlUnknown() {}
|
||||||
|
|
||||||
TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN ) { copy.CopyTo( this ); }
|
TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) { copy.CopyTo( this ); }
|
||||||
void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); }
|
void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); }
|
||||||
|
|
||||||
/// Creates a copy of this Unknown and returns it.
|
/// Creates a copy of this Unknown and returns it.
|
||||||
@@ -1397,14 +1428,10 @@ public:
|
|||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version.
|
bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version.
|
||||||
{
|
{
|
||||||
// StringToBuffer f( filename );
|
|
||||||
// return ( f.buffer && LoadFile( f.buffer, encoding ));
|
|
||||||
return LoadFile( filename.c_str(), encoding );
|
return LoadFile( filename.c_str(), encoding );
|
||||||
}
|
}
|
||||||
bool SaveFile( const std::string& filename ) const ///< STL std::string version.
|
bool SaveFile( const std::string& filename ) const ///< STL std::string version.
|
||||||
{
|
{
|
||||||
// StringToBuffer f( filename );
|
|
||||||
// return ( f.buffer && SaveFile( f.buffer ));
|
|
||||||
return SaveFile( filename.c_str() );
|
return SaveFile( filename.c_str() );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+75
-52
@@ -21,7 +21,7 @@ must not be misrepresented as being the original software.
|
|||||||
3. This notice may not be removed or altered from any source
|
3. This notice may not be removed or altered from any source
|
||||||
distribution.
|
distribution.
|
||||||
*/
|
*/
|
||||||
#define TIXML_USE_STL
|
|
||||||
|
|
||||||
#ifndef TINYXML_INCLUDED
|
#ifndef TINYXML_INCLUDED
|
||||||
#define TINYXML_INCLUDED
|
#define TINYXML_INCLUDED
|
||||||
@@ -63,17 +63,20 @@ distribution.
|
|||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
|
||||||
// Microsoft visual studio, version 2005 and higher.
|
// Microsoft visual studio, version 2005 and higher.
|
||||||
#define TIXML_SNPRINTF _snprintf_s
|
#define TIXML_SNPRINTF _snprintf_s
|
||||||
#define TIXML_SNSCANF _snscanf_s
|
#define TIXML_SSCANF sscanf_s
|
||||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
|
#elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
|
||||||
// Microsoft visual studio, version 6 and higher.
|
// Microsoft visual studio, version 6 and higher.
|
||||||
//#pragma message( "Using _sn* functions." )
|
//#pragma message( "Using _sn* functions." )
|
||||||
#define TIXML_SNPRINTF _snprintf
|
#define TIXML_SNPRINTF _snprintf
|
||||||
#define TIXML_SNSCANF _snscanf
|
#define TIXML_SSCANF sscanf
|
||||||
#elif defined(__GNUC__) && (__GNUC__ >= 3 )
|
#elif defined(__GNUC__) && (__GNUC__ >= 3 )
|
||||||
// GCC version 3 and higher.s
|
// GCC version 3 and higher.s
|
||||||
//#warning( "Using sn* functions." )
|
//#warning( "Using sn* functions." )
|
||||||
#define TIXML_SNPRINTF snprintf
|
#define TIXML_SNPRINTF snprintf
|
||||||
#define TIXML_SNSCANF snscanf
|
#define TIXML_SSCANF sscanf
|
||||||
|
#else
|
||||||
|
#define TIXML_SNPRINTF snprintf
|
||||||
|
#define TIXML_SSCANF sscanf
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -87,8 +90,8 @@ class TiXmlDeclaration;
|
|||||||
class TiXmlParsingData;
|
class TiXmlParsingData;
|
||||||
|
|
||||||
const int TIXML_MAJOR_VERSION = 2;
|
const int TIXML_MAJOR_VERSION = 2;
|
||||||
const int TIXML_MINOR_VERSION = 5;
|
const int TIXML_MINOR_VERSION = 6;
|
||||||
const int TIXML_PATCH_VERSION = 2;
|
const int TIXML_PATCH_VERSION = 1;
|
||||||
|
|
||||||
/* Internal structure for tracking location of items
|
/* Internal structure for tracking location of items
|
||||||
in the XML file.
|
in the XML file.
|
||||||
@@ -104,10 +107,11 @@ struct TiXmlCursor
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Implements the interface to the "Visitor pattern" (see the Accept() method.)
|
||||||
If you call the Accept() method, it requires being passed a TiXmlVisitor
|
If you call the Accept() method, it requires being passed a TiXmlVisitor
|
||||||
class to handle callbacks. For nodes that contain other nodes (Document, Element)
|
class to handle callbacks. For nodes that contain other nodes (Document, Element)
|
||||||
you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves
|
you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves
|
||||||
are simple called with Visit().
|
are simply called with Visit().
|
||||||
|
|
||||||
If you return 'true' from a Visit method, recursive parsing will continue. If you return
|
If you return 'true' from a Visit method, recursive parsing will continue. If you return
|
||||||
false, <b>no children of this node or its sibilings</b> will be Visited.
|
false, <b>no children of this node or its sibilings</b> will be Visited.
|
||||||
@@ -127,23 +131,23 @@ public:
|
|||||||
virtual ~TiXmlVisitor() {}
|
virtual ~TiXmlVisitor() {}
|
||||||
|
|
||||||
/// Visit a document.
|
/// Visit a document.
|
||||||
virtual bool VisitEnter( const TiXmlDocument& doc ) { return true; }
|
virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; }
|
||||||
/// Visit a document.
|
/// Visit a document.
|
||||||
virtual bool VisitExit( const TiXmlDocument& doc ) { return true; }
|
virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; }
|
||||||
|
|
||||||
/// Visit an element.
|
/// Visit an element.
|
||||||
virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) { return true; }
|
virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; }
|
||||||
/// Visit an element.
|
/// Visit an element.
|
||||||
virtual bool VisitExit( const TiXmlElement& element ) { return true; }
|
virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; }
|
||||||
|
|
||||||
/// Visit a declaration
|
/// Visit a declaration
|
||||||
virtual bool Visit( const TiXmlDeclaration& declaration ) { return true; }
|
virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; }
|
||||||
/// Visit a text node
|
/// Visit a text node
|
||||||
virtual bool Visit( const TiXmlText& text ) { return true; }
|
virtual bool Visit( const TiXmlText& /*text*/ ) { return true; }
|
||||||
/// Visit a comment node
|
/// Visit a comment node
|
||||||
virtual bool Visit( const TiXmlComment& comment ) { return true; }
|
virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; }
|
||||||
/// Visit an unknow node
|
/// Visit an unknow node
|
||||||
virtual bool Visit( const TiXmlUnknown& unknown ) { return true; }
|
virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Only used by Attribute::Query functions
|
// Only used by Attribute::Query functions
|
||||||
@@ -252,12 +256,16 @@ public:
|
|||||||
TiXmlParsingData* data,
|
TiXmlParsingData* data,
|
||||||
TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
|
TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
|
||||||
|
|
||||||
|
/** Expands entities in a string. Note this should not contian the tag's '<', '>', etc,
|
||||||
|
or they will be transformed into entities!
|
||||||
|
*/
|
||||||
|
static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out );
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
TIXML_NO_ERROR = 0,
|
TIXML_NO_ERROR = 0,
|
||||||
TIXML_ERROR,
|
TIXML_ERROR,
|
||||||
TIXML_ERROR_OPENING_FILE,
|
TIXML_ERROR_OPENING_FILE,
|
||||||
TIXML_ERROR_OUT_OF_MEMORY,
|
|
||||||
TIXML_ERROR_PARSING_ELEMENT,
|
TIXML_ERROR_PARSING_ELEMENT,
|
||||||
TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
|
TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
|
||||||
TIXML_ERROR_READING_ELEMENT_VALUE,
|
TIXML_ERROR_READING_ELEMENT_VALUE,
|
||||||
@@ -278,6 +286,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
|
static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
|
||||||
|
|
||||||
inline static bool IsWhiteSpace( char c )
|
inline static bool IsWhiteSpace( char c )
|
||||||
{
|
{
|
||||||
return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
|
return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
|
||||||
@@ -351,10 +360,6 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Puts a string to a stream, expanding entities as it goes.
|
|
||||||
// Note this should not contian the '<', '>', etc, or they will be transformed into entities!
|
|
||||||
static void PutString( const TIXML_STRING& str, TIXML_STRING* out );
|
|
||||||
|
|
||||||
// Return true if the next characters in the stream are any of the endTag sequences.
|
// Return true if the next characters in the stream are any of the endTag sequences.
|
||||||
// Ignore case only works for english, and should only be relied on when comparing
|
// Ignore case only works for english, and should only be relied on when comparing
|
||||||
// to English words: StringEqual( p, "version", true ) is fine.
|
// to English words: StringEqual( p, "version", true ) is fine.
|
||||||
@@ -456,13 +461,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
enum NodeType
|
enum NodeType
|
||||||
{
|
{
|
||||||
DOCUMENT,
|
TINYXML_DOCUMENT,
|
||||||
ELEMENT,
|
TINYXML_ELEMENT,
|
||||||
COMMENT,
|
TINYXML_COMMENT,
|
||||||
UNKNOWN,
|
TINYXML_UNKNOWN,
|
||||||
TEXT,
|
TINYXML_TEXT,
|
||||||
DECLARATION,
|
TINYXML_DECLARATION,
|
||||||
TYPECOUNT
|
TINYXML_TYPECOUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~TiXmlNode();
|
virtual ~TiXmlNode();
|
||||||
@@ -489,6 +494,8 @@ public:
|
|||||||
const std::string& ValueStr() const { return value; }
|
const std::string& ValueStr() const { return value; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const TIXML_STRING& ValueTStr() const { return value; }
|
||||||
|
|
||||||
/** Changes the value of the node. Defined as:
|
/** Changes the value of the node. Defined as:
|
||||||
@verbatim
|
@verbatim
|
||||||
Document: filename of the xml file
|
Document: filename of the xml file
|
||||||
@@ -512,8 +519,8 @@ public:
|
|||||||
TiXmlNode* Parent() { return parent; }
|
TiXmlNode* Parent() { return parent; }
|
||||||
const TiXmlNode* Parent() const { return parent; }
|
const TiXmlNode* Parent() const { return parent; }
|
||||||
|
|
||||||
const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children.
|
const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children.
|
||||||
TiXmlNode* FirstChild() { return firstChild; }
|
TiXmlNode* FirstChild() { return firstChild; }
|
||||||
const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found.
|
const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found.
|
||||||
/// The first child of this node with the matching 'value'. Will be null if none found.
|
/// The first child of this node with the matching 'value'. Will be null if none found.
|
||||||
TiXmlNode* FirstChild( const char * _value ) {
|
TiXmlNode* FirstChild( const char * _value ) {
|
||||||
@@ -907,17 +914,14 @@ public:
|
|||||||
const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
|
const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
|
||||||
TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
|
TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
|
||||||
|
|
||||||
const TiXmlAttribute* Find( const char* _name ) const;
|
TiXmlAttribute* Find( const char* _name ) const;
|
||||||
TiXmlAttribute* Find( const char* _name ) {
|
TiXmlAttribute* FindOrCreate( const char* _name );
|
||||||
return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
|
|
||||||
}
|
# ifdef TIXML_USE_STL
|
||||||
#ifdef TIXML_USE_STL
|
TiXmlAttribute* Find( const std::string& _name ) const;
|
||||||
const TiXmlAttribute* Find( const std::string& _name ) const;
|
TiXmlAttribute* FindOrCreate( const std::string& _name );
|
||||||
TiXmlAttribute* Find( const std::string& _name ) {
|
# endif
|
||||||
return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
|
//*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
|
||||||
@@ -990,11 +994,24 @@ public:
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
|
/// QueryStringAttribute examines the attribute - see QueryIntAttribute().
|
||||||
|
int QueryStringAttribute( const char* name, std::string* _value ) const {
|
||||||
|
const char* cstr = Attribute( name );
|
||||||
|
if ( cstr ) {
|
||||||
|
*_value = std::string( cstr );
|
||||||
|
return TIXML_SUCCESS;
|
||||||
|
}
|
||||||
|
return TIXML_NO_ATTRIBUTE;
|
||||||
|
}
|
||||||
|
|
||||||
/** Template form of the attribute query which will try to read the
|
/** Template form of the attribute query which will try to read the
|
||||||
attribute into the specified type. Very easy, very powerful, but
|
attribute into the specified type. Very easy, very powerful, but
|
||||||
be careful to make sure to call this with the correct type.
|
be careful to make sure to call this with the correct type.
|
||||||
|
|
||||||
|
NOTE: This method doesn't work correctly for 'string' types that contain spaces.
|
||||||
|
|
||||||
@return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE
|
@return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE
|
||||||
*/
|
*/
|
||||||
template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const
|
template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const
|
||||||
@@ -1009,6 +1026,15 @@ public:
|
|||||||
return TIXML_SUCCESS;
|
return TIXML_SUCCESS;
|
||||||
return TIXML_WRONG_TYPE;
|
return TIXML_WRONG_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int QueryValueAttribute( const std::string& name, std::string* outValue ) const
|
||||||
|
{
|
||||||
|
const TiXmlAttribute* node = attributeSet.Find( name );
|
||||||
|
if ( !node )
|
||||||
|
return TIXML_NO_ATTRIBUTE;
|
||||||
|
*outValue = node->ValueStr();
|
||||||
|
return TIXML_SUCCESS;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Sets an attribute of name to a given value. The attribute
|
/** Sets an attribute of name to a given value. The attribute
|
||||||
@@ -1027,6 +1053,8 @@ public:
|
|||||||
void SetAttribute( const std::string& name, const std::string& _value );
|
void SetAttribute( const std::string& name, const std::string& _value );
|
||||||
///< STL std::string form.
|
///< STL std::string form.
|
||||||
void SetAttribute( const std::string& name, int _value );
|
void SetAttribute( const std::string& name, int _value );
|
||||||
|
///< STL std::string form.
|
||||||
|
void SetDoubleAttribute( const std::string& name, double value );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Sets an attribute of name to a given value. The attribute
|
/** Sets an attribute of name to a given value. The attribute
|
||||||
@@ -1118,7 +1146,6 @@ protected:
|
|||||||
const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
|
const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
TiXmlAttributeSet attributeSet;
|
TiXmlAttributeSet attributeSet;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1129,9 +1156,9 @@ class TiXmlComment : public TiXmlNode
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Constructs an empty comment.
|
/// Constructs an empty comment.
|
||||||
TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {}
|
TiXmlComment() : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {}
|
||||||
/// Construct a comment from text.
|
/// Construct a comment from text.
|
||||||
TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) {
|
TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {
|
||||||
SetValue( _value );
|
SetValue( _value );
|
||||||
}
|
}
|
||||||
TiXmlComment( const TiXmlComment& );
|
TiXmlComment( const TiXmlComment& );
|
||||||
@@ -1183,7 +1210,7 @@ public:
|
|||||||
normal, encoded text. If you want it be output as a CDATA text
|
normal, encoded text. If you want it be output as a CDATA text
|
||||||
element, set the parameter _cdata to 'true'
|
element, set the parameter _cdata to 'true'
|
||||||
*/
|
*/
|
||||||
TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT)
|
TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT)
|
||||||
{
|
{
|
||||||
SetValue( initValue );
|
SetValue( initValue );
|
||||||
cdata = false;
|
cdata = false;
|
||||||
@@ -1192,14 +1219,14 @@ public:
|
|||||||
|
|
||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT)
|
TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT)
|
||||||
{
|
{
|
||||||
SetValue( initValue );
|
SetValue( initValue );
|
||||||
cdata = false;
|
cdata = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT ) { copy.CopyTo( this ); }
|
TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TINYXML_TEXT ) { copy.CopyTo( this ); }
|
||||||
void operator=( const TiXmlText& base ) { base.CopyTo( this ); }
|
void operator=( const TiXmlText& base ) { base.CopyTo( this ); }
|
||||||
|
|
||||||
// Write this text object to a FILE stream.
|
// Write this text object to a FILE stream.
|
||||||
@@ -1252,7 +1279,7 @@ class TiXmlDeclaration : public TiXmlNode
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Construct an empty declaration.
|
/// Construct an empty declaration.
|
||||||
TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {}
|
TiXmlDeclaration() : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) {}
|
||||||
|
|
||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
@@ -1320,10 +1347,10 @@ private:
|
|||||||
class TiXmlUnknown : public TiXmlNode
|
class TiXmlUnknown : public TiXmlNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {}
|
TiXmlUnknown() : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) {}
|
||||||
virtual ~TiXmlUnknown() {}
|
virtual ~TiXmlUnknown() {}
|
||||||
|
|
||||||
TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN ) { copy.CopyTo( this ); }
|
TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) { copy.CopyTo( this ); }
|
||||||
void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); }
|
void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); }
|
||||||
|
|
||||||
/// Creates a copy of this Unknown and returns it.
|
/// Creates a copy of this Unknown and returns it.
|
||||||
@@ -1397,14 +1424,10 @@ public:
|
|||||||
#ifdef TIXML_USE_STL
|
#ifdef TIXML_USE_STL
|
||||||
bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version.
|
bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version.
|
||||||
{
|
{
|
||||||
// StringToBuffer f( filename );
|
|
||||||
// return ( f.buffer && LoadFile( f.buffer, encoding ));
|
|
||||||
return LoadFile( filename.c_str(), encoding );
|
return LoadFile( filename.c_str(), encoding );
|
||||||
}
|
}
|
||||||
bool SaveFile( const std::string& filename ) const ///< STL std::string version.
|
bool SaveFile( const std::string& filename ) const ///< STL std::string version.
|
||||||
{
|
{
|
||||||
// StringToBuffer f( filename );
|
|
||||||
// return ( f.buffer && SaveFile( f.buffer ));
|
|
||||||
return SaveFile( filename.c_str() );
|
return SaveFile( filename.c_str() );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
-1
@@ -36,7 +36,6 @@ const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] =
|
|||||||
"No error",
|
"No error",
|
||||||
"Error",
|
"Error",
|
||||||
"Failed to open file",
|
"Failed to open file",
|
||||||
"Memory allocation failed.",
|
|
||||||
"Error parsing Element.",
|
"Error parsing Element.",
|
||||||
"Failed to read Element name",
|
"Failed to read Element name",
|
||||||
"Error reading Element value.",
|
"Error reading Element value.",
|
||||||
|
|||||||
+51
-22
@@ -346,7 +346,7 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) // Still using old rules for white space.
|
if ( IsWhiteSpace( *p ) ) // Still using old rules for white space.
|
||||||
++p;
|
++p;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
@@ -354,7 +354,7 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' )
|
while ( *p && IsWhiteSpace( *p ) )
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -631,7 +631,7 @@ const char* TiXmlBase::ReadText( const char* p,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( p )
|
if ( p && *p )
|
||||||
p += strlen( endTag );
|
p += strlen( endTag );
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@@ -825,7 +825,6 @@ TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TiXmlDocument* doc = GetDocument();
|
|
||||||
p = SkipWhiteSpace( p, encoding );
|
p = SkipWhiteSpace( p, encoding );
|
||||||
|
|
||||||
if ( !p || !*p )
|
if ( !p || !*p )
|
||||||
@@ -896,11 +895,6 @@ TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
|
|||||||
// Set the parent, so it can report errors
|
// Set the parent, so it can report errors
|
||||||
returnNode->parent = this;
|
returnNode->parent = this;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( doc )
|
|
||||||
doc->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
|
||||||
}
|
|
||||||
return returnNode;
|
return returnNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1083,7 +1077,6 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
|
|||||||
|
|
||||||
TIXML_STRING endTag ("</");
|
TIXML_STRING endTag ("</");
|
||||||
endTag += value;
|
endTag += value;
|
||||||
endTag += ">";
|
|
||||||
|
|
||||||
// Check for and read attributes. Also look for an empty
|
// Check for and read attributes. Also look for an empty
|
||||||
// tag or an end tag.
|
// tag or an end tag.
|
||||||
@@ -1114,14 +1107,28 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
|
|||||||
// elements -- read the end tag, and return.
|
// elements -- read the end tag, and return.
|
||||||
++p;
|
++p;
|
||||||
p = ReadValue( p, data, encoding ); // Note this is an Element method, and will set the error if one happens.
|
p = ReadValue( p, data, encoding ); // Note this is an Element method, and will set the error if one happens.
|
||||||
if ( !p || !*p )
|
if ( !p || !*p ) {
|
||||||
|
// We were looking for the end tag, but found nothing.
|
||||||
|
// Fix for [ 1663758 ] Failure to report error on bad XML
|
||||||
|
if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// We should find the end tag now
|
// We should find the end tag now
|
||||||
|
// note that:
|
||||||
|
// </foo > and
|
||||||
|
// </foo>
|
||||||
|
// are both valid end tags.
|
||||||
if ( StringEqual( p, endTag.c_str(), false, encoding ) )
|
if ( StringEqual( p, endTag.c_str(), false, encoding ) )
|
||||||
{
|
{
|
||||||
p += endTag.length();
|
p += endTag.length();
|
||||||
return p;
|
p = SkipWhiteSpace( p, encoding );
|
||||||
|
if ( p && *p && *p == '>' ) {
|
||||||
|
++p;
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1135,7 +1142,6 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
|
|||||||
TiXmlAttribute* attrib = new TiXmlAttribute();
|
TiXmlAttribute* attrib = new TiXmlAttribute();
|
||||||
if ( !attrib )
|
if ( !attrib )
|
||||||
{
|
{
|
||||||
if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, pErr, data, encoding );
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1158,7 +1164,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
|
|||||||
#endif
|
#endif
|
||||||
if ( node )
|
if ( node )
|
||||||
{
|
{
|
||||||
node->SetValue( attrib->Value() );
|
if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding );
|
||||||
delete attrib;
|
delete attrib;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1187,8 +1193,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm
|
|||||||
|
|
||||||
if ( !textNode )
|
if ( !textNode )
|
||||||
{
|
{
|
||||||
if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, encoding );
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( TiXmlBase::IsWhiteSpaceCondensed() )
|
if ( TiXmlBase::IsWhiteSpaceCondensed() )
|
||||||
@@ -1349,7 +1354,35 @@ const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
p += strlen( startTag );
|
p += strlen( startTag );
|
||||||
p = ReadText( p, &value, false, endTag, false, encoding );
|
|
||||||
|
// [ 1475201 ] TinyXML parses entities in comments
|
||||||
|
// Oops - ReadText doesn't work, because we don't want to parse the entities.
|
||||||
|
// p = ReadText( p, &value, false, endTag, false, encoding );
|
||||||
|
//
|
||||||
|
// from the XML spec:
|
||||||
|
/*
|
||||||
|
[Definition: Comments may appear anywhere in a document outside other markup; in addition,
|
||||||
|
they may appear within the document type declaration at places allowed by the grammar.
|
||||||
|
They are not part of the document's character data; an XML processor MAY, but need not,
|
||||||
|
make it possible for an application to retrieve the text of comments. For compatibility,
|
||||||
|
the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity
|
||||||
|
references MUST NOT be recognized within comments.
|
||||||
|
|
||||||
|
An example of a comment:
|
||||||
|
|
||||||
|
<!-- declarations for <head> & <body> -->
|
||||||
|
*/
|
||||||
|
|
||||||
|
value = "";
|
||||||
|
// Keep all the white space.
|
||||||
|
while ( p && *p && !StringEqual( p, endTag, false, encoding ) )
|
||||||
|
{
|
||||||
|
value.append( p, 1 );
|
||||||
|
++p;
|
||||||
|
}
|
||||||
|
if ( p && *p )
|
||||||
|
p += strlen( endTag );
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1359,10 +1392,6 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE
|
|||||||
p = SkipWhiteSpace( p, encoding );
|
p = SkipWhiteSpace( p, encoding );
|
||||||
if ( !p || !*p ) return 0;
|
if ( !p || !*p ) return 0;
|
||||||
|
|
||||||
// int tabsize = 4;
|
|
||||||
// if ( document )
|
|
||||||
// tabsize = document->TabSize();
|
|
||||||
|
|
||||||
if ( data )
|
if ( data )
|
||||||
{
|
{
|
||||||
data->Stamp( p, encoding );
|
data->Stamp( p, encoding );
|
||||||
@@ -1414,7 +1443,7 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE
|
|||||||
// its best, even without them.
|
// its best, even without them.
|
||||||
value = "";
|
value = "";
|
||||||
while ( p && *p // existence
|
while ( p && *p // existence
|
||||||
&& !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r' // whitespace
|
&& !IsWhiteSpace( *p ) // whitespace
|
||||||
&& *p != '/' && *p != '>' ) // tag end
|
&& *p != '/' && *p != '>' ) // tag end
|
||||||
{
|
{
|
||||||
if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) {
|
if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user