23 #include "proton/data.hpp"
33 class value :
public comparable<value> {
36 PN_CPP_EXTERN
value();
39 PN_CPP_EXTERN
value(
const value&);
42 PN_CPP_EXTERN
value(value&&);
46 PN_CPP_EXTERN value&
operator=(
const value&);
49 template <
class T>
explicit value(
const T& x) : data_(proton::data::create()) { encode() << x; }
55 template <
class T> value&
operator=(
const T& x) { encode() << x;
return *
this; }
58 PN_CPP_EXTERN
void clear();
61 PN_CPP_EXTERN
bool empty()
const;
64 PN_CPP_EXTERN type_id
type()
const;
73 template<
class T>
void get(T &t)
const { decode() >> t; }
76 template<
class T>
void get_map(T& t)
const { decode() >> to_map(t); }
79 template<
class T>
void get_pairs(T& t)
const { decode() >> to_pairs(t); }
82 template<
class T>
void get_sequence(T& t)
const { decode() >> to_sequence(t); }
87 template<
class T> T
get()
const { T t;
get(t);
return t; }
95 PN_CPP_EXTERN int64_t
as_int()
const;
96 PN_CPP_EXTERN uint64_t
as_uint()
const;
98 PN_CPP_EXTERN std::string
as_string()
const;
103 PN_CPP_EXTERN encoder encode();
104 PN_CPP_EXTERN decoder decode()
const;
105 PN_CPP_EXTERN
class data& data()
const;
109 mutable class data data_;
112 friend PN_CPP_EXTERN
void swap(value&, value&);
113 friend PN_CPP_EXTERN
bool operator==(
const value& x,
const value& y);
114 friend PN_CPP_EXTERN
bool operator<(
const value& x,
const value& y);
115 friend PN_CPP_EXTERN
class encoder operator<<(class encoder e, const value& dv);
116 friend PN_CPP_EXTERN
class decoder operator>>(class decoder d, value& dv);
117 friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream& o,
const value& dv);
A holder for an instance of any scalar AMQP type.
Definition: scalar.hpp:35
An AMQP message.
Definition: message.hpp:48
value()
Create an empty value.
value(const scalar &x)
Allow implicit conversion from a proton::scalar.
Definition: value.hpp:52
void get_sequence(T &t) const
Get an AMQP array or list as type T that satisfies the sequence concept. */.
Definition: value.hpp:82
value & operator=(const T &x)
Create a value from C++ type T.
Definition: value.hpp:55
bool empty() const
True if the value contains no data.
Defines C++ types representing AMQP types.
std::string as_string() const
Allowed if type_id_is_string_like(type())
value(const T &x)
Explicit conversion from from C++ type T.
Definition: value.hpp:49
int64_t as_int() const
Allowed if type_id_is_integral(type())
value & operator=(const value &)
Copy a value.
A holder for an AMQP value.
Definition: value.hpp:33
double as_double() const
Allowed if type_id_is_floating_point(type())
void get_pairs(T &t) const
Get a map as a as any type T that is a sequence pair-like types with first and second.
Definition: value.hpp:79
void get_map(T &t) const
Get an AMQP map as any type T that satisfies the map concept.
Definition: value.hpp:76
void clear()
Remove any contained data.
type_id type() const
Get the type of the current value.
uint64_t as_uint() const
Allowed if type_id_is_integral(type())