diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 5e1b1d8..4a3152a 100644 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -88,6 +88,8 @@ const char* XMLBase::ParseText( char* p, const char* endTag, char** next ) } +char* XMLBase::ParseName( char* in, StrPair* pair ); + const char* XMLBase::ParseName( char* p, char** next ) { char* start = p; @@ -115,10 +117,10 @@ const char* XMLBase::ParseName( char* p, char** next ) *p = 0; if ( p > start ) { - *next = p; + *next = p+1; return start; } - return p+1; + return 0; } diff --git a/tinyxml2.h b/tinyxml2.h index b087349..f081758 100644 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -45,6 +45,28 @@ struct CharBuffer static void Free( CharBuffer* ); }; +// FIXME: refactor to be the basis for all string handling. +class StrPair +{ + enum { + NEEDS_FLUSH = 0x01, + NEEDS_ENTITY_PROCESSING = 0x02, + NEEDS_NEWLINE_NORMALIZATION = 0x04 + }; + + StrPair() : flags( 0 ), start( 0 ), end( 0 ) {} + void Init( const char* start, char* end, int flags; ) { + this->start = start; this->end = end; this->flags = flags | NEEDS_FLUSH; + } + const char* GetStr(); + +private: + // After parsing, if *end != 0, it can be set to zero. + int flags; + const char* start; + char* end; +}; + class XMLBase { @@ -71,7 +93,7 @@ protected: inline static int IsAlpha( unsigned char anyByte ) { return ( anyByte <= 127 ) ? isalpha( anyByte ) : 1; } const char* ParseText( char* in, const char* endTag, char** next ); - const char* ParseName( char* in, char** next ); + char* ParseName( char* in, StrPair* pair ); char* Identify( XMLDocument* document, char* p, XMLNode** node ); }; diff --git a/tinyxml2.suo b/tinyxml2.suo index c801a47..5924ebf 100644 Binary files a/tinyxml2.suo and b/tinyxml2.suo differ diff --git a/xmltest.cpp b/xmltest.cpp index 2bc5de6..3152ebd 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -28,7 +28,7 @@ int main( int argc, const char* argv ) } #endif { - static const char* test[] = { "", + static const char* test[] = { //"", "", 0 };