WarpX
Functions
ablastr::utils::serialization Namespace Reference

Functions

template<typename T >
void put_in (const T &val, std::vector< char > &vec)
 
template<typename T >
void put_in_vec (const std::vector< T > &val, std::vector< char > &vec)
 
template<typename T >
get_out (std::vector< char >::const_iterator &it)
 
template<typename T >
std::vector< T > get_out_vec (std::vector< char >::const_iterator &it)
 

Function Documentation

◆ get_out()

template<typename T >
T ablastr::utils::serialization::get_out ( std::vector< char >::const_iterator &  it)

This function extracts a variable of type T from a byte vector, at the position given by a std::vector<char> iterator. The iterator is then advanced according to the number of bytes read from the byte vector. T must be either a trivially copyable type or an std::string.

Template Parameters
Tthe variable type (must be trivially copyable)
Parameters
[in,out]itthe iterator to a byte vector
Returns
the variable extracted from the byte array

◆ get_out_vec()

template<typename T >
std::vector<T> ablastr::utils::serialization::get_out_vec ( std::vector< char >::const_iterator &  it)

This function extracts an std::vector<T> from a byte vector, at the position given by a std::vector<char> iterator. The iterator is then advanced according to the number of bytes read from the byte vector. T must be either a trivially copyable type or an std::string.

Template Parameters
Tthe variable type (must be trivially copyable)
Parameters
[in,out]itthe iterator to a byte vector
Returns
the variable extracted from the byte array

◆ put_in()

template<typename T >
void ablastr::utils::serialization::put_in ( const T &  val,
std::vector< char > &  vec 
)

This function transforms a variable of type T into a vector of chars holding its byte representation and it appends this vector at the end of an existing vector of chars. T must be either a trivially copyable type or an std::string

Template Parameters
Tthe variable type
Parameters
[in]vala variable of type T to be serialized
[in,out]veca reference to the vector to which the byte representation of val is appended

◆ put_in_vec()

template<typename T >
void ablastr::utils::serialization::put_in_vec ( const std::vector< T > &  val,
std::vector< char > &  vec 
)

This function transforms an std::vector<T> into a vector of chars holding its byte representation and it appends this vector at the end of an existing vector of chars. T must be either a trivially copyable type or an std::string. A specialization exists in case val is a vector of chars.

Template Parameters
Tthe variable type
Parameters
[in]vala variable of type T to be serialized
[in,out]veca reference to the vector to which the byte representation of val is appended