pstore2
Public Types | Static Public Member Functions | List of all members
pstore::serialize::container_archive_helper< Container > Struct Template Reference

A helper class which can be used to emit containers which have a size() method and which support the requirements for range-based 'for'. More...

#include <standard_types.hpp>

Public Types

using insert_callback = std::function< void(typename Container::value_type const &)>
 

Static Public Member Functions

template<typename Archive >
static auto write (Archive &&archive, Container const &ty) -> archive_result_type< Archive >
 Writes the contents of a container to an archive. More...
 
template<typename Archive >
static void read (Archive &&archive, insert_callback inserter)
 Reads the contents of a container from an archive. More...
 

Detailed Description

template<typename Container>
struct pstore::serialize::container_archive_helper< Container >

A helper class which can be used to emit containers which have a size() method and which support the requirements for range-based 'for'.

Member Function Documentation

◆ read()

template<typename Container >
template<typename Archive >
static void pstore::serialize::container_archive_helper< Container >::read ( Archive &&  archive,
insert_callback  inserter 
)
inlinestatic

Reads the contents of a container from an archive.

Reads a std::size_t value – the number of following elements – and an array of Container::vaue_type elements. For each element, the inserter function is invoked: it is passed the container and value to be inserted. Its job is simply to insert the value into the given container.

Parameters
archiveThe archive from which the container will be read.
inserterA function which is responsible for inserting each of the Container::value_type elements from the archive into the container.

◆ write()

template<typename Container >
template<typename Archive >
static auto pstore::serialize::container_archive_helper< Container >::write ( Archive &&  archive,
Container const &  ty 
) -> archive_result_type<Archive>
inlinestatic

Writes the contents of a container to an archive.

Writes an initial std::size_t value with the number of elements in the container followed by an array of of those elements, in the order returned by iteration.

Parameters
archiveThe archive to which the container is to be serialized.
tyThe container whose contents are to be written.

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