1#ifndef PROTON_VALUE_HPP
2#define PROTON_VALUE_HPP
27#include "./internal/type_traits.hpp"
31#include <proton/type_compat.h>
45 internal::data& data();
48 friend class codec::encoder;
49 friend class codec::decoder;
57class value :
public internal::value_base,
private internal::comparable<value> {
60 template<
class T,
class U=
void>
struct assignable :
61 public std::enable_if<codec::is_encodable<T>::value, U> {};
62 template<
class U>
struct assignable<
value, U> {};
77 template <
class T>
value(
const T& x,
typename assignable<T>::type* = 0) { *
this = x; }
80 template <
class T>
typename assignable<T, value&>::type
operator=(
const T& x) {
90 PN_CPP_EXTERN
bool empty()
const;
96 template<
class T> PN_CPP_DEPRECATED(
"Use 'proton::get'") void
get(T &t) const;
97 template<class T> PN_CPP_DEPRECATED("Use '
proton::
get'") T
get() const;
105 friend PN_CPP_EXTERN
bool operator==(const
value& x, const
value& y);
106 friend PN_CPP_EXTERN
bool operator<(const
value& x, const
value& y);
113 friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const
value&);
118 void reset(pn_data_t* d = 0);
124template<class T> T
get(const
value& v) { T x;
get(v, x);
return x; }
134template<
class T,
class U>
inline void get(
const U& u, T& x) {
const value v(u);
get(v, x); }
148 if (type_id_is_scalar(v.
type())) {
150 x = internal::coerce<T>(s);
170template<
class T>
void value::get(T &x)
const { x = proton::get<T>(*
this); }
171template<
class T> T
value::get()
const {
return proton::get<T>(*
this); }
Unsettled API - A stream-like decoder from AMQP bytes to C++ values.
Definition decoder.hpp:56
Unsettled API - A stream-like encoder from C++ values to AMQP bytes.
Definition encoder.hpp:50
The type of the AMQP null value.
Definition null.hpp:38
A holder for an instance of any scalar AMQP type.
Definition scalar.hpp:37
A holder for any AMQP value, simple or complex.
Definition value.hpp:57
T get(const value &v)
Get a contained value of type T.
Definition value.hpp:124
void get(const value &v, T &x)
Like get(const value&) but extracts the value to a reference x instead of returning it.
Definition value.hpp:131
T coerce(const value &v)
Coerce the contained value to type T.
Definition value.hpp:138
void coerce(const value &v, T &x)
Like coerce(const value&) but assigns the value to a reference instead of returning it.
Definition value.hpp:145
bool empty() const
True if the value is null.
assignable< T, value & >::type operator=(const T &x)
Assign from any allowed type T.
Definition value.hpp:80
type_id type() const
Get the type ID for the current value.
void clear()
Reset the value to null/empty.
value(const T &x, typename assignable< T >::type *=0)
Copy from any allowed type T.
Definition value.hpp:77
value()
Create a null value.
friend void swap(value &, value &)
swap values
Unsettled API - A stream-like decoder from AMQP bytes to C++ values.
Unsettled API - A stream-like encoder from C++ values to AMQP bytes.
The main Proton namespace.
Definition annotation_key.hpp:33
void get< decltype(nullptr)>(const value &v, decltype(nullptr)&)
Special case for null, just checks that value contains NULL.
Definition value.hpp:162
std::string to_string(const message &)
Human readable string representation.
void get< null >(const value &v, null &)
Special case for null, just checks that value contains NULL.
Definition value.hpp:157
type_id
An identifier for AMQP types.
Definition type_id.hpp:37
@ NULL_TYPE
The null type, contains no data.
Definition type_id.hpp:38
void assert_type_equal(type_id want, type_id got)
Throw a conversion_error if want != got with a message including the names of the types.
A holder for an instance of any scalar AMQP type.
Forward declarations for Proton types used to represent AMQP types.