From eda249ff22edb3726243da81ff48c82e4d88e872 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 4 Nov 2008 19:52:49 +0000 Subject: constants.rb: generate type code constants for AMQP types. Useful with Array. framing/Array: - added some std:::vector like functions & typedefs. - use TypeCode enums, human readable ostream << operator. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@711365 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/framing/Array.h | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'cpp/src/qpid/framing/Array.h') diff --git a/cpp/src/qpid/framing/Array.h b/cpp/src/qpid/framing/Array.h index d3ca04dd1d..183fcb6d5c 100644 --- a/cpp/src/qpid/framing/Array.h +++ b/cpp/src/qpid/framing/Array.h @@ -18,12 +18,12 @@ * under the License. * */ -#include -#include -#include -#include #include "amqp_types.h" #include "FieldValue.h" +#include "qpid/framing/TypeCode.h" +#include +#include +#include #ifndef _Array_ #define _Array_ @@ -38,6 +38,8 @@ class Array public: typedef boost::shared_ptr ValuePtr; typedef std::vector ValueVector; + typedef ValueVector::const_iterator const_iterator; + typedef ValueVector::iterator iterator; uint32_t encodedSize() const; void encode(Buffer& buffer) const; @@ -47,11 +49,30 @@ class Array bool operator==(const Array& other) const; Array(); + Array(TypeCode type); Array(uint8_t type); //creates a longstr array Array(const std::vector& in); - void add(ValuePtr value); + TypeCode getType() const { return type; } + + // std collection interface. + const_iterator begin() const { return values.begin(); } + const_iterator end() const { return values.end(); } + iterator begin() { return values.begin(); } + iterator end(){ return values.end(); } + + ValuePtr front() const { return values.front(); } + ValuePtr back() const { return values.back(); } + size_t size() const { return values.size(); } + + void insert(iterator i, ValuePtr value); + void erase(iterator i) { values.erase(i); } + void push_back(ValuePtr value) { values.insert(end(), value); } + void pop_back() { values.pop_back(); } + + // Non-std interface + void add(ValuePtr value) { push_back(value); } template void collect(std::vector& out) const @@ -60,12 +81,9 @@ class Array out.push_back((*i)->get()); } } - - ValueVector::const_iterator begin() const { return values.begin(); } - ValueVector::const_iterator end() const { return values.end(); } private: - uint8_t typeOctet; + TypeCode type; ValueVector values; friend std::ostream& operator<<(std::ostream& out, const Array& body); -- cgit v1.2.1