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