8 #ifndef UTOPIA_DATAIO_HDFUTILITIES_HH
9 #define UTOPIA_DATAIO_HDFUTILITIES_HH
15 #include <string_view>
16 #include <type_traits>
82 throw std::runtime_error(
"Object " + std::string(object_name) +
": " +
83 "Error in validity check");
109 hid_t link_property_list = H5P_DEFAULT)
113 std::size_t seg_pos = (path.find(
"/") == 0) ? 1 : 0;
119 while (seg_pos != std::string::npos)
123 seg_pos = path.find(
"/", seg_pos + 1);
128 loc_id, path.substr(0, seg_pos).c_str(), link_property_list);
152 auto test = H5LTpath_valid(
id, path.c_str(),
true);
163 throw std::runtime_error(
"Error when checking path " + path);
188 template < HDFCategory category >
218 template <
class Object >
222 return "category " + category_to_string< Object::category >() +
" at '" +
223 object.get_path() +
"'";
233 template <
typename Object >
239 return H5Dget_space(
object.get_C_id());
241 else if constexpr (std::decay_t< Object >::category ==
244 return H5Aget_space(
object.get_C_id());
259 template <
typename Object >
265 return H5Dget_type(
object.get_C_id());
267 else if constexpr (std::decay_t< Object >::category ==
270 return H5Aget_type(
object.get_C_id());
hid_t open_dataspace(Object &&object)
Depending on object category, opens a dataset or attribute dataspace.
Definition: hdfutilities.hh:235
bool check_validity(htri_t valid, const std::string_view object_name)
Check for validity of a hdf5 htri_t type or similar.
Definition: hdfutilities.hh:73
std::string generate_object_name(const Object &object)
Use category and path variable of object to make a string that identifies the object it is applied to...
Definition: hdfutilities.hh:220
auto path_is_valid(hid_t id, std::string path)
Check if the path given relative to the object identified by 'id' exists and points to a valid hdf5 o...
Definition: hdfutilities.hh:150
htri_t path_exists(hid_t loc_id, std::string path, hid_t link_property_list=H5P_DEFAULT)
Checks iteratively if each segment of a path exists.
Definition: hdfutilities.hh:107
std::string category_to_string()
Turn category enum into a string that names it.
Definition: hdfutilities.hh:190
hid_t open_type(Object &&object)
Depending on object category, invokes H5Dget_type or H5Aget_type.
Definition: hdfutilities.hh:261
HDFCategory
Enumerate the different HDF5 object types for use in HDFObject class.
Definition: hdfutilities.hh:173