µSer
uSer Namespace Reference

µSer main API. More...

Namespaces

 ByteOrder
 Byte orders for integers in serialized data.
 
 Hook
 Attributes to define hook functions for uSer.
 
 SignFormat
 Formats for signed integers.
 

Classes

struct  DynSize
 
class  Exception
 
struct  FixedSize
 
struct  InfSize
 
struct  MaxSize
 Indicates a fixed maximum size for a dynamic data structure. More...
 
struct  NoDyn
 Indicates a data structure with no dynamic data. More...
 
struct  RawInfo
 Attribute: Declares the serialization word explicitly. More...
 
struct  StructMembers
 Define the members of a struct by providing member pointers. More...
 
struct  Unlimited
 Indicates a dynamic data structure whose maximum serialized size can not be pre-calculated (e.g. when containers are used) More...
 
struct  Width
 Attribute: Define the serialized size of an integer type. May not be larger than the C(++) data type used. More...
 

Typedefs

using AttrNone = Attributes<>
 
template<typename RawIter , typename Obj , typename... Attr>
using RawMaxDynamic = typename decltype(SWalk::walk(GetSerAlgo< true, RawIter, Attr... >::template root< Obj, InfSize, Helper::GetRootAttr< Attr... >>(std::declval< RawIter >(), std::declval< Obj & >(), infSize), Helper::GetRootAttr< Attr... >{}))::MaxDyn
 Indicates the maximum number of dynamic serialization words in raw data; may be an alias to Unlimited, NoDyn, or MaxSize.
 

Functions

template<typename... Attr, typename RawIter , typename Obj , typename SizeT , std::enable_if_t< std::is_convertible_v< SizeT, Helper::SizeDefTag >, int > = 42>
decltype(auto) serialize (RawIter &&raw, const Obj &obj, SizeT size, std::size_t *sizeUsed=nullptr)
 
template<typename... Attr, typename SWord , typename Obj , std::size_t N>
decltype(auto) serialize (SWord(&raw)[N], const Obj &obj, std::size_t *sizeUsed=nullptr)
 
template<typename... Attr, typename SWord , typename Obj , std::size_t N>
decltype(auto) serialize (std::array< SWord, N > &raw, const Obj &obj, std::size_t *sizeUsed=nullptr)
 
template<typename... Attr, typename RawIter , typename Obj >
decltype(auto) serialize (RawIter &&raw, const Obj &obj, std::size_t size, std::size_t *sizeUsed=nullptr)
 
template<typename... Attr, typename RawContainer , typename Obj , decltype(std::size(std::declval< RawContainer >()))* = nullptr>
decltype(auto) serialize (RawContainer &&raw, const Obj &obj, std::size_t *sizeUsed=nullptr)
 
template<typename... Attr, typename RawIter , typename Obj , typename SizeT , std::enable_if_t< std::is_convertible_v< SizeT, Helper::SizeDefTag >, int > = 42>
decltype(auto) deserialize (RawIter &&raw, Obj &obj, SizeT size, std::size_t *sizeUsed=nullptr)
 
template<typename... Attr, typename SWord , typename Obj , std::size_t N>
decltype(auto) deserialize (const SWord(&raw)[N], Obj &obj, std::size_t *sizeUsed=nullptr)
 
template<typename... Attr, typename SWord , typename Obj , std::size_t N>
decltype(auto) deserialize (const std::array< SWord, N > &raw, Obj &obj, std::size_t *sizeUsed=nullptr)
 
template<typename... Attr, typename SWord , typename Obj , std::size_t N>
decltype(auto) deserialize (SWord(&raw)[N], Obj &obj, std::size_t *sizeUsed=nullptr)
 
template<typename... Attr, typename SWord , typename Obj , std::size_t N>
decltype(auto) deserialize (std::array< SWord, N > &raw, Obj &obj, std::size_t *sizeUsed=nullptr)
 
template<typename... Attr, typename RawIter , typename Obj >
decltype(auto) deserialize (RawIter &&raw, Obj &obj, std::size_t size, std::size_t *sizeUsed=nullptr)
 
template<typename... Attr, typename RawContainer , typename Obj , decltype(std::size(std::declval< RawContainer >()))* = nullptr>
decltype(auto) deserialize (RawContainer &&raw, Obj &obj, std::size_t *sizeUsed=nullptr)
 
template<typename... Attr, typename Obj >
constexpr bool compare (const Obj &a, const Obj &b)
 
template<typename... Attr, typename Obj >
std::ostream & print (std::ostream &os, const Obj &obj)
 

Detailed Description

µSer main API.

Function Documentation

template<typename... Attr, typename Obj >
constexpr bool uSer::compare ( const Obj &  a,
const Obj &  b 
)

Compares two serializable objects of equal type.

Returns
true if a and b are equal, else false.
template<typename... Attr, typename RawIter , typename Obj , typename SizeT , std::enable_if_t< std::is_convertible_v< SizeT, Helper::SizeDefTag >, int > = 42>
decltype(auto) uSer::deserialize ( RawIter &&  raw,
Obj &  obj,
SizeT  size,
std::size_t *  sizeUsed = nullptr 
)

Deserialize an arbitrary raw input stream or container given via an iterator. The input buffer size must me given explicitly.

Parameters
[in]rawAny input iterator for the raw data.
[out]objThe object to receive the deserialized data
[in]sizeThe size of the raw data stream; either a fixedSize or infSize
[out]sizeUsedOptional output parameter indicating the number of serialization words actually used in the raw data stream.
Returns
If an error is possible for the requested data types AND exceptions are disabled, an uSer_ErrorCode is returned; else the return type is void.
template<typename... Attr, typename SWord , typename Obj , std::size_t N>
decltype(auto) uSer::deserialize ( const SWord(&)  raw[N],
Obj &  obj,
std::size_t *  sizeUsed = nullptr 
)

Deserialize from a const C-array given as a reference. The array's type must include the size, i.e. it can't be a pointer to an array.

Parameters
[in]rawA reference to a constant C array.
[out]objThe object to receive the deserialized data
[out]sizeUsedOptional output parameter indicating the number of serialization words actually used in the raw data stream.
Returns
If an error is possible for the requested data types AND exceptions are disabled, an uSer_ErrorCode is returned; else the return type is void.
template<typename... Attr, typename SWord , typename Obj , std::size_t N>
decltype(auto) uSer::deserialize ( const std::array< SWord, N > &  raw,
Obj &  obj,
std::size_t *  sizeUsed = nullptr 
)

Deserialize from a const std::array<T,N> given as a reference.

Parameters
[in]rawA reference to constant std::array<T,N>.
[out]objThe object to receive the deserialized data
[out]sizeUsedOptional output parameter indicating the number of serialization words actually used in the raw data stream.
Returns
If an error is possible for the requested data types AND exceptions are disabled, an uSer_ErrorCode is returned; else the return type is void.
template<typename... Attr, typename SWord , typename Obj , std::size_t N>
decltype(auto) uSer::deserialize ( SWord(&)  raw[N],
Obj &  obj,
std::size_t *  sizeUsed = nullptr 
)

Deserialize from a non-const C-array given as a reference. The array's type must include the size, i.e. it can't be a pointer to an array. This overload prevents the one for generic containers from being called if the array is non-const.

Parameters
[in]rawA reference to a C array.
[out]objThe object to receive the deserialized data
[out]sizeUsedOptional output parameter indicating the number of serialization words actually used in the raw data stream.
Returns
If an error is possible for the requested data types AND exceptions are disabled, an uSer_ErrorCode is returned; else the return type is void.
template<typename... Attr, typename SWord , typename Obj , std::size_t N>
decltype(auto) uSer::deserialize ( std::array< SWord, N > &  raw,
Obj &  obj,
std::size_t *  sizeUsed = nullptr 
)

Deserialize from a non-const std::array<T,N> given as a reference. This overload prevents the one for generic containers from being called if the array is non-const.

Parameters
[in]rawA reference to std::array<T,N>.
[out]objThe object to receive the deserialized data
[out]sizeUsedOptional output parameter indicating the number of serialization words actually used in the raw data stream.
Returns
If an error is possible for the requested data types AND exceptions are disabled, an uSer_ErrorCode is returned; else the return type is void.
template<typename... Attr, typename RawIter , typename Obj >
decltype(auto) uSer::deserialize ( RawIter &&  raw,
Obj &  obj,
std::size_t  size,
std::size_t *  sizeUsed = nullptr 
)

Deserialize from an arbitrary raw input stream or container given via an iterator. The input buffer size must me given explicitly as an integer.

Parameters
[in]rawAny input iterator for the raw data.
[out]objThe object to receive the deserialized data
[in]sizeThe size of the raw data stream given as a std::size_t
[out]sizeUsedOptional output parameter indicating the number of serialization words actually used in the raw data stream.
Returns
If exceptions are disabled, an uSer_ErrorCode is returned; else the return type is void.
template<typename... Attr, typename RawContainer , typename Obj , decltype(std::size(std::declval< RawContainer >()))* = nullptr>
decltype(auto) uSer::deserialize ( RawContainer &&  raw,
Obj &  obj,
std::size_t *  sizeUsed = nullptr 
)

Deserialize from an arbitrary container given as a reference. The input buffer's size is queried via its .size() member function.

Parameters
[in]rawAny container supporting iterators and a .size() member function
[out]objThe object to receive the deserialized data
[out]sizeUsedOptional output parameter indicating the number of serialization words actually used in the raw data stream.
Returns
If exceptions are disabled, an uSer_ErrorCode is returned; else the return type is void.
template<typename... Attr, typename Obj >
std::ostream& uSer::print ( std::ostream &  os,
const Obj &  obj 
)

Outputs a textual version of a serializable object.

Parameters
[out]osA stream to write the textual data to, e.g. std::cout.
[in]objThe object to print
Returns
os
template<typename... Attr, typename RawIter , typename Obj , typename SizeT , std::enable_if_t< std::is_convertible_v< SizeT, Helper::SizeDefTag >, int > = 42>
decltype(auto) uSer::serialize ( RawIter &&  raw,
const Obj &  obj,
SizeT  size,
std::size_t *  sizeUsed = nullptr 
)

Serialize to an arbitrary raw output stream or container given via an iterator. The output buffer size must me given explicitly.

Parameters
[out]rawAny output iterator for the raw data.
[in]objThe object to serialize
[in]sizeThe size of the raw data stream; either a fixedSize or infSize
[out]sizeUsedOptional output parameter indicating the number of serialization words actually used in the raw data stream.
Returns
If an error is possible for the requested data types AND exceptions are disabled, an uSer_ErrorCode is returned; else the return type is void.
template<typename... Attr, typename SWord , typename Obj , std::size_t N>
decltype(auto) uSer::serialize ( SWord(&)  raw[N],
const Obj &  obj,
std::size_t *  sizeUsed = nullptr 
)

Serialize to a C-array given as a reference. The array's type must include the size, i.e. it can't be a pointer to an array.

Parameters
[out]rawA reference to a C array.
[in]objThe object to serialize
[out]sizeUsedOptional output parameter indicating the number of serialization words actually used in the raw data stream.
Returns
If an error is possible for the requested data types AND exceptions are disabled, an uSer_ErrorCode is returned; else the return type is void.
template<typename... Attr, typename SWord , typename Obj , std::size_t N>
decltype(auto) uSer::serialize ( std::array< SWord, N > &  raw,
const Obj &  obj,
std::size_t *  sizeUsed = nullptr 
)

Serialize to std::array<T,N> given as a reference.

Parameters
[out]rawA reference to std::array<T,N>.
[in]objThe object to serialize
[out]sizeUsedOptional output parameter indicating the number of serialization words actually used in the raw data stream.
Returns
If an error is possible for the requested data types AND exceptions are disabled, an uSer_ErrorCode is returned; else the return type is void.
template<typename... Attr, typename RawIter , typename Obj >
decltype(auto) uSer::serialize ( RawIter &&  raw,
const Obj &  obj,
std::size_t  size,
std::size_t *  sizeUsed = nullptr 
)

Serialize to an arbitrary raw output stream or container given via an iterator. The output buffer size must me given explicitly as an integer.

Parameters
[out]rawAny output iterator for the raw data.
[in]objThe object to serialize
[in]sizeThe size of the raw data stream given as a std::size_t
[out]sizeUsedOptional output parameter indicating the number of serialization words actually used in the raw data stream.
Returns
If exceptions are disabled, an uSer_ErrorCode is returned; else the return type is void.
template<typename... Attr, typename RawContainer , typename Obj , decltype(std::size(std::declval< RawContainer >()))* = nullptr>
decltype(auto) uSer::serialize ( RawContainer &&  raw,
const Obj &  obj,
std::size_t *  sizeUsed = nullptr 
)

Serialize to an arbitrary container given as a reference. The output buffer's size is queried via its .size() member function.

Parameters
[out]rawAny container supporting iterators and a .size() member function
[in]objThe object to serialize
[out]sizeUsedOptional output parameter indicating the number of serialization words actually used in the raw data stream.
Returns
If exceptions are disabled, an uSer_ErrorCode is returned; else the return type is void.