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

Detailed Description

Specialized functions to read/write hdf5_format tags from/to HDF5 attributes.

An hdf5_format tag is a string that describes the type of object stored in an HDF5 file. A type T which is HDF5 readable/writeable should do one of the following:

The specialized h5_write function for type T should write the format tag to file (see h5::write_hdf5_format and h5::write_hdf5_format_as_string) and the h5_read function should check that the format tag is correct (see h5::assert_hdf5_format and h5::assert_hdf5_format_as_string).

Classes

struct  h5::hdf5_format_impl< T >
 Default type trait to get the hdf5_format tag of type T by calling its static member function T::hdf5_format(). More...
 
struct  h5::hdf5_format_impl< bool >
 Specialization of h5::hdf5_format_impl for bool. More...
 
struct  h5::hdf5_format_impl< double >
 Specialization of h5::hdf5_format_impl for double. More...
 
struct  h5::hdf5_format_impl< float >
 Specialization of h5::hdf5_format_impl for float. More...
 
struct  h5::hdf5_format_impl< int >
 Specialization of h5::hdf5_format_impl for int. More...
 
struct  h5::hdf5_format_impl< long >
 Specialization of h5::hdf5_format_impl for long. More...
 
struct  h5::hdf5_format_impl< long double >
 Specialization of h5::hdf5_format_impl for long double. More...
 
struct  h5::hdf5_format_impl< long long >
 Specialization of h5::hdf5_format_impl for long long. More...
 
struct  h5::hdf5_format_impl< std::complex< double > >
 Specialization of h5::hdf5_format_impl for std::complex<double>. More...
 
struct  h5::hdf5_format_impl< unsigned int >
 Specialization of h5::hdf5_format_impl for unsigned int. More...
 
struct  h5::hdf5_format_impl< unsigned long >
 Specialization of h5::hdf5_format_impl for unsigned long. More...
 
struct  h5::hdf5_format_impl< unsigned long long >
 Specialization of h5::hdf5_format_impl for unsigned long long. More...
 

Functions

template<typename T >
void h5::assert_hdf5_format (group g, T const &, bool ignore_if_absent=false)
 Assert that the hdf5_format tag attached to the given group is the same as the hdf5_format tag of the type T using template argument deduction.
 
void h5::assert_hdf5_format_as_string (group g, const char *tag_expected, bool ignore_if_absent=false)
 Assert that the hdf5_format tag attached to the given group is the same as the given tag.
 
template<typename T >
std::string h5::get_hdf5_format ()
 Get the hdf5_format tag of type T.
 
template<typename T >
std::string h5::get_hdf5_format (T const &)
 Get the hdf5_format tag of type T using template argument deduction.
 
std::string h5::read_hdf5_format (group g)
 Read an hdf5_format tag from an HDF5 attribute with the name 'Format' attached to a given h5::group.
 
void h5::read_hdf5_format (object obj, std::string &s)
 Read an hdf5_format tag from an HDF5 attribute with the name 'Format'.
 
void h5::read_hdf5_format_from_key (group g, std::string const &key, std::string &s)
 Read an hdf5_format tag from an HDF5 attribute with the name 'Format'.
 
template<typename T >
void h5::write_hdf5_format (object obj, T const &)
 Write an hdf5_format tag for type T to an HDF5 attribute with the name 'Format' using template argument deduction.
 
void h5::write_hdf5_format_as_string (object obj, std::string const &s)
 Write a std::string to an HDF5 attribute with the name 'Format'.
 

Function Documentation

◆ assert_hdf5_format()

template<typename T >
void h5::assert_hdf5_format ( group g,
T const & ,
bool ignore_if_absent = false )

#include <h5/format.hpp>

Assert that the hdf5_format tag attached to the given group is the same as the hdf5_format tag of the type T using template argument deduction.

Throws a std::runtime_error if the tags don't match.

Template Parameters
TType for which the hdf5_format tag is to be checked.
Parameters
gh5::group to be checked.
ignore_if_absentIf true, the assertion is ignored if the group does not have a 'Format' attribute.

Definition at line 164 of file format.hpp.

◆ assert_hdf5_format_as_string()

void h5::assert_hdf5_format_as_string ( group g,
const char * tag_expected,
bool ignore_if_absent = false )

#include <h5/format.cpp>

Assert that the hdf5_format tag attached to the given group is the same as the given tag.

Throws a std::runtime_error if the tags don't match.

Parameters
gh5::group to be checked.
tag_expectedExpected hdf5_format tag.
ignore_if_absentIf true, the assertion is ignored if the group does not have a 'Format' attribute.

Definition at line 52 of file format.cpp.

◆ get_hdf5_format() [1/2]

template<typename T >
std::string h5::get_hdf5_format ( )

#include <h5/format.hpp>

Get the hdf5_format tag of type T.

Template Parameters
TType for which the hdf5_format tag is to be retrieved..
Returns
std::string containing the hdf5_format tag.

Definition at line 82 of file format.hpp.

◆ get_hdf5_format() [2/2]

template<typename T >
std::string h5::get_hdf5_format ( T const & )

#include <h5/format.hpp>

Get the hdf5_format tag of type T using template argument deduction.

Template Parameters
TType for which the hdf5_format tag is to be retrieved..
Returns
std::string containing the hdf5_format tag.

Definition at line 93 of file format.hpp.

◆ read_hdf5_format() [1/2]

std::string h5::read_hdf5_format ( group g)

#include <h5/format.cpp>

Read an hdf5_format tag from an HDF5 attribute with the name 'Format' attached to a given h5::group.

Parameters
gh5::group from which the attribute is read.
Returns
String containing the hdf5_format tag.

Definition at line 39 of file format.cpp.

◆ read_hdf5_format() [2/2]

void h5::read_hdf5_format ( object obj,
std::string & s )

#include <h5/format.cpp>

Read an hdf5_format tag from an HDF5 attribute with the name 'Format'.

Parameters
objh5::object from which the attribute is read.
sString to be read into.

Definition at line 32 of file format.cpp.

◆ read_hdf5_format_from_key()

void h5::read_hdf5_format_from_key ( group g,
std::string const & key,
std::string & s )

#include <h5/format.cpp>

Read an hdf5_format tag from an HDF5 attribute with the name 'Format'.

Parameters
gh5::group containing the HDF5 object from which the attribute is read.
keyName of the object.
sString to be read into.

Definition at line 45 of file format.cpp.

◆ write_hdf5_format()

template<typename T >
void h5::write_hdf5_format ( object obj,
T const &  )
inline

#include <h5/format.hpp>

Write an hdf5_format tag for type T to an HDF5 attribute with the name 'Format' using template argument deduction.

Template Parameters
TType for which the hdf5_format tag is to be written.
Parameters
objh5::object to which the attribute is attached.

Definition at line 113 of file format.hpp.

◆ write_hdf5_format_as_string()

void h5::write_hdf5_format_as_string ( object obj,
std::string const & s )
inline

#include <h5/format.hpp>

Write a std::string to an HDF5 attribute with the name 'Format'.

Parameters
objh5::object to which the attribute is attached.
sString to be written.

Definition at line 103 of file format.hpp.