mirror of
https://github.com/AxioDL/tinyxml2.git
synced 2025-06-07 07:03:41 +00:00
Merge branch 'master' of https://github.com/leethomason/tinyxml2
This commit is contained in:
commit
2489afcc61
28
tinyxml2.cpp
28
tinyxml2.cpp
@ -1728,9 +1728,8 @@ XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !attrib ) {
|
if ( !attrib ) {
|
||||||
TIXMLASSERT( sizeof( XMLAttribute ) == _document->_attributePool.ItemSize() );
|
attrib = CreateAttribute();
|
||||||
attrib = new (_document->_attributePool.Alloc() ) XMLAttribute();
|
TIXMLASSERT( attrib );
|
||||||
attrib->_memPool = &_document->_attributePool;
|
|
||||||
if ( last ) {
|
if ( last ) {
|
||||||
last->_next = attrib;
|
last->_next = attrib;
|
||||||
}
|
}
|
||||||
@ -1738,7 +1737,6 @@ XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name )
|
|||||||
_rootAttribute = attrib;
|
_rootAttribute = attrib;
|
||||||
}
|
}
|
||||||
attrib->SetName( name );
|
attrib->SetName( name );
|
||||||
attrib->_memPool->SetTracked(); // always created and linked.
|
|
||||||
}
|
}
|
||||||
return attrib;
|
return attrib;
|
||||||
}
|
}
|
||||||
@ -1778,11 +1776,9 @@ char* XMLElement::ParseAttributes( char* p, int& curLineNum )
|
|||||||
|
|
||||||
// attribute.
|
// attribute.
|
||||||
if (XMLUtil::IsNameStartChar( *p ) ) {
|
if (XMLUtil::IsNameStartChar( *p ) ) {
|
||||||
TIXMLASSERT( sizeof( XMLAttribute ) == _document->_attributePool.ItemSize() );
|
XMLAttribute* attrib = CreateAttribute();
|
||||||
XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute();
|
TIXMLASSERT( attrib );
|
||||||
attrib->_parseLineNum = _document->_parseCurLineNum;
|
attrib->_parseLineNum = _document->_parseCurLineNum;
|
||||||
attrib->_memPool = &_document->_attributePool;
|
|
||||||
attrib->_memPool->SetTracked();
|
|
||||||
|
|
||||||
int attrLineNum = attrib->_parseLineNum;
|
int attrLineNum = attrib->_parseLineNum;
|
||||||
|
|
||||||
@ -1833,6 +1829,15 @@ void XMLElement::DeleteAttribute( XMLAttribute* attribute )
|
|||||||
pool->Free( attribute );
|
pool->Free( attribute );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XMLAttribute* XMLElement::CreateAttribute()
|
||||||
|
{
|
||||||
|
TIXMLASSERT( sizeof( XMLAttribute ) == _document->_attributePool.ItemSize() );
|
||||||
|
XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute();
|
||||||
|
attrib->_memPool = &_document->_attributePool;
|
||||||
|
attrib->_memPool->SetTracked();
|
||||||
|
return attrib;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// <ele></ele>
|
// <ele></ele>
|
||||||
// <ele>foo<b>bar</b></ele>
|
// <ele>foo<b>bar</b></ele>
|
||||||
@ -1972,10 +1977,7 @@ void XMLDocument::Clear()
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
const bool hadError = Error();
|
const bool hadError = Error();
|
||||||
#endif
|
#endif
|
||||||
_errorID = XML_SUCCESS;
|
ClearError();
|
||||||
_errorStr1.Reset();
|
|
||||||
_errorStr2.Reset();
|
|
||||||
_errorLineNum = 0;
|
|
||||||
|
|
||||||
delete [] _charBuffer;
|
delete [] _charBuffer;
|
||||||
_charBuffer = 0;
|
_charBuffer = 0;
|
||||||
@ -2180,7 +2182,7 @@ XMLError XMLDocument::SaveFile( FILE* fp, bool compact )
|
|||||||
{
|
{
|
||||||
// Clear any error from the last save, otherwise it will get reported
|
// Clear any error from the last save, otherwise it will get reported
|
||||||
// for *this* call.
|
// for *this* call.
|
||||||
SetError(XML_SUCCESS, 0, 0, 0);
|
ClearError();
|
||||||
XMLPrinter stream( fp, compact );
|
XMLPrinter stream( fp, compact );
|
||||||
Print( &stream );
|
Print( &stream );
|
||||||
return _errorID;
|
return _errorID;
|
||||||
|
@ -1574,6 +1574,7 @@ private:
|
|||||||
//void LinkAttribute( XMLAttribute* attrib );
|
//void LinkAttribute( XMLAttribute* attrib );
|
||||||
char* ParseAttributes( char* p, int& curLineNum );
|
char* ParseAttributes( char* p, int& curLineNum );
|
||||||
static void DeleteAttribute( XMLAttribute* attribute );
|
static void DeleteAttribute( XMLAttribute* attribute );
|
||||||
|
XMLAttribute* CreateAttribute();
|
||||||
|
|
||||||
enum { BUF_SIZE = 200 };
|
enum { BUF_SIZE = 200 };
|
||||||
int _closingType;
|
int _closingType;
|
||||||
@ -1751,6 +1752,10 @@ public:
|
|||||||
|
|
||||||
void SetError( XMLError error, const char* str1, const char* str2, int lineNum );
|
void SetError( XMLError error, const char* str1, const char* str2, int lineNum );
|
||||||
|
|
||||||
|
void ClearError() {
|
||||||
|
SetError(XML_SUCCESS, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/// Return true if there was an error parsing the document.
|
/// Return true if there was an error parsing the document.
|
||||||
bool Error() const {
|
bool Error() const {
|
||||||
return _errorID != XML_SUCCESS;
|
return _errorID != XML_SUCCESS;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user