summaryrefslogtreecommitdiff
path: root/codemaker
diff options
context:
space:
mode:
Diffstat (limited to 'codemaker')
-rw-r--r--codemaker/source/cppumaker/cpputype.cxx63
1 files changed, 63 insertions, 0 deletions
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
index 98510c367ff9..1f98590e2a0f 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -1942,6 +1942,33 @@ void PlainStructType::dumpHppFile(
dec();
out << "{\n}\n\n";
}
+ // print the operator==
+ out << "\ninline bool operator==(const " << id_ << "& the_lhs, const " << id_ << "& the_rhs)\n";
+ out << "{\n";
+ inc();
+ out << indent() << "return ";
+ bFirst = true;
+ if (!base.isEmpty()) {
+ out << "operator==( static_cast< " << codemaker::cpp::scopedCppName(u2b(base))
+ << ">(the_lhs), static_cast< " << codemaker::cpp::scopedCppName(u2b(base)) << ">(the_rhs) )\n";
+ bFirst = false;
+ }
+ for (const unoidl::PlainStructTypeEntity::Member& member : entity_->getDirectMembers())
+ {
+ if (!bFirst)
+ out << "\n" << indent() << indent() << "&& ";
+ out << "the_lhs." << member.name << " == the_rhs." << member.name;
+ bFirst = false;
+ }
+ out << ";\n";
+ dec();
+ out << "}\n";
+ // print the operator!=
+ out << "\ninline bool operator!=(const " << id_ << "& the_lhs, const " << id_ << "& the_rhs)\n";
+ out << "{\n";
+ out << indent() << "return !operator==(the_lhs, the_rhs);\n";
+ out << "}\n";
+ // close namespace
if (codemaker::cppumaker::dumpNamespaceClose(out, name_, false)) {
out << "\n";
}
@@ -2233,6 +2260,7 @@ void PolyStructType::dumpDeclaration(FileStream & out) {
out << " " << i->name << "_";
}
out << ");\n\n";
+ // print the member fields
for (const unoidl::PolymorphicStructTypeTemplateEntity::Member& member :
entity_->getMembers())
{
@@ -2260,6 +2288,7 @@ void PolyStructType::dumpHppFile(
out << "\n";
}
out << "\n";
+ // dump default (no-arg) constructor
dumpTemplateHead(out);
out << "inline " << id_;
dumpTemplateParameters(out);
@@ -2277,6 +2306,7 @@ void PolyStructType::dumpHppFile(
dec();
out << "{\n}\n\n";
if (!entity_->getMembers().empty()) {
+ // dump takes-all-fields constructor
dumpTemplateHead(out);
out << "inline " << id_;
dumpTemplateParameters(out);
@@ -2309,6 +2339,7 @@ void PolyStructType::dumpHppFile(
}
dec();
out << "{\n}\n\n" << indent();
+ // dump make_T method
dumpTemplateHead(out);
out << "\n" << indent() << "inline " << id_;
dumpTemplateParameters(out);
@@ -2348,6 +2379,38 @@ void PolyStructType::dumpHppFile(
dec();
out << indent() << "}\n\n";
}
+ // print the operator==
+ dumpTemplateHead(out);
+ out << " inline bool operator==(const " << id_;
+ dumpTemplateParameters(out);
+ out << "& the_lhs, const " << id_;
+ dumpTemplateParameters(out);
+ out << "& the_rhs)\n";
+ out << "{\n";
+ inc();
+ out << indent() << "return ";
+ bool bFirst = true;
+ for (const unoidl::PolymorphicStructTypeTemplateEntity::Member& member : entity_->getMembers())
+ {
+ if (!bFirst)
+ out << "\n" << indent() << indent() << "&& ";
+ out << "the_lhs." << member.name << " == the_rhs." << member.name;
+ bFirst = false;
+ }
+ out << ";\n";
+ dec();
+ out << "}\n";
+ // print the operator!=
+ dumpTemplateHead(out);
+ out << " inline bool operator!=(const " << id_;
+ dumpTemplateParameters(out);
+ out << "& the_lhs, const " << id_;
+ dumpTemplateParameters(out);
+ out << "& the_rhs)\n";
+ out << "{\n";
+ out << indent() << "return !operator==(the_lhs, the_rhs);\n";
+ out << "}\n";
+ // close namespace
if (codemaker::cppumaker::dumpNamespaceClose(out, name_, false)) {
out << "\n";
}