TRIQS/h5 1.3.0
C++ interface to HDF5
Loading...
Searching...
No Matches
h5.hpp
Go to the documentation of this file.
1// Copyright (c) 2019-2024 Simons Foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0.txt
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Authors: Thomas Hahn, Olivier Parcollet, Nils Wentzell
16
22#ifndef LIBH5_H5_HPP
23#define LIBH5_H5_HPP
24
25#include <concepts>
26
27#include "./array_interface.hpp"
28#include "./complex.hpp"
29#include "./file.hpp"
30#include "./format.hpp"
31#include "./generic.hpp"
32#include "./group.hpp"
33#include "./object.hpp"
34#include "./scalar.hpp"
35#include "./utils.hpp"
36#include "./stl/string.hpp"
37#include "./stl/array.hpp"
38#include "./stl/vector.hpp"
39#include "./stl/map.hpp"
40#include "./stl/pair.hpp"
41#include "./stl/tuple.hpp"
42#include "./stl/optional.hpp"
43#include "./stl/variant.hpp"
44
45// Define this so cpp2py modules know whether hdf5 was included
46#define H5_INTERFACE_INCLUDED
47
48// in some old version of hdf5 (Ubuntu 12.04 e.g.), the macro is not yet defined.
49#ifndef H5_VERSION_GE
50#define H5_VERSION_GE(Maj, Min, Rel) \
51 (((H5_VERS_MAJOR == Maj) && (H5_VERS_MINOR == Min) && (H5_VERS_RELEASE >= Rel)) || ((H5_VERS_MAJOR == Maj) && (H5_VERS_MINOR > Min)) \
52 || (H5_VERS_MAJOR > Maj))
53#endif
54
55namespace h5 {
56
62 template <typename T>
63 concept Storable = requires(T const &xc, T &x, h5::group g, std::string const &name) {
64 { T::hdf5_format() } -> std::convertible_to<std::string>;
65 { h5_write(g, name, xc) };
66 { h5_read(g, name, x) };
67 };
68
69} // namespace h5
70
71// Python wrapping declaration
72#ifdef C2PY_INCLUDED
73#include <h5/_h5py.wrap.hxx>
74#endif
75
76#endif // LIBH5_H5_HPP
Provides functions to read/write std::array objects from/to HDF5.
Provides a generic interface to read/write n-dimensional arrays from/to HDF5.
A handle to an HDF5 group.
Definition group.hpp:44
Provides a compound type and type traits for complex numbers.
Concept to check if a type can be read/written from/to HDF5.
Definition h5.hpp:63
Provides a handle to an HDF5 file.
Provides utilities for reading and writing hdf5_format tags.
Provides a generic interface for reading/writing data from/to various HDF5 objects.
Provides a handle to an HDF5 group and various methods to simplify the creation/opening of subgroups,...
T h5_read(group g, std::string const &key)
Generic implementation for reading from an HDF5 dataset/subgroup.
Definition generic.hpp:51
void h5_write(group g, std::string const &name, T const &x) H5_REQUIRES(std
Write a scalar to an HDF5 dataset.
Definition scalar.hpp:70
Provides functions to read/write std::map objects from/to HDF5.
Provides a generic handle for HDF5 objects.
Provides functions to read/write std::optional objects from/to HDF5.
Provides functions to read/write std::pair objects from/to HDF5.
Provides a generic interface to read/write scalars from/to HDF5.
Provides functions to read/write std::string, char* and h5::char_buf objects from/to HDF5.
Provides functions to read/write std::tuple object from/to HDF5.
Provides some utility functions for h5.
Provides functions to read/write std::variant object from/to HDF5.
Provides functions to read/write std::vector objects from/to HDF5.