From: Egor C. <eg...@us...> - 2003-02-03 18:59:41
|
Update of /cvsroot/eas-dev/eas-dev/libs/libsxmlstream/include In directory sc8-pr-cvs1:/tmp/cvs-serv11498/libs/libsxmlstream/include Modified Files: sxml.hxx sxmlstream.hxx Log Message: Bugfixes, bugfixes.. descendants in SXmlNode now is not a pointer. Binary stream test still fails, but IMHO the problem is in the test itself. 2Yurii: please have a look at libs/libsxmlstream/tests/BinaryStreamTest.h Index: sxml.hxx =================================================================== RCS file: /cvsroot/eas-dev/eas-dev/libs/libsxmlstream/include/sxml.hxx,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- sxml.hxx 3 Feb 2003 06:30:46 -0000 1.5 +++ sxml.hxx 3 Feb 2003 18:59:37 -0000 1.6 @@ -39,16 +39,11 @@ struct SXmlNode { SXmlNode_t type; string data; - list<SXmlNode> *descendants; + list<SXmlNode> descendants; - SXmlNode() {descendants = new list<SXmlNode>; type = SXmlNode_Element_t;} - SXmlNode(const SXmlNode& v); - SXmlNode& operator=(const SXmlNode& v); - ~SXmlNode() { delete descendants; } - - SXmlNode(const SXmlNode_t aType, const string aData) {descendants = new list<SXmlNode>; - data = aData; + SXmlNode(const SXmlNode_t aType, const string aData) {data = aData; type = aType;} + SXmlNode() { type = SXmlNode_Element_t; } bool isElement() const { return type == SXmlNode_Element_t; } bool isAttribute() const { return type == SXmlNode_Attribute_t; } @@ -56,13 +51,12 @@ bool isNamespace() const { return type == SXmlNode_Namespace_t; } // FIXME: is this correct? copied from previous realization - bool hasProperty() const { return descendants->size() == 1 && - type == descendants->front().type; } + bool hasProperty() const { return descendants.size() == 1 && + type == descendants.front().type; } - // We do not copy the child element for better performance - void addChild(const SXmlNode& e) { descendants->push_back(e); } + void addChild(const SXmlNode& e) { descendants.push_back(e); } string getProperty() const { return hasProperty() ? - descendants->front().data : 0; } + descendants.front().data : 0; } // FIXME: Should I create subclasses for Element, Attributr, etc? Index: sxmlstream.hxx =================================================================== RCS file: /cvsroot/eas-dev/eas-dev/libs/libsxmlstream/include/sxmlstream.hxx,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- sxmlstream.hxx 3 Feb 2003 06:30:47 -0000 1.8 +++ sxmlstream.hxx 3 Feb 2003 18:59:38 -0000 1.9 @@ -23,7 +23,7 @@ #include <queue> #include <sxml.hxx> -#include <sxmlhandler.hxx> +//#include <sxmlhandler.hxx> using namespace std; @@ -33,30 +33,19 @@ { protected: - queue<SXmlNode> * m_queue; + queue<SXmlNode> m_queue; public: - SXmlStream(); - ~SXmlStream(); - bool queueIsEmpty(); - // Do not copy an element, instead return by reference. - // Copying it might be expensive if we have a lot of - // descendants. - // FIXME: Is it ok? - SXmlNode& pop(); - - // FIXME: Pass by reference, is it ok? - void push(const SXmlNode& e) {m_queue->push(e);} + SXmlNode pop(); + void push(const SXmlNode& e) {m_queue.push(e);} }; class SXmlBinaryStream: public SXmlStream { public: - SXmlBinaryStream(); - ~SXmlBinaryStream(); friend ostream& operator<<(ostream&, SXmlBinaryStream&); @@ -68,8 +57,6 @@ class SXmlTextStream: public SXmlStream { public: - SXmlTextStream(); - ~SXmlTextStream(); friend ostream& operator<<(ostream&, SXmlTextStream&); |