Changed the copy() and copyUnion() functions to be const.
Declared the XML_Node copy constructor and assignment operators to be private -> they don't work, so accidently invoking them is an error. Now, a compilation error will occur. Note, the copy() routine can be used instead to create copies of XML trees.
This commit is contained in:
parent
a42ef08f9c
commit
92c76dd5af
3 changed files with 34 additions and 9 deletions
|
|
@ -18,6 +18,14 @@ namespace Cantera {
|
|||
class ThermoPhase;
|
||||
|
||||
std::string fp2str(double x, std::string fmt);
|
||||
|
||||
//! Convert a double into a c++ string
|
||||
/*!
|
||||
* The default format to use is equivalent to the default
|
||||
* format used by printf's %g formatting.
|
||||
*
|
||||
* @param x double to be converted
|
||||
*/
|
||||
std::string fp2str(double x);
|
||||
std::string int2str(int n, std::string fmt);
|
||||
std::string int2str(int n);
|
||||
|
|
|
|||
|
|
@ -300,7 +300,9 @@ namespace Cantera {
|
|||
if (!p) m_root = this;
|
||||
else m_root = &p->root();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
XML_Node::~XML_Node() {
|
||||
if (m_locked)
|
||||
|
|
@ -525,7 +527,7 @@ namespace Cantera {
|
|||
}
|
||||
}
|
||||
|
||||
void XML_Node::copyUnion(XML_Node *node_dest) {
|
||||
void XML_Node::copyUnion(XML_Node *node_dest) const {
|
||||
XML_Node *sc, *dc;
|
||||
int ndc, idc;
|
||||
node_dest->addValue(m_value);
|
||||
|
|
@ -569,7 +571,7 @@ namespace Cantera {
|
|||
}
|
||||
}
|
||||
|
||||
void XML_Node::copy(XML_Node *node_dest) {
|
||||
void XML_Node::copy(XML_Node *node_dest) const {
|
||||
XML_Node *sc, *dc;
|
||||
int ndc;
|
||||
node_dest->addValue(m_value);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
//using namespace std;
|
||||
|
||||
|
||||
#include "ctexceptions.h"
|
||||
#include "ct_defs.h"
|
||||
|
|
@ -62,6 +62,11 @@ namespace Cantera {
|
|||
public:
|
||||
|
||||
XML_Node(std::string nm = "--", XML_Node* p = 0, int n = 0);
|
||||
private:
|
||||
XML_Node(const XML_Node &right);
|
||||
XML_Node& operator=(const XML_Node &right);
|
||||
|
||||
public:
|
||||
virtual ~XML_Node();
|
||||
void addComment(std::string comment);
|
||||
XML_Node& addChild(XML_Node& node);
|
||||
|
|
@ -126,8 +131,11 @@ namespace Cantera {
|
|||
return (m_attribs.find(a) != m_attribs.end());
|
||||
}
|
||||
|
||||
|
||||
std::string name() const { return m_name; }
|
||||
//! Returns the name of the XML node
|
||||
/*!
|
||||
* The name is the XML node is the XML node name
|
||||
*/
|
||||
std::string name() const { return m_name; }
|
||||
std::string id() const {
|
||||
if (hasAttrib("id")) return attrib("id");
|
||||
else return "";
|
||||
|
|
@ -167,8 +175,8 @@ namespace Cantera {
|
|||
void write(std::ostream& s, int level = 0) const;
|
||||
XML_Node& root() const { return *m_root; }
|
||||
void setRoot(XML_Node& root) { m_root = &root; }
|
||||
void copyUnion(XML_Node *node_dest);
|
||||
void copy(XML_Node *node_dest);
|
||||
void copyUnion(XML_Node *node_dest) const;
|
||||
void copy(XML_Node *node_dest) const;
|
||||
void lock() {m_locked = true;}
|
||||
void unlock() {m_locked = false; }
|
||||
|
||||
|
|
@ -177,7 +185,14 @@ namespace Cantera {
|
|||
|
||||
protected:
|
||||
|
||||
std::string m_name;
|
||||
//! XML node name of the node.
|
||||
/*!
|
||||
* For example, if we were in the XML_Node where
|
||||
* <phase dim="3" id="gas">
|
||||
* </phase>
|
||||
* Then, this string would be equal to "phase"
|
||||
*/
|
||||
std::string m_name;
|
||||
std::string m_value;
|
||||
std::map<std::string, XML_Node*> m_childindex;
|
||||
std::map<std::string, std::string> m_attribs;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue