switching over to StrPair

This commit is contained in:
Lee Thomason 2012-01-20 12:55:24 -08:00
parent 39ede2487d
commit d34f52c43b
3 changed files with 12 additions and 10 deletions

View File

@ -88,9 +88,7 @@ const char* XMLBase::ParseText( char* p, const char* endTag, char** next )
} }
char* XMLBase::ParseName( char* in, StrPair* pair ); char* XMLBase::ParseName( char* p, StrPair* pair )
const char* XMLBase::ParseName( char* p, char** next )
{ {
char* start = p; char* start = p;
char* nextTag = 0; char* nextTag = 0;

View File

@ -48,6 +48,7 @@ struct CharBuffer
// FIXME: refactor to be the basis for all string handling. // FIXME: refactor to be the basis for all string handling.
class StrPair class StrPair
{ {
public:
enum { enum {
NEEDS_FLUSH = 0x01, NEEDS_FLUSH = 0x01,
NEEDS_ENTITY_PROCESSING = 0x02, NEEDS_ENTITY_PROCESSING = 0x02,
@ -55,7 +56,7 @@ class StrPair
}; };
StrPair() : flags( 0 ), start( 0 ), end( 0 ) {} StrPair() : flags( 0 ), start( 0 ), end( 0 ) {}
void Init( const char* start, char* end, int flags; ) { void Init( const char* start, char* end, int flags ) {
this->start = start; this->end = end; this->flags = flags | NEEDS_FLUSH; this->start = start; this->end = end; this->flags = flags | NEEDS_FLUSH;
} }
const char* GetStr(); const char* GetStr();
@ -80,6 +81,9 @@ protected:
inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) { inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
int n = 0; int n = 0;
if ( p == q ) {
return true;
}
while( *p && *q && *p == *q && n<nChar ) { while( *p && *q && *p == *q && n<nChar ) {
++p; ++q; ++n; ++p; ++q; ++n;
} }
@ -138,14 +142,14 @@ public:
virtual void Print( FILE* cfile, int depth ); virtual void Print( FILE* cfile, int depth );
const char* Value() const { return value; } const char* Value() { return value.GetStr(); }
char* ParseDeep( char* ); char* ParseDeep( char* );
protected: protected:
private: private:
const char* value; StrPair value;
}; };
@ -153,14 +157,14 @@ class XMLAttribute : public XMLBase
{ {
friend class XMLElement; friend class XMLElement;
public: public:
XMLAttribute( XMLElement* element ) : value( 0 ), next( 0 ) {} XMLAttribute( XMLElement* element ) : next( 0 ) {}
virtual ~XMLAttribute() {} virtual ~XMLAttribute() {}
virtual void Print( FILE* cfile ); virtual void Print( FILE* cfile );
private: private:
char* ParseDeep( char* p ); char* ParseDeep( char* p );
const char* value; StrPair value;
XMLAttribute* next; XMLAttribute* next;
}; };
@ -171,7 +175,7 @@ public:
XMLElement( XMLDocument* doc ); XMLElement( XMLDocument* doc );
virtual ~XMLElement(); virtual ~XMLElement();
const char* Name() const { return name; } const char* Name() { return name.GetStr(); }
virtual void Print( FILE* cfile, int depth ); virtual void Print( FILE* cfile, int depth );
virtual XMLElement* ToElement() { return this; } virtual XMLElement* ToElement() { return this; }
@ -182,7 +186,7 @@ public:
protected: protected:
private: private:
const char* name; StrPair name;
bool closing; bool closing;
XMLAttribute* rootAttribute; XMLAttribute* rootAttribute;
XMLAttribute* lastAttribute; XMLAttribute* lastAttribute;

Binary file not shown.