|
|
@ -2,23 +2,23 @@
|
|
|
|
www.sourceforge.net/projects/tinyxml
|
|
|
|
www.sourceforge.net/projects/tinyxml
|
|
|
|
Original code by Lee Thomason (www.grinninglizard.com)
|
|
|
|
Original code by Lee Thomason (www.grinninglizard.com)
|
|
|
|
|
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any
|
|
|
|
warranty. In no event will the authors be held liable for any
|
|
|
|
damages arising from the use of this software.
|
|
|
|
damages arising from the use of this software.
|
|
|
|
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any
|
|
|
|
Permission is granted to anyone to use this software for any
|
|
|
|
purpose, including commercial applications, and to alter it and
|
|
|
|
purpose, including commercial applications, and to alter it and
|
|
|
|
redistribute it freely, subject to the following restrictions:
|
|
|
|
redistribute it freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must
|
|
|
|
1. The origin of this software must not be misrepresented; you must
|
|
|
|
not claim that you wrote the original software. If you use this
|
|
|
|
not claim that you wrote the original software. If you use this
|
|
|
|
software in a product, an acknowledgment in the product documentation
|
|
|
|
software in a product, an acknowledgment in the product documentation
|
|
|
|
would be appreciated but is not required.
|
|
|
|
would be appreciated but is not required.
|
|
|
|
|
|
|
|
|
|
|
|
2. Altered source versions must be plainly marked as such, and
|
|
|
|
2. Altered source versions must be plainly marked as such, and
|
|
|
|
must not be misrepresented as being the original software.
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
@ -39,8 +39,8 @@ distribution.
|
|
|
|
|
|
|
|
|
|
|
|
// Note tha "PutString" hardcodes the same list. This
|
|
|
|
// Note tha "PutString" hardcodes the same list. This
|
|
|
|
// is less flexible than it appears. Changing the entries
|
|
|
|
// is less flexible than it appears. Changing the entries
|
|
|
|
// or order will break putstring.
|
|
|
|
// or order will break putstring.
|
|
|
|
TiXmlBase::Entity TiXmlBase::entity[ TiXmlBase::NUM_ENTITY ] =
|
|
|
|
TiXmlBase::Entity TiXmlBase::entity[ TiXmlBase::NUM_ENTITY ] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ "&", 5, '&' },
|
|
|
|
{ "&", 5, '&' },
|
|
|
|
{ "<", 4, '<' },
|
|
|
|
{ "<", 4, '<' },
|
|
|
@ -54,16 +54,16 @@ TiXmlBase::Entity TiXmlBase::entity[ TiXmlBase::NUM_ENTITY ] =
|
|
|
|
// Including the basic of this table, which determines the #bytes in the
|
|
|
|
// Including the basic of this table, which determines the #bytes in the
|
|
|
|
// sequence from the lead byte. 1 placed for invalid sequences --
|
|
|
|
// sequence from the lead byte. 1 placed for invalid sequences --
|
|
|
|
// although the result will be junk, pass it through as much as possible.
|
|
|
|
// although the result will be junk, pass it through as much as possible.
|
|
|
|
// Beware of the non-characters in UTF-8:
|
|
|
|
// Beware of the non-characters in UTF-8:
|
|
|
|
// ef bb bf (Microsoft "lead bytes")
|
|
|
|
// ef bb bf (Microsoft "lead bytes")
|
|
|
|
// ef bf be
|
|
|
|
// ef bf be
|
|
|
|
// ef bf bf
|
|
|
|
// ef bf bf
|
|
|
|
|
|
|
|
|
|
|
|
const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
|
|
|
|
const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
|
|
|
|
const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
|
|
|
|
const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
|
|
|
|
const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
|
|
|
|
const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
|
|
|
|
|
|
|
|
|
|
|
|
const int TiXmlBase::utf8ByteTable[256] =
|
|
|
|
const int TiXmlBase::utf8ByteTable[256] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
|
|
|
|
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00
|
|
|
@ -75,9 +75,9 @@ const int TiXmlBase::utf8ByteTable[256] =
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0
|
|
|
|
1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte
|
|
|
|
1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte
|
|
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0
|
|
|
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0
|
|
|
|
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte
|
|
|
|
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte
|
|
|
@ -91,7 +91,7 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng
|
|
|
|
const unsigned long BYTE_MARK = 0x80;
|
|
|
|
const unsigned long BYTE_MARK = 0x80;
|
|
|
|
const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
|
|
|
|
const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
|
|
|
|
|
|
|
|
|
|
|
|
if (input < 0x80)
|
|
|
|
if (input < 0x80)
|
|
|
|
*length = 1;
|
|
|
|
*length = 1;
|
|
|
|
else if ( input < 0x800 )
|
|
|
|
else if ( input < 0x800 )
|
|
|
|
*length = 2;
|
|
|
|
*length = 2;
|
|
|
@ -105,22 +105,22 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng
|
|
|
|
output += *length;
|
|
|
|
output += *length;
|
|
|
|
|
|
|
|
|
|
|
|
// Scary scary fall throughs.
|
|
|
|
// Scary scary fall throughs.
|
|
|
|
switch (*length)
|
|
|
|
switch (*length)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case 4:
|
|
|
|
case 4:
|
|
|
|
--output;
|
|
|
|
--output;
|
|
|
|
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
|
|
|
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
|
|
|
input >>= 6;
|
|
|
|
input >>= 6;
|
|
|
|
case 3:
|
|
|
|
case 3:
|
|
|
|
--output;
|
|
|
|
--output;
|
|
|
|
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
|
|
|
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
|
|
|
input >>= 6;
|
|
|
|
input >>= 6;
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
--output;
|
|
|
|
--output;
|
|
|
|
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
|
|
|
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
|
|
|
input >>= 6;
|
|
|
|
input >>= 6;
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
--output;
|
|
|
|
--output;
|
|
|
|
*output = (char)(input | FIRST_BYTE_MARK[*length]);
|
|
|
|
*output = (char)(input | FIRST_BYTE_MARK[*length]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -130,7 +130,7 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// This will only work for low-ascii, everything else is assumed to be a valid
|
|
|
|
// This will only work for low-ascii, everything else is assumed to be a valid
|
|
|
|
// letter. I'm not sure this is the best approach, but it is quite tricky trying
|
|
|
|
// letter. I'm not sure this is the best approach, but it is quite tricky trying
|
|
|
|
// to figure out alhabetical vs. not across encoding. So take a very
|
|
|
|
// to figure out alhabetical vs. not across encoding. So take a very
|
|
|
|
// conservative approach.
|
|
|
|
// conservative approach.
|
|
|
|
|
|
|
|
|
|
|
|
// if ( encoding == TIXML_ENCODING_UTF8 )
|
|
|
|
// if ( encoding == TIXML_ENCODING_UTF8 )
|
|
|
@ -151,7 +151,7 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// This will only work for low-ascii, everything else is assumed to be a valid
|
|
|
|
// This will only work for low-ascii, everything else is assumed to be a valid
|
|
|
|
// letter. I'm not sure this is the best approach, but it is quite tricky trying
|
|
|
|
// letter. I'm not sure this is the best approach, but it is quite tricky trying
|
|
|
|
// to figure out alhabetical vs. not across encoding. So take a very
|
|
|
|
// to figure out alhabetical vs. not across encoding. So take a very
|
|
|
|
// conservative approach.
|
|
|
|
// conservative approach.
|
|
|
|
|
|
|
|
|
|
|
|
// if ( encoding == TIXML_ENCODING_UTF8 )
|
|
|
|
// if ( encoding == TIXML_ENCODING_UTF8 )
|
|
|
@ -224,7 +224,7 @@ void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding )
|
|
|
|
case '\r':
|
|
|
|
case '\r':
|
|
|
|
// bump down to the next line
|
|
|
|
// bump down to the next line
|
|
|
|
++row;
|
|
|
|
++row;
|
|
|
|
col = 0;
|
|
|
|
col = 0;
|
|
|
|
// Eat the character
|
|
|
|
// Eat the character
|
|
|
|
++p;
|
|
|
|
++p;
|
|
|
|
|
|
|
|
|
|
|
@ -266,11 +266,11 @@ void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding )
|
|
|
|
// In these cases, don't advance the column. These are
|
|
|
|
// In these cases, don't advance the column. These are
|
|
|
|
// 0-width spaces.
|
|
|
|
// 0-width spaces.
|
|
|
|
if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 )
|
|
|
|
if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 )
|
|
|
|
p += 3;
|
|
|
|
p += 3;
|
|
|
|
else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU )
|
|
|
|
else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU )
|
|
|
|
p += 3;
|
|
|
|
p += 3;
|
|
|
|
else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU )
|
|
|
|
else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU )
|
|
|
|
p += 3;
|
|
|
|
p += 3;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{ p +=3; ++col; } // A normal character.
|
|
|
|
{ p +=3; ++col; } // A normal character.
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -322,10 +322,10 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
|
|
|
|
while ( *p )
|
|
|
|
while ( *p )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const unsigned char* pU = (const unsigned char*)p;
|
|
|
|
const unsigned char* pU = (const unsigned char*)p;
|
|
|
|
|
|
|
|
|
|
|
|
// Skip the stupid Microsoft UTF-8 Byte order marks
|
|
|
|
// Skip the stupid Microsoft UTF-8 Byte order marks
|
|
|
|
if ( *(pU+0)==TIXML_UTF_LEAD_0
|
|
|
|
if ( *(pU+0)==TIXML_UTF_LEAD_0
|
|
|
|
&& *(pU+1)==TIXML_UTF_LEAD_1
|
|
|
|
&& *(pU+1)==TIXML_UTF_LEAD_1
|
|
|
|
&& *(pU+2)==TIXML_UTF_LEAD_2 )
|
|
|
|
&& *(pU+2)==TIXML_UTF_LEAD_2 )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
p += 3;
|
|
|
|
p += 3;
|
|
|
@ -413,12 +413,12 @@ const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncodi
|
|
|
|
// After that, they can be letters, underscores, numbers,
|
|
|
|
// After that, they can be letters, underscores, numbers,
|
|
|
|
// hyphens, or colons. (Colons are valid ony for namespaces,
|
|
|
|
// hyphens, or colons. (Colons are valid ony for namespaces,
|
|
|
|
// but tinyxml can't tell namespaces from names.)
|
|
|
|
// but tinyxml can't tell namespaces from names.)
|
|
|
|
if ( p && *p
|
|
|
|
if ( p && *p
|
|
|
|
&& ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) )
|
|
|
|
&& ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const char* start = p;
|
|
|
|
const char* start = p;
|
|
|
|
while( p && *p
|
|
|
|
while( p && *p
|
|
|
|
&& ( IsAlphaNum( (unsigned char ) *p, encoding )
|
|
|
|
&& ( IsAlphaNum( (unsigned char ) *p, encoding )
|
|
|
|
|| *p == '_'
|
|
|
|
|| *p == '_'
|
|
|
|
|| *p == '-'
|
|
|
|
|| *p == '-'
|
|
|
|
|| *p == '.'
|
|
|
|
|| *p == '.'
|
|
|
@ -469,7 +469,7 @@ const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXml
|
|
|
|
ucs += mult * (*q - 'a' + 10);
|
|
|
|
ucs += mult * (*q - 'a' + 10);
|
|
|
|
else if ( *q >= 'A' && *q <= 'F' )
|
|
|
|
else if ( *q >= 'A' && *q <= 'F' )
|
|
|
|
ucs += mult * (*q - 'A' + 10 );
|
|
|
|
ucs += mult * (*q - 'A' + 10 );
|
|
|
|
else
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
mult *= 16;
|
|
|
|
mult *= 16;
|
|
|
|
--q;
|
|
|
|
--q;
|
|
|
@ -492,7 +492,7 @@ const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXml
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( *q >= '0' && *q <= '9' )
|
|
|
|
if ( *q >= '0' && *q <= '9' )
|
|
|
|
ucs += mult * (*q - '0');
|
|
|
|
ucs += mult * (*q - '0');
|
|
|
|
else
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
mult *= 10;
|
|
|
|
mult *= 10;
|
|
|
|
--q;
|
|
|
|
--q;
|
|
|
@ -571,10 +571,10 @@ bool TiXmlBase::StringEqual( const char* p,
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char* TiXmlBase::ReadText( const char* p,
|
|
|
|
const char* TiXmlBase::ReadText( const char* p,
|
|
|
|
TIXML_STRING * text,
|
|
|
|
TIXML_STRING * text,
|
|
|
|
bool trimWhiteSpace,
|
|
|
|
bool trimWhiteSpace,
|
|
|
|
const char* endTag,
|
|
|
|
const char* endTag,
|
|
|
|
bool caseInsensitive,
|
|
|
|
bool caseInsensitive,
|
|
|
|
TiXmlEncoding encoding )
|
|
|
|
TiXmlEncoding encoding )
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -647,7 +647,7 @@ void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag )
|
|
|
|
// This "pre-streaming" will never read the closing ">" so the
|
|
|
|
// This "pre-streaming" will never read the closing ">" so the
|
|
|
|
// sub-tag can orient itself.
|
|
|
|
// sub-tag can orient itself.
|
|
|
|
|
|
|
|
|
|
|
|
if ( !StreamTo( in, '<', tag ) )
|
|
|
|
if ( !StreamTo( in, '<', tag ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
|
|
|
SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -669,7 +669,7 @@ void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag )
|
|
|
|
|
|
|
|
|
|
|
|
if ( in->good() )
|
|
|
|
if ( in->good() )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// We now have something we presume to be a node of
|
|
|
|
// We now have something we presume to be a node of
|
|
|
|
// some sort. Identify it, and call the node to
|
|
|
|
// some sort. Identify it, and call the node to
|
|
|
|
// continue streaming.
|
|
|
|
// continue streaming.
|
|
|
|
TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING );
|
|
|
|
TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING );
|
|
|
@ -778,7 +778,7 @@ const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiX
|
|
|
|
encoding = TIXML_ENCODING_UTF8;
|
|
|
|
encoding = TIXML_ENCODING_UTF8;
|
|
|
|
else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) )
|
|
|
|
else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) )
|
|
|
|
encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice
|
|
|
|
encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice
|
|
|
|
else
|
|
|
|
else
|
|
|
|
encoding = TIXML_ENCODING_LEGACY;
|
|
|
|
encoding = TIXML_ENCODING_LEGACY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -796,7 +796,7 @@ const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiX
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding )
|
|
|
|
void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// The first error in a chain is more accurate - don't set again!
|
|
|
|
// The first error in a chain is more accurate - don't set again!
|
|
|
|
if ( error )
|
|
|
|
if ( error )
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -832,7 +832,7 @@ TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// What is this thing?
|
|
|
|
// What is this thing?
|
|
|
|
// - Elements start with a letter or underscore, but xml is reserved.
|
|
|
|
// - Elements start with a letter or underscore, but xml is reserved.
|
|
|
|
// - Comments: <!--
|
|
|
|
// - Comments: <!--
|
|
|
|
// - Decleration: <?xml
|
|
|
|
// - Decleration: <?xml
|
|
|
@ -915,7 +915,7 @@ void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
(*tag) += (char) c ;
|
|
|
|
(*tag) += (char) c ;
|
|
|
|
|
|
|
|
|
|
|
|
if ( c == '>' )
|
|
|
|
if ( c == '>' )
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -925,7 +925,7 @@ void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag)
|
|
|
|
// Okay...if we are a "/>" tag, then we're done. We've read a complete tag.
|
|
|
|
// Okay...if we are a "/>" tag, then we're done. We've read a complete tag.
|
|
|
|
// If not, identify and stream.
|
|
|
|
// If not, identify and stream.
|
|
|
|
|
|
|
|
|
|
|
|
if ( tag->at( tag->length() - 1 ) == '>'
|
|
|
|
if ( tag->at( tag->length() - 1 ) == '>'
|
|
|
|
&& tag->at( tag->length() - 2 ) == '/' )
|
|
|
|
&& tag->at( tag->length() - 2 ) == '/' )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// All good!
|
|
|
|
// All good!
|
|
|
@ -943,7 +943,7 @@ void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag)
|
|
|
|
StreamWhiteSpace( in, tag );
|
|
|
|
StreamWhiteSpace( in, tag );
|
|
|
|
|
|
|
|
|
|
|
|
// Do we have text?
|
|
|
|
// Do we have text?
|
|
|
|
if ( in->good() && in->peek() != '<' )
|
|
|
|
if ( in->good() && in->peek() != '<' )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Yep, text.
|
|
|
|
// Yep, text.
|
|
|
|
TiXmlText text( "" );
|
|
|
|
TiXmlText text( "" );
|
|
|
@ -976,7 +976,7 @@ void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag)
|
|
|
|
document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
|
|
|
|
document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( c == '>' )
|
|
|
|
if ( c == '>' )
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
@ -1095,7 +1095,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
|
|
|
|
// Empty tag.
|
|
|
|
// Empty tag.
|
|
|
|
if ( *p != '>' )
|
|
|
|
if ( *p != '>' )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding );
|
|
|
|
if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding );
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (p+1);
|
|
|
|
return (p+1);
|
|
|
@ -1117,7 +1117,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
|
|
|
|
// We should find the end tag now
|
|
|
|
// We should find the end tag now
|
|
|
|
// note that:
|
|
|
|
// note that:
|
|
|
|
// </foo > and
|
|
|
|
// </foo > and
|
|
|
|
// </foo>
|
|
|
|
// </foo>
|
|
|
|
// are both valid end tags.
|
|
|
|
// are both valid end tags.
|
|
|
|
if ( StringEqual( p, endTag.c_str(), false, encoding ) )
|
|
|
|
if ( StringEqual( p, endTag.c_str(), false, encoding ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1211,8 +1211,8 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm
|
|
|
|
LinkEndChild( textNode );
|
|
|
|
LinkEndChild( textNode );
|
|
|
|
else
|
|
|
|
else
|
|
|
|
delete textNode;
|
|
|
|
delete textNode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// We hit a '<'
|
|
|
|
// We hit a '<'
|
|
|
|
// Have we hit a new element or an end tag? This could also be
|
|
|
|
// Have we hit a new element or an end tag? This could also be
|
|
|
@ -1228,7 +1228,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm
|
|
|
|
{
|
|
|
|
{
|
|
|
|
p = node->Parse( p, data, encoding );
|
|
|
|
p = node->Parse( p, data, encoding );
|
|
|
|
LinkEndChild( node );
|
|
|
|
LinkEndChild( node );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
@ -1242,7 +1242,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm
|
|
|
|
if ( !p )
|
|
|
|
if ( !p )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding );
|
|
|
|
if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return p;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1252,7 +1252,7 @@ void TiXmlUnknown::StreamIn( std::istream * in, TIXML_STRING * tag )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
while ( in->good() )
|
|
|
|
while ( in->good() )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int c = in->get();
|
|
|
|
int c = in->get();
|
|
|
|
if ( c <= 0 )
|
|
|
|
if ( c <= 0 )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TiXmlDocument* document = GetDocument();
|
|
|
|
TiXmlDocument* document = GetDocument();
|
|
|
@ -1265,7 +1265,7 @@ void TiXmlUnknown::StreamIn( std::istream * in, TIXML_STRING * tag )
|
|
|
|
if ( c == '>' )
|
|
|
|
if ( c == '>' )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// All is well.
|
|
|
|
// All is well.
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1298,7 +1298,7 @@ const char* TiXmlUnknown::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
|
|
|
|
|
|
|
|
|
|
|
|
if ( !p )
|
|
|
|
if ( !p )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( document )
|
|
|
|
if ( document )
|
|
|
|
document->SetError( TIXML_ERROR_PARSING_UNKNOWN, 0, 0, encoding );
|
|
|
|
document->SetError( TIXML_ERROR_PARSING_UNKNOWN, 0, 0, encoding );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( p && *p == '>' )
|
|
|
|
if ( p && *p == '>' )
|
|
|
@ -1311,7 +1311,7 @@ void TiXmlComment::StreamIn( std::istream * in, TIXML_STRING * tag )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
while ( in->good() )
|
|
|
|
while ( in->good() )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int c = in->get();
|
|
|
|
int c = in->get();
|
|
|
|
if ( c <= 0 )
|
|
|
|
if ( c <= 0 )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TiXmlDocument* document = GetDocument();
|
|
|
|
TiXmlDocument* document = GetDocument();
|
|
|
@ -1322,12 +1322,12 @@ void TiXmlComment::StreamIn( std::istream * in, TIXML_STRING * tag )
|
|
|
|
|
|
|
|
|
|
|
|
(*tag) += (char) c;
|
|
|
|
(*tag) += (char) c;
|
|
|
|
|
|
|
|
|
|
|
|
if ( c == '>'
|
|
|
|
if ( c == '>'
|
|
|
|
&& tag->at( tag->length() - 2 ) == '-'
|
|
|
|
&& tag->at( tag->length() - 2 ) == '-'
|
|
|
|
&& tag->at( tag->length() - 3 ) == '-' )
|
|
|
|
&& tag->at( tag->length() - 3 ) == '-' )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// All is well.
|
|
|
|
// All is well.
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1363,11 +1363,11 @@ const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// from the XML spec:
|
|
|
|
// from the XML spec:
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
[Definition: Comments may appear anywhere in a document outside other markup; in addition,
|
|
|
|
[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 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,
|
|
|
|
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,
|
|
|
|
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
|
|
|
|
the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity
|
|
|
|
references MUST NOT be recognized within comments.
|
|
|
|
references MUST NOT be recognized within comments.
|
|
|
|
|
|
|
|
|
|
|
|
An example of a comment:
|
|
|
|
An example of a comment:
|
|
|
@ -1382,7 +1382,7 @@ const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
|
|
|
|
value.append( p, 1 );
|
|
|
|
value.append( p, 1 );
|
|
|
|
++p;
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( p && *p )
|
|
|
|
if ( p && *p )
|
|
|
|
p += strlen( endTag );
|
|
|
|
p += strlen( endTag );
|
|
|
|
|
|
|
|
|
|
|
|
return p;
|
|
|
|
return p;
|
|
|
@ -1421,7 +1421,7 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE
|
|
|
|
if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
|
|
|
|
if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char* end;
|
|
|
|
const char* end;
|
|
|
|
const char SINGLE_QUOTE = '\'';
|
|
|
|
const char SINGLE_QUOTE = '\'';
|
|
|
|
const char DOUBLE_QUOTE = '\"';
|
|
|
|
const char DOUBLE_QUOTE = '\"';
|
|
|
@ -1450,7 +1450,7 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) {
|
|
|
|
if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) {
|
|
|
|
// [ 1451649 ] Attribute values with trailing quotes not handled correctly
|
|
|
|
// [ 1451649 ] Attribute values with trailing quotes not handled correctly
|
|
|
|
// We did not have an opening quote but seem to have a
|
|
|
|
// We did not have an opening quote but seem to have a
|
|
|
|
// closing one. Give up and throw an error.
|
|
|
|
// closing one. Give up and throw an error.
|
|
|
|
if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
|
|
|
|
if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
@ -1467,8 +1467,8 @@ void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
while ( in->good() )
|
|
|
|
while ( in->good() )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int c = in->peek();
|
|
|
|
int c = in->peek();
|
|
|
|
if ( !cdata && (c == '<' ) )
|
|
|
|
if ( !cdata && (c == '<' ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1489,7 +1489,7 @@ void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag )
|
|
|
|
// terminator of cdata.
|
|
|
|
// terminator of cdata.
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
@ -1529,7 +1529,7 @@ const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncodi
|
|
|
|
++p;
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TIXML_STRING dummy;
|
|
|
|
TIXML_STRING dummy;
|
|
|
|
p = ReadText( p, &dummy, false, endTag, false, encoding );
|
|
|
|
p = ReadText( p, &dummy, false, endTag, false, encoding );
|
|
|
|
return p;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1603,19 +1603,19 @@ const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXm
|
|
|
|
if ( StringEqual( p, "version", true, _encoding ) )
|
|
|
|
if ( StringEqual( p, "version", true, _encoding ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TiXmlAttribute attrib;
|
|
|
|
TiXmlAttribute attrib;
|
|
|
|
p = attrib.Parse( p, data, _encoding );
|
|
|
|
p = attrib.Parse( p, data, _encoding );
|
|
|
|
version = attrib.Value();
|
|
|
|
version = attrib.Value();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( StringEqual( p, "encoding", true, _encoding ) )
|
|
|
|
else if ( StringEqual( p, "encoding", true, _encoding ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TiXmlAttribute attrib;
|
|
|
|
TiXmlAttribute attrib;
|
|
|
|
p = attrib.Parse( p, data, _encoding );
|
|
|
|
p = attrib.Parse( p, data, _encoding );
|
|
|
|
encoding = attrib.Value();
|
|
|
|
encoding = attrib.Value();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( StringEqual( p, "standalone", true, _encoding ) )
|
|
|
|
else if ( StringEqual( p, "standalone", true, _encoding ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TiXmlAttribute attrib;
|
|
|
|
TiXmlAttribute attrib;
|
|
|
|
p = attrib.Parse( p, data, _encoding );
|
|
|
|
p = attrib.Parse( p, data, _encoding );
|
|
|
|
standalone = attrib.Value();
|
|
|
|
standalone = attrib.Value();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|