HighFive 2.10.1
HighFive - Header-only C++ HDF5 interface
Loading...
Searching...
No Matches
H5Easy.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c), 2017, Adrien Devresse <adrien.devresse@epfl.ch>
3 *
4 * Distributed under the Boost Software License, Version 1.0.
5 * (See accompanying file LICENSE_1_0.txt or copy at
6 * http://www.boost.org/LICENSE_1_0.txt)
7 *
8 */
9
17
18#pragma once
19
20#include <string>
21#include <vector>
22
23// optionally enable xtensor plug-in and load the library
24#ifdef XTENSOR_VERSION_MAJOR
25#ifndef H5_USE_XTENSOR
26#define H5_USE_XTENSOR
27#endif
28#endif
29
30#ifdef H5_USE_XTENSOR
31#include <xtensor/xarray.hpp>
32#include <xtensor/xtensor.hpp>
33#endif
34
35// optionally enable Eigen plug-in and load the library
36#ifdef EIGEN_WORLD_VERSION
37#ifndef H5_USE_EIGEN
38#define H5_USE_EIGEN
39#endif
40#endif
41
42#ifdef H5_USE_EIGEN
43#include <Eigen/Eigen>
44#endif
45
46// optionally enable OpenCV plug-in and load the library
47#ifdef CV_MAJOR_VERSION
48#ifndef H5_USE_OPENCV
49#define H5_USE_OPENCV
50#endif
51#endif
52
53#ifdef H5_USE_OPENCV
54#include <opencv2/opencv.hpp>
55#endif
56
57#include "H5File.hpp"
58
59namespace H5Easy {
60
69using HighFive::File;
72
75enum class DumpMode {
76 Create = 0,
77 Overwrite = 1
78};
79
82enum class Flush {
83 False = 0,
84 True = 1
85};
86
89class Compression {
90 public:
96 explicit Compression(bool enable = true);
97
102 template <class T>
103 Compression(T level);
104
107 inline unsigned get() const;
108
109 private:
110 unsigned m_compression_level;
111};
112
121class DumpOptions {
122 public:
125 DumpOptions() = default;
126
130 template <class... Args>
131 DumpOptions(Args... args) {
132 set(args...);
133 }
134
138 inline void set(DumpMode mode);
139
143 inline void set(Flush mode);
144
148 inline void set(const Compression& level);
149
154 template <class T, class... Args>
155 inline void set(T arg, Args... args);
156
160 template <class T>
161 inline void setChunkSize(const std::vector<T>& shape);
162
166 inline void setChunkSize(std::initializer_list<size_t> shape);
167
171 inline bool overwrite() const;
172
176 inline bool flush() const;
177
181 inline bool compress() const;
182
186 inline unsigned getCompressionLevel() const;
187
192 inline bool isChunked() const;
193
197 inline std::vector<hsize_t> getChunkSize() const;
198
199 private:
200 bool m_overwrite = false;
201 bool m_flush = true;
202 unsigned m_compression_level = 0;
203 std::vector<hsize_t> m_chunk_size = {};
204};
205
213inline size_t getSize(const File& file, const std::string& path);
214
222inline std::vector<size_t> getShape(const File& file, const std::string& path);
223
234template <class T>
235inline DataSet dump(File& file,
236 const std::string& path,
237 const T& data,
238 DumpMode mode = DumpMode::Create);
239
250template <class T>
251inline DataSet dump(File& file, const std::string& path, const T& data, const DumpOptions& options);
252
263template <class T>
264inline DataSet dump(File& file,
265 const std::string& path,
266 const T& data,
267 const std::vector<size_t>& idx);
268
279template <class T>
280inline DataSet dump(File& file,
281 const std::string& path,
282 const T& data,
283 const std::initializer_list<size_t>& idx);
284
296template <class T>
297inline DataSet dump(File& file,
298 const std::string& path,
299 const T& data,
300 const std::vector<size_t>& idx,
301 const DumpOptions& options);
302
314template <class T>
315inline DataSet dump(File& file,
316 const std::string& path,
317 const T& data,
318 const std::initializer_list<size_t>& idx,
319 const DumpOptions& options);
320
330template <class T>
331inline T load(const File& file, const std::string& path, const std::vector<size_t>& idx);
332
341template <class T>
342inline T load(const File& file, const std::string& path);
343
355template <class T>
356inline Attribute dumpAttribute(File& file,
357 const std::string& path,
358 const std::string& key,
359 const T& data,
360 DumpMode mode = DumpMode::Create);
361
373template <class T>
374inline Attribute dumpAttribute(File& file,
375 const std::string& path,
376 const std::string& key,
377 const T& data,
378 const DumpOptions& options);
379
389template <class T>
390inline T loadAttribute(const File& file, const std::string& path, const std::string& key);
391
392} // namespace H5Easy
393
create an HDF5 DataType from a C++ type
Definition H5DataType.hpp:189
Class representing an Attribute of a DataSet or Group.
Definition H5Attribute.hpp:46
Definition H5PropertyList.hpp:503
Class representing a dataset.
Definition H5DataSet.hpp:30
Class representing the space (dimensions) of a DataSet.
Definition H5DataSpace.hpp:39
Definition H5PropertyList.hpp:522
Basic HighFive Exception class.
Definition H5Exception.hpp:23
File class.
Definition H5File.hpp:24
HDF5 property Lists.
Definition H5PropertyList.hpp:160
Definition H5PropertyList.hpp:550
Definition H5Easy_Eigen.hpp:17
size_t getSize(const File &file, const std::string &path)
Definition H5Easy_public.hpp:82
T loadAttribute(const File &file, const std::string &path, const std::string &key)
Definition H5Easy_public.hpp:166
DataSet dump(File &file, const std::string &path, const T &data, const DumpOptions &options)
Definition H5Easy_public.hpp:91
T load(const File &file, const std::string &path, const std::vector< size_t > &idx)
Definition H5Easy_public.hpp:138
std::vector< size_t > getShape(const File &file, const std::string &path)
Definition H5Easy_public.hpp:86
Attribute dumpAttribute(File &file, const std::string &path, const std::string &key, const T &data, DumpMode mode)
Definition H5Easy_public.hpp:148
ObjectType
Enum of the types of objects (H5O api)
Definition H5Object.hpp:24