6#include <bond/core/config.h>
9#include "detail/double_pass.h"
10#include "detail/marshaled_bonded.h"
11#include "detail/protocol_visitors.h"
13#include "runtime_schema.h"
14#include "select_protocol_fwd.h"
21template <
typename Protocols,
typename Transform,
typename T,
typename Reader>
22typename boost::disable_if<need_double_pass<Transform>,
bool>::type
inline
23ApplyTransform(
const Transform& transform,
const bonded<T, Reader>& bonded);
25template <
typename Protocols,
typename Transform,
typename T,
typename Reader>
26typename boost::enable_if<need_double_pass<Transform>,
bool>::type
inline
27ApplyTransform(
const Transform& transform,
const bonded<T, Reader>& bonded);
31template <
typename T,
typename U>
32typename boost::enable_if<std::is_reference<T>, T>::type
33inline move_data(U& data) BOND_NOEXCEPT
35 BOOST_STATIC_ASSERT(std::is_same<T, U&>::value);
39template <
typename T,
typename U>
40typename boost::disable_if<std::is_reference<T>, T&&>::type
41inline move_data(U& data) BOND_NOEXCEPT_IF(
42 std::is_nothrow_move_constructible<T>::value)
44 BOOST_STATIC_ASSERT(std::is_same<T, U>::value);
45 return std::move(data);
51template <
typename T,
typename Reader,
typename Unused =
void>
struct
53 : std::integral_constant<bool,
54 uses_marshaled_bonded<Reader, Unused>::value
55 && is_bonded<T>::value> {};
61template <
typename T,
typename Reader>
81 BOND_NOEXCEPT_EXPR(detail::move_data<Reader>(
bonded._data))
82 && std::is_nothrow_move_constructible<RuntimeSchema>::value)
83 : _data(detail::move_data<Reader>(
bonded._data)),
94 template <
typename U,
typename ReaderT>
102 BOOST_STATIC_ASSERT((std::is_base_of<U, T>::value || std::is_base_of<T, U>::value));
115 template <
typename U>
126 bonded(Reader data,
bool base =
false)
134 template <
typename ReaderT>
148 detail::Skip(_data, *
this, std::nothrow);
153 template <
typename U,
typename ReaderT>
154 operator bonded<U, ReaderT>()
const
156 BOOST_STATIC_ASSERT((std::is_base_of<U, T>::value));
157 return bonded<U, ReaderT>(*
this);
161 template <
typename ReaderT>
162 operator bonded<void, ReaderT>()
const
164 return bonded<void, ReaderT>(*
this);
168 template <
typename Protocols = BuiltInProtocols,
typename Writer>
171 Apply<Protocols>(SerializeTo<Protocols>(output), *
this);
175 template <
typename X = T,
typename Protocols = BuiltInProtocols>
179 Apply<Protocols>(To<X, Protocols>(tmp), *
this);
184 template <
typename Protocols = BuiltInProtocols,
typename X>
187 Apply<Protocols>(To<X, Protocols>(var), *
this);
191 template <
typename Protocols = BuiltInProtocols,
typename U>
192 typename boost::enable_if<is_marshaled_bonded<T, Reader, U> >::type
195 _SelectProtocolAndApply<Protocols>(boost::ref(var));
199 template <
typename Protocols = BuiltInProtocols,
typename U>
200 typename boost::disable_if<is_marshaled_bonded<T, Reader, U> >::type
208 template <
typename Protocols = BuiltInProtocols,
typename X>
209 void Merge(
const X& var)
211 detail::Merge<Protocols>(var, _data);
219 detail::Skip(_data, *
this);
229 return _data == rhs._data;
233 template <
typename Protocols,
typename Transform,
typename U,
typename ReaderT>
234 friend typename boost::disable_if<detail::need_double_pass<Transform>,
bool>::type
inline
235 detail::ApplyTransform(
const Transform& transform,
const bonded<U, ReaderT>& bonded);
237 template <
typename Protocols,
typename Transform,
typename U,
typename ReaderT>
238 friend typename boost::enable_if<detail::need_double_pass<Transform>,
bool>::type
inline
239 detail::ApplyTransform(
const Transform& transform,
const bonded<U, ReaderT>& bonded);
241 template <
typename U,
typename ReaderT>
246 template <
typename Protocols,
typename Transform>
247 typename boost::enable_if<is_marshaled_bonded<T, Reader, Transform>,
bool>::type
248 _Apply(
const Transform& transform)
const
250 return _SelectProtocolAndApply<Protocols>(transform);
254 template <
typename Protocols,
typename Transform>
255 typename boost::disable_if<is_marshaled_bonded<T, Reader, Transform>,
bool>::type
256 _Apply(
const Transform& transform)
const
259 return detail::Parse<T, Protocols>(transform, _data,
typename schema_for_passthrough<T>::type(), _schema.get(), _base);
263 template <
typename Protocols,
typename Transform>
264 bool _SelectProtocolAndApply(
const Transform& transform)
const
267 auto input = CreateInputBuffer(_data.GetBuffer(), detail::ReadBlob(_data));
268 return SelectProtocolAndApply<typename remove_bonded<T>::type, Protocols>(input, transform).second;
272 RuntimeSchema _schema;
Represents data for a struct T known at compile-time.
Definition: bonded.h:63
bonded()
Default constructor.
Definition: bonded.h:66
bool operator==(const bonded &rhs) const
Compare for equality.
Definition: bonded.h:225
void Merge(const X &var)
Update bonded<T> payload by merging it with an object of type X.
Definition: bonded.h:207
bonded(bonded &&bonded) BOND_NOEXCEPT_IF(&&std
Move constructor.
Definition: bonded.h:80
void Serialize(Writer &output) const
Serialize bonded using specified protocol writer.
Definition: bonded.h:167
bonded(const bonded &bonded)
Copy constructor.
Definition: bonded.h:72
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