ritsuko
Helper utilities for ArtifactDB C++ code
Loading...
Searching...
No Matches
get_name.hpp
Go to the documentation of this file.
1#ifndef RITSUKO_HDF5_GET_NAME_HPP
2#define RITSUKO_HDF5_GET_NAME_HPP
3
4#include "H5Cpp.h"
5#include <string>
6#include <vector>
7
13namespace ritsuko {
14
15namespace hdf5 {
16
23template<class Handle_>
24std::string get_name(const Handle_& handle) {
25 if constexpr(std::is_same<Handle_, H5::Attribute>::value) {
26 std::string name;
27 handle.getName(name);
28 return name;
29 } else {
30 size_t len = H5Iget_name(handle.getId(), NULL, 0);
31 std::vector<char> buffer(len + 1);
32 H5Iget_name(handle.getId(), buffer.data(), buffer.size());
33 return std::string(buffer.begin(), buffer.begin() + len);
34 }
35}
36
37}
38
39}
40
41#endif
std::string get_name(const Handle_ &handle)
Definition get_name.hpp:24
Assorted helper functions for parsing and validation.
Definition choose_missing_placeholder.hpp:15