PIP 5.6.1
Platform-Independent Primitives
Classes | Functions
pibinarystream.h File Reference

Binary serialization interface. More...

#include "pibitarray.h"
#include "pimap.h"
#include "pimemoryblock.h"
#include "piset.h"
#include "pivector2d.h"

Classes

class  PIBinaryStream< P >
 CRTP interface for binary serialization streams. More...
 
class  PIBinaryStreamTrivialRef< P >
 Helper wrapper used to detect default trivial streaming operators. Helper class to detect default operators. More...
 

Functions

template<typename P , typename T >
PIBinaryStream< P > & operator<< (PIBinaryStreamTrivialRef< P > s, const T &v)
 Forwards write operation through PIBinaryStreamTrivialRef.
 
template<typename P , typename T >
PIBinaryStream< P > & operator>> (PIBinaryStreamTrivialRef< P > s, T &v)
 Forwards read operation through PIBinaryStreamTrivialRef.
 
template<typename P >
PIBinaryStream< P > & operator<< (PIBinaryStreamTrivialRef< P > s, const PIMemoryBlock v)
 Forwards raw memory block write through PIBinaryStreamTrivialRef.
 
template<typename P >
PIBinaryStream< P > & operator>> (PIBinaryStreamTrivialRef< P > s, PIMemoryBlock v)
 Forwards raw memory block read through PIBinaryStreamTrivialRef.
 
template<typename P >
PIBinaryStream< P > & operator<< (PIBinaryStream< P > &s, const bool v)
 Stores bool as one unsigned byte.
 
template<typename P >
PIBinaryStream< P > & operator>> (PIBinaryStream< P > &s, bool &v)
 Restores bool from one unsigned byte.
 
template<typename P >
PIBinaryStream< P > & operator<< (PIBinaryStream< P > &s, const PIMemoryBlock v)
 Writes raw bytes from PIMemoryBlock.
 
template<typename P >
PIBinaryStream< P > & operator>> (PIBinaryStream< P > &s, PIMemoryBlock v)
 Reads raw bytes into PIMemoryBlock.
 
template<typename P , typename T , typename std::enable_if< std::is_enum< T >::value, int >::type = 0>
PIBinaryStream< P > & operator<< (PIBinaryStream< P > &s, const T &v)
 Stores enum values as int. More...
 
template<typename P , typename T , typename std::enable_if<!std::is_enum< T >::value, int >::type = 0, typename std::enable_if< std::is_trivially_copyable< T >::value, int >::type = 0>
PIBinaryStreamTrivialRef< P > operator<< (PIBinaryStream< P > &s, const T &v)
 Stores trivially copyable values by raw memory copy and returns a helper marker for bulk container paths.
 
template<typename P , typename T , typename std::enable_if< std::is_trivially_copyable< T >::value, int >::type = 0, typename std::enable_if< std::is_same< decltype(std::declval< PIBinaryStream< P > & >()<< std::declval< const T & >()), PIBinaryStreamTrivialRef< P > >::value , int , ::type = 0>
PIBinaryStream< P > & operator<< (PIBinaryStream< P > &s, const PIVector< T > &v)
 Stores PIVector of trivial elements in bulk. More...
 
template<typename P , typename T , typename std::enable_if< std::is_trivially_copyable< T >::value, int >::type = 0, typename std::enable_if< std::is_same< decltype(std::declval< PIBinaryStream< P > & >()<< std::declval< const T & >()), PIBinaryStreamTrivialRef< P > >::value , int , ::type = 0>
PIBinaryStream< P > & operator<< (PIBinaryStream< P > &s, const PIDeque< T > &v)
 Stores PIDeque of trivial elements in bulk. More...
 
template<typename P , typename T , typename std::enable_if< std::is_trivially_copyable< T >::value, int >::type = 0, typename std::enable_if< std::is_same< decltype(std::declval< PIBinaryStream< P > & >()<< std::declval< const T & >()), PIBinaryStreamTrivialRef< P > >::value , int , ::type = 0>
PIBinaryStream< P > & operator<< (PIBinaryStream< P > &s, const PIVector2D< T > &v)
 Stores PIVector2D of trivial elements in bulk. More...
 
template<typename P >
PIBinaryStream< P > & operator<< (PIBinaryStream< P > &s, const PIBitArray &v)
 Stores PIBitArray content.
 
template<typename P , typename Type0 , typename Type1 >
PIBinaryStream< P > & operator<< (PIBinaryStream< P > &s, const PIPair< Type0, Type1 > &v)
 Stores both members of PIPair.
 
template<typename P , typename T , typename std::enable_if< std::is_enum< T >::value, int >::type = 0>
PIBinaryStream< P > & operator>> (PIBinaryStream< P > &s, T &v)
 Restores enum values from int. More...
 
template<typename P , typename T , typename std::enable_if<!std::is_enum< T >::value, int >::type = 0, typename std::enable_if< std::is_trivially_copyable< T >::value, int >::type = 0>
PIBinaryStreamTrivialRef< P > operator>> (PIBinaryStream< P > &s, T &v)
 Restores trivially copyable values by raw memory copy and returns a helper marker for bulk container paths.
 
template<typename P , typename T , typename std::enable_if< std::is_trivially_copyable< T >::value, int >::type = 0, typename std::enable_if< std::is_same< decltype(std::declval< PIBinaryStream< P > & >() > > std::declval< T & >()), PIBinaryStreamTrivialRef< P > >::value , int , ::type = 0>
PIBinaryStream< P > & operator>> (PIBinaryStream< P > &s, PIVector< T > &v)
 Restores PIVector of trivial elements in bulk. More...
 
template<typename P , typename T , typename std::enable_if< std::is_trivially_copyable< T >::value, int >::type = 0, typename std::enable_if< std::is_same< decltype(std::declval< PIBinaryStream< P > & >() > > std::declval< T & >()), PIBinaryStreamTrivialRef< P > >::value , int , ::type = 0>
PIBinaryStream< P > & operator>> (PIBinaryStream< P > &s, PIDeque< T > &v)
 Restores PIDeque of trivial elements in bulk. More...
 
template<typename P , typename T , typename std::enable_if< std::is_trivially_copyable< T >::value, int >::type = 0, typename std::enable_if< std::is_same< decltype(std::declval< PIBinaryStream< P > & >() > > std::declval< T & >()), PIBinaryStreamTrivialRef< P > >::value , int , ::type = 0>
PIBinaryStream< P > & operator>> (PIBinaryStream< P > &s, PIVector2D< T > &v)
 Restores PIVector2D of trivial elements in bulk. More...
 
template<typename P >
PIBinaryStream< P > & operator>> (PIBinaryStream< P > &s, PIBitArray &v)
 Restores PIBitArray content.
 
template<typename P , typename Type0 , typename Type1 >
PIBinaryStream< P > & operator>> (PIBinaryStream< P > &s, PIPair< Type0, Type1 > &v)
 Restores both members of PIPair.
 
template<typename P , typename T , typename std::enable_if<!std::is_trivially_copyable< T >::value, int >::type = 0>
PIBinaryStream< P > & operator<< (PIBinaryStream< P > &s, const PIVector< T > &v)
 Stores PIVector of non-trivial elements one-by-one.
 
template<typename P , typename T , typename std::enable_if<!std::is_trivially_copyable< T >::value, int >::type = 0>
PIBinaryStream< P > & operator<< (PIBinaryStream< P > &s, const PIDeque< T > &v)
 Stores PIDeque of non-trivial elements one-by-one.
 
template<typename P , typename T , typename std::enable_if<!std::is_trivially_copyable< T >::value, int >::type = 0>
PIBinaryStream< P > & operator<< (PIBinaryStream< P > &s, const PIVector2D< T > &v)
 Stores PIVector2D of non-trivial elements via its plain vector representation.
 
template<typename P , typename T , typename std::enable_if<!std::is_trivially_copyable< T >::value, int >::type = 0>
PIBinaryStream< P > & operator>> (PIBinaryStream< P > &s, PIVector< T > &v)
 Restores PIVector of non-trivial elements one-by-one.
 
template<typename P , typename T , typename std::enable_if<!std::is_trivially_copyable< T >::value, int >::type = 0>
PIBinaryStream< P > & operator>> (PIBinaryStream< P > &s, PIDeque< T > &v)
 Restores PIDeque of non-trivial elements one-by-one.
 
template<typename P , typename T , typename std::enable_if<!std::is_trivially_copyable< T >::value, int >::type = 0>
PIBinaryStream< P > & operator>> (PIBinaryStream< P > &s, PIVector2D< T > &v)
 Restores PIVector2D of non-trivial elements via an intermediate plain vector.
 
template<typename P , typename Key , typename T >
PIBinaryStream< P > & operator<< (PIBinaryStream< P > &s, const PIMap< Key, T > &v)
 Stores PIMap keys and values.
 
template<typename P , typename Key , typename T >
PIBinaryStream< P > & operator>> (PIBinaryStream< P > &s, PIMap< Key, T > &v)
 Restores PIMap keys and values.
 
template<typename P , typename Key >
PIBinaryStream< P > & operator<< (PIBinaryStream< P > &s, const PISet< Key > &v)
 Stores PISet keys.
 
template<typename P , typename Key >
PIBinaryStream< P > & operator>> (PIBinaryStream< P > &s, PISet< Key > &v)
 Restores PISet keys.
 

Detailed Description

Binary serialization interface.

Function Documentation

◆ operator<<() [1/4]

template<typename P , typename T , typename std::enable_if< std::is_enum< T >::value, int >::type = 0>
PIBinaryStream< P > & operator<< ( PIBinaryStream< P > &  s,
const T &  v 
)
inline

Stores enum values as int.

Fallback overload that intentionally fails for unsupported non-trivial write types.

◆ operator<<() [2/4]

template<typename P , typename T , typename std::enable_if< std::is_trivially_copyable< T >::value, int >::type = 0, typename std::enable_if< std::is_same< decltype(std::declval< PIBinaryStream< P > & >()<< std::declval< const T & >()), PIBinaryStreamTrivialRef< P > >::value , int , ::type = 0>
PIBinaryStream< P > & operator<< ( PIBinaryStream< P > &  s,
const PIVector< T > &  v 
)
inline

Stores PIVector of trivial elements in bulk.

Stores PIVector element-by-element when the element type has custom binary streaming.

◆ operator<<() [3/4]

template<typename P , typename T , typename std::enable_if< std::is_trivially_copyable< T >::value, int >::type = 0, typename std::enable_if< std::is_same< decltype(std::declval< PIBinaryStream< P > & >()<< std::declval< const T & >()), PIBinaryStreamTrivialRef< P > >::value , int , ::type = 0>
PIBinaryStream< P > & operator<< ( PIBinaryStream< P > &  s,
const PIDeque< T > &  v 
)
inline

Stores PIDeque of trivial elements in bulk.

Stores PIDeque element-by-element when the element type has custom binary streaming.

◆ operator<<() [4/4]

template<typename P , typename T , typename std::enable_if< std::is_trivially_copyable< T >::value, int >::type = 0, typename std::enable_if< std::is_same< decltype(std::declval< PIBinaryStream< P > & >()<< std::declval< const T & >()), PIBinaryStreamTrivialRef< P > >::value , int , ::type = 0>
PIBinaryStream< P > & operator<< ( PIBinaryStream< P > &  s,
const PIVector2D< T > &  v 
)
inline

Stores PIVector2D of trivial elements in bulk.

Stores PIVector2D row data through the element streaming path.

◆ operator>>() [1/4]

template<typename P , typename T , typename std::enable_if< std::is_enum< T >::value, int >::type = 0>
PIBinaryStream< P > & operator>> ( PIBinaryStream< P > &  s,
T &  v 
)
inline

Restores enum values from int.

Fallback overload that intentionally fails for unsupported non-trivial read types.

◆ operator>>() [2/4]

template<typename P , typename T , typename std::enable_if< std::is_trivially_copyable< T >::value, int >::type = 0, typename std::enable_if< std::is_same< decltype(std::declval< PIBinaryStream< P > & >() > > std::declval< T & >()), PIBinaryStreamTrivialRef< P > >::value , int , ::type = 0>
PIBinaryStream< P > & operator>> ( PIBinaryStream< P > &  s,
PIVector< T > &  v 
)
inline

Restores PIVector of trivial elements in bulk.

Restores PIVector element-by-element when the element type has custom binary streaming.

◆ operator>>() [3/4]

template<typename P , typename T , typename std::enable_if< std::is_trivially_copyable< T >::value, int >::type = 0, typename std::enable_if< std::is_same< decltype(std::declval< PIBinaryStream< P > & >() > > std::declval< T & >()), PIBinaryStreamTrivialRef< P > >::value , int , ::type = 0>
PIBinaryStream< P > & operator>> ( PIBinaryStream< P > &  s,
PIDeque< T > &  v 
)
inline

Restores PIDeque of trivial elements in bulk.

Restores PIDeque element-by-element when the element type has custom binary streaming.

◆ operator>>() [4/4]

template<typename P , typename T , typename std::enable_if< std::is_trivially_copyable< T >::value, int >::type = 0, typename std::enable_if< std::is_same< decltype(std::declval< PIBinaryStream< P > & >() > > std::declval< T & >()), PIBinaryStreamTrivialRef< P > >::value , int , ::type = 0>
PIBinaryStream< P > & operator>> ( PIBinaryStream< P > &  s,
PIVector2D< T > &  v 
)
inline

Restores PIVector2D of trivial elements in bulk.

Restores PIVector2D through the element streaming path.