diff options
author | Gordon Sim <gsim@apache.org> | 2014-10-27 17:00:16 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2014-10-27 17:00:16 +0000 |
commit | aa356a34b9c4f8e46a97ed11cf46428789e2cc84 (patch) | |
tree | dec314ed0701af53bd37c3b62b4e7dbbf1c39251 | |
parent | a1d58191d8b393f4eb7a2a1691572ef1b5aa9e8f (diff) | |
download | qpid-python-aa356a34b9c4f8e46a97ed11cf46428789e2cc84.tar.gz |
QPID-4710: Handle nested descriptors i.e. described types where the value is itself a described type. Required for sending transaction control messages.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1634595 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/cpp/src/qpid/amqp/Decoder.cpp | 3 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/amqp/Descriptor.cpp | 10 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/amqp/Descriptor.h | 3 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/amqp/descriptors.h | 16 |
4 files changed, 32 insertions, 0 deletions
diff --git a/qpid/cpp/src/qpid/amqp/Decoder.cpp b/qpid/cpp/src/qpid/amqp/Decoder.cpp index de2c5ce64d..53cd367c25 100644 --- a/qpid/cpp/src/qpid/amqp/Decoder.cpp +++ b/qpid/cpp/src/qpid/amqp/Decoder.cpp @@ -274,6 +274,9 @@ Constructor Decoder::readConstructor() result.isDescribed = true; result.descriptor = readDescriptor(); result.code = readCode(); + for (Descriptor* d = &result.descriptor; result.code == DESCRIPTOR; result.code = readCode()) { + d = d->nest(readDescriptor()); + } } else { result.isDescribed = false; } diff --git a/qpid/cpp/src/qpid/amqp/Descriptor.cpp b/qpid/cpp/src/qpid/amqp/Descriptor.cpp index 384eba15b0..9e33294edd 100644 --- a/qpid/cpp/src/qpid/amqp/Descriptor.cpp +++ b/qpid/cpp/src/qpid/amqp/Descriptor.cpp @@ -51,6 +51,13 @@ size_t Descriptor::getSize() const return size; } +Descriptor* Descriptor::nest(const Descriptor& d) +{ + nested = boost::shared_ptr<Descriptor>(new Descriptor(0)); + *nested = d; + return nested.get(); +} + std::ostream& operator<<(std::ostream& os, const Descriptor& d) { switch (d.type) { @@ -62,6 +69,9 @@ std::ostream& operator<<(std::ostream& os, const Descriptor& d) os << "0x" << std::hex << d.value.code; break; } + if (d.nested.get()) { + os << " ->(" << *d.nested << ")"; + } return os; } }} // namespace qpid::amqp diff --git a/qpid/cpp/src/qpid/amqp/Descriptor.h b/qpid/cpp/src/qpid/amqp/Descriptor.h index b9a83628e7..6b0cb80e87 100644 --- a/qpid/cpp/src/qpid/amqp/Descriptor.h +++ b/qpid/cpp/src/qpid/amqp/Descriptor.h @@ -24,6 +24,7 @@ #include "qpid/amqp/CharSequence.h" #include "qpid/sys/IntegerTypes.h" #include <ostream> +#include <boost/shared_ptr.hpp> namespace qpid { namespace amqp { @@ -41,11 +42,13 @@ struct Descriptor NUMERIC, SYMBOLIC } type; + boost::shared_ptr<Descriptor> nested; QPID_COMMON_EXTERN Descriptor(uint64_t code); QPID_COMMON_EXTERN Descriptor(const CharSequence& symbol); QPID_COMMON_EXTERN bool match(const std::string&, uint64_t) const; QPID_COMMON_EXTERN size_t getSize() const; + QPID_COMMON_EXTERN Descriptor* nest(const Descriptor& d); }; QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& os, const Descriptor& d); diff --git a/qpid/cpp/src/qpid/amqp/descriptors.h b/qpid/cpp/src/qpid/amqp/descriptors.h index 6c7aadd13e..2cdaaf9202 100644 --- a/qpid/cpp/src/qpid/amqp/descriptors.h +++ b/qpid/cpp/src/qpid/amqp/descriptors.h @@ -102,6 +102,18 @@ const uint64_t DELETE_ON_NO_MESSAGES_CODE(0x2D); const uint64_t DELETE_ON_NO_LINKS_OR_MESSAGES_CODE(0x2E); } +namespace transaction { +const std::string DECLARE_SYMBOL("amqp:declare:list"); +const std::string DISCHARGE_SYMBOL("amqp:discharge:list"); +const std::string DECLARED_SYMBOL("amqp:declared:list"); +const std::string TRANSACTIONAL_STATE_SYMBOL("amqp:transactional-state:list"); + +const uint64_t DECLARE_CODE(0x31); +const uint64_t DISCHARGE_CODE(0x32); +const uint64_t DECLARED_CODE(0x33); +const uint64_t TRANSACTIONAL_STATE_CODE(0x34); +} + namespace error_conditions { //note these are not actually descriptors const std::string INTERNAL_ERROR("amqp:internal-error"); @@ -113,6 +125,10 @@ const std::string NOT_IMPLEMENTED("amqp:not-implemented"); const std::string RESOURCE_LIMIT_EXCEEDED("amqp:resource-limit-exceeded"); const std::string RESOURCE_DELETED("amqp:resource-deleted"); const std::string PRECONDITION_FAILED("amqp:precondition-failed"); +namespace transaction { +const std::string UNKNOWN_ID("amqp:transaction:unknown-id"); +const std::string ROLLBACK("amqp:transaction:rolback"); +} } }} // namespace qpid::amqp |