TRIQS/h5 1.3.0
C++ interface to HDF5
Loading...
Searching...
No Matches
Serialize/Deserialize

Detailed Description

Serialize/Deserialize an object to/from a byte buffer using HDF5's memory file.

Example 3: Serialization shows a simple example how this interface could be used in practice.

Functions

template<typename T >
h5::deserialize (std::vector< std::byte > const &buf)
 Deserialize an object from a byte buffer.
 
template<typename T >
std::vector< std::byte > h5::serialize (T const &x)
 Serialize an object to a byte buffer.
 

Function Documentation

◆ deserialize()

template<typename T >
T h5::deserialize ( std::vector< std::byte > const & buf)
nodiscard

#include <h5/serialization.hpp>

Deserialize an object from a byte buffer.

It first creates a buffered memory file from the given byte buffer and then reads the object from the file.

Template Parameters
TType of the object.
Parameters
bufByte buffer containing the serialized object.
Returns
Object restored from the given byte buffer.

Definition at line 64 of file serialization.hpp.

◆ serialize()

template<typename T >
std::vector< std::byte > h5::serialize ( T const & x)
nodiscard

#include <h5/serialization.hpp>

Serialize an object to a byte buffer.

It first writes the object to a buffered memory file and then returns the underlying byte buffer.

Template Parameters
TType of the object.
Parameters
xObject to be serialized.
Returns
Byte buffer containing the serialized object.

Definition at line 48 of file serialization.hpp.