About the Examples#

You find examples for most implemented features on the project GitHub page, or, if installed from a package manager, in /usr/local/share/h5cpp. Only cmake, a C++17 compatible toolchain, and a copy of the HDF5 library (1.10.x) are required to run them. The examples can be built with cmake or from traditional makefiles.


This example demonstrates how to create and manipulate HDF5 containers with H5CPP read on HDF5 container here.


Akin to files in file systems, datasets in HDF5 containers are organized in a tree-like data structure, where each non-terminal node in the path is called a group. These examples illustrate how to manipulate groups, including how to add attributes. You can read more about groups here.


This example is a guide on how to create HDF5 datasets, and control their properties. You can read more on datasets here.


Objects may have additional information attached to them via so-called attributes ("key-value pairs"). Currently only datasets h5::ds_t are supported, but at some point this will be extended to h5::gr_t and h5::dt_t. Attributes are intended to record metadata about objects. While (as of HDF5 1.8) there is no restriction on their size, they can be accessed only in an atomic fashion, i.e., selection-based I/O is not supported for HDF5 attributes. You can read more on attributes here.


Sparse matrices are ubiquitous in engineering. For low fill-rate matrices, various storage formats are explored. Read more on sparse matrices here.


This example demonstrates data descriptors, their properties, and how to work with them.


This example provides an API comparison between the C API and H5CPP for persisting a compound datatype. While the example uses the h5cpp compiler, the generated.hpp header file is provided for convenience. Written by Gerd Heber, The HDFGroup


This is another example for persisting Plain Old Data (POD) Struct types, where a more complex struct was chosen to show that the compiler can handle arbitrarily nested types, and to give a glimpse of the quality of the generated header file.


This includes all the linear algebra-related examples for various systems. If you are a data-scientist/engineer working with massive HDF5 datasets, probably this is where you want to start.


The Message Passing Interface (MPI) is de facto standard for parallel application development on HPC clusters and supercomputers. This example demonstrates how to persist data to a parallel file system with collective and independent IO requests. This section is for people who intend to write code for MPI based systems.

multi translation unit - h5cpp compiler#

Projects are rarely small. To break such projects into different translation units is a natural way of handling complexity for compiled systems. This example shows you how to organize a makefile and how to write the program file so that it can work correctly with the h5cpp source code transformation tool.

packet table#

Streams of packets from sensor networks, stock exchanges, ... need a high-performance event processor. This example shows you how simple it is to persist a variety record streams into an HDF5 datasets. Supported objects include:

The packet table is also known to work with matrices, vectors, etc...

raw memory#

The example illustrates how to save data from memory locations, demonstrates the use of filtering algorithms such as h5::fletcher32 | h5::shuffle | h5::nbit | h5::gzip{9}, and how to set a fill value with h5::fill_value<short>{42}


This is a brief example of how to save a set of strings with h5::utf8 encoding


This is a simple example of how to transform/change data within the data transfer buffer of the HDF5 C library. The purpose of this feature is to change the dataset transparently before loading, or saving.

google test#

Integrity tests are with google-test framework and placed under test/ directory