summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/framing/Array.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/qpid/framing/Array.h')
-rw-r--r--cpp/src/qpid/framing/Array.h36
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);