TRIQS/h5 2.0.0
C++ interface to HDF5
Loading...
Searching...
No Matches
storable.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
21
22#ifndef LIBH5_STORABLE_HPP
23#define LIBH5_STORABLE_HPP
24
25#include "./format.hpp"
26#include "./group.hpp"
27
28#include <concepts>
29#include <string>
30
31namespace h5 {
32
38 template <typename T>
39 concept Storable = requires(T const &xc, h5::group g, std::string const &name) {
40 { T::hdf5_format() } -> std::convertible_to<std::string>;
41 { h5_write(g, name, xc) };
42 } && (requires(T &x, h5::group g, std::string const &name) {
43 { h5_read(g, name, x) };
44 } || requires(h5::group g, std::string const &name) {
45 { T::h5_read_construct(g, name) };
46 });
47
48} // namespace h5
49
50#endif // LIBH5_STORABLE_HPP
A handle to an HDF5 group.
Definition group.hpp:44
Concept to check if a type can be read/written from/to HDF5.
Definition storable.hpp:39
Provides utilities for reading and writing hdf5_format tags.
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:53
void h5_write(group g, std::string const &name, T const &x)
Write a scalar to an HDF5 dataset.
Definition scalar.hpp:71