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
00027 #ifndef _FieldTable_
00028 #define _FieldTable_
00029
00030 namespace qpid {
00035 namespace framing {
00036
00037 class Array;
00038 class FieldValue;
00039 class Buffer;
00040
00047 class FieldTable
00048 {
00049 public:
00050 typedef boost::shared_ptr<FieldValue> ValuePtr;
00051 typedef std::map<std::string, ValuePtr> ValueMap;
00052 typedef ValueMap::iterator iterator;
00053
00054 FieldTable() {};
00055 FieldTable(const FieldTable& ft);
00056 ~FieldTable();
00057 FieldTable& operator=(const FieldTable& ft);
00058 uint32_t encodedSize() const;
00059 void encode(Buffer& buffer) const;
00060 void decode(Buffer& buffer);
00061
00062 int count() const;
00063 void set(const std::string& name, const ValuePtr& value);
00064 ValuePtr get(const std::string& name) const;
00065 bool isSet(const std::string& name) const { return get(name).get() != 0; }
00066
00067 void setString(const std::string& name, const std::string& value);
00068 void setInt(const std::string& name, const int value);
00069 void setInt64(const std::string& name, const int64_t value);
00070 void setTimestamp(const std::string& name, const uint64_t value);
00071 void setUInt64(const std::string& name, const uint64_t value);
00072 void setTable(const std::string& name, const FieldTable& value);
00073 void setArray(const std::string& name, const Array& value);
00074 void setFloat(const std::string& name, const float value);
00075 void setDouble(const std::string& name, const double value);
00076
00077
00078 int getAsInt(const std::string& name) const;
00079 uint64_t getAsUInt64(const std::string& name) const;
00080 int64_t getAsInt64(const std::string& name) const;
00081 std::string getAsString(const std::string& name) const;
00082
00083 bool getTable(const std::string& name, FieldTable& value) const;
00084 bool getArray(const std::string& name, Array& value) const;
00085 bool getFloat(const std::string& name, float& value) const;
00086 bool getDouble(const std::string& name, double& value) const;
00087
00088
00089 void erase(const std::string& name);
00090
00091
00092 bool operator==(const FieldTable& other) const;
00093
00094
00095
00096 ValueMap::const_iterator begin() const { return values.begin(); }
00097 ValueMap::const_iterator end() const { return values.end(); }
00098 ValueMap::const_iterator find(const std::string& s) const { return values.find(s); }
00099
00100 std::pair <ValueMap::iterator, bool> insert(const ValueMap::value_type&);
00101 void clear() { values.clear(); }
00102
00103
00104
00105 ValueMap::iterator getValues() { return values.begin(); }
00106
00107 private:
00108 ValueMap values;
00109
00110 friend std::ostream& operator<<(std::ostream& out, const FieldTable& body);
00111 };
00112
00113
00114
00115
00116 }
00117 }
00118
00119
00120 #endif