1 #ifndef _framing_FieldValue_h
2 #define _framing_FieldValue_h
70 virtual uint32_t encodedSize()
const = 0;
80 virtual void print(std::ostream& out)
const = 0;
89 bool empty()
const {
return data.get() == 0; }
97 template <
typename T>
bool convertsTo()
const {
return false; }
100 template <
class T,
int W> T getIntegerValue()
const;
101 template <
class T> T getIntegerValue()
const;
102 template <
class T,
int W> T getFloatingPointValue()
const;
103 template <
int W>
void getFixedWidthValue(
unsigned char*)
const;
104 template <
class T>
bool get(T&)
const;
113 std::auto_ptr<Data> data;
118 inline bool FieldValue::convertsTo<int>()
const {
return data->convertsToInt(); }
121 inline bool FieldValue::convertsTo<int64_t>()
const {
return data->convertsToInt(); }
124 inline bool FieldValue::convertsTo<std::string>()
const {
return data->convertsToString(); }
127 inline int FieldValue::get<int>()
const {
return static_cast<int>(data->getInt()); }
130 inline int64_t FieldValue::get<int64_t>()
const {
return data->getInt(); }
133 inline std::string FieldValue::get<std::string>()
const {
return data->getString(); }
149 for (
int i = 0; i < width; i++) octets[i] = data[i];
153 for (
int i = width; i > 1; --i) {
154 octets[i-1] = (
uint8_t) (0xFF & v); v >>= 8;
156 octets[0] = (
uint8_t) (0xFF & v);
163 if (rhs == 0)
return false;
164 else return std::equal(&octets[0], &octets[width], &rhs->octets[0]);
171 for (
int i = 0; i < width-1; ++i) {
172 v |= octets[i]; v <<= 8;
174 v |= octets[width-1];
180 void print(std::ostream& o)
const { o <<
"F" << width <<
":"; };
186 UuidData(
const unsigned char* bytes);
191 template <
class T,
int W>
198 for (
int i = 0; i < W-1; ++i) {
199 v |= octets[i]; v <<= 8;
220 template <
class T,
int W>
227 for (
size_t i = 0; i < W; ++i) target[i] = octets[i];
238 for (
size_t i = 0; i < W; ++i) value[i] = fwv->
rawOctets()[i];
245 inline float FieldValue::get<float>()
const {
246 return getFloatingPointValue<float, 4>();
250 inline double FieldValue::get<double>()
const {
251 return getFloatingPointValue<double, 8>();
265 void print(std::ostream& o)
const { o <<
"F0"; };
268 template <
int lenw
idth>
270 std::vector<uint8_t> octets;
278 buffer.
putUInt<lenwidth>(octets.size());
279 if (octets.size() > 0)
291 if (rhs == 0)
return false;
292 else return octets==rhs->octets;
296 std::string
getString()
const {
return std::string(octets.begin(), octets.end()); }
298 void print(std::ostream& o)
const { o <<
"V" << lenwidth <<
":" << octets.size() <<
":"; };
315 value.encode(buffer);
318 value.decode(buffer);
322 if (rhs == 0)
return false;
323 else return value==rhs->value;
326 void print(std::ostream& o)
const { o <<
"[" << value <<
"]"; };
#define QPID_COMMON_EXTERN
boost::shared_ptr< FieldValue > ValuePtr
bool convertsToString() const
Str16Value(const std::string &v)
void encode(const qpid::types::Variant::Map &map, Message &message, const std::string &encoding=std::string())
Encodes a Variant::Map into a message.
Definitions and forward declarations of all types used in AMQP messages.
Representation of an AMQP 0-10 list.
T getFloatingPointValue() const
bool operator==(const Data &d) const
Var32Value(const std::string &v, uint8_t code)
Unsigned32Value(uint32_t)
Integer64Value(int64_t v)
Var16Value(const std::string &v, uint8_t code)
Unsigned16Value(uint16_t)
VariableWidthValue(const uint8_t *start, const uint8_t *end)
void print(std::ostream &out) const
Unsigned64Value(uint64_t v)
bool operator==(const Address &x, const Address &y)
virtual int64_t getInt() const
Struct32Value(const std::string &v)
virtual bool convertsToString() const
void encode(Buffer &buffer)
uint32_t encodedSize() const
void putRawData(const std::string &s)
void decode(Buffer &buffer)
Value that can appear in an AMQP field table.
Exception thrown when we can't perform requested conversion.
FieldValue(uint8_t t, Data *d)
virtual bool convertsToInt() const
Base class for Qpid runtime exceptions.
QPID_COMMON_INLINE_EXTERN bool operator!=(const FieldValue &v) const
FixedWidthValue(const uint8_t(&data)[width])
void print(std::ostream &o) const
bool operator==(const Data &d) const
void getFixedWidthValue(unsigned char *) const
bool convertsToString() const
InvalidConversionException()
uint32_t encodedSize() const
void decode(Buffer &buffer)
bool convertsToInt() const
uint32_t encodedSize() const
void getRawData(std::string &s, uint32_t size)
Exception that is the base exception for all field table errors.
const uint8_t * rawOctets() const
void encode(Buffer &buffer)
T getIntegerValue() const
void decode(Buffer &buffer)
IntegerValue Integer32Value
FieldTableValue(const FieldTable &)
static uint8_t * convertIfRequired(uint8_t *const octets, int width)
bool operator==(const Data &d) const
const T & getValue() const
void print(std::ostream &o) const
Str8Value(const std::string &v)
std::ostream & operator<<(std::ostream &, const Buffer &)
bool operator==(const Data &d) const
This file was automatically generated from the AMQP specification.
void checkAvailable(size_t count)
void print(std::ostream &o) const
FixedWidthValue(const uint8_t *const data)
uint32_t encodedSize() const
ArrayValue(const Array &)
std::string getString() const
std::string getString() const
FixedWidthValue(uint64_t v)
virtual std::string getString() const
#define QPID_COMMON_INLINE_EXTERN
A set of name-value pairs.
void encode(Buffer &buffer)
VariableWidthValue(const std::vector< uint8_t > &data)
#define QPID_COMMON_CLASS_EXTERN
bool getEncodedValue(FieldTable::ValuePtr vptr, T &value)
uint32_t encodedSize() const
void decode(const Message &message, qpid::types::Variant::Map &map, const std::string &encoding=std::string())
Decodes message content into a Variant::Map.
void print(std::ostream &o) const