|
pstore2
|
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"

Go to the source code of this file.
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. | |
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:
| 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.
| 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.
| archive | The archive from which the range of values will be read |
| output | An iterator to which the values read from the archive are written. Must meet the requirements of OutputIterator |
| 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.
| archive | The archive to which the range of values is to be written |
| begin | The beginning of the iterator range to be written |
| end | The end of the iterator range to be written |
1.8.13