diff options
author | Noel Grandin <noel@peralex.com> | 2016-02-10 08:43:01 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-02-11 06:22:28 +0000 |
commit | 0f8ec3036f44b02aa03795ede3052a790134a90d (patch) | |
tree | a7cbba9eb70fcee3f793c07f8d8db6c092d0e594 /codemaker/source | |
parent | a6f876d45bd4e41a7143594a6cb11b6893a0f620 (diff) |
[API CHANGE] add operator==/!= to UNO structs
this is useful now that we are storing UNO structs in std::vector
Change-Id: Ic558bcd669bd2b3cdf9eb8393269eb906ac52369
Reviewed-on: https://gerrit.libreoffice.org/22257
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'codemaker/source')
-rw-r--r-- | codemaker/source/cppumaker/cpputype.cxx | 63 |
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"; } |