00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <iostream>
00022 #include <vector>
00023 #include <boost/shared_ptr.hpp>
00024 #include <map>
00025 #include "amqp_types.h"
00026 #include "FieldValue.h"
00027
00028 #ifndef _Array_
00029 #define _Array_
00030
00031 namespace qpid {
00032 namespace framing {
00033
00034 class Buffer;
00035
00036 class Array
00037 {
00038 public:
00039 typedef boost::shared_ptr<FieldValue> ValuePtr;
00040 typedef std::vector<ValuePtr> ValueVector;
00041
00042 uint32_t size() const;
00043 void encode(Buffer& buffer) const;
00044 void decode(Buffer& buffer);
00045
00046 int count() const;
00047 bool operator==(const Array& other) const;
00048
00049 Array();
00050 Array(uint8_t type);
00051
00052 Array(const std::vector<std::string>& in);
00053
00054 void add(ValuePtr value);
00055
00056 template <class T>
00057 void collect(std::vector<T>& out)
00058 {
00059 for (ValueVector::const_iterator i = values.begin(); i != values.end(); ++i) {
00060 out.push_back((*i)->get<T>());
00061 }
00062 }
00063
00064 private:
00065 uint8_t typeOctet;
00066 ValueVector values;
00067
00068 ValueVector::const_iterator begin() const { return values.begin(); }
00069 ValueVector::const_iterator end() const { return values.end(); }
00070
00071 friend std::ostream& operator<<(std::ostream& out, const Array& body);
00072 };
00073
00074 }
00075 }
00076
00077
00078 #endif