J :
* Update for linux support.
This commit is contained in:
@@ -2,23 +2,23 @@
|
||||
www.sourceforge.net/projects/tinyxml
|
||||
Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
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
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
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.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -38,8 +38,8 @@ distribution.
|
||||
|
||||
// Note tha "PutString" hardcodes the same list. This
|
||||
// is less flexible than it appears. Changing the entries
|
||||
// or order will break putstring.
|
||||
TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] =
|
||||
// or order will break putstring.
|
||||
TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] =
|
||||
{
|
||||
{ "&", 5, '&' },
|
||||
{ "<", 4, '<' },
|
||||
@@ -53,16 +53,16 @@ TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] =
|
||||
// Including the basic of this table, which determines the #bytes in the
|
||||
// sequence from the lead byte. 1 placed for invalid sequences --
|
||||
// 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 bf be
|
||||
// ef bf bf
|
||||
// ef bf bf
|
||||
|
||||
const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
|
||||
const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
|
||||
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
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00
|
||||
@@ -74,9 +74,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, // 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, // 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, // 0xb0
|
||||
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, // 0xb0
|
||||
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
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte
|
||||
@@ -90,7 +90,7 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng
|
||||
const unsigned long BYTE_MARK = 0x80;
|
||||
const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
|
||||
|
||||
if (input < 0x80)
|
||||
if (input < 0x80)
|
||||
*length = 1;
|
||||
else if ( input < 0x800 )
|
||||
*length = 2;
|
||||
@@ -104,22 +104,22 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng
|
||||
output += *length;
|
||||
|
||||
// Scary scary fall throughs.
|
||||
switch (*length)
|
||||
switch (*length)
|
||||
{
|
||||
case 4:
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
input >>= 6;
|
||||
case 3:
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
input >>= 6;
|
||||
case 2:
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
input >>= 6;
|
||||
case 1:
|
||||
--output;
|
||||
--output;
|
||||
*output = (char)(input | FIRST_BYTE_MARK[*length]);
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,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
|
||||
// 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.
|
||||
|
||||
// if ( encoding == TIXML_ENCODING_UTF8 )
|
||||
@@ -150,7 +150,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
|
||||
// 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.
|
||||
|
||||
// if ( encoding == TIXML_ENCODING_UTF8 )
|
||||
@@ -223,7 +223,7 @@ void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding )
|
||||
case '\r':
|
||||
// bump down to the next line
|
||||
++row;
|
||||
col = 0;
|
||||
col = 0;
|
||||
// Eat the character
|
||||
++p;
|
||||
|
||||
@@ -265,11 +265,11 @@ void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding )
|
||||
// In these cases, don't advance the column. These are
|
||||
// 0-width spaces.
|
||||
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 )
|
||||
p += 3;
|
||||
p += 3;
|
||||
else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU )
|
||||
p += 3;
|
||||
p += 3;
|
||||
else
|
||||
{ p +=3; ++col; } // A normal character.
|
||||
}
|
||||
@@ -321,10 +321,10 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
|
||||
while ( *p )
|
||||
{
|
||||
const unsigned char* pU = (const unsigned char*)p;
|
||||
|
||||
|
||||
// Skip the stupid Microsoft UTF-8 Byte order marks
|
||||
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 )
|
||||
{
|
||||
p += 3;
|
||||
@@ -353,7 +353,7 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
|
||||
}
|
||||
else
|
||||
{
|
||||
while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' )
|
||||
while ( ( *p && IsWhiteSpace( *p ) ) || *p == '\n' || *p =='\r' )
|
||||
++p;
|
||||
}
|
||||
|
||||
@@ -406,11 +406,11 @@ const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncodi
|
||||
// After that, they can be letters, underscores, numbers,
|
||||
// hyphens, or colons. (Colons are valid ony for namespaces,
|
||||
// but tinyxml can't tell namespaces from names.)
|
||||
if ( p && *p
|
||||
if ( p && *p
|
||||
&& ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) )
|
||||
{
|
||||
while( p && *p
|
||||
&& ( IsAlphaNum( (unsigned char ) *p, encoding )
|
||||
&& ( IsAlphaNum( (unsigned char ) *p, encoding )
|
||||
|| *p == '_'
|
||||
|| *p == '-'
|
||||
|| *p == '.'
|
||||
@@ -458,7 +458,7 @@ const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXml
|
||||
ucs += mult * (*q - 'a' + 10);
|
||||
else if ( *q >= 'A' && *q <= 'F' )
|
||||
ucs += mult * (*q - 'A' + 10 );
|
||||
else
|
||||
else
|
||||
return 0;
|
||||
mult *= 16;
|
||||
--q;
|
||||
@@ -481,7 +481,7 @@ const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXml
|
||||
{
|
||||
if ( *q >= '0' && *q <= '9' )
|
||||
ucs += mult * (*q - '0');
|
||||
else
|
||||
else
|
||||
return 0;
|
||||
mult *= 10;
|
||||
--q;
|
||||
@@ -558,10 +558,10 @@ bool TiXmlBase::StringEqual( const char* p,
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* TiXmlBase::ReadText( const char* p,
|
||||
TIXML_STRING * text,
|
||||
bool trimWhiteSpace,
|
||||
const char* endTag,
|
||||
const char* TiXmlBase::ReadText( const char* p,
|
||||
TIXML_STRING * text,
|
||||
bool trimWhiteSpace,
|
||||
const char* endTag,
|
||||
bool caseInsensitive,
|
||||
TiXmlEncoding encoding )
|
||||
{
|
||||
@@ -632,7 +632,7 @@ void TiXmlDocument::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
|
||||
// This "pre-streaming" will never read the closing ">" so the
|
||||
// sub-tag can orient itself.
|
||||
|
||||
if ( !StreamTo( in, '<', tag ) )
|
||||
if ( !StreamTo( in, '<', tag ) )
|
||||
{
|
||||
SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
|
||||
return;
|
||||
@@ -654,7 +654,7 @@ void TiXmlDocument::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
|
||||
|
||||
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
|
||||
// continue streaming.
|
||||
TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING );
|
||||
@@ -763,7 +763,7 @@ const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiX
|
||||
encoding = TIXML_ENCODING_UTF8;
|
||||
else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) )
|
||||
encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice
|
||||
else
|
||||
else
|
||||
encoding = TIXML_ENCODING_LEGACY;
|
||||
}
|
||||
|
||||
@@ -781,7 +781,7 @@ const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiX
|
||||
}
|
||||
|
||||
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!
|
||||
if ( error )
|
||||
return;
|
||||
@@ -818,7 +818,7 @@ TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
|
||||
return 0;
|
||||
}
|
||||
|
||||
// What is this thing?
|
||||
// What is this thing?
|
||||
// - Elements start with a letter or underscore, but xml is reserved.
|
||||
// - Comments: <!--
|
||||
// - Decleration: <?xml
|
||||
@@ -906,7 +906,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
|
||||
return;
|
||||
}
|
||||
(*tag) += (char) c ;
|
||||
|
||||
|
||||
if ( c == '>' )
|
||||
break;
|
||||
}
|
||||
@@ -916,7 +916,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
|
||||
// Okay...if we are a "/>" tag, then we're done. We've read a complete tag.
|
||||
// If not, identify and stream.
|
||||
|
||||
if ( tag->at( tag->length() - 1 ) == '>'
|
||||
if ( tag->at( tag->length() - 1 ) == '>'
|
||||
&& tag->at( tag->length() - 2 ) == '/' )
|
||||
{
|
||||
// All good!
|
||||
@@ -933,7 +933,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
|
||||
StreamWhiteSpace( in, tag );
|
||||
|
||||
// Do we have text?
|
||||
if ( in->good() && in->peek() != '<' )
|
||||
if ( in->good() && in->peek() != '<' )
|
||||
{
|
||||
// Yep, text.
|
||||
TiXmlText text( "" );
|
||||
@@ -966,7 +966,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
|
||||
document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( c == '>' )
|
||||
break;
|
||||
|
||||
@@ -1075,7 +1075,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
|
||||
// Empty tag.
|
||||
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 (p+1);
|
||||
@@ -1175,8 +1175,8 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm
|
||||
LinkEndChild( textNode );
|
||||
else
|
||||
delete textNode;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
// We hit a '<'
|
||||
// Have we hit a new element or an end tag? This could also be
|
||||
@@ -1192,7 +1192,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm
|
||||
{
|
||||
p = node->Parse( p, data, encoding );
|
||||
LinkEndChild( node );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
@@ -1206,7 +1206,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm
|
||||
if ( !p )
|
||||
{
|
||||
if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding );
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -1216,7 +1216,7 @@ void TiXmlUnknown::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
|
||||
{
|
||||
while ( in->good() )
|
||||
{
|
||||
int c = in->get();
|
||||
int c = in->get();
|
||||
if ( c <= 0 )
|
||||
{
|
||||
TiXmlDocument* document = GetDocument();
|
||||
@@ -1229,7 +1229,7 @@ void TiXmlUnknown::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
|
||||
if ( c == '>' )
|
||||
{
|
||||
// All is well.
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1274,7 +1274,7 @@ void TiXmlComment::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
|
||||
{
|
||||
while ( in->good() )
|
||||
{
|
||||
int c = in->get();
|
||||
int c = in->get();
|
||||
if ( c <= 0 )
|
||||
{
|
||||
TiXmlDocument* document = GetDocument();
|
||||
@@ -1285,12 +1285,12 @@ void TiXmlComment::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
|
||||
|
||||
(*tag) += (char) c;
|
||||
|
||||
if ( c == '>'
|
||||
if ( c == '>'
|
||||
&& tag->at( tag->length() - 2 ) == '-'
|
||||
&& tag->at( tag->length() - 3 ) == '-' )
|
||||
{
|
||||
// All is well.
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1359,7 +1359,7 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE
|
||||
if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
const char* end;
|
||||
|
||||
if ( *p == '\'' )
|
||||
@@ -1396,7 +1396,7 @@ void TiXmlText::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
|
||||
{
|
||||
if ( cdata )
|
||||
{
|
||||
int c = in->get();
|
||||
int c = in->get();
|
||||
if ( c <= 0 )
|
||||
{
|
||||
TiXmlDocument* document = GetDocument();
|
||||
@@ -1407,19 +1407,19 @@ void TiXmlText::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
|
||||
|
||||
(*tag) += (char) c;
|
||||
|
||||
if ( c == '>'
|
||||
if ( c == '>'
|
||||
&& tag->at( tag->length() - 2 ) == ']'
|
||||
&& tag->at( tag->length() - 3 ) == ']' )
|
||||
{
|
||||
// All is well.
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while ( in->good() )
|
||||
{
|
||||
int c = in->peek();
|
||||
int c = in->peek();
|
||||
if ( c == '<' )
|
||||
return;
|
||||
if ( c <= 0 )
|
||||
@@ -1471,7 +1471,7 @@ const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncodi
|
||||
++p;
|
||||
}
|
||||
|
||||
TIXML_STRING dummy;
|
||||
TIXML_STRING dummy;
|
||||
p = ReadText( p, &dummy, false, endTag, false, encoding );
|
||||
return p;
|
||||
}
|
||||
@@ -1545,19 +1545,19 @@ const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXm
|
||||
if ( StringEqual( p, "version", true, _encoding ) )
|
||||
{
|
||||
TiXmlAttribute attrib;
|
||||
p = attrib.Parse( p, data, _encoding );
|
||||
p = attrib.Parse( p, data, _encoding );
|
||||
version = attrib.Value();
|
||||
}
|
||||
else if ( StringEqual( p, "encoding", true, _encoding ) )
|
||||
{
|
||||
TiXmlAttribute attrib;
|
||||
p = attrib.Parse( p, data, _encoding );
|
||||
p = attrib.Parse( p, data, _encoding );
|
||||
encoding = attrib.Value();
|
||||
}
|
||||
else if ( StringEqual( p, "standalone", true, _encoding ) )
|
||||
{
|
||||
TiXmlAttribute attrib;
|
||||
p = attrib.Parse( p, data, _encoding );
|
||||
p = attrib.Parse( p, data, _encoding );
|
||||
standalone = attrib.Value();
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user