I have the following class definition and it needs a copy constructor so deep copies are made to copy the raw pointers. Can anybody advice on how to best do this?
Using xerces-c++ for XML
class XMLDocument
{
private:
typedef std::vector<XML::XMLNode> v_nodes;
public:
XMLDocument::XMLDocument();
XMLDocument::XMLDocument(const XMLDocument& copy);
XMLDocument::~XMLDocument();
XMLDocument& operator=(XMLDocument const& rhs);
void CreateDocument(const std::string& docname);
void AddChildNode(XMLNode& node);
void RemoveNode(XMLNode& node);
void AddNodeValue(XMLNode& node, const std::string& value);
void AddNodeValue(XMLNode& node, int value);
void AddNodeValue(XMLNode& node, double value);
void AddNodeValue(XMLNode& node, float value);
std::string GetXMLAttributes();
std::string GetXMLAttribute(const std::string& attrib);
std::string GetXMLNodeText(XML::XMLNode& node);
std::string DumpToString();
XMLNode GetXPathNode(const std::string xpathXpression);
XMLNode GetNode(const XMLNode ¤tnode);
typedef v_nodes::iterator nodes_iterator;
nodes_iterator begin()
{
nodes_iterator iter;
iter = xmlnodes.begin();
return iter;
}
nodes_iterator end()
{
nodes_iterator iter;
iter = xmlnodes.end();
return iter;
}
private:
v_nodes xmlnodes;
bool InitializeXML();
DOMImplementation* impl; //Abstract
DOMDocument* document; //Abstract
DOMElement* rootelement; //Abstract
};
The DOMDocument is created calling a function and so is the DOMElement. So I can't just call new on these pointers.
Not sure if I just literally recreate all these object?
Example:
document = impl->createDocument(0, "mydoc", 0);
Who's gone on a downvote rage and not given a reason???