From 1d31f66fcc9601db06f5fbdd158c16bc3180f0fd Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 7 Nov 2007 20:55:35 +0000 Subject: Fix for QPID-639: c++ now includes sizes for all structs (enabled the same in python & java) git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@592895 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/rubygen/templates/structs.rb | 61 +++++++++++++++++++++++++---- qpid/cpp/src/qpid/framing/AMQHeaderBody.cpp | 2 +- qpid/cpp/src/qpid/framing/AMQHeaderBody.h | 19 +++++++-- qpid/cpp/src/qpid/framing/StructHelper.h | 4 +- 4 files changed, 73 insertions(+), 13 deletions(-) (limited to 'qpid/cpp') diff --git a/qpid/cpp/rubygen/templates/structs.rb b/qpid/cpp/rubygen/templates/structs.rb index d67a8925c4..edbadb01f6 100644 --- a/qpid/cpp/rubygen/templates/structs.rb +++ b/qpid/cpp/rubygen/templates/structs.rb @@ -260,7 +260,7 @@ EOS genl "}" end genl "bool #{s.cppname}::has#{f.name.caps}() const { return flags & #{flag_mask(s, i)}; }" - genl "void #{s.cppname}::clear#{f.name.caps}() { flags &= ~#{flag_mask(s, i)}; }" + genl "void #{s.cppname}::clear#{f.name.caps}Flag() { flags &= ~#{flag_mask(s, i)}; }" end genl "" end @@ -275,9 +275,11 @@ EOS if (f.cpptype.name == "FieldTable") genl "#{f.cpptype.name}& get#{f.name.caps}();" end - #extra 'accessors' for packed fields: - genl "bool has#{f.name.caps}() const;"; - genl "void clear#{f.name.caps}();"; + if (f.domain.type_ != "bit") + #extra 'accessors' for packed fields: + genl "bool has#{f.name.caps}() const;" + genl "void clear#{f.name.caps}Flag();" + end end def define_accessors(f) @@ -370,7 +372,10 @@ EOS gen < void decode(T t, Buffer& b, uint32_t size) { - t.decode(b, size); + t.decodeStructBody(b, size); properties.push_back(t); } @@ -52,10 +57,14 @@ class AMQHeaderBody : public AMQBody Encode(Buffer& b) : buffer(b) {} template void operator()(T& t) const { - buffer.putLong(t.size() + 2/*typecode*/); - buffer.putShort(T::TYPE); t.encode(buffer); } + + void operator()(const BasicHeaderProperties& s) const { + buffer.putLong(s.size() + 2/*typecode*/); + buffer.putShort(BasicHeaderProperties::TYPE); + s.encode(buffer); + } }; class CalculateSize : public boost::static_visitor<> { @@ -67,6 +76,10 @@ class AMQHeaderBody : public AMQBody size += t.size(); } + void operator()(const BasicHeaderProperties& s) { + size += s.size() + 2/*typecode*/ + 4/*size field*/; + } + uint32_t totalSize() { return size; } diff --git a/qpid/cpp/src/qpid/framing/StructHelper.h b/qpid/cpp/src/qpid/framing/StructHelper.h index 7fc1d2e22b..ad6ba89906 100644 --- a/qpid/cpp/src/qpid/framing/StructHelper.h +++ b/qpid/cpp/src/qpid/framing/StructHelper.h @@ -38,14 +38,14 @@ public: data.resize(size); Buffer wbuffer(const_cast(data.data()), size); wbuffer.putShort(T::TYPE); - t.encode(wbuffer); + t.encodeStructBody(wbuffer); } template void decode(T& t, const std::string& data) { Buffer rbuffer(const_cast(data.data()), data.length()); uint16_t type = rbuffer.getShort(); if (type == T::TYPE) { - t.decode(rbuffer); + t.decodeStructBody(rbuffer); } else { throw Exception("Type code does not match"); } -- cgit v1.2.1