28 auto dtype = attr.getDataType();
33 if (dtype.isVariableStr()) {
34 auto mspace = attr.getSpace();
36 attr.read(dtype, &buffer);
37 [[maybe_unused]] VariableStringCleaner deletor(dtype.getId(), mspace.getId(), &buffer);
39 throw std::runtime_error(
"detected a NULL pointer for a variable length string attribute");
41 return std::string(buffer);
44 size_t len = dtype.getSize();
45 std::vector<char> buffer(len);
46 attr.read(dtype, buffer.data());
47 auto ptr = buffer.data();
48 return std::string(ptr, ptr + find_string_length(ptr, len));
60 auto dtype = attr.getDataType();
61 auto mspace = attr.getSpace();
62 std::vector<std::string> output;
63 output.reserve(full_length);
65 if (dtype.isVariableStr()) {
66 std::vector<char*> buffer(full_length);
67 attr.read(dtype, buffer.data());
68 [[maybe_unused]] VariableStringCleaner deletor(dtype.getId(), mspace.getId(), buffer.data());
69 for (hsize_t i = 0; i < full_length; ++i) {
70 if (buffer[i] == NULL) {
71 throw std::runtime_error(
"detected a NULL pointer for a variable length string attribute");
73 output.emplace_back(buffer[i]);
77 size_t len = dtype.getSize();
78 std::vector<char> buffer(len * full_length);
79 attr.read(dtype, buffer.data());
80 auto ptr = buffer.data();
81 for (
size_t i = 0; i < full_length; ++i, ptr += len) {
82 output.emplace_back(ptr, ptr + find_string_length(ptr, len));