CAF 0.17.6
Loading...
Searching...
No Matches
caf::data_processor< Derived > Class Template Referenceabstract

A data processor translates an object into a format that can be stored or vice versa. More...

#include <data_processor.hpp>

Public Types

using result_type = error
 Return type for operator().
using builtin_t
 List of builtin types for data processors.

Public Member Functions

 data_processor (const data_processor &)=delete
data_processor & operator= (const data_processor &)=delete
 data_processor (execution_unit *ctx=nullptr)
virtual error begin_object (uint16_t &typenr, std::string &name)=0
 Begins processing of an object.
virtual error end_object ()=0
 Ends processing of an object.
virtual error begin_sequence (size_t &num)=0
 Begins processing of a sequence.
virtual error end_sequence ()=0
 Ends processing of a sequence.
execution_unitcontext ()
 Returns the actor system associated to this data processor.
template<class T>
std::enable_if< std::is_floating_point< T >::value, error >::type apply (T &x)
 Applies this processor to an arithmetic type.
template<class T>
std::enable_if< std::is_integral< T >::value &&!std::is_same< bool, T >::value, error >::type apply (T &x)
error apply (std::string &x)
error apply (std::u16string &x)
error apply (std::u32string &x)
template<atom_value V>
error apply (atom_constant< V > &x)
template<class T>
std::enable_if< std::is_enum< T >::value &&!detail::has_serialize< T >::value, error >::type apply (T &x)
 Serializes enums using the underlying type if no user-defined serialization is defined.
template<class T>
std::enable_if< std::is_empty< T >::value &&!detail::is_inspectable< Derived, T >::value, error >::type apply (T &)
 Applies this processor to an empty type.
error apply (bool &x)
error apply (std::vector< bool > &x)
template<class T>
error consume_range (T &xs)
template<class U, class T>
error consume_range_c (T &xs)
 Converts each element in xs to U before calling apply.
template<class T>
error fill_range (T &xs, size_t num_elements)
template<class U, class T>
error fill_range_c (T &xs, size_t num_elements)
 Loads elements from type U before inserting to xs.
template<class T>
std::enable_if< detail::is_iterable< T >::value &&!detail::has_serialize< T >::value &&!detail::is_inspectable< Derived, T >::value, error >::type apply (T &xs)
 Applies this processor to a sequence of values.
template<class T, size_t S>
std::enable_if< detail::is_serializable< T >::value, error >::type apply (std::array< T, S > &xs)
 Applies this processor to an array.
template<class T, size_t S>
std::enable_if< detail::is_serializable< T >::value, error >::type apply (T(&xs)[S])
 Applies this processor to an array.
template<class F, class S>
std::enable_if< detail::is_serializable< typenamestd::remove_const< F >::type >::value &&detail::is_serializable< S >::value, error >::type apply (std::pair< F, S > &xs)
template<class... Ts>
std::enable_if< detail::conjunction< detail::is_serializable< Ts >::value... >::value, error >::type apply (std::tuple< Ts... > &xs)
template<class T>
std::enable_if<!std::is_empty< T >::value &&detail::has_serialize< T >::value, error >::type apply (T &x)
template<class Rep, class Period>
std::enable_if< std::is_integral< Rep >::value, error >::type apply (std::chrono::duration< Rep, Period > &x)
template<class Rep, class Period>
std::enable_if< std::is_floating_point< Rep >::value, error >::type apply (std::chrono::duration< Rep, Period > &x)
template<class Clock, class Duration>
error apply (std::chrono::time_point< Clock, Duration > &t)
virtual error apply_raw (size_t num_bytes, void *data)=0
 Applies this processor to a raw block of data of size num_bytes.
template<class T>
std::enable_if< detail::is_inspectable< Derived, T >::value &&!detail::has_serialize< T >::value, decltype(inspect(std::declval< Derived & >(), std::declval< T & >()))>::type apply (T &x)
error operator() ()
template<class F, class... Ts>
error operator() (meta::save_callback_t< F > x, Ts &&... xs)
template<class F, class... Ts>
error operator() (meta::load_callback_t< F > x, Ts &&... xs)
template<class... Ts>
error operator() (const meta::annotation &, Ts &&... xs)
template<class T, class... Ts>
std::enable_if< is_allowed_unsafe_message_type< T >::value, error >::type operator() (const T &, Ts &&... xs)
template<class T, class... Ts>
std::enable_if<!meta::is_annotation< T >::value &&!is_allowed_unsafe_message_type< T >::value, error >::type operator() (T &&x, Ts &&... xs)

Static Public Member Functions

template<class D, atom_value V>
static error apply_atom_constant (D &self, atom_constant< V > &)
template<class D, class T>
static std::enable_if< D::reads_state &&!detail::is_byte_sequence< T >::value, error >::type apply_sequence (D &self, T &xs)
template<class D, class T>
static std::enable_if<!D::reads_state &&!detail::is_byte_sequence< T >::value, error >::type apply_sequence (D &self, T &xs)
template<class D, class T>
static std::enable_if< D::reads_state &&detail::is_byte_sequence< T >::value, error >::type apply_sequence (D &self, T &xs)
template<class D, class T>
static std::enable_if<!D::reads_state &&detail::is_byte_sequence< T >::value, error >::type apply_sequence (D &self, T &xs)

Protected Member Functions

virtual error apply_impl (int8_t &)=0
virtual error apply_impl (uint8_t &)=0
virtual error apply_impl (int16_t &)=0
virtual error apply_impl (uint16_t &)=0
virtual error apply_impl (int32_t &)=0
virtual error apply_impl (uint32_t &)=0
virtual error apply_impl (int64_t &)=0
virtual error apply_impl (uint64_t &)=0
virtual error apply_impl (float &)=0
virtual error apply_impl (double &)=0
virtual error apply_impl (long double &)=0
virtual error apply_impl (std::string &)=0
virtual error apply_impl (std::u16string &)=0
virtual error apply_impl (std::u32string &)=0

Detailed Description

template<class Derived>
class caf::data_processor< Derived >

A data processor translates an object into a format that can be stored or vice versa.

A data processor can be either in saving or loading mode.

Member Typedef Documentation

◆ builtin_t

template<class Derived>
using caf::data_processor< Derived >::builtin_t
Initial value:
int8_t,
uint8_t,
int16_t,
uint16_t,
int32_t,
uint32_t,
int64_t,
uint64_t,
float,
double,
long double,
std::string,
std::u16string,
std::u32string
>
A list of types.
Definition type_list.hpp:36

List of builtin types for data processors.

Member Function Documentation

◆ apply_raw()

template<class Derived>
virtual error caf::data_processor< Derived >::apply_raw ( size_t num_bytes,
void * data )
pure virtual

◆ begin_object()

template<class Derived>
virtual error caf::data_processor< Derived >::begin_object ( uint16_t & typenr,
std::string & name )
pure virtual

Begins processing of an object.

Saves the type information to the underlying storage when in saving mode, otherwise extracts them and sets both arguments accordingly.

Implemented in caf::binary_deserializer, caf::serializer_impl< Container >, caf::serializer_impl< std::vector< char > >, caf::stream_deserializer< Streambuf >, and caf::stream_serializer< Streambuf >.

◆ begin_sequence()

template<class Derived>
virtual error caf::data_processor< Derived >::begin_sequence ( size_t & num)
pure virtual

Begins processing of a sequence.

Saves the size to the underlying storage when in saving mode, otherwise sets num accordingly.

Implemented in caf::binary_deserializer, caf::serializer_impl< Container >, caf::serializer_impl< std::vector< char > >, caf::stream_deserializer< Streambuf >, and caf::stream_serializer< Streambuf >.

◆ end_object()

template<class Derived>
virtual error caf::data_processor< Derived >::end_object ( )
pure virtual

◆ end_sequence()

template<class Derived>
virtual error caf::data_processor< Derived >::end_sequence ( )
pure virtual

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