6#include <bond/core/config.h>
9#include "detail/nonassignable.h"
11#include "select_protocol.h"
20template <
typename Reader>
22 : detail::nonassignable
36 _schema(other._schema),
42 template <
typename T,
typename ReaderT>
53 BOND_NOEXCEPT_EXPR(detail::move_data<Reader>(other._data))
54 && std::is_nothrow_move_constructible<RuntimeSchema>::value)
55 : _data(detail::move_data<Reader>(other._data)),
56 _schema(
std::move(other._schema)),
57 _skip(
std::move(other._skip)),
58 _base(
std::move(other._base))
68 detail::Skip(_data, *
this, std::nothrow);
73 template <
typename Protocols = BuiltInProtocols,
typename Writer>
74 typename boost::disable_if<uses_marshaled_bonded<typename Writer::Reader> >::type
77 Apply<Protocols>(SerializeTo<Protocols>(output), *
this);
81 template <
typename Protocols = BuiltInProtocols,
typename Writer>
82 typename boost::enable_if<uses_marshaled_bonded<typename Writer::Reader> >::type
85 if (_schema.GetType().bonded_type)
86 detail::MarshalToBlob<Protocols>(*
this, output);
88 Apply<Protocols>(SerializeTo<Protocols>(output), *
this);
93 template <
typename T,
typename Protocols = BuiltInProtocols>
97 Apply<Protocols>(To<T, Protocols>(tmp), *
this);
103 template <
typename Protocols = BuiltInProtocols,
typename T>
106 Apply<Protocols>(To<T, Protocols>(var), *
this);
111 template <
typename Protocols = BuiltInProtocols,
typename T>
112 typename boost::enable_if<uses_marshaled_bonded<Reader, T> >::type
115 if (_schema.GetType().bonded_type)
118 _SelectProtocolAndApply<Protocols>(boost::ref(tmp));
119 tmp.template Deserialize<Protocols>(var);
129 template <
typename Protocols = BuiltInProtocols,
typename T>
130 typename boost::disable_if<uses_marshaled_bonded<Reader, T> >::type
141 detail::Skip(_data, *
this);
145 template <
typename Protocols,
typename Transform,
typename U,
typename ReaderT>
146 friend typename boost::disable_if<detail::need_double_pass<Transform>,
bool>::type
inline
149 template <
typename Protocols,
typename Transform,
typename U,
typename ReaderT>
150 friend typename boost::enable_if<detail::need_double_pass<Transform>,
bool>::type
inline
153 template <
typename T,
typename ReaderT>
158 template <
typename Protocols,
typename Transform>
159 typename boost::enable_if<uses_marshaled_bonded<Reader, Transform>,
bool>::type
160 _Apply(
const Transform& transform)
const
162 if (_schema.GetType().bonded_type)
164 return _SelectProtocolAndApply<Protocols>(transform);
169 return detail::Parse<void, Protocols>(transform, _data, _schema,
nullptr, _base);
173 template <
typename Protocols,
typename Transform>
174 typename boost::disable_if<uses_marshaled_bonded<Reader, Transform>,
bool>::type
175 _Apply(
const Transform& transform)
const
178 return detail::Parse<void, Protocols>(transform, _data, _schema,
nullptr, _base);
182 template <
typename Protocols,
typename Transform>
183 bool _SelectProtocolAndApply(
const Transform& transform)
const
185 BOOST_STATIC_ASSERT(uses_marshaled_bonded<Reader>::value);
188 auto input = CreateInputBuffer(_data.GetBuffer(), detail::ReadBlob(_data));
189 return SelectProtocolAndApply<Protocols>(_schema, input, transform).second;
194 const RuntimeSchema _schema;
Represents runtime schema See User's Manual
Definition: runtime_schema.h:26
bonded(bonded &&other) BOND_NOEXCEPT_IF(&&std
Move constructor.
Definition: bonded_void.h:52
bonded(const bonded< T, ReaderT > &other)
Explicit cast from bonded<T>
Definition: bonded_void.h:43
bonded(Reader data, const RuntimeSchema &schema, bool base=false)
Initialize from serialized data and runtime schema.
Definition: bonded_void.h:26
bonded(const bonded &other)
Copy constructor.
Definition: bonded_void.h:34
Represents data for a struct T known at compile-time.
Definition: bonded.h:63
void Serialize(Writer &output) const
Serialize bonded using specified protocol writer.
Definition: bonded.h:167
X Deserialize() const
Deserialize an object of type X.
Definition: bonded.h:174
void Skip()
Skip struct data in the underlying payload.
Definition: bonded.h:214
namespace bond
Definition: apply.h:17
RuntimeSchema GetRuntimeSchema()
Returns an instance of RuntimeSchema for a user defined struct.
Definition: schema.h:330