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