From 428de9b6fe6f81f2bfc3f47d5db013b4b00da6a2 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 16 Oct 2007 19:07:54 +0000 Subject: * Summary: generalized Invoker visitor to all *Operations and *Handler classes, client and broker. Single template free function invoke(Invocable, const AMQBody&); works for all invocable handlers. * rubygen/templates/OperationsInvoker.rb: Generates invoker visitors for all Operations classes, client and server. * src/qpid/framing/Invoker.h: Invoker base class and template invoke() function. * rubygen/templates/structs.rb: add generic invoke method template to invoke an arbitrary object with the correct memeber function. * src/qpid/framing/AMQMethodBody.cpp, .h: Removed invoke(), replaced by qpid::framing::invoke() * src/qpid/broker/SemanticHandler.cpp, ConnectionHandler.cpp: Replace AMQMethodBody::invoke with invoke() free function. * src/qpid/framing/StructHelper.h: Avoid un-necessary alloc and copy in encode/decode. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@585223 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/framing/StructHelper.h | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'cpp/src/qpid/framing/StructHelper.h') diff --git a/cpp/src/qpid/framing/StructHelper.h b/cpp/src/qpid/framing/StructHelper.h index 6b111e1f9e..7fc1d2e22b 100644 --- a/cpp/src/qpid/framing/StructHelper.h +++ b/cpp/src/qpid/framing/StructHelper.h @@ -35,21 +35,14 @@ public: template void encode(const T t, std::string& data) { uint32_t size = t.size() + 2/*type*/; - char* bytes = static_cast(::alloca(size)); - Buffer wbuffer(bytes, size); + data.resize(size); + Buffer wbuffer(const_cast(data.data()), size); wbuffer.putShort(T::TYPE); t.encode(wbuffer); - - Buffer rbuffer(bytes, size); - rbuffer.getRawData(data, size); } template void decode(T& t, const std::string& data) { - char* bytes = static_cast(::alloca(data.length())); - Buffer wbuffer(bytes, data.length()); - wbuffer.putRawData(data); - - Buffer rbuffer(bytes, data.length()); + Buffer rbuffer(const_cast(data.data()), data.length()); uint16_t type = rbuffer.getShort(); if (type == T::TYPE) { t.decode(rbuffer); -- cgit v1.2.1