https://issues.shibboleth.net/jira/browse/CPPOST-70
[shibboleth/cpp-xmltooling.git] / xmltooling / impl / AnyElement.cpp
index 5724804..72c833d 100644 (file)
@@ -45,10 +45,25 @@ AnyElementImpl::AnyElementImpl(const XMLCh* nsURI, const XMLCh* localName, const
 {
 }
 
+AnyElementImpl::AnyElementImpl(const AnyElementImpl& src)
+        : AbstractXMLObject(src),
+          AbstractDOMCachingXMLObject(src),
+          AbstractComplexElement(src),
+          AbstractAttributeExtensibleXMLObject(src)
+{
+}
+
 AnyElementImpl::~AnyElementImpl()
 {
 }
 
+void AnyElementImpl::_clone(const AnyElementImpl& src)
+{
+    const vector<XMLObject*>& children = src.getUnknownXMLObjects();
+    for (vector<XMLObject*>::const_iterator i=children.begin(); i!=children.end(); ++i)
+        getUnknownXMLObjects().push_back((*i)->clone());
+}
+
 XMLObject* AnyElementImpl::clone() const {
     auto_ptr<XMLObject> domClone(AbstractDOMCachingXMLObject::clone());
     AnyElementImpl* ret=dynamic_cast<AnyElementImpl*>(domClone.get());
@@ -57,19 +72,11 @@ XMLObject* AnyElementImpl::clone() const {
         return ret;
     }
 
-    return new AnyElementImpl(*this);
+    auto_ptr<AnyElementImpl> ret2(new AnyElementImpl(*this));
+    ret2->_clone(*ret2.get());
+    return ret2.release();
 }
 
-AnyElementImpl::AnyElementImpl(const AnyElementImpl& src)
-        : AbstractXMLObject(src),
-          AbstractDOMCachingXMLObject(src),
-          AbstractComplexElement(src),
-          AbstractAttributeExtensibleXMLObject(src) {
-    const vector<XMLObject*>& children = src.getUnknownXMLObjects();
-    for (vector<XMLObject*>::const_iterator i=children.begin(); i!=children.end(); ++i)
-        getUnknownXMLObjects().push_back((*i)->clone());
-}       
-
 void AnyElementImpl::marshallAttributes(DOMElement* domElement) const
 {
     marshallExtensionAttributes(domElement);