Closed Darwinnpos closed 1 year ago
you can just construct a ostream
for your provided ptr
and size
:
void *shared_ptr = ...
size_t shared_size = ...
yas::mem_ostream os{shared_ptr, shared_size};
yas::binary_oarchive<yas::mem_ostream> oa{os};
oa & YAS_OBJECT(...);
How do you estimate the memory of the target object? Or it can be roughly estimated.
yes, you must determine/specify the maximum possible size of the required memory for a specific object.
also, you can use yas::count_ostream
: https://github.com/niXman/yas/blob/7c5ced1d940ddc6826cf537468e65ea1f592bfe4/include/yas/serialize.hpp#L310
You mean the space needed for serialization can be calculated using this without actual serialization happening?
correct!
If I have a custom class that defines a custom serialization function, do I need to customize the serialization space calculation method?
could you please provide the code you are talking about? I'm unsure I understood the question...
We want the binary data to be in shared memory when the serialization of the Request or Response completes. Instead of serializing into a non-shared-memory buffer and copying it into a shared-memory buffer.
Whether it is possible to provide a save function to construct the last object in advance, the last serialization is over, and the data exists in the target location.