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

Detailed Description

Implementations of various types representing some of the key concepts of the abstract HDF5 data model.

The base type in this hierarchy is h5::object. The h5::object class is a simple wrapper around an HDF5 object. It stores the HDF5 ID of the wrapped object and is either used as a base class (h5::file, h5::group) or as an alias (h5::dataset, h5::datatype, h5::dataspace, h5::proplist, h5::attribute) for other HDF5 objects.

All object lifetimes are handled by a reference counting approach based on RAII.

The following code shows how one can use those basic types to create a file ("file.h5") and write a number ("e") to the root ("/") group. Then a subgroup ("mydata") is created in the root group and the number "pi" is written to it:

#include <h5/h5.hpp>
int main() {
// create file in write mode
h5::file file("file.h5", 'w');
// write Euler number
h5::write(file, "e", 2.7182);
// create root group
h5::group root(file);
// create a subgroup of root
auto subgroup = root.create_group("mydata");
// write pi to subgroup
h5::write(subgroup, "pi", 3.1415);
}
A handle to an HDF5 file.
Definition file.hpp:43
A handle to an HDF5 group.
Definition group.hpp:44
void write(group g, std::string const &key, T const &x, auto const &...args)
Generic implementation for writing a variable to an HDF5 dataset/subgroup.
Definition generic.hpp:105
Includes all relevant h5 headers.

Contents of file.h5:

HDF5 "file.h5" {
GROUP "/" {
DATASET "e" {
DATATYPE H5T_IEEE_F64LE
DATASPACE SCALAR
DATA {
(0): 2.7182
}
}
GROUP "mydata" {
DATASET "pi" {
DATATYPE H5T_IEEE_F64LE
DATASPACE SCALAR
DATA {
(0): 3.1415
}
}
}
}
}

Classes

class  h5::file
 A handle to an HDF5 file. More...
 
class  h5::group
 A handle to an HDF5 group. More...
 
class  h5::object
 A generic handle for HDF5 objects. More...
 

Typedefs

using h5::attribute = object
 Type alias for an HDF5 attribute.
 
using h5::dataset = object
 Type alias for an HDF5 dataset.
 
using h5::dataspace = object
 Type alias for an HDF5 dataspace.
 
using h5::datatype = object
 Type alias for an HDF5 datatype.
 
using h5::proplist = object
 Type alias for an HDF5 property list.