diff options
author | Alan Conway <aconway@apache.org> | 2008-11-04 19:52:49 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2008-11-04 19:52:49 +0000 |
commit | eda249ff22edb3726243da81ff48c82e4d88e872 (patch) | |
tree | 0939d790e6a1b0d86993c9c3804c1adaa369aeb8 /cpp/src/qpid/framing/Array.h | |
parent | 5d2471636928eff8b8031237c54348db0d5c388d (diff) | |
download | qpid-python-eda249ff22edb3726243da81ff48c82e4d88e872.tar.gz |
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
Diffstat (limited to 'cpp/src/qpid/framing/Array.h')
-rw-r--r-- | cpp/src/qpid/framing/Array.h | 36 |
1 files changed, 27 insertions, 9 deletions
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 <iostream> -#include <vector> -#include <boost/shared_ptr.hpp> -#include <map> #include "amqp_types.h" #include "FieldValue.h" +#include "qpid/framing/TypeCode.h" +#include <boost/shared_ptr.hpp> +#include <iostream> +#include <vector> #ifndef _Array_ #define _Array_ @@ -38,6 +38,8 @@ class Array public: typedef boost::shared_ptr<FieldValue> ValuePtr; typedef std::vector<ValuePtr> 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<std::string>& 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 <class T> void collect(std::vector<T>& out) const @@ -60,12 +81,9 @@ class Array out.push_back((*i)->get<T>()); } } - - 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); |