mirror of
https://github.com/AxioDL/tinyxml2.git
synced 2025-05-15 11:51:37 +00:00
Merge pull request #98 from martinsh-shaiters/devel
Implementation & unit test for enhancement described in issue #74
This commit is contained in:
commit
c97ded4872
13
tinyxml2.cpp
13
tinyxml2.cpp
@ -1520,8 +1520,10 @@ XMLDocument::~XMLDocument()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void XMLDocument::InitDocument()
|
void XMLDocument::Clear()
|
||||||
{
|
{
|
||||||
|
DeleteChildren();
|
||||||
|
|
||||||
_errorID = XML_NO_ERROR;
|
_errorID = XML_NO_ERROR;
|
||||||
_errorStr1 = 0;
|
_errorStr1 = 0;
|
||||||
_errorStr2 = 0;
|
_errorStr2 = 0;
|
||||||
@ -1578,8 +1580,7 @@ XMLUnknown* XMLDocument::NewUnknown( const char* str )
|
|||||||
|
|
||||||
XMLError XMLDocument::LoadFile( const char* filename )
|
XMLError XMLDocument::LoadFile( const char* filename )
|
||||||
{
|
{
|
||||||
DeleteChildren();
|
Clear();
|
||||||
InitDocument();
|
|
||||||
FILE* fp = 0;
|
FILE* fp = 0;
|
||||||
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
|
||||||
@ -1600,8 +1601,7 @@ XMLError XMLDocument::LoadFile( const char* filename )
|
|||||||
|
|
||||||
XMLError XMLDocument::LoadFile( FILE* fp )
|
XMLError XMLDocument::LoadFile( FILE* fp )
|
||||||
{
|
{
|
||||||
DeleteChildren();
|
Clear();
|
||||||
InitDocument();
|
|
||||||
|
|
||||||
fseek( fp, 0, SEEK_END );
|
fseek( fp, 0, SEEK_END );
|
||||||
size_t size = ftell( fp );
|
size_t size = ftell( fp );
|
||||||
@ -1662,8 +1662,7 @@ XMLError XMLDocument::SaveFile( FILE* fp, bool compact )
|
|||||||
|
|
||||||
XMLError XMLDocument::Parse( const char* p, size_t len )
|
XMLError XMLDocument::Parse( const char* p, size_t len )
|
||||||
{
|
{
|
||||||
DeleteChildren();
|
Clear();
|
||||||
InitDocument();
|
|
||||||
|
|
||||||
if ( !p || !*p ) {
|
if ( !p || !*p ) {
|
||||||
SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
|
SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
|
||||||
|
@ -1533,6 +1533,9 @@ public:
|
|||||||
/// If there is an error, print it to stdout.
|
/// If there is an error, print it to stdout.
|
||||||
void PrintError() const;
|
void PrintError() const;
|
||||||
|
|
||||||
|
/// Clear the document, resetting it to the initial state.
|
||||||
|
void Clear();
|
||||||
|
|
||||||
// internal
|
// internal
|
||||||
char* Identify( char* p, XMLNode** node );
|
char* Identify( char* p, XMLNode** node );
|
||||||
|
|
||||||
@ -1546,7 +1549,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
XMLDocument( const XMLDocument& ); // not supported
|
XMLDocument( const XMLDocument& ); // not supported
|
||||||
void operator=( const XMLDocument& ); // not supported
|
void operator=( const XMLDocument& ); // not supported
|
||||||
void InitDocument();
|
|
||||||
|
|
||||||
bool _writeBOM;
|
bool _writeBOM;
|
||||||
bool _processEntities;
|
bool _processEntities;
|
||||||
|
@ -1072,6 +1072,13 @@ int main( int argc, const char ** argv )
|
|||||||
XMLTest( "Set length of incoming data", doc.Error(), false );
|
XMLTest( "Set length of incoming data", doc.Error(), false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
XMLDocument doc;
|
||||||
|
doc.LoadFile( "resources/dream.xml" );
|
||||||
|
doc.Clear();
|
||||||
|
XMLTest( "Document Clear()'s", doc.NoChildren(), true );
|
||||||
|
}
|
||||||
|
|
||||||
// ----------- Whitespace ------------
|
// ----------- Whitespace ------------
|
||||||
{
|
{
|
||||||
const char* xml = "<element>"
|
const char* xml = "<element>"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user