summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/CPlusPlusUtil.cpp
diff options
context:
space:
mode:
authorJoe George <joe@zeroc.com>2016-06-08 15:30:30 -0400
committerJoe George <joe@zeroc.com>2016-06-08 15:30:30 -0400
commite5a8741b6af4bff17d3db4a3f37c26c4f21194c4 (patch)
treedfeb2fb83d200b8a411cd65b7de3db928a418ce4 /cpp/src/Slice/CPlusPlusUtil.cpp
parentReplaced some ScopeArrays by vector or wstring (diff)
downloadice-e5a8741b6af4bff17d3db4a3f37c26c4f21194c4.tar.bz2
ice-e5a8741b6af4bff17d3db4a3f37c26c4f21194c4.tar.xz
ice-e5a8741b6af4bff17d3db4a3f37c26c4f21194c4.zip
ICE-6982 and ICE-6946
- Refactord C++ class/exception stream generated code - Changed return type of Obejct::ice_id() to std::string for C++11
Diffstat (limited to 'cpp/src/Slice/CPlusPlusUtil.cpp')
-rw-r--r--cpp/src/Slice/CPlusPlusUtil.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp
index 8197c7612c8..ce2b2690324 100644
--- a/cpp/src/Slice/CPlusPlusUtil.cpp
+++ b/cpp/src/Slice/CPlusPlusUtil.cpp
@@ -1254,6 +1254,55 @@ Slice::writeEndCode(Output& out, const ParamDeclList& params, const OperationPtr
}
}
+void
+Slice::writeMarshalUnmarshalDataMemberInHolder(IceUtilInternal::Output& C,
+ const string& holder,
+ const DataMemberPtr& p,
+ bool marshal)
+{
+ writeMarshalUnmarshalCode(C, p->type(), p->optional(), p->tag(), holder + fixKwd(p->name()), marshal,
+ p->getMetaData());
+}
+
+void
+Slice::writeStreamHelpers(Output& out, const ContainedPtr& c, DataMemberList dataMembers, bool checkClassMetaData)
+{
+ string scoped = c->scoped();
+ bool classMetaData = false;
+
+ if(checkClassMetaData)
+ {
+ classMetaData = findMetaData(c->getMetaData(), false) == "%class";
+ }
+
+ string fullName = classMetaData ? fixKwd(scoped + "Ptr") : fixKwd(scoped);
+ string holder = classMetaData ? "v->" : "v.";
+
+ out << nl << "template<typename S>";
+ out << nl << "struct StreamWriter< " << fullName << ", S>";
+ out << sb;
+ out << nl << "static void write(S* __os, const " << fullName << "& v)";
+ out << sb;
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeMarshalUnmarshalDataMemberInHolder(out, holder, *q, true);
+ }
+ out << eb;
+ out << eb << ";" << nl;
+
+ out << nl << "template<typename S>";
+ out << nl << "struct StreamReader< " << fullName << ", S>";
+ out << sb;
+ out << nl << "static void read(S* __is, " << fullName << "& v)";
+ out << sb;
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeMarshalUnmarshalDataMemberInHolder(out, holder, *q, false);
+ }
+ out << eb;
+ out << eb << ";" << nl;
+}
+
bool
Slice::findMetaData(const string& prefix, const ClassDeclPtr& cl, string& value)
{