15 std::size_t
to_bytes(
const std::string& b,
char* v) {
17 return b.length() + 1;
21 return b.length() + 1;
26 b.ensure_registered(dm);
35 std::function<void(char const* const, std::size_t)>
post_to_buffer(std::size_t& index,
char* dest_buf) {
36 return [&index, dest_buf](
char const*
const read_buf, std::size_t size) {
37 memcpy(dest_buf + index, read_buf, size);
46 void post_object(
const std::function<
void(
char const*
const, std::size_t)>& f,
const std::string& str) {
47 f(str.c_str(), str.length() + 1);
std::size_t from_bytes_noalloc_v(DeserializationManager *, char const *const)
std::enable_if_t< std::is_base_of< ByteRepresentable CMA std::decay_t< T > >::value, context_ptr< T > > from_bytes_noalloc(DeserializationManager *ctx, const char *v, context_ptr< std::decay_t< T >>=context_ptr< std::decay_t< T >>{})
Calls T::from_bytes_noalloc(ctx,v) when T is a ByteRepresentable.
std::size_t from_bytes_v(DeserializationManager *, char const *const)
std::size_t to_bytes_v(char *)
For Serializing and Deserializing many objects at once.
std::function< void(char const *const, std::size_t)> post_to_buffer(std::size_t &index, char *dest_buf)
virtual void post_object(const std::function< void(char const *const, std::size_t)> &) const =0
Pass a pointer to a buffer containing this class's marshalled representation into the function f...
A non-POD type which wishes to mark itself byte representable should extend this class.
virtual std::size_t to_bytes(char *v) const =0
Write this class's marshalled representation into the array found at v.
auto bytes_size(const T &)
Just calls sizeof(T)
virtual std::size_t bytes_size() const =0
the size of the marshalled representation of this object.
std::unique_ptr< T, ContextDeleter< T > > context_ptr
The manager for any RemoteDeserializationContexts.
The "marshalled" type is a wrapper for already-serialized types;.
std::enable_if_t< std::is_pod< BR >::value > post_object(const F &f, const BR &br, Args &&... args)
In-place serialization is also sometimes possible.
std::size_t to_bytes(const ByteRepresentable &b, char *v)
calls b.to_bytes(v) when b is a ByteRepresentable; calls std::memcpy() when b is POD.