2011-12-29 03:42:49 +00:00
|
|
|
#include "tinyxml2.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2011-12-31 22:58:18 +00:00
|
|
|
#include <ctype.h>
|
2011-12-29 03:42:49 +00:00
|
|
|
|
|
|
|
using namespace tinyxml2;
|
|
|
|
|
|
|
|
/*static*/ CharBuffer* CharBuffer::Construct( const char* in )
|
|
|
|
{
|
|
|
|
size_t len = strlen( in );
|
|
|
|
size_t size = len + sizeof( CharBuffer );
|
|
|
|
CharBuffer* cb = (CharBuffer*) malloc( size );
|
|
|
|
cb->length = len;
|
|
|
|
strcpy( cb->mem, in );
|
|
|
|
return cb;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*static*/ void CharBuffer::Free( CharBuffer* cb )
|
|
|
|
{
|
|
|
|
free( cb );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-31 22:58:18 +00:00
|
|
|
const char* XMLNode::SkipWhiteSpace( const char* p )
|
|
|
|
{
|
|
|
|
while( isspace( *p ) ) {
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-29 03:42:49 +00:00
|
|
|
XMLDocument::XMLDocument() :
|
|
|
|
charBuffer( 0 )
|
|
|
|
{
|
|
|
|
}
|
2011-12-28 22:36:55 +00:00
|
|
|
|
|
|
|
|
2011-12-31 22:58:18 +00:00
|
|
|
bool XMLDocument::Parse( const char* p )
|
2011-12-28 22:36:55 +00:00
|
|
|
{
|
2011-12-31 22:58:18 +00:00
|
|
|
XMLNode* returnNode = 0;
|
|
|
|
|
|
|
|
p = XMLNode::SkipWhiteSpace( p );
|
|
|
|
if( !p || !*p || *p != '<' )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// What is this thing?
|
|
|
|
// - Elements start with a letter or underscore, but xml is reserved.
|
|
|
|
// - Comments: <!--
|
|
|
|
// - Decleration: <?xml
|
|
|
|
// - Everthing else is unknown to tinyxml.
|
|
|
|
//
|
|
|
|
|
|
|
|
const char* xmlHeader = { "<?xml" };
|
|
|
|
const char* commentHeader = { "<!--" };
|
|
|
|
const char* dtdHeader = { "<!" };
|
|
|
|
const char* cdataHeader = { "<![CDATA[" };
|
|
|
|
|
|
|
|
if ( XMLNode::StringEqual( p, xmlHeader, 5 ) ) {
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
TIXMLASSERT( 0 );
|
|
|
|
}
|
2011-12-28 22:36:55 +00:00
|
|
|
|
2011-12-29 03:42:49 +00:00
|
|
|
return true;
|
2011-12-28 22:36:55 +00:00
|
|
|
}
|