HighFive 3.0.0
HighFive - Header-only C++ HDF5 interface
Loading...
Searching...
No Matches
H5DataSpace.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#pragma once
10
11#include <vector>
12#include <array>
13#include <cstdint>
14#include <type_traits>
15#include <initializer_list>
16
17#include "H5Object.hpp"
19
20namespace HighFive {
21
22namespace detail {
27DataSpace make_data_space(hid_t hid);
28} // namespace detail
29
39class DataSpace: public Object {
40 public:
42
49 static const size_t UNLIMITED = SIZE_MAX;
50
56 enum class DataspaceType {
59 // simple dataspace are handle directly from their dimensions
60 };
61
62 // For backward compatibility: `DataSpace::dataspace_scalar`.
65
74 explicit DataSpace(const std::vector<size_t>& dims);
75
84 template <size_t N>
85 explicit DataSpace(const std::array<size_t, N>& dims);
86
95 DataSpace(const std::initializer_list<size_t>& dims);
96
106 template <typename... Args>
107 explicit DataSpace(size_t dim1, Args... dims);
108
120 // Attention: Explicitly disable DataSpace(int_like, int_like) from trying
121 // to use this constructor
122 template <typename IT,
123 typename = typename std::enable_if<!std::is_integral<IT>::value, IT>::type>
124 DataSpace(const IT begin, const IT end);
125
138 explicit DataSpace(const std::vector<size_t>& dims, const std::vector<size_t>& maxdims);
139
158 explicit DataSpace(DataspaceType space_type);
159
167 static DataSpace Scalar();
168
176 static DataSpace Null();
177
186 DataSpace clone() const;
187
194 size_t getNumberDimensions() const;
195
209 std::vector<size_t> getDimensions() const;
210
218 size_t getElementCount() const;
219
232 std::vector<size_t> getMaxDimensions() const;
233
247 template <typename T>
248 static DataSpace From(const T& value);
249
259 template <std::size_t N, std::size_t Width>
260 static DataSpace FromCharArrayStrings(const char (&string_array)[N][Width]);
261
262 protected:
263 DataSpace() = default;
264
265 static DataSpace fromId(hid_t hid) {
266 DataSpace space;
267 space._hid = hid;
268
269 return space;
270 }
271
272 friend class Attribute;
273 friend class File;
274 friend class DataSet;
275
276 friend DataSpace detail::make_data_space(hid_t hid);
277};
278
279} // namespace HighFive
280
281// We include bits right away since DataSpace is user-constructible
Class representing an Attribute of a DataSet or Group.
Definition H5Attribute.hpp:47
Class representing a dataset.
Definition H5DataSet.hpp:30
Class representing the space (dimensions) of a DataSet.
Definition H5DataSpace.hpp:39
static DataSpace FromCharArrayStrings(const char(&string_array)[N][Width])
Create a DataSpace from a value of type string array.
Definition H5Dataspace_misc.hpp:134
static const ObjectType type
Definition H5DataSpace.hpp:41
static DataSpace fromId(hid_t hid)
Definition H5DataSpace.hpp:265
static DataSpace From(const T &value)
Automatically deduce the DataSpace from a container/value.
Definition H5Dataspace_misc.hpp:128
size_t getNumberDimensions() const
Returns the number of dimensions of a DataSpace.
Definition H5Dataspace_misc.hpp:100
std::vector< size_t > getMaxDimensions() const
Returns the maximum size of the dataset in each dimension.
Definition H5Dataspace_misc.hpp:116
DataspaceType
An enum to create scalar and null DataSpace with DataSpace::DataSpace(DataspaceType dtype).
Definition H5DataSpace.hpp:56
@ dataspace_null
Value to create null DataSpace.
@ dataspace_scalar
Value to create scalar DataSpace.
static DataSpace Scalar()
Create a scalar DataSpace.
Definition H5Dataspace_misc.hpp:51
static constexpr DataspaceType dataspace_scalar
Definition H5DataSpace.hpp:63
size_t getElementCount() const
Return the number of elements in this DataSpace.
Definition H5Dataspace_misc.hpp:112
std::vector< size_t > getDimensions() const
Returns the size of the dataset in each dimension.
Definition H5Dataspace_misc.hpp:104
DataSpace clone() const
Create a copy of the DataSpace which will have different id.
Definition H5Dataspace_misc.hpp:94
static constexpr DataspaceType dataspace_null
Definition H5DataSpace.hpp:64
static DataSpace Null()
Create a null DataSpace.
Definition H5Dataspace_misc.hpp:55
static const size_t UNLIMITED
Magic value to specify that a DataSpace can grow without limit.
Definition H5DataSpace.hpp:49
File class.
Definition H5File.hpp:25
Definition H5Object.hpp:35
hid_t _hid
Definition H5Object.hpp:86
Definition assert_compatible_spaces.hpp:15
ObjectType
Enum of the types of objects (H5O api)
Definition H5Object.hpp:24