summaryrefslogtreecommitdiff
path: root/xsd/cxx/tree/tree-header.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-08-29 15:24:56 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-08-29 15:24:56 +0200
commit474046c375d24bfdb51a20b0bfd3ac4ac928ef3e (patch)
tree58e80190a253381fe4e0bf636ceb33679e2647fb /xsd/cxx/tree/tree-header.cxx
parent54333e04060f50cb9d8babb40d3469b7a2a7c38e (diff)
Implement generation of assignment operators
Also add the --suppress-assignment option. We need to generate these operators into the .cxx file instead of relying on the implicit inline ones because in the file-per-type mode types of members are only forward- declared in the header. Also, we don't want to assign the DOMDocument member used to store the wildcard content.
Diffstat (limited to 'xsd/cxx/tree/tree-header.cxx')
-rw-r--r--xsd/cxx/tree/tree-header.cxx49
1 files changed, 49 insertions, 0 deletions
diff --git a/xsd/cxx/tree/tree-header.cxx b/xsd/cxx/tree/tree-header.cxx
index 9b5acc6..8805c8b 100644
--- a/xsd/cxx/tree/tree-header.cxx
+++ b/xsd/cxx/tree/tree-header.cxx
@@ -2969,12 +2969,61 @@ namespace CXX
<< container << "* c = 0) const;"
<< endl;
+ // operator=
+ //
+ bool priv (false);
+
+ if (!simple)
+ {
+ if (options.value<CLI::suppress_assignment> ())
+ {
+ priv = true;
+ os << "private:" << endl;
+
+ if (doxygen)
+ {
+ os << "/**" << endl
+ << " * @brief Disabled copy assignment operator." << endl
+ << " *" << endl
+ << " * @param x An instance to make a copy of." << endl
+ << " * @return A reference to itself." << endl
+ << " */" << endl;
+ }
+
+ os << name << "&" << endl
+ << "operator= (const " << name << "& x);"
+ << endl;
+ }
+ else if (has_members || (gen_wildcard && (hae || haa)))
+ {
+ if (doxygen)
+ {
+ os << "/**" << endl
+ << " * @brief Copy assignment operator." << endl
+ << " *" << endl
+ << " * @param x An instance to make a copy of." << endl
+ << " * @return A reference to itself." << endl
+ << " *" << endl
+ << " * For polymorphic object models use the @c _clone " <<
+ "function instead." << endl
+ << " */" << endl;
+ }
+
+ os << name << "&" << endl
+ << "operator= (const " << name << "& x);"
+ << endl;
+ }
+ }
+
if (doxygen)
{
os << "//@}" << endl
<< endl;
}
+ if (priv)
+ os << "public:" << endl;
+
// d-tor
//
if (doxygen)