diff options
author | Stephen D. Huston <shuston@apache.org> | 2011-10-21 14:42:12 +0000 |
---|---|---|
committer | Stephen D. Huston <shuston@apache.org> | 2011-10-21 14:42:12 +0000 |
commit | f83677056891e436bf5ba99e79240df2a44528cd (patch) | |
tree | 625bfd644b948e89105630759cf6decb0435354d /cpp/src/qpid/framing | |
parent | ebfd9ff053b04ab379acfc0fefedee5a31b6d8a5 (diff) | |
download | qpid-python-QPID-2519.tar.gz |
Merged out from trunkQPID-2519
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/QPID-2519@1187375 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/framing')
-rw-r--r-- | cpp/src/qpid/framing/AMQBody.h | 2 | ||||
-rw-r--r-- | cpp/src/qpid/framing/AMQContentBody.h | 12 | ||||
-rw-r--r-- | cpp/src/qpid/framing/AMQFrame.cpp | 5 | ||||
-rw-r--r-- | cpp/src/qpid/framing/AMQFrame.h | 7 | ||||
-rw-r--r-- | cpp/src/qpid/framing/AMQHeaderBody.h | 14 | ||||
-rw-r--r-- | cpp/src/qpid/framing/AMQHeartbeatBody.h | 2 | ||||
-rw-r--r-- | cpp/src/qpid/framing/FieldTable.cpp | 6 | ||||
-rw-r--r-- | cpp/src/qpid/framing/List.cpp | 6 | ||||
-rw-r--r-- | cpp/src/qpid/framing/MethodBodyFactory.h | 1 | ||||
-rw-r--r-- | cpp/src/qpid/framing/SendContent.h | 2 | ||||
-rw-r--r-- | cpp/src/qpid/framing/TransferContent.h | 2 | ||||
-rw-r--r-- | cpp/src/qpid/framing/Uuid.cpp | 4 |
12 files changed, 44 insertions, 19 deletions
diff --git a/cpp/src/qpid/framing/AMQBody.h b/cpp/src/qpid/framing/AMQBody.h index 60ac2d3b7e..56d1d250c1 100644 --- a/cpp/src/qpid/framing/AMQBody.h +++ b/cpp/src/qpid/framing/AMQBody.h @@ -46,7 +46,7 @@ struct AMQBodyConstVisitor { virtual void visit(const AMQMethodBody&) = 0; }; -class AMQBody : public RefCounted { +class QPID_COMMON_CLASS_EXTERN AMQBody : public RefCounted { public: AMQBody() {} QPID_COMMON_EXTERN virtual ~AMQBody(); diff --git a/cpp/src/qpid/framing/AMQContentBody.h b/cpp/src/qpid/framing/AMQContentBody.h index 69813b221c..e25451e354 100644 --- a/cpp/src/qpid/framing/AMQContentBody.h +++ b/cpp/src/qpid/framing/AMQContentBody.h @@ -29,7 +29,7 @@ namespace qpid { namespace framing { -class AMQContentBody : public AMQBody +class QPID_COMMON_CLASS_EXTERN AMQContentBody : public AMQBody { string data; @@ -37,15 +37,15 @@ public: QPID_COMMON_EXTERN AMQContentBody(); QPID_COMMON_EXTERN AMQContentBody(const string& data); inline virtual ~AMQContentBody(){} - QPID_COMMON_EXTERN inline uint8_t type() const { return CONTENT_BODY; }; - QPID_COMMON_EXTERN inline const string& getData() const { return data; } - QPID_COMMON_EXTERN inline string& getData() { return data; } + inline uint8_t type() const { return CONTENT_BODY; }; + inline const string& getData() const { return data; } + inline string& getData() { return data; } QPID_COMMON_EXTERN uint32_t encodedSize() const; QPID_COMMON_EXTERN void encode(Buffer& buffer) const; QPID_COMMON_EXTERN void decode(Buffer& buffer, uint32_t size); QPID_COMMON_EXTERN void print(std::ostream& out) const; - QPID_COMMON_EXTERN void accept(AMQBodyConstVisitor& v) const { v.visit(*this); } - QPID_COMMON_EXTERN boost::intrusive_ptr<AMQBody> clone() const { return BodyFactory::copy(*this); } + void accept(AMQBodyConstVisitor& v) const { v.visit(*this); } + boost::intrusive_ptr<AMQBody> clone() const { return BodyFactory::copy(*this); } }; } diff --git a/cpp/src/qpid/framing/AMQFrame.cpp b/cpp/src/qpid/framing/AMQFrame.cpp index cd60cd971f..5b9673f0d0 100644 --- a/cpp/src/qpid/framing/AMQFrame.cpp +++ b/cpp/src/qpid/framing/AMQFrame.cpp @@ -139,6 +139,11 @@ bool AMQFrame::decode(Buffer& buffer) return true; } +void AMQFrame::cloneBody() +{ + body = body->clone(); +} + std::ostream& operator<<(std::ostream& out, const AMQFrame& f) { return diff --git a/cpp/src/qpid/framing/AMQFrame.h b/cpp/src/qpid/framing/AMQFrame.h index d7b04f0f65..4f6faf4199 100644 --- a/cpp/src/qpid/framing/AMQFrame.h +++ b/cpp/src/qpid/framing/AMQFrame.h @@ -33,7 +33,7 @@ namespace qpid { namespace framing { -class AMQFrame : public AMQDataBlock +class QPID_COMMON_CLASS_EXTERN AMQFrame : public AMQDataBlock { public: QPID_COMMON_EXTERN AMQFrame(const boost::intrusive_ptr<AMQBody>& b=0); @@ -59,6 +59,11 @@ class AMQFrame : public AMQDataBlock return boost::polymorphic_downcast<const T*>(getBody()); } + /** + * Take a deep copy of the body currently referenced + */ + QPID_COMMON_EXTERN void cloneBody(); + QPID_COMMON_EXTERN void encode(Buffer& buffer) const; QPID_COMMON_EXTERN bool decode(Buffer& buffer); QPID_COMMON_EXTERN uint32_t encodedSize() const; diff --git a/cpp/src/qpid/framing/AMQHeaderBody.h b/cpp/src/qpid/framing/AMQHeaderBody.h index 8d96e35720..452154eb5c 100644 --- a/cpp/src/qpid/framing/AMQHeaderBody.h +++ b/cpp/src/qpid/framing/AMQHeaderBody.h @@ -10,9 +10,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -35,7 +35,7 @@ namespace qpid { namespace framing { -class AMQHeaderBody : public AMQBody +class QPID_COMMON_CLASS_EXTERN AMQHeaderBody : public AMQBody { template <class T> struct OptProps { boost::optional<T> props; }; template <class Base, class T> @@ -58,7 +58,7 @@ class AMQHeaderBody : public AMQBody } else return Base::decode(buffer, size, type); - } + } void print(std::ostream& out) const { const boost::optional<T>& p=this->OptProps<T>::props; if (p) out << *p; @@ -77,7 +77,7 @@ class AMQHeaderBody : public AMQBody typedef PropSet<PropSet<Empty, DeliveryProperties>, MessageProperties> Properties; Properties properties; - + public: inline uint8_t type() const { return HEADER_BODY; } @@ -99,6 +99,10 @@ public: return properties.OptProps<T>::props.get_ptr(); } + template <class T> void erase() { + properties.OptProps<T>::props.reset(); + } + boost::intrusive_ptr<AMQBody> clone() const { return BodyFactory::copy(*this); } }; diff --git a/cpp/src/qpid/framing/AMQHeartbeatBody.h b/cpp/src/qpid/framing/AMQHeartbeatBody.h index 9b1fe8a4c1..19ac2be013 100644 --- a/cpp/src/qpid/framing/AMQHeartbeatBody.h +++ b/cpp/src/qpid/framing/AMQHeartbeatBody.h @@ -29,7 +29,7 @@ namespace qpid { namespace framing { -class AMQHeartbeatBody : public AMQBody +class QPID_COMMON_CLASS_EXTERN AMQHeartbeatBody : public AMQBody { public: QPID_COMMON_EXTERN virtual ~AMQHeartbeatBody(); diff --git a/cpp/src/qpid/framing/FieldTable.cpp b/cpp/src/qpid/framing/FieldTable.cpp index 023e4af819..f80d2f9fb1 100644 --- a/cpp/src/qpid/framing/FieldTable.cpp +++ b/cpp/src/qpid/framing/FieldTable.cpp @@ -129,7 +129,7 @@ FieldTable::ValuePtr FieldTable::get(const std::string& name) const namespace { template <class T> T default_value() { return T(); } template <> int default_value<int>() { return 0; } - template <> uint64_t default_value<uint64_t>() { return 0; } + //template <> uint64_t default_value<uint64_t>() { return 0; } } template <class T> @@ -198,10 +198,12 @@ void FieldTable::encode(Buffer& buffer) const { void FieldTable::decode(Buffer& buffer){ clear(); + if (buffer.available() < 4) + throw IllegalArgumentException(QPID_MSG("Not enough data for field table.")); uint32_t len = buffer.getLong(); if (len) { uint32_t available = buffer.available(); - if (available < len) + if ((available < len) || (available < 4)) throw IllegalArgumentException(QPID_MSG("Not enough data for field table.")); uint32_t count = buffer.getLong(); uint32_t leftover = available - len; diff --git a/cpp/src/qpid/framing/List.cpp b/cpp/src/qpid/framing/List.cpp index 963ebc206b..d7ea172bac 100644 --- a/cpp/src/qpid/framing/List.cpp +++ b/cpp/src/qpid/framing/List.cpp @@ -49,6 +49,9 @@ void List::encode(Buffer& buffer) const void List::decode(Buffer& buffer) { values.clear(); + if (buffer.available() < 4) + throw IllegalArgumentException(QPID_MSG("Not enough data for list, expected at least " + " 4 bytes but only " << buffer.available() << " available")); uint32_t size = buffer.getLong(); uint32_t available = buffer.available(); if (available < size) { @@ -56,6 +59,9 @@ void List::decode(Buffer& buffer) << size << " bytes but only " << available << " available")); } if (size) { + if (buffer.available() < 4) + throw IllegalArgumentException(QPID_MSG("Not enough data for list, expected at least " + " 4 bytes but only " << buffer.available() << " available")); uint32_t count = buffer.getLong(); for (uint32_t i = 0; i < count; i++) { ValuePtr value(new FieldValue); diff --git a/cpp/src/qpid/framing/MethodBodyFactory.h b/cpp/src/qpid/framing/MethodBodyFactory.h index 607ec9d959..88bc444795 100644 --- a/cpp/src/qpid/framing/MethodBodyFactory.h +++ b/cpp/src/qpid/framing/MethodBodyFactory.h @@ -22,6 +22,7 @@ * */ #include "qpid/framing/amqp_types.h" +#include "qpid/framing/AMQBody.h" #include <boost/intrusive_ptr.hpp> namespace qpid { diff --git a/cpp/src/qpid/framing/SendContent.h b/cpp/src/qpid/framing/SendContent.h index 745c948c9e..1c464b9c8b 100644 --- a/cpp/src/qpid/framing/SendContent.h +++ b/cpp/src/qpid/framing/SendContent.h @@ -37,7 +37,7 @@ namespace framing { */ class SendContent { - mutable FrameHandler& handler; + FrameHandler& handler; const uint16_t maxFrameSize; uint expectedFrameCount; uint frameCount; diff --git a/cpp/src/qpid/framing/TransferContent.h b/cpp/src/qpid/framing/TransferContent.h index 5fe1a513a9..9a698a1823 100644 --- a/cpp/src/qpid/framing/TransferContent.h +++ b/cpp/src/qpid/framing/TransferContent.h @@ -32,7 +32,7 @@ namespace qpid { namespace framing { /** Message content */ -class TransferContent : public MethodContent +class QPID_COMMON_CLASS_EXTERN TransferContent : public MethodContent { AMQHeaderBody header; std::string data; diff --git a/cpp/src/qpid/framing/Uuid.cpp b/cpp/src/qpid/framing/Uuid.cpp index 945c0a4d24..b3d1e2e1e4 100644 --- a/cpp/src/qpid/framing/Uuid.cpp +++ b/cpp/src/qpid/framing/Uuid.cpp @@ -59,7 +59,9 @@ void Uuid::clear() { // Force int 0/!0 to false/true; avoids compile warnings. bool Uuid::isNull() const { - return !!uuid_is_null(data()); + // This const cast is for Solaris which has a + // uuid_is_null that takes a non const argument + return !!uuid_is_null(const_cast<uint8_t*>(data())); } void Uuid::encode(Buffer& buf) const { |