checkpoint namespace

Namespaces

namespace buffer
namespace debug
namespace detail
namespace dispatch
namespace serializerUserTraits

Classes

struct BaseSerializer
General base class for serialiers.
template<typename T>
struct ByteCopyNonIntrusive
template<typename... Args>
struct ByteCopyNonIntrusive<std::variant<Args...>>
template<typename T>
struct CheckpointReconstructor
template<typename... Args>
struct CheckpointReconstructor<std::tuple<Args...>>
struct Footprinter
template<typename T, typename SerializerT>
struct SerializeVirtualTypeIfNeeded<T, SerializerT, typename std::enable_if_t<dispatch::vrt::VirtualSerializeTraits<T>::has_not_virtual_serialize>>
template<typename T, typename SerializerT>
struct ReconstructAsVirtualIfNeeded<T, SerializerT, typename std::enable_if_t<dispatch::vrt::VirtualSerializeTraits<T>::has_virtual_serialize>>
template<typename T, typename SerializerT>
struct SerializeVirtualTypeIfNeeded<T, SerializerT, typename std::enable_if_t<dispatch::vrt::VirtualSerializeTraits<T>::has_virtual_serialize>>
template<typename T, typename SerializerT>
struct ReconstructAsVirtualIfNeeded<T, SerializerT, typename std::enable_if_t<dispatch::vrt::VirtualSerializeTraits<T>::has_not_virtual_serialize and not checkpoint::is_footprinter_v<SerializerT>>>
template<typename T, typename SerializerT>
struct ReconstructAsVirtualIfNeeded<T, SerializerT, typename std::enable_if_t<dispatch::vrt::VirtualSerializeTraits<T>::has_not_virtual_serialize and checkpoint::is_footprinter_v<SerializerT>>>
template<typename T>
struct isByteCopyable
struct MemorySerializer
template<typename BufferT>
struct PackerBuffer
template<typename T, typename SerializerT, typename _enabled = void>
struct ReconstructAsVirtualIfNeeded
Do a static trait test on type to check for virtual serializability. If virtually serializable, we need to perform some extra work to register the type, allocate, and construct the proper type. Otherwise, we go through the normal path for allocating memory for T and serializing what the pointer points to.
struct SerdesByteCopy
template<typename T, typename S = checkpoint::SerializerRef<BaseSerializer>>
struct SerializableTraits
struct SerializedInfo
Return of serialize that contains the buffer and size serialized.
template<typename SerT, typename UserTraits = UserTraitHolder<>>
struct SerializerRef
template<typename T>
struct SerializerTraits
template<typename T, typename SerializerT, typename _enabled = void>
struct SerializeVirtualTypeIfNeeded
Do a static trait test on type to check for virtual serializability.
struct Sizer
Sizer serializers for sizing the contents of classes as a preprocessing pass before packing content so a properly sized buffer can be allocated.
template<typename StreamT = std::ostream>
struct StreamPacker
template<typename StreamT = std::istream>
struct StreamUnpacker
template<typename BufferT>
struct UnpackerBuffer

Enums

enum class eSerializationMode: int8_t { None = 0, Unpacking = 1, Packing = 2, Sizing = 3, Footprinting = 4, Invalid = -1 }

Typedefs

using BufferCallbackType = std::function<char*(std::size_t size)>
Callback for user to allocate bytes during serialization.
using SerializedReturnType = std::unique_ptr<SerializedInfo>
Convenience typedef for std::unique_ptr<SerializedInfo>
using SerialSizeType = size_t
using SerialByteType = char
using BufferObtainFnType = std::function<SerialByteType*(SerialSizeType size)>
using SERIALIZE_CONSTRUCT_TAG = dispatch::SERIALIZE_CONSTRUCT_TAG
template<typename BaseT>
using SerializableBase = dispatch::vrt::SerializableBase<BaseT>
template<typename DerivedT, typename BaseT>
using SerializableDerived = dispatch::vrt::SerializableDerived<DerivedT, BaseT>
template<typename U>
using is_footprinter = is_footprinter_impl<std::decay_t<U>>
using Packer = PackerBuffer<buffer::ManagedBuffer>
using PackerUserBuf = PackerBuffer<buffer::UserBuffer>
using PackerIO = PackerBuffer<buffer::IOBuffer>
template<typename S, typename... Traits>
using has_user_traits = typename S::TraitHolder::template has<Traits...>
template<typename S, typename... Traits>
using has_any_user_traits = typename S::TraitHolder::template has_any<Traits...>
template<typename S>
using CopyUserTraits = serializerUserTraits::CopyTraits<typename S::TraitHolder>
using Unpacker = UnpackerBuffer<buffer::UserBuffer>
using UnpackerIO = UnpackerBuffer<buffer::IOBuffer>
template<typename T>
using isDefaultConsType = std::enable_if_t<std::is_default_constructible<T>::value>
template<typename T>
using isNotDefaultConsType = std::enable_if_t<not std::is_default_constructible<T>::value>
template<typename T>
using isReconstructibleType = std::enable_if_t<SerializableTraits<T, void>::is_intrusive_reconstructible>
template<typename T>
using isNonIntReconstructibleType = std::enable_if_t<SerializableTraits<T, void>::is_nonintrusive_reconstructible>
template<typename T>
using isNotReconstructibleType = std::enable_if_t<not SerializableTraits<T, void>::is_reconstructible>
template<typename T>
using isSpecializedReconstructibleType = std::enable_if_t<SerializableTraits<T, void>::is_specialized_reconstructible>
template<typename T>
using isTaggedConstructibleType = std::enable_if_t<SerializableTraits<T, void>::is_tagged_constructible>
template<typename T>
using isNotTaggedConstructibleType = std::enable_if_t<not SerializableTraits<T, void>::is_tagged_constructible>
template<typename T>
using isConstructible = std::enable_if_t<SerializableTraits<T, void>::is_constructible>
template<typename T>
using isNotConstructible = std::enable_if_t<not SerializableTraits<T, void>::is_constructible>
template<typename T>
using isNotCopyConstructible = std::enable_if_t<not std::is_copy_constructible<T>::value>
template<typename T>
using isCopyConstructible = std::enable_if_t<std::is_copy_constructible<T>::value>
template<typename... Traits>
using UserTraitHolder = serializerUserTraits::UnwrapTraits<serializerUserTraits::TraitHolder<Traits...>>

Functions

template<typename T, typename... UserTraits>
auto serialize(T& target, BufferCallbackType fn = nullptr) -> SerializedReturnType
Serialize T into a byte buffer.
template<typename T, typename... UserTraits>
auto deserialize(char* buf, char* object_buf) -> T*
De-serialize and reify T from a byte buffer and corresponding size.
template<typename T, typename... UserTraits>
auto deserialize(char* buf) -> std::unique_ptr<T>
De-serialize and reify T from a byte buffer and corresponding size.
template<typename T, typename... UserTraits>
void deserializeInPlace(char* buf, T* t)
De-serialize and reify T from a byte buffer and corresponding size in-place on the user-provided t.
template<typename T, typename... UserTraits>
auto deserialize(SerializedReturnType&& in) -> std::unique_ptr<T>
Convenience function for de-serializing and reify T directly from in the return value from serialize.
template<typename T, typename... UserTraits>
auto getSize(T& target) -> std::size_t
Get the number of bytes that target requires for serialization.
template<typename T, typename... UserTraits>
auto getMemoryFootprint(T& target, std::size_t size_offset = 0) -> std::size_t
Get memory footprint of target.
template<typename T, typename... UserTraits>
void serializeToFile(T& target, std::string const& file)
Serialize T to file with filename file.
template<typename T, typename... UserTraits>
auto deserializeFromFile(std::string const& file) -> std::unique_ptr<T>
De-serialize and reify T from a file.
template<typename T, typename... UserTraits>
void deserializeInPlaceFromFile(std::string const& file, T* buf)
De-serialize and reify T from a file in place on an existing pointer to T.
template<typename T, typename... UserTraits, typename StreamT>
void serializeToStream(T& target, StreamT& stream)
Serialize T to a stream.
template<typename T, typename... UserTraits, typename StreamT>
auto deserializeFromStream(StreamT& stream) -> std::unique_ptr<T>
De-serialize and reify T from a stream.
template<typename T, typename... UserTraits, typename StreamT>
void deserializeInPlaceFromStream(StreamT& stream, T* buf)
De-serialize and reify T from a stream in place on an existing pointer to T.
template<typename Serializer, typename T, size_t N>
void serialize(Serializer& s, std::array<T, N>& array)
template<typename SerializerT, typename T, typename = std::enable_if_t< checkpoint::is_footprinter_v<SerializerT> >>
void serialize(SerializerT& s, const std::atomic<T>& atomic)
template<typename Serializer, typename Rep, typename Period>
void serialize(Serializer& s, std::chrono::duration<Rep, Period>& d)
template<typename Serializer, typename ContainerT>
auto serializeContainerSize(Serializer& s, ContainerT& cont) -> ContainerT::size_type
template<typename Serializer, typename ContainerT>
auto serializeContainerCapacity(Serializer& s, ContainerT& cont) -> ContainerT::size_type
template<typename Serializer, typename ContainerT>
void serializeContainerElems(Serializer& s, ContainerT& cont)
template<typename Serializer, typename Enum, typename Underlying = std::underlying_type_t<Enum>>
void serializeEnum(Serializer& s, Enum& e)
template<typename SerializerT, typename Res, typename... ArgTypes>
void serialize(SerializerT& s, std::function<Res(ArgTypes...)>& fn)
Serialize function func.
template<typename SerializerT, typename Res, typename... ArgTypes, typename = std::enable_if_t< checkpoint::is_footprinter_v<SerializerT> >>
void serializeFunction(SerializerT& s, std::function<Res(ArgTypes...)>& fn)
template<typename Serializer, typename ContainerT, typename ElmT>
auto deserializeOrderedElems(Serializer& s, ContainerT& cont, typename ContainerT::size_type size, isCopyConstructible<ElmT>* = nullptr) -> std::enable_if_t<not checkpoint::is_footprinter_v<Serializer>, void>
template<typename Serializer, typename ContainerT, typename ElmT>
auto deserializeOrderedElems(Serializer& s, ContainerT& cont, typename ContainerT::size_type size, isNotCopyConstructible<ElmT>* = nullptr) -> std::enable_if_t<not checkpoint::is_footprinter_v<Serializer>, void>
template<typename Serializer, typename ContainerT, typename ElmT>
auto deserializeOrderedElems(Serializer&, ContainerT&, typename ContainerT::size_type) -> std::enable_if_t<checkpoint::is_footprinter_v<Serializer>, void>
template<typename Serializer, typename ContainerT>
void serializeOrderedContainer(Serializer& s, ContainerT& cont)
template<typename Serializer, typename T>
void serialize(Serializer& s, std::list<T>& lst)
template<typename Serializer, typename T>
void serialize(Serializer& s, std::deque<T>& lst)
template<typename Serializer, typename ContainerT, typename ElmT>
auto deserializeEmplaceElems(Serializer& s, ContainerT& cont, typename ContainerT::size_type size) -> std::enable_if_t<not checkpoint::is_footprinter_v<Serializer>, void>
template<typename Serializer, typename ContainerT, typename ElmT>
auto deserializeEmplaceElems(Serializer&, ContainerT&, typename ContainerT::size_type) -> std::enable_if_t<checkpoint::is_footprinter_v<Serializer>, void>
template<typename Serializer, typename ContainerT>
void serializeMapLikeContainer(Serializer& s, ContainerT& cont)
template<typename Serializer, typename T, typename U, typename Comp>
void serialize(Serializer& s, std::map<T, U, Comp>& map)
template<typename Serializer, typename T, typename U, typename Comp>
void serialize(Serializer& s, std::multimap<T, U, Comp>& map)
template<typename Serializer, typename T, typename Comp>
void serialize(Serializer& s, std::set<T, Comp>& set)
template<typename Serializer, typename T, typename Comp>
void serialize(Serializer& s, std::multiset<T, Comp>& set)
template<typename Serializer, typename T, typename U, typename Hash, typename Eq>
void serialize(Serializer& s, std::unordered_map<T, U, Hash, Eq>& map)
template<typename Serializer, typename T, typename U, typename Hash, typename Eq>
void serialize(Serializer& s, std::unordered_multimap<T, U, Hash, Eq>& map)
template<typename Serializer, typename T, typename Hash, typename Eq>
void serialize(Serializer& s, std::unordered_set<T, Hash, Eq>& set)
template<typename Serializer, typename T, typename Hash, typename Eq>
void serialize(Serializer& s, std::unordered_multiset<T, Hash, Eq>& set)
template<typename SerializerT, typename T>
void deserializeOptional(SerializerT& s, std::optional<T>& optional)
template<typename SerializerT, typename T>
void serialize(SerializerT& s, std::optional<T>& optional)
template<typename SerializerT, typename T>
void deserializeQueueElems(SerializerT& s, std::queue<T>& q, typename std::queue<T>::size_type size)
template<typename SerializerT, typename T>
void serializeQueueElems(SerializerT& s, std::queue<T> q)
template<typename SerializerT, typename T, typename = std::enable_if_t< not checkpoint::is_footprinter_v<SerializerT> >>
void serializeQueueLikeContainer(SerializerT& s, std::queue<T>& q)
template<typename Serializer, typename T>
void serialize(Serializer& s, std::queue<T>& q)
template<typename Serializer, typename T>
void serialize(Serializer& s, const std::priority_queue<T>& q)
template<typename Serializer, typename T>
void serialize(Serializer& s, const std::stack<T>& stack)
template<typename SerializerT, typename Q, typename = std::enable_if_t< checkpoint::is_footprinter_v<SerializerT> >>
void serializeQueueLikeContainer(SerializerT& s, const Q& q)
template<typename SerializerT, typename T, typename = std::enable_if_t< checkpoint::is_footprinter_v<SerializerT> >>
void serialize(SerializerT& s, T* ptr)
Serialize raw pointer ptr.
template<typename SerializerT, typename T>
void serializeRawPtr(SerializerT& s, T* ptr)
template<typename SerializerT>
void serializeRawPtr(SerializerT& s, void* ptr)
template<typename SerializerT, typename T, typename = std::enable_if_t< checkpoint::is_footprinter_v<SerializerT> >>
void serialize(SerializerT& s, std::shared_ptr<T>& ptr)
template<typename Serializer>
void serializeStringMeta(Serializer& s, std::string& str)
template<typename Serializer>
void serialize(Serializer& s, std::string& str)
Serialize string str.
template<typename SerializerT, typename = std::enable_if_t< checkpoint::is_footprinter_v<SerializerT> >>
void serialize(SerializerT& s, const std::thread& t)
template<typename Serializer, typename... T, size_t... Idxs>
void tuple_helper(Serializer& s, std::tuple<T...>& tup, std::index_sequence<Idxs...>)
template<typename... T, size_t... Idxs>
void tuple_helper_reconstruct(std::tuple<T...>*& tup, std::index_sequence<Idxs...>)
template<typename Serializer, typename... Args>
void serialize(Serializer& s, std::tuple<Args...>& tuple)
template<typename Serializer, typename T, typename U>
void serialize(Serializer& s, std::pair<T, U>& pair)
template<typename Serializer, typename T, typename Deleter>
void serialize(Serializer& s, std::unique_ptr<T, Deleter>& ptr)
template<typename SerializerT, typename... Args>
void serialize(SerializerT& s, std::variant<Args...>& v)
template<typename SerializerT, typename T, typename VectorAllocator>
auto serializeVectorMeta(SerializerT& s, std::vector<T, VectorAllocator>& vec) -> std::enable_if_t<not checkpoint::is_footprinter_v<SerializerT>, SerialSizeType>
template<typename T, typename VectorAllocator>
void constructVectorData(SerialSizeType const vec_size, std::vector<T, VectorAllocator>& vec, isDefaultConsType<T>* = nullptr)
template<typename T, typename VectorAllocator>
void constructVectorData(SerialSizeType const vec_size, std::vector<T, VectorAllocator>& vec, isNotDefaultConsType<T>* = nullptr, isCopyConstructible<T>* = nullptr)
template<typename T, typename VectorAllocator>
void constructVectorData(SerialSizeType const vec_size, std::vector<T, VectorAllocator>& vec, isNotDefaultConsType<T>* = nullptr, isNotCopyConstructible<T>* = nullptr)
template<typename SerializerT, typename T, typename VectorAllocator>
auto serialize(SerializerT& s, std::vector<T, VectorAllocator>& vec) -> std::enable_if_t<not checkpoint::is_footprinter_v<SerializerT>, void>
template<typename SerializerT, typename VectorAllocator>
auto serialize(SerializerT& s, std::vector<bool, VectorAllocator>& vec) -> std::enable_if_t<not checkpoint::is_footprinter_v<SerializerT>, void>
template<typename SerializerT, typename T, typename VectorAllocator>
auto serialize(SerializerT& s, std::vector<T, VectorAllocator>& vec) -> std::enable_if_t<checkpoint::is_footprinter_v<SerializerT>, void>
template<typename SerializerT, typename VectorAllocator>
auto serialize(SerializerT& s, std::vector<bool, VectorAllocator>& vec) -> std::enable_if_t<checkpoint::is_footprinter_v<SerializerT>, void>
template<typename Serializer, typename T>
auto operator|(Serializer& s, T& target) -> Serializer&
template<typename ObjT, typename... SerializerTs>
void instantiateObjSerializer()
template<typename SerializerT, typename T>
void reconstructPointedToObjectIfNeeded(SerializerT& s, T*& target)
Allocate and construct memory for a pointer with type T.
template<typename T>
void reconstruct(T)

Variables

template<typename U>
static const bool is_footprinter_v constexpr
template<typename S, typename... Traits>
bool has_user_traits_v constexpr
template<typename S, typename... Traits>
bool has_any_user_traits_v constexpr

Enum documentation

Typedef documentation

using checkpoint::BufferCallbackType = std::function<char*(std::size_t size)>

Callback for user to allocate bytes during serialization.

using checkpoint::SerializedReturnType = std::unique_ptr<SerializedInfo>

Convenience typedef for std::unique_ptr<SerializedInfo>

using checkpoint::SerialSizeType = size_t

using checkpoint::SerialByteType = char

template<typename DerivedT, typename BaseT>
using checkpoint::SerializableDerived = dispatch::vrt::SerializableDerived<DerivedT, BaseT>

template<typename U>
using checkpoint::is_footprinter = is_footprinter_impl<std::decay_t<U>>

template<typename S, typename... Traits>
using checkpoint::has_user_traits = typename S::TraitHolder::template has<Traits...>

template<typename S, typename... Traits>
using checkpoint::has_any_user_traits = typename S::TraitHolder::template has_any<Traits...>

template<typename S>
using checkpoint::CopyUserTraits = serializerUserTraits::CopyTraits<typename S::TraitHolder>

template<typename T>
using checkpoint::isDefaultConsType = std::enable_if_t<std::is_default_constructible<T>::value>

template<typename T>
using checkpoint::isNotDefaultConsType = std::enable_if_t<not std::is_default_constructible<T>::value>

template<typename T>
using checkpoint::isReconstructibleType = std::enable_if_t<SerializableTraits<T, void>::is_intrusive_reconstructible>

template<typename T>
using checkpoint::isNonIntReconstructibleType = std::enable_if_t<SerializableTraits<T, void>::is_nonintrusive_reconstructible>

template<typename T>
using checkpoint::isNotReconstructibleType = std::enable_if_t<not SerializableTraits<T, void>::is_reconstructible>

template<typename T>
using checkpoint::isSpecializedReconstructibleType = std::enable_if_t<SerializableTraits<T, void>::is_specialized_reconstructible>

template<typename T>
using checkpoint::isTaggedConstructibleType = std::enable_if_t<SerializableTraits<T, void>::is_tagged_constructible>

template<typename T>
using checkpoint::isNotTaggedConstructibleType = std::enable_if_t<not SerializableTraits<T, void>::is_tagged_constructible>

template<typename T>
using checkpoint::isConstructible = std::enable_if_t<SerializableTraits<T, void>::is_constructible>

template<typename T>
using checkpoint::isNotConstructible = std::enable_if_t<not SerializableTraits<T, void>::is_constructible>

template<typename T>
using checkpoint::isNotCopyConstructible = std::enable_if_t<not std::is_copy_constructible<T>::value>

template<typename T>
using checkpoint::isCopyConstructible = std::enable_if_t<std::is_copy_constructible<T>::value>

Function documentation

template<typename T, typename... UserTraits>
SerializedReturnType checkpoint::serialize(T& target, BufferCallbackType fn = nullptr)

Serialize T into a byte buffer.

Parameters
target in the T to serialize
fn in (optional) callback to supply buffer for to allow user allocation of the produced byte buffer. The callback will be passed the number of bytes required and return a char* to a buffer of at least that many bytes.
Returns a std::unique_ptr to a SerializedInfo containing the buffer with serialized data and the size of the buffer

Serializes an object recursively by invoking the serialize functions/methods recursively.

template<typename T, typename... UserTraits>
T* checkpoint::deserialize(char* buf, char* object_buf)

De-serialize and reify T from a byte buffer and corresponding size.

Parameters
buf in the buffer containing the bytes to reify T
object_buf in (optional) buffer containing bytes allocated with sufficient size for T. If this buffer != null, the caller is responsible for deallocating the buffer. If it is not passed, the system will allocate a buffer that must be de-allocated with delete
Returns a pointer to the newly reified T based on bytes in buf

De-serializes an object recursively by first invoking the reconstruction strategy and then serialize functions/methods recursively to rebuild the state of the object as serialized. During reconstruction, based on trait detection, T will either be default constructed on user_buf (or a system allocated buffer) or reconstructed based on a user-defined reconstruct method. If user_buf is not passed, the returned object point must be deallocated with delete

template<typename T, typename... UserTraits>
std::unique_ptr<T> checkpoint::deserialize(char* buf)

De-serialize and reify T from a byte buffer and corresponding size.

Parameters
buf in the buffer containing the bytes to reify T
Returns a unique pointer to the newly reified T based on bytes in buf

De-serializes an object recursively by first invoking the reconstruction strategy and then serialize functions/methods recursively to rebuild the state of the object as serialized. During reconstruction, based on trait detection, T will either be default constructed or reconstructed based on a user-defined reconstruct method.

template<typename T, typename... UserTraits>
void checkpoint::deserializeInPlace(char* buf, T* t)

De-serialize and reify T from a byte buffer and corresponding size in-place on the user-provided t.

Parameters
buf in the buffer containing the bytes to reify T
in a valid pointer to a T that has been user-allocated and constructed

Note: the other form of deserialize will either reconstruct to default construct T in-place. This overload will not allocate or construct T

template<typename T, typename... UserTraits>
std::unique_ptr<T> checkpoint::deserialize(SerializedReturnType&& in)

Convenience function for de-serializing and reify T directly from in the return value from serialize.

Parameters
in in the buffer and size combo returned from serialize
Returns a unique pointer to T that must be deallocated

template<typename T, typename... UserTraits>
std::size_t checkpoint::getSize(T& target)

Get the number of bytes that target requires for serialization.

Parameters
target in reference to T to size
Returns number of bytes for the target

template<typename T, typename... UserTraits>
std::size_t checkpoint::getMemoryFootprint(T& target, std::size_t size_offset = 0)

Get memory footprint of target.

Parameters
target in reference to T to measure footprint
size_offset in add an arbitrary size_offset to the footprint
Returns memory footprint of the target

Calculates memory footprint for both serializable and non-serializable objects. Uses serialize functions/methods recursively when they are available. For non-serializable objects, simplified footprinting is performed by just applying 'sizeof' operator (note: this means that complex objects will not be traversed).

template<typename T, typename... UserTraits>
void checkpoint::serializeToFile(T& target, std::string const& file)

Serialize T to file with filename file.

Parameters
target in the T to serialize
file in name of the file to create

Byte-serializes T to file, truncating file if it already exists. If any error occurs while opening/closing/mapping the file, std::runtime_error will be thrown with an appropriate error message containing the corresponding errno.

template<typename T, typename... UserTraits>
std::unique_ptr<T> checkpoint::deserializeFromFile(std::string const& file)

De-serialize and reify T from a file.

Parameters
file in the filename to read with bytes for T
Returns unique pointer to the new object T

De-serializes an object recursively by first invoking the reconstruction strategy and then serialize functions/methods recursively to rebuild the state of the object as serialized. During reconstruction, based on trait detection, T will either be default constructed or reconstructed based on a user-defined reconstruct method.

template<typename T, typename... UserTraits>
void checkpoint::deserializeInPlaceFromFile(std::string const& file, T* buf)

De-serialize and reify T from a file in place on an existing pointer to T.

Parameters
file in the filename to read with bytes for T
buf

De-serializes an object recursively by invoking the serialize functions/methods recursively to rebuild the state of the object as serialized.

template<typename T, typename... UserTraits, typename StreamT>
void checkpoint::serializeToStream(T& target, StreamT& stream)

Serialize T to a stream.

Parameters
target in the T to serialize
stream in to serialize into, with tellp and write functions.

Byte-serializes T to stream. Handling of any errors during writing to the stream will be handled by the stream itself, e.g. any exceptions or status bits to check will depend on stream type.

template<typename T, typename... UserTraits, typename StreamT>
std::unique_ptr<T> checkpoint::deserializeFromStream(StreamT& stream)

De-serialize and reify T from a stream.

Parameters
stream in the stream to read with bytes for T, with tellg and read functions
Returns unique pointer to the new object T

De-serializes an object recursively by first invoking the reconstruction strategy and then serialize functions/methods recursively to rebuild the state of the object as serialized. During reconstruction, based on trait detection, T will either be default constructed or reconstructed based on a user-defined reconstruct method.

template<typename T, typename... UserTraits, typename StreamT>
void checkpoint::deserializeInPlaceFromStream(StreamT& stream, T* buf)

De-serialize and reify T from a stream in place on an existing pointer to T.

Parameters
stream in the stream to read with bytes for T, with tellg and read functions
buf

De-serializes an object recursively by invoking the serialize functions/methods recursively to rebuild the state of the object as serialized.

template<typename Serializer, typename T, size_t N>
void checkpoint::serialize(Serializer& s, std::array<T, N>& array)

template<typename SerializerT, typename T, typename = std::enable_if_t< checkpoint::is_footprinter_v<SerializerT> >>
void checkpoint::serialize(SerializerT& s, const std::atomic<T>& atomic)

template<typename Serializer, typename Rep, typename Period>
void checkpoint::serialize(Serializer& s, std::chrono::duration<Rep, Period>& d)

template<typename Serializer, typename ContainerT>
ContainerT::size_type checkpoint::serializeContainerSize(Serializer& s, ContainerT& cont)

template<typename Serializer, typename ContainerT>
ContainerT::size_type checkpoint::serializeContainerCapacity(Serializer& s, ContainerT& cont)

template<typename Serializer, typename ContainerT>
void checkpoint::serializeContainerElems(Serializer& s, ContainerT& cont)

template<typename Serializer, typename Enum, typename Underlying = std::underlying_type_t<Enum>>
void checkpoint::serializeEnum(Serializer& s, Enum& e)

template<typename SerializerT, typename Res, typename... ArgTypes>
void checkpoint::serialize(SerializerT& s, std::function<Res(ArgTypes...)>& fn)

Serialize function func.

Only footprinting mode is supported at the moment.

template<typename SerializerT, typename Res, typename... ArgTypes, typename = std::enable_if_t< checkpoint::is_footprinter_v<SerializerT> >>
void checkpoint::serializeFunction(SerializerT& s, std::function<Res(ArgTypes...)>& fn)

template<typename Serializer, typename ContainerT, typename ElmT>
std::enable_if_t<not checkpoint::is_footprinter_v<Serializer>, void> checkpoint::deserializeOrderedElems(Serializer& s, ContainerT& cont, typename ContainerT::size_type size, isCopyConstructible<ElmT>* = nullptr)

template<typename Serializer, typename ContainerT, typename ElmT>
std::enable_if_t<not checkpoint::is_footprinter_v<Serializer>, void> checkpoint::deserializeOrderedElems(Serializer& s, ContainerT& cont, typename ContainerT::size_type size, isNotCopyConstructible<ElmT>* = nullptr)

template<typename Serializer, typename ContainerT, typename ElmT>
std::enable_if_t<checkpoint::is_footprinter_v<Serializer>, void> checkpoint::deserializeOrderedElems(Serializer&, ContainerT&, typename ContainerT::size_type)

template<typename Serializer, typename ContainerT>
void checkpoint::serializeOrderedContainer(Serializer& s, ContainerT& cont)

template<typename Serializer, typename T>
void checkpoint::serialize(Serializer& s, std::list<T>& lst)

template<typename Serializer, typename T>
void checkpoint::serialize(Serializer& s, std::deque<T>& lst)

template<typename Serializer, typename ContainerT, typename ElmT>
std::enable_if_t<not checkpoint::is_footprinter_v<Serializer>, void> checkpoint::deserializeEmplaceElems(Serializer& s, ContainerT& cont, typename ContainerT::size_type size)

template<typename Serializer, typename ContainerT, typename ElmT>
std::enable_if_t<checkpoint::is_footprinter_v<Serializer>, void> checkpoint::deserializeEmplaceElems(Serializer&, ContainerT&, typename ContainerT::size_type)

template<typename Serializer, typename ContainerT>
void checkpoint::serializeMapLikeContainer(Serializer& s, ContainerT& cont)

template<typename Serializer, typename T, typename U, typename Comp>
void checkpoint::serialize(Serializer& s, std::map<T, U, Comp>& map)

template<typename Serializer, typename T, typename U, typename Comp>
void checkpoint::serialize(Serializer& s, std::multimap<T, U, Comp>& map)

template<typename Serializer, typename T, typename Comp>
void checkpoint::serialize(Serializer& s, std::set<T, Comp>& set)

template<typename Serializer, typename T, typename Comp>
void checkpoint::serialize(Serializer& s, std::multiset<T, Comp>& set)

template<typename Serializer, typename T, typename U, typename Hash, typename Eq>
void checkpoint::serialize(Serializer& s, std::unordered_map<T, U, Hash, Eq>& map)

template<typename Serializer, typename T, typename U, typename Hash, typename Eq>
void checkpoint::serialize(Serializer& s, std::unordered_multimap<T, U, Hash, Eq>& map)

template<typename Serializer, typename T, typename Hash, typename Eq>
void checkpoint::serialize(Serializer& s, std::unordered_set<T, Hash, Eq>& set)

template<typename Serializer, typename T, typename Hash, typename Eq>
void checkpoint::serialize(Serializer& s, std::unordered_multiset<T, Hash, Eq>& set)

template<typename SerializerT, typename T>
void checkpoint::deserializeOptional(SerializerT& s, std::optional<T>& optional)

template<typename SerializerT, typename T>
void checkpoint::serialize(SerializerT& s, std::optional<T>& optional)

template<typename SerializerT, typename T>
void checkpoint::deserializeQueueElems(SerializerT& s, std::queue<T>& q, typename std::queue<T>::size_type size)

template<typename SerializerT, typename T>
void checkpoint::serializeQueueElems(SerializerT& s, std::queue<T> q)

template<typename SerializerT, typename T, typename = std::enable_if_t< not checkpoint::is_footprinter_v<SerializerT> >>
void checkpoint::serializeQueueLikeContainer(SerializerT& s, std::queue<T>& q)

template<typename Serializer, typename T>
void checkpoint::serialize(Serializer& s, std::queue<T>& q)

template<typename Serializer, typename T>
void checkpoint::serialize(Serializer& s, const std::priority_queue<T>& q)

template<typename Serializer, typename T>
void checkpoint::serialize(Serializer& s, const std::stack<T>& stack)

template<typename SerializerT, typename Q, typename = std::enable_if_t< checkpoint::is_footprinter_v<SerializerT> >>
void checkpoint::serializeQueueLikeContainer(SerializerT& s, const Q& q)

template<typename SerializerT, typename T, typename = std::enable_if_t< checkpoint::is_footprinter_v<SerializerT> >>
void checkpoint::serialize(SerializerT& s, T* ptr)

Serialize raw pointer ptr.

Parameters
s
ptr in pointer to serialize

Only footprinting mode is supported at the moment. Counts the pointer size and follows it (note that it doesn't work correctly for C-style arrays!).

template<typename SerializerT, typename T>
void checkpoint::serializeRawPtr(SerializerT& s, T* ptr)

template<typename SerializerT>
void checkpoint::serializeRawPtr(SerializerT& s, void* ptr)

Note: do not follow void pointer.

template<typename SerializerT, typename T, typename = std::enable_if_t< checkpoint::is_footprinter_v<SerializerT> >>
void checkpoint::serialize(SerializerT& s, std::shared_ptr<T>& ptr)

template<typename Serializer>
void checkpoint::serializeStringMeta(Serializer& s, std::string& str)

template<typename Serializer>
void checkpoint::serialize(Serializer& s, std::string& str)

Serialize string str.

Parameters
s
str in string to serialize

Resizes a string to its actual size and serializes it. Note: footprinting mode does not detect small string optimization, so a limited overcount is possible.

template<typename SerializerT, typename = std::enable_if_t< checkpoint::is_footprinter_v<SerializerT> >>
void checkpoint::serialize(SerializerT& s, const std::thread& t)

template<typename Serializer, typename... T, size_t... Idxs>
void checkpoint::tuple_helper(Serializer& s, std::tuple<T...>& tup, std::index_sequence<Idxs...>)

template<typename... T, size_t... Idxs>
void checkpoint::tuple_helper_reconstruct(std::tuple<T...>*& tup, std::index_sequence<Idxs...>)

template<typename Serializer, typename... Args>
void checkpoint::serialize(Serializer& s, std::tuple<Args...>& tuple)

template<typename Serializer, typename T, typename U>
void checkpoint::serialize(Serializer& s, std::pair<T, U>& pair)

template<typename Serializer, typename T, typename Deleter>
void checkpoint::serialize(Serializer& s, std::unique_ptr<T, Deleter>& ptr)

template<typename SerializerT, typename... Args>
void checkpoint::serialize(SerializerT& s, std::variant<Args...>& v)

template<typename SerializerT, typename T, typename VectorAllocator>
std::enable_if_t<not checkpoint::is_footprinter_v<SerializerT>, SerialSizeType> checkpoint::serializeVectorMeta(SerializerT& s, std::vector<T, VectorAllocator>& vec)

template<typename T, typename VectorAllocator>
void checkpoint::constructVectorData(SerialSizeType const vec_size, std::vector<T, VectorAllocator>& vec, isDefaultConsType<T>* = nullptr)

template<typename T, typename VectorAllocator>
void checkpoint::constructVectorData(SerialSizeType const vec_size, std::vector<T, VectorAllocator>& vec, isNotDefaultConsType<T>* = nullptr, isCopyConstructible<T>* = nullptr)

template<typename T, typename VectorAllocator>
void checkpoint::constructVectorData(SerialSizeType const vec_size, std::vector<T, VectorAllocator>& vec, isNotDefaultConsType<T>* = nullptr, isNotCopyConstructible<T>* = nullptr)

template<typename SerializerT, typename T, typename VectorAllocator>
std::enable_if_t<not checkpoint::is_footprinter_v<SerializerT>, void> checkpoint::serialize(SerializerT& s, std::vector<T, VectorAllocator>& vec)

template<typename SerializerT, typename VectorAllocator>
std::enable_if_t<not checkpoint::is_footprinter_v<SerializerT>, void> checkpoint::serialize(SerializerT& s, std::vector<bool, VectorAllocator>& vec)

template<typename SerializerT, typename T, typename VectorAllocator>
std::enable_if_t<checkpoint::is_footprinter_v<SerializerT>, void> checkpoint::serialize(SerializerT& s, std::vector<T, VectorAllocator>& vec)

template<typename SerializerT, typename VectorAllocator>
std::enable_if_t<checkpoint::is_footprinter_v<SerializerT>, void> checkpoint::serialize(SerializerT& s, std::vector<bool, VectorAllocator>& vec)

template<typename Serializer, typename T>
Serializer& checkpoint::operator|(Serializer& s, T& target)

template<typename ObjT, typename... SerializerTs>
void checkpoint::instantiateObjSerializer()

template<typename SerializerT, typename T>
void checkpoint::reconstructPointedToObjectIfNeeded(SerializerT& s, T*& target)

Allocate and construct memory for a pointer with type T.

Parameters
in the serializer
target in a reference to a pointer to the target object

This function automatically handles allocating and constructing the right type for virtually serialized pointers or non-virtual static allocation and construction.

An example of how to use this to properly serialize a std::shared_ptr<T>:

template <typename t>=""> struct X { std::shared_ptr<T> a;

template <typename serializert>=""> void serialize(SerializerT& s) { T* raw = elm.get(); checkpoint::reconstructPointedToObjectIfNeeded(s, raw); if (s.isUnpacking()) { a = std::shared_ptr<T>(raw); } s | *a; } };

template<typename T>
void checkpoint::reconstruct(T)

Variable documentation

template<typename U>
static const bool checkpoint::is_footprinter_v constexpr

template<typename S, typename... Traits>
bool checkpoint::has_user_traits_v constexpr

template<typename S, typename... Traits>
bool checkpoint::has_any_user_traits_v constexpr