H5pp - a C++17 wrapper for the HDF5 C library

Hi all!

I humbly present h5pp, a C++17 wrapper for HDF5. Yes. Another one.

I have been working on h5pp for a bit more than a year now as a weekend project and I think it’s ready for some new eyes. You can find an up-to-date feature list and other details on the github readme, so I think some highlights will suffice here:

  • Header-only template library.
  • Support for common C++ types including std::string and std::complex.
  • Any of these types inside contiguous containers such as C-style arrays, std::vector, Eigen::Matrix and Eigen::Tensor. Any contiguous buffer can be treated as a multidimensional array by specifying the dimensions when writing to file.
  • Support for user-defined compound types as datasets and tables
  • Only the HDF5 C libraries are required dependencies: Eigen and spdlog are optional.
  • Easy installation with CMake, conan or conda. Automated install of all the dependencies is optional (opt-in).

Right now the library is stable enough that some colleagues and I use it in production code on our respective research projects since a few months back. There is always room for improvement (and a whole lot of documentation), but it should be stressed that this library has a much smaller scope and ambition compared to other libraries (looking at H5CPP, h5cpp and other such libraries). Most importantly, h5pp does not intend to expose the entire API of HDF5 or anything like that. Rather, the goal of h5pp is to make reasonable abstractions and defaults so anybody can start using HDF5 without knowing much at all about it. At the same time though, more confident users of HDF5 should not feel too limited as there are a multitude of optional function arguments that allow more control.

Any questions or feedback are welcome! Big, small, first impressions or even typos. Bear in mind though that this is my first library, so be gentle :wink: I’m happy to consider API-breaking changes, the earlier the better.
If you are so kind to take a look, there are some things that I am particularly interested in to get your thoughts on:

  • The readme, something unclear?
  • Build/installation/linking. Did it work?
  • Naming conventions, are they clear?
  • Examples, were they useful/clear? (I’m planning to add many more)
  • Win/OSX users: anything to report? It seems to work in CI-testing but I don’t have access to any such machines of my own.

I feel I should also mention that I haven’t been around this forum much until very recently, and to be honest I felt really dumb when I realized that I should perhaps just have started using H5CPP or contributed to existing libraries instead. When I first started another research project around 3 years ago, I was looking for std::complex and tensor support, and it seemed to me then that the only option was to use HDF5 directly. In short time all my HDF5-related code was an unmaintainable mess, so last year I decided to break it out into a separate library mostly as a learning experience. But at least it has been fun!

3 Likes