NDDEM
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
cereal::InputArchive< ArchiveType, Flags > Class Template Reference

The base input archive class. More...

#include <cereal.hpp>

+ Inheritance diagram for cereal::InputArchive< ArchiveType, Flags >:

Public Member Functions

 InputArchive (ArchiveType *const derived)
 Construct the output archive. More...
 
InputArchiveoperator= (InputArchive const &)=delete
 
template<class ... Types>
ArchiveType & operator() (Types &&... args)
 Serializes all passed in data. More...
 
void serializeDeferments ()
 Serializes any data marked for deferment using defer. More...
 
std::shared_ptr< void > getSharedPointer (std::uint32_t const id)
 Retrieves a shared pointer given a unique key for it. More...
 
void registerSharedPointer (std::uint32_t const id, std::shared_ptr< void > ptr)
 Registers a shared pointer to its unique identifier. More...
 
std::string getPolymorphicName (std::uint32_t const id)
 Retrieves the string for a polymorphic type given a unique key for it. More...
 
void registerPolymorphicName (std::uint32_t const id, std::string const &name)
 Registers a polymorphic name string to its unique identifier. More...
 
- Public Member Functions inherited from cereal::detail::InputArchiveBase
 InputArchiveBase ()=default
 
 InputArchiveBase (InputArchiveBase &&) CEREAL_NOEXCEPT
 
InputArchiveBaseoperator= (InputArchiveBase &&) CEREAL_NOEXCEPT
 
virtual ~InputArchiveBase () CEREAL_NOEXCEPT=default
 

Private Member Functions

template<class T >
void process (T &&head)
 Serializes data after calling prologue, then calls epilogue. More...
 
template<class T , class ... Other>
void process (T &&head, Other &&... tail)
 Unwinds to process all data. More...
 
template<class T >
ArchiveType & processImpl (virtual_base_class< T > &b)
 Serialization of a virtual_base_class wrapper. More...
 
template<class T >
ArchiveType & processImpl (base_class< T > &b)
 Serialization of a base_class wrapper. More...
 
template<class T >
ArchiveType & processImpl (DeferredData< T > const &d)
 
template<class T , PROCESS_IF(member_serialize) >
ArchiveType & processImpl (T &t)
 Member serialization. More...
 
template<class T , PROCESS_IF(non_member_serialize) >
ArchiveType & processImpl (T &t)
 Non member serialization. More...
 
template<class T , PROCESS_IF(member_load) >
ArchiveType & processImpl (T &t)
 Member split (load) More...
 
template<class T , PROCESS_IF(non_member_load) >
ArchiveType & processImpl (T &t)
 Non member split (load) More...
 
template<class T , PROCESS_IF(member_load_minimal) >
ArchiveType & processImpl (T &t)
 Member split (load_minimal) More...
 
template<class T , PROCESS_IF(non_member_load_minimal) >
ArchiveType & processImpl (T &t)
 Non member split (load_minimal) More...
 
template<class T , traits::EnableIf<(Flags &AllowEmptyClassElision), !traits::is_input_serializable< T, ArchiveType >::value, std::is_empty< T >::value > = traits::sfinae>
ArchiveType & processImpl (T const &)
 Empty class specialization. More...
 
template<class T , traits::EnableIf< traits::has_invalid_input_versioning< T, ArchiveType >::value||(!traits::is_input_serializable< T, ArchiveType >::value &&(!(Flags &AllowEmptyClassElision)||((Flags &AllowEmptyClassElision) &&!std::is_empty< T >::value)))> = traits::sfinae>
ArchiveType & processImpl (T const &)
 No matching serialization. More...
 
template<class T >
std::uint32_t loadClassVersion ()
 Registers a class version with the archive and serializes it if necessary. More...
 
template<class T , PROCESS_IF(member_versioned_serialize) >
ArchiveType & processImpl (T &t)
 Member serialization. More...
 
template<class T , PROCESS_IF(non_member_versioned_serialize) >
ArchiveType & processImpl (T &t)
 Non member serialization. More...
 
template<class T , PROCESS_IF(member_versioned_load) >
ArchiveType & processImpl (T &t)
 Member split (load) More...
 
template<class T , PROCESS_IF(non_member_versioned_load) >
ArchiveType & processImpl (T &t)
 Non member split (load) More...
 
template<class T , PROCESS_IF(member_versioned_load_minimal) >
ArchiveType & processImpl (T &t)
 Member split (load_minimal) More...
 
template<class T , PROCESS_IF(non_member_versioned_load_minimal) >
ArchiveType & processImpl (T &t)
 Non member split (load_minimal) More...
 

Private Attributes

std::vector< std::function< void(void)> > itsDeferments
 
ArchiveType *const self
 
std::unordered_set< traits::detail::base_class_id, traits::detail::base_class_id_hashitsBaseClassSet
 A set of all base classes that have been serialized. More...
 
std::unordered_map< std::uint32_t, std::shared_ptr< void > > itsSharedPointerMap
 Maps from pointer ids to metadata. More...
 
std::unordered_map< std::uint32_t, std::string > itsPolymorphicTypeMap
 Maps from name ids to names. More...
 
std::unordered_map< std::size_t, std::uint32_titsVersionedTypes
 Maps from type hash codes to version numbers. More...
 

Friends

template<class A , class B , bool C, bool D, bool E, bool F>
struct detail::Construct
 Befriend for versioning in load_and_construct. More...
 

Boost Transition Layer

Functionality that mirrors the syntax for Boost. This is useful if you are transitioning a large project from Boost to cereal. The preferred interface for cereal is using operator().

using is_loading = std::true_type
 Indicates this archive is intended for loading. More...
 
using is_saving = std::false_type
 Indicates this archive is not intended for saving. More...
 
template<class T >
ArchiveType & operator& (T &&arg)
 Serializes passed in data. More...
 
template<class T >
ArchiveType & operator>> (T &&arg)
 Serializes passed in data. More...
 

Detailed Description

template<class ArchiveType, std::uint32_t Flags = 0>
class cereal::InputArchive< ArchiveType, Flags >

The base input archive class.

This is the base input archive for all input archives. If you create a custom archive class, it should derive from this, passing itself as a template parameter for the ArchiveType.

The base class provides all of the functionality necessary to properly forward data to the correct serialization functions.

Individual archives should use a combination of prologue and epilogue functions together with specializations of serialize, save, and load to alter the functionality of their serialization.

Template Parameters
ArchiveTypeThe archive type that derives from InputArchive
FlagsFlags to control advanced functionality. See the Flags enum for more information.

Member Typedef Documentation

◆ is_loading

template<class ArchiveType , std::uint32_t Flags = 0>
using cereal::InputArchive< ArchiveType, Flags >::is_loading = std::true_type

Indicates this archive is intended for loading.

This ensures compatibility with boost archive types. If you are transitioning from boost, you can check this value within a member or external serialize function (i.e., Archive::is_loading::value) to enable behavior specific to loading, until you can transition to split save/load or save_minimal/load_minimal functions

◆ is_saving

template<class ArchiveType , std::uint32_t Flags = 0>
using cereal::InputArchive< ArchiveType, Flags >::is_saving = std::false_type

Indicates this archive is not intended for saving.

This ensures compatibility with boost archive types. If you are transitioning from boost, you can check this value within a member or external serialize function (i.e., Archive::is_saving::value) to disable behavior specific to loading, until you can transition to split save/load or save_minimal/load_minimal functions

Constructor & Destructor Documentation

◆ InputArchive()

template<class ArchiveType , std::uint32_t Flags = 0>
cereal::InputArchive< ArchiveType, Flags >::InputArchive ( ArchiveType *const  derived)
inline

Construct the output archive.

Parameters
derivedA pointer to the derived ArchiveType (pass this from the derived archive)

Member Function Documentation

◆ getPolymorphicName()

template<class ArchiveType , std::uint32_t Flags = 0>
std::string cereal::InputArchive< ArchiveType, Flags >::getPolymorphicName ( std::uint32_t const  id)
inline

Retrieves the string for a polymorphic type given a unique key for it.

This is used to retrieve a string previously registered during a polymorphic load.

◆ getSharedPointer()

template<class ArchiveType , std::uint32_t Flags = 0>
std::shared_ptr<void> cereal::InputArchive< ArchiveType, Flags >::getSharedPointer ( std::uint32_t const  id)
inline

Retrieves a shared pointer given a unique key for it.

This is used to retrieve a previously registered shared_ptr which has already been loaded.

◆ loadClassVersion()

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T >
std::uint32_t cereal::InputArchive< ArchiveType, Flags >::loadClassVersion ( )
inlineprivate

Registers a class version with the archive and serializes it if necessary.

If this is the first time this class has been serialized, we will record its version number and serialize that.

Template Parameters
TThe type of the class being serialized

◆ operator&()

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T >
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::operator& ( T &&  arg)
inline

Serializes passed in data.

This is a boost compatability layer and is not the preferred way of using cereal. If you are transitioning from boost, use this until you can transition to the operator() overload

◆ operator()()

template<class ArchiveType , std::uint32_t Flags = 0>
template<class ... Types>
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::operator() ( Types &&...  args)
inline

Serializes all passed in data.

This is the primary interface for serializing data with an archive

◆ operator=()

template<class ArchiveType , std::uint32_t Flags = 0>
InputArchive& cereal::InputArchive< ArchiveType, Flags >::operator= ( InputArchive< ArchiveType, Flags > const )
delete

◆ operator>>()

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T >
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::operator>> ( T &&  arg)
inline

Serializes passed in data.

This is a boost compatability layer and is not the preferred way of using cereal. If you are transitioning from boost, use this until you can transition to the operator() overload

◆ process() [1/2]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T >
void cereal::InputArchive< ArchiveType, Flags >::process ( T &&  head)
inlineprivate

Serializes data after calling prologue, then calls epilogue.

◆ process() [2/2]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T , class ... Other>
void cereal::InputArchive< ArchiveType, Flags >::process ( T &&  head,
Other &&...  tail 
)
inlineprivate

Unwinds to process all data.

◆ processImpl() [1/17]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T >
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::processImpl ( base_class< T > &  b)
inlineprivate

Serialization of a base_class wrapper.

See also
base_class

◆ processImpl() [2/17]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T >
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::processImpl ( DeferredData< T > const d)
inlineprivate

◆ processImpl() [3/17]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T , PROCESS_IF(member_serialize) >
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::processImpl ( T &  t)
inlineprivate

Member serialization.

◆ processImpl() [4/17]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T , PROCESS_IF(non_member_serialize) >
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::processImpl ( T &  t)
inlineprivate

Non member serialization.

◆ processImpl() [5/17]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T , PROCESS_IF(member_load) >
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::processImpl ( T &  t)
inlineprivate

Member split (load)

◆ processImpl() [6/17]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T , PROCESS_IF(non_member_load) >
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::processImpl ( T &  t)
inlineprivate

Non member split (load)

◆ processImpl() [7/17]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T , PROCESS_IF(member_load_minimal) >
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::processImpl ( T &  t)
inlineprivate

Member split (load_minimal)

◆ processImpl() [8/17]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T , PROCESS_IF(non_member_load_minimal) >
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::processImpl ( T &  t)
inlineprivate

Non member split (load_minimal)

◆ processImpl() [9/17]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T , PROCESS_IF(member_versioned_serialize) >
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::processImpl ( T &  t)
inlineprivate

Member serialization.

Versioning implementation

◆ processImpl() [10/17]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T , PROCESS_IF(non_member_versioned_serialize) >
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::processImpl ( T &  t)
inlineprivate

Non member serialization.

Versioning implementation

◆ processImpl() [11/17]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T , PROCESS_IF(member_versioned_load) >
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::processImpl ( T &  t)
inlineprivate

Member split (load)

Versioning implementation

◆ processImpl() [12/17]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T , PROCESS_IF(non_member_versioned_load) >
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::processImpl ( T &  t)
inlineprivate

Non member split (load)

Versioning implementation

◆ processImpl() [13/17]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T , PROCESS_IF(member_versioned_load_minimal) >
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::processImpl ( T &  t)
inlineprivate

Member split (load_minimal)

Versioning implementation

◆ processImpl() [14/17]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T , PROCESS_IF(non_member_versioned_load_minimal) >
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::processImpl ( T &  t)
inlineprivate

Non member split (load_minimal)

Versioning implementation

◆ processImpl() [15/17]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T , traits::EnableIf<(Flags &AllowEmptyClassElision), !traits::is_input_serializable< T, ArchiveType >::value, std::is_empty< T >::value > = traits::sfinae>
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::processImpl ( T const )
inlineprivate

Empty class specialization.

◆ processImpl() [16/17]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T , traits::EnableIf< traits::has_invalid_input_versioning< T, ArchiveType >::value||(!traits::is_input_serializable< T, ArchiveType >::value &&(!(Flags &AllowEmptyClassElision)||((Flags &AllowEmptyClassElision) &&!std::is_empty< T >::value)))> = traits::sfinae>
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::processImpl ( T const )
inlineprivate

No matching serialization.

Invalid if we have invalid input versioning or we are not input serializable, and either don't allow empty class ellision or allow it but are not serializing an empty class

◆ processImpl() [17/17]

template<class ArchiveType , std::uint32_t Flags = 0>
template<class T >
ArchiveType& cereal::InputArchive< ArchiveType, Flags >::processImpl ( virtual_base_class< T > &  b)
inlineprivate

Serialization of a virtual_base_class wrapper.

See also
virtual_base_class

◆ registerPolymorphicName()

template<class ArchiveType , std::uint32_t Flags = 0>
void cereal::InputArchive< ArchiveType, Flags >::registerPolymorphicName ( std::uint32_t const  id,
std::string const name 
)
inline

Registers a polymorphic name string to its unique identifier.

After a polymorphic type has been loaded for the first time, it should be registered with its loaded id for future references to it.

◆ registerSharedPointer()

template<class ArchiveType , std::uint32_t Flags = 0>
void cereal::InputArchive< ArchiveType, Flags >::registerSharedPointer ( std::uint32_t const  id,
std::shared_ptr< void >  ptr 
)
inline

Registers a shared pointer to its unique identifier.

After a shared pointer has been allocated for the first time, it should be registered with its loaded id for future references to it.

◆ serializeDeferments()

template<class ArchiveType , std::uint32_t Flags = 0>
void cereal::InputArchive< ArchiveType, Flags >::serializeDeferments ( )
inline

Serializes any data marked for deferment using defer.

This will cause any data wrapped in DeferredData to be immediately serialized

Friends And Related Function Documentation

◆ detail::Construct

template<class ArchiveType , std::uint32_t Flags = 0>
template<class A , class B , bool C, bool D, bool E, bool F>
friend struct detail::Construct
friend

Befriend for versioning in load_and_construct.

Member Data Documentation

◆ itsBaseClassSet

template<class ArchiveType , std::uint32_t Flags = 0>
std::unordered_set<traits::detail::base_class_id, traits::detail::base_class_id_hash> cereal::InputArchive< ArchiveType, Flags >::itsBaseClassSet
private

A set of all base classes that have been serialized.

◆ itsDeferments

template<class ArchiveType , std::uint32_t Flags = 0>
std::vector<std::function<void(void)> > cereal::InputArchive< ArchiveType, Flags >::itsDeferments
private

◆ itsPolymorphicTypeMap

template<class ArchiveType , std::uint32_t Flags = 0>
std::unordered_map<std::uint32_t, std::string> cereal::InputArchive< ArchiveType, Flags >::itsPolymorphicTypeMap
private

Maps from name ids to names.

◆ itsSharedPointerMap

template<class ArchiveType , std::uint32_t Flags = 0>
std::unordered_map<std::uint32_t, std::shared_ptr<void> > cereal::InputArchive< ArchiveType, Flags >::itsSharedPointerMap
private

Maps from pointer ids to metadata.

◆ itsVersionedTypes

template<class ArchiveType , std::uint32_t Flags = 0>
std::unordered_map<std::size_t, std::uint32_t> cereal::InputArchive< ArchiveType, Flags >::itsVersionedTypes
private

Maps from type hash codes to version numbers.

◆ self

template<class ArchiveType , std::uint32_t Flags = 0>
ArchiveType* const cereal::InputArchive< ArchiveType, Flags >::self
private

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