HighFive 2.7.1
HighFive - Header-only C++ HDF5 interface
Loading...
Searching...
No Matches
H5Node_traits.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 <string>
12
13#include "../H5PropertyList.hpp"
14#include "H5_definitions.hpp"
15#include "H5Converter_misc.hpp"
16
17namespace HighFive {
18
19enum class IndexType : std::underlying_type<H5_index_t>::type {
20 NAME = H5_INDEX_NAME,
21 CRT_ORDER = H5_INDEX_CRT_ORDER,
22};
23
27template <typename Derivate>
29 public:
40 DataSet createDataSet(const std::string& dataset_name,
41 const DataSpace& space,
42 const DataType& type,
45 bool parents = true);
46
56 template <typename T,
57 typename std::enable_if<
58 std::is_same<typename details::inspector<T>::base_type, details::Boolean>::value,
59 int>::type* = nullptr>
60 DataSet createDataSet(const std::string& dataset_name,
61 const DataSpace& space,
64 bool parents = true);
65
66 template <typename T,
67 typename std::enable_if<
68 !std::is_same<typename details::inspector<T>::base_type, details::Boolean>::value,
69 int>::type* = nullptr>
70 DataSet createDataSet(const std::string& dataset_name,
71 const DataSpace& space,
74 bool parents = true);
75
86 template <typename T>
87 DataSet createDataSet(const std::string& dataset_name,
88 const T& data,
91 bool parents = true);
92
93
94 template <std::size_t N>
95 DataSet createDataSet(const std::string& dataset_name,
96 const FixedLenStringArray<N>& data,
99 bool parents = true);
100
106 DataSet getDataSet(const std::string& dataset_name,
107 const DataSetAccessProps& accessProps = DataSetAccessProps::Default()) const;
108
114 Group createGroup(const std::string& group_name, bool parents = true);
115
122 Group createGroup(const std::string& group_name,
123 const GroupCreateProps& createProps,
124 bool parents = true);
125
130 Group getGroup(const std::string& group_name) const;
131
135 size_t getNumberObjects() const;
136
140 std::string getObjectName(size_t index) const;
141
148 bool rename(const std::string& src_path,
149 const std::string& dest_path,
150 bool parents = true) const;
151
158 std::vector<std::string> listObjectNames(IndexType idx_type = IndexType::NAME) const;
159
164 bool exist(const std::string& node_name) const;
165
169 void unlink(const std::string& node_name) const;
170
174 LinkType getLinkType(const std::string& node_name) const;
175
179 ObjectType getObjectType(const std::string& node_name) const;
180
184 template <typename T, typename = decltype(&T::getPath)>
185 void createSoftLink(const std::string& linkName, const T& obj) {
186 static_assert(!std::is_same<T, Attribute>::value,
187 "hdf5 doesn't support soft links to Attributes");
188 createSoftLink(linkName, obj.getPath());
189 }
190
198 void createSoftLink(const std::string& link_name,
199 const std::string& obj_path,
200 LinkCreateProps linkCreateProps = LinkCreateProps(),
201 const LinkAccessProps& linkAccessProps = LinkAccessProps(),
202 const bool parents = true);
203
204 void createExternalLink(const std::string& link_name,
205 const std::string& h5_file,
206 const std::string& obj_path,
207 LinkCreateProps linkCreateProps = LinkCreateProps(),
208 const LinkAccessProps& linkAccessProps = LinkAccessProps(),
209 const bool parents = true);
210
211 private:
212 using derivate_type = Derivate;
213
214 // A wrapper over the low-level H5Lexist
215 // It makes behavior consistent among versions and by default transforms
216 // errors to exceptions
217 bool _exist(const std::string& node_name, bool raise_errors = true) const;
218
219 // Opens an arbitrary object to obtain info
220 Object _open(const std::string& node_name,
221 const DataSetAccessProps& accessProps = DataSetAccessProps::Default()) const;
222};
223
224
228enum class LinkType {
229 Hard,
230 Soft,
231 External,
232 Other // Reserved or User-defined
233};
234
235
236} // namespace HighFive
Class representing a dataset.
Definition H5DataSet.hpp:30
Class representing the space (dimensions) of a dataset.
Definition H5DataSpace.hpp:25
HDF5 Data Type.
Definition H5DataType.hpp:54
A structure representing a set of fixed-length strings.
Definition H5DataType.hpp:284
Represents an hdf5 group.
Definition H5Group.hpp:46
NodeTraits: Base class for Group and File.
Definition H5Node_traits.hpp:28
Group getGroup(const std::string &group_name) const
open an existing group with the name group_name
Definition H5Node_traits_misc.hpp:167
std::vector< std::string > listObjectNames(IndexType idx_type=IndexType::NAME) const
list all leaf objects name of the node / group
Definition H5Node_traits_misc.hpp:222
void unlink(const std::string &node_name) const
unlink the given dataset or group
Definition H5Node_traits_misc.hpp:274
void createExternalLink(const std::string &link_name, const std::string &h5_file, const std::string &obj_path, LinkCreateProps linkCreateProps=LinkCreateProps(), const LinkAccessProps &linkAccessProps=LinkAccessProps(), const bool parents=true)
Definition H5Node_traits_misc.hpp:341
DataSet getDataSet(const std::string &dataset_name, const DataSetAccessProps &accessProps=DataSetAccessProps::Default()) const
get an existing dataset in the current file
Definition H5Node_traits_misc.hpp:120
void createSoftLink(const std::string &linkName, const T &obj)
A shorthand to create softlink to any object which provides getPath The link will be created with def...
Definition H5Node_traits.hpp:185
Group createGroup(const std::string &group_name, bool parents=true)
create a new group, and eventually intermediate groups
Definition H5Node_traits_misc.hpp:133
DataSet createDataSet(const std::string &dataset_name, const DataSpace &space, const DataType &type, const DataSetCreateProps &createProps=DataSetCreateProps::Default(), const DataSetAccessProps &accessProps=DataSetAccessProps::Default(), bool parents=true)
createDataSet Create a new dataset in the current file of datatype type and of size space
Definition H5Node_traits_misc.hpp:34
bool rename(const std::string &src_path, const std::string &dest_path, bool parents=true) const
moves an object and its content within an HDF5 file.
Definition H5Node_traits_misc.hpp:202
bool exist(const std::string &node_name) const
check a dataset or group exists in the current node / group
Definition H5Node_traits_misc.hpp:261
ObjectType getObjectType(const std::string &node_name) const
A shorthand to get the kind of object pointed to (group, dataset, type...)
Definition H5Node_traits_misc.hpp:315
size_t getNumberObjects() const
return the number of leaf objects of the node / group
Definition H5Node_traits_misc.hpp:178
std::string getObjectName(size_t index) const
return the name of the object with the given index
Definition H5Node_traits_misc.hpp:188
LinkType getLinkType(const std::string &node_name) const
Returns the kind of link of the given name (soft, hard...)
Definition H5Node_traits_misc.hpp:301
DataSet createDataSet(const std::string &dataset_name, const DataSpace &space, const DataSetCreateProps &createProps=DataSetCreateProps::Default(), const DataSetAccessProps &accessProps=DataSetAccessProps::Default(), bool parents=true)
Definition H5Object.hpp:54
HDF5 property Lists.
Definition H5PropertyList.hpp:79
static const PropertyList< T > & Default() noexcept
Return the Default property type object.
Definition H5PropertyList.hpp:97
Definition H5_definitions.hpp:15
PropertyList< PropertyType::LINK_CREATE > LinkCreateProps
Definition H5PropertyList.hpp:118
PropertyList< PropertyType::LINK_ACCESS > LinkAccessProps
Definition H5PropertyList.hpp:119
LinkType
The possible types of group entries (link concept)
Definition H5Node_traits.hpp:228
ObjectType
Enum of the types of objects (H5O api)
Definition H5Object.hpp:24
IndexType
Definition H5Node_traits.hpp:19