diff --git a/tinyxml2.cpp b/tinyxml2.cpp index ee0f88c..3614b46 100644 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -275,7 +275,7 @@ bool XMLDocument::Accept( XMLVisitor* visitor ) const XMLNode::XMLNode( XMLDocument* doc ) : document( doc ), parent( 0 ), - isTextParent( false ), +// isTextParent( false ), firstChild( 0 ), lastChild( 0 ), prev( 0 ), next( 0 ) { @@ -342,9 +342,9 @@ XMLNode* XMLNode::InsertEndChild( XMLNode* addThis ) addThis->prev = 0; addThis->next = 0; } - if ( addThis->ToText() ) { - SetTextParent(); - } +// if ( addThis->ToText() ) { +// SetTextParent(); +// } return addThis; } diff --git a/tinyxml2.h b/tinyxml2.h index 27f38c9..066e38d 100644 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -3,16 +3,19 @@ /* TODO - - const and non-const versions of API + X const and non-const versions of API X memory pool the class construction - - attribute accessors - - node navigation + X attribute accessors + X node navigation - handles - - visit pattern - change streamer? - - make constructors protected - - hide copy constructor - - hide = operator + X visit pattern - change streamer? + X make constructors protected + X hide copy constructor + X hide = operator X UTF8 support: isAlpha, etc. + - tests from xml1 + - perf test: xml1 + - perf test: xenowar */ #include @@ -156,6 +159,7 @@ private: int size; // number objects in use }; + class MemPool { public: @@ -167,6 +171,7 @@ public: virtual void Free( void* ) = 0; }; + template< int SIZE > class MemPoolT : public MemPool { @@ -371,18 +376,17 @@ public: //virtual void Print( XMLStreamer* streamer ); virtual char* ParseDeep( char* ); - void SetTextParent() { isTextParent = true; } - bool IsTextParent() const { return isTextParent; } virtual bool IsClosingElement() const { return false; } protected: XMLNode( XMLDocument* ); virtual ~XMLNode(); + XMLNode( const XMLNode& ); // not supported + void operator=( const XMLNode& ); // not supported XMLDocument* document; XMLNode* parent; - bool isTextParent; - mutable StrPair value; + mutable StrPair value; XMLNode* firstChild; XMLNode* lastChild; @@ -402,6 +406,7 @@ class XMLText : public XMLNode friend class XMLDocument; public: virtual bool Accept( XMLVisitor* visitor ) const; + virtual XMLText* ToText() { return this; } virtual const XMLText* ToText() const { return this; } @@ -413,6 +418,8 @@ public: protected: XMLText( XMLDocument* doc ) : XMLNode( doc ), isCData( false ) {} virtual ~XMLText() {} + XMLText( const XMLText& ); // not supported + void operator=( const XMLText& ); // not supported private: bool isCData; @@ -433,6 +440,8 @@ public: protected: XMLComment( XMLDocument* doc ); virtual ~XMLComment(); + XMLComment( const XMLComment& ); // not supported + void operator=( const XMLComment& ); // not supported private: }; @@ -452,6 +461,8 @@ public: protected: XMLDeclaration( XMLDocument* doc ); virtual ~XMLDeclaration(); + XMLDeclaration( const XMLDeclaration& ); // not supported + void operator=( const XMLDeclaration& ); // not supported }; @@ -469,6 +480,8 @@ public: protected: XMLUnknown( XMLDocument* doc ); virtual ~XMLUnknown(); + XMLUnknown( const XMLUnknown& ); // not supported + void operator=( const XMLUnknown& ); // not supported }; @@ -476,15 +489,28 @@ class XMLAttribute { friend class XMLElement; public: - //virtual void Print( XMLStreamer* streamer ); - const char* Name() const { return name.GetStr(); } const char* Value() const { return value.GetStr(); } const XMLAttribute* Next() const { return next; } + int QueryIntAttribute( const char* name, int* value ) const; + int QueryUnsignedAttribute( const char* name, unsigned int* value ) const; + int QueryBoolAttribute( const char* name, bool* value ) const; + int QueryDoubleAttribute( const char* name, double* _value ) const; + int QueryFloatAttribute( const char* name, float* _value ) const; + + void SetAttribute( const char* name, const char* value ); + void SetAttribute( const char* name, int value ); + void SetAttribute( const char* name, unsigned value ); + void SetAttribute( const char* name, bool value ); + void SetAttribute( const char* name, double value ); + private: XMLAttribute( XMLElement* element ) : next( 0 ) {} virtual ~XMLAttribute() {} + XMLAttribute( const XMLAttribute& ); // not supported + void operator=( const XMLAttribute& ); // not supported + char* ParseDeep( char* p ); mutable StrPair name; @@ -530,11 +556,12 @@ public: virtual bool IsClosingElement() const { return closing; } char* ParseDeep( char* p ); -protected: +private: XMLElement( XMLDocument* doc ); virtual ~XMLElement(); + XMLElement( const XMLElement& ); // not supported + void operator=( const XMLElement& ); // not supported -private: char* ParseAttributes( char* p, bool *closedElement ); bool closing; @@ -579,8 +606,8 @@ public: char* Identify( char* p, XMLNode** node ); private: - - XMLDocument( const XMLDocument& ); // intentionally not implemented + XMLDocument( const XMLDocument& ); // not supported + void operator=( const XMLDocument& ); // not supported void InitDocument(); int errorID; diff --git a/xmltest.cpp b/xmltest.cpp index 7be7c2e..b624d9b 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -7,14 +7,7 @@ using namespace tinyxml2; int main( int argc, const char* argv ) { -#if 0 - { - static const char* test = ""; - - XMLDocument doc; - doc.Parse( test ); - doc.Print( stdout ); - } +#if 1 { static const char* test = "