pstore2
Classes | Typedefs | Functions
types.hpp File Reference

Provides serialization capabilities for trivial and user-defined types. More...

#include <algorithm>
#include <cstring>
#include "pstore/serialize/common.hpp"
#include "pstore/support/gsl.hpp"
#include "pstore/support/portab.hpp"
Include dependency graph for types.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pstore::serialize::serializer< Ty, Enable >
 The primary template for serialization of non standard layout types. More...
 
struct  pstore::serialize::details::getn_helper
 
struct  pstore::serialize::details::readn_helper
 
struct  pstore::serialize::details::writen_helper
 This template class enables us to provide the "writen()" interface on all serialization classes without forcing every one to reimplement identical boilerplate code. More...
 
struct  pstore::serialize::serializer< Ty, typename std::enable_if< std::is_trivial< Ty >::value >::type >
 A serializer for trivial types. More...
 
struct  pstore::serialize::is_compatible< T1, T2 >
 If the two types T1 and T2 have a compatible representation when serialized, provides the member constant value equal to true, otherwise false. More...
 
struct  pstore::serialize::is_compatible< T, T >
 
struct  pstore::serialize::is_compatible< T1 const, T2 >
 
struct  pstore::serialize::is_compatible< T1, T2 const >
 
struct  pstore::serialize::is_compatible< T1 const, T2 const >
 
struct  pstore::serialize::details::aligned_storage< Len, Align >
 
struct  pstore::serialize::details::aligned_storage< Len, Align >::type
 

Typedefs

template<typename Archive >
using pstore::serialize::archive_result_type = typename std::remove_reference< Archive >::type::result_type
 

Functions

template<typename Archive , typename ElementType >
void pstore::serialize::read_uninit (Archive &&archive, ElementType &uninit)
 
template<typename Archive , typename ElementType >
void pstore::serialize::read_uninit (Archive &&archive, gsl::span< ElementType, 1 > uninit_span)
 A read of a span of 1 is optimized into a read of an individual value.
 
template<typename Archive , typename ElementType , std::ptrdiff_t Extent>
void pstore::serialize::read_uninit (Archive &&archive, gsl::span< ElementType, Extent > uninit_span)
 
template<std::ptrdiff_t SpanExtent>
void pstore::serialize::flood (gsl::span< std::uint8_t, SpanExtent > sp) noexcept
 
template<typename T >
void pstore::serialize::flood (T *const t) noexcept
 
template<typename Archive , typename InputIterator >
void pstore::serialize::write_range (Archive &&archive, InputIterator begin, InputIterator end)
 Writes a range of values [first, last) to the supplied archive. More...
 
template<typename Ty , typename Archive , typename OutputIterator >
OutputIterator pstore::serialize::read_range (Archive &&archive, OutputIterator output)
 Reads a sequence of values from the given archive and adds them to an iterator range beginning at 'output'. More...
 
template<typename Ty , typename Archive >
Ty pstore::serialize::read (Archive &&archive)
 Read a single value from an archive.
 
template<typename Archive , typename Ty >
void pstore::serialize::read (Archive &&archive, gsl::span< Ty, 1 > span)
 Read a span containing a single value from an archive. More...
 
template<typename Archive , typename ElementType , std::ptrdiff_t Extent>
void pstore::serialize::read (Archive &&archive, gsl::span< ElementType, Extent > span)
 
template<typename Archive , typename Ty >
auto pstore::serialize::write (Archive &&archive, Ty const &ty) -> archive_result_type< Archive >
 Write a single value to an archive.
 
template<typename Archive , typename ElementType , std::ptrdiff_t Extent>
auto pstore::serialize::write (Archive &&archive, gsl::span< ElementType, Extent > sp) -> archive_result_type< Archive >
 Write a span of elements to an archive.
 
template<typename Archive , typename ElementType >
auto pstore::serialize::write (Archive &&archive, gsl::span< ElementType, 1 > sp) -> archive_result_type< Archive >
 Write a single-element span to an archive.
 
template<typename Archive , typename Ty , typename... Args>
auto pstore::serialize::write (Archive &&archive, Ty const &ty, Args const &... args) -> archive_result_type< Archive >
 Write a series of values to an archive.
 

Detailed Description

Provides serialization capabilities for trivial and user-defined types.

There are two basic serialization operations: writing and reading. For example:

These operations are implemented by instances of an Archiver. The individual pieces of an object are written to, or read from, an Archiver using the serialize() function. This module provides a number of overrides of this function to serialize trivial types as well as some of the common types from the Standard Library.

Writing the built-in types is easy:

Function Documentation

◆ read()

template<typename Archive , typename Ty >
void pstore::serialize::read ( Archive &&  archive,
gsl::span< Ty, 1 >  span 
)

Read a span containing a single value from an archive.

This is optimized as a read of a single value.

◆ read_range()

template<typename Ty , typename Archive , typename OutputIterator >
OutputIterator pstore::serialize::read_range ( Archive &&  archive,
OutputIterator  output 
)

Reads a sequence of values from the given archive and adds them to an iterator range beginning at 'output'.

The function assumes that the first value is std::size_t containing the number of following values and that an array of serialized OutputIterator::value_type instances follows immediately.

Parameters
archiveThe archive from which the range of values will be read
outputAn iterator to which the values read from the archive are written. Must meet the requirements of OutputIterator
Returns
Input iterator to the element in the destination range, one past the last element copied.

◆ write_range()

template<typename Archive , typename InputIterator >
void pstore::serialize::write_range ( Archive &&  archive,
InputIterator  begin,
InputIterator  end 
)

Writes a range of values [first, last) to the supplied archive.

The function first writes the distance, as a value of type std::size_t, between the two iterators so that the number of following values is known by the equivalent reader. This is followed by a sequence of the actual values.

Parameters
archiveThe archive to which the range of values is to be written
beginThe beginning of the iterator range to be written
endThe end of the iterator range to be written