cereal
A C++11 library for serialization
Classes | Public Member Functions | Static Public Member Functions | List of all members
cereal::detail::OutputBindingCreator< Archive, T > Struct Template Reference

Creates a binding (map entry) between an output archive type and a polymorphic type. More...

#include </home/shane/workspace/cereal/include/cereal/details/polymorphic_impl.hpp>

Classes

class  PolymorphicSharedPointerWrapper
 Holds a properly typed shared_ptr to the polymorphic type. More...
 

Public Member Functions

 OutputBindingCreator ()
 Initialize the binding.
 

Static Public Member Functions

static void writeMetadata (Archive &ar)
 Writes appropriate metadata to the archive for this polymorphic type.
 
static void savePolymorphicSharedPtr (Archive &ar, T const *dptr, std::true_type)
 Does the actual work of saving a polymorphic shared_ptr. More...
 
static void savePolymorphicSharedPtr (Archive &ar, T const *dptr, std::false_type)
 Does the actual work of saving a polymorphic shared_ptr. More...
 

Detailed Description

template<class Archive, class T>
struct cereal::detail::OutputBindingCreator< Archive, T >

Creates a binding (map entry) between an output archive type and a polymorphic type.

Bindings are made when types are registered, assuming that at least one archive has already been registered. When this struct is created, it will insert (at run time) an entry into a map that properly handles casting for serializing polymorphic objects

Member Function Documentation

◆ savePolymorphicSharedPtr() [1/2]

template<class Archive , class T >
static void cereal::detail::OutputBindingCreator< Archive, T >::savePolymorphicSharedPtr ( Archive &  ar,
T const *  dptr,
std::false_type   
)
inlinestatic

Does the actual work of saving a polymorphic shared_ptr.

This function will properly create a shared_ptr from the void * that is passed in before passing it to the archive for serialization.

This version is for types that do not inherit from std::enable_shared_from_this.

Parameters
arThe archive to serialize to
dptrPointer to the actual data held by the shared_ptr

◆ savePolymorphicSharedPtr() [2/2]

template<class Archive , class T >
static void cereal::detail::OutputBindingCreator< Archive, T >::savePolymorphicSharedPtr ( Archive &  ar,
T const *  dptr,
std::true_type   
)
inlinestatic

Does the actual work of saving a polymorphic shared_ptr.

This function will properly create a shared_ptr from the void * that is passed in before passing it to the archive for serialization.

In addition, this will also preserve the state of any internal enable_shared_from_this mechanisms

Parameters
arThe archive to serialize to
dptrPointer to the actual data held by the shared_ptr

The documentation for this struct was generated from the following file: