#include <xmltooling/io/AbstractXMLObjectMarshaller.h>\r
#include <xmltooling/io/AbstractXMLObjectUnmarshaller.h>\r
#include <xmltooling/util/ParserPool.h>\r
+#include <xmltooling/util/XMLObjectChildrenList.h>\r
#include <xmltooling/util/XMLHelper.h>\r
\r
using namespace xmltooling;\r
virtual ~SimpleXMLObject() {\r
XMLString::release(&m_id);\r
XMLString::release(&m_value);\r
- for_each(m_children.begin(), m_children.end(), cleanup<SimpleXMLObject>());\r
}\r
\r
const XMLCh* getId() const { return m_id; }\r
void setValue(const XMLCh* value) { m_value=prepareForAssignment(m_value,value); }\r
\r
// TODO: Leave non-const, but wrap STL container to intercept adds. \r
- list<SimpleXMLObject*>& getSimpleXMLObjects() { return m_children; }\r
- \r
- bool hasChildren() const { return !m_children.empty(); }\r
- size_t getOrderedChildren(vector<XMLObject*>& children) const {\r
- children.assign(m_children.begin(),m_children.end());\r
- return children.size();\r
+ ListOf(SimpleXMLObject) getSimpleXMLObjects() {\r
+ return ListOf(SimpleXMLObject)(this, m_simples, m_children, m_children.end());\r
}\r
+ \r
SimpleXMLObject* clone() const {\r
- SimpleXMLObject* ret=new SimpleXMLObject();\r
+ auto_ptr<XMLObject> domClone(AbstractDOMCachingXMLObject::clone());\r
+ SimpleXMLObject* ret=dynamic_cast<SimpleXMLObject*>(domClone.get());\r
+ if (ret) {\r
+ domClone.release();\r
+ return ret;\r
+ }\r
+\r
+ ret=new SimpleXMLObject();\r
ret->setId(m_id);\r
ret->setValue(m_value);\r
xmltooling::clone(m_children, ret->m_children);\r
private:\r
XMLCh* m_id;\r
XMLCh* m_value;\r
- list<SimpleXMLObject*> m_children;\r
+ vector<SimpleXMLObject*> m_simples;\r
\r
friend class SimpleXMLObjectUnmarshaller;\r
};\r
SimpleXMLObject* child = dynamic_cast<SimpleXMLObject*>(childXMLObject);\r
if (child) {\r
simpleXMLObject.m_children.push_back(child);\r
+ simpleXMLObject.m_simples.push_back(child);\r
}\r
else {\r
throw UnmarshallingException("Unknown child element cannot be added to parent object.");\r