mirror of
https://github.com/AxioDL/tinyxml2.git
synced 2025-06-05 14:13:43 +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 ) {
|
||||
TIXMLASSERT( sizeof( XMLAttribute ) == _document->_attributePool.ItemSize() );
|
||||
attrib = new (_document->_attributePool.Alloc() ) XMLAttribute();
|
||||
attrib->_memPool = &_document->_attributePool;
|
||||
attrib = CreateAttribute();
|
||||
TIXMLASSERT( attrib );
|
||||
if ( last ) {
|
||||
last->_next = attrib;
|
||||
}
|
||||
@ -1738,7 +1737,6 @@ XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name )
|
||||
_rootAttribute = attrib;
|
||||
}
|
||||
attrib->SetName( name );
|
||||
attrib->_memPool->SetTracked(); // always created and linked.
|
||||
}
|
||||
return attrib;
|
||||
}
|
||||
@ -1778,11 +1776,9 @@ char* XMLElement::ParseAttributes( char* p, int& curLineNum )
|
||||
|
||||
// attribute.
|
||||
if (XMLUtil::IsNameStartChar( *p ) ) {
|
||||
TIXMLASSERT( sizeof( XMLAttribute ) == _document->_attributePool.ItemSize() );
|
||||
XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute();
|
||||
XMLAttribute* attrib = CreateAttribute();
|
||||
TIXMLASSERT( attrib );
|
||||
attrib->_parseLineNum = _document->_parseCurLineNum;
|
||||
attrib->_memPool = &_document->_attributePool;
|
||||
attrib->_memPool->SetTracked();
|
||||
|
||||
int attrLineNum = attrib->_parseLineNum;
|
||||
|
||||
@ -1833,6 +1829,15 @@ void XMLElement::DeleteAttribute( XMLAttribute* 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>foo<b>bar</b></ele>
|
||||
@ -1972,10 +1977,7 @@ void XMLDocument::Clear()
|
||||
#ifdef DEBUG
|
||||
const bool hadError = Error();
|
||||
#endif
|
||||
_errorID = XML_SUCCESS;
|
||||
_errorStr1.Reset();
|
||||
_errorStr2.Reset();
|
||||
_errorLineNum = 0;
|
||||
ClearError();
|
||||
|
||||
delete [] _charBuffer;
|
||||
_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
|
||||
// for *this* call.
|
||||
SetError(XML_SUCCESS, 0, 0, 0);
|
||||
ClearError();
|
||||
XMLPrinter stream( fp, compact );
|
||||
Print( &stream );
|
||||
return _errorID;
|
||||
|
@ -1574,6 +1574,7 @@ private:
|
||||
//void LinkAttribute( XMLAttribute* attrib );
|
||||
char* ParseAttributes( char* p, int& curLineNum );
|
||||
static void DeleteAttribute( XMLAttribute* attribute );
|
||||
XMLAttribute* CreateAttribute();
|
||||
|
||||
enum { BUF_SIZE = 200 };
|
||||
int _closingType;
|
||||
@ -1751,6 +1752,10 @@ public:
|
||||
|
||||
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.
|
||||
bool Error() const {
|
||||
return _errorID != XML_SUCCESS;
|
||||
|
Loading…
x
Reference in New Issue
Block a user