30 const auto& dtype = data.getDataType();
31 assert(dtype.getClass() == H5T_STRING);
32 assert(data.getSpace().getSimpleExtentNdims() == 0);
34 if (dtype.isVariableStr()) {
35 const auto& dspace = data.getSpace();
36 const auto& plist = H5::DSetMemXferPropList::DEFAULT;
38 data.read(&vptr, dtype);
41 throw std::runtime_error(
"detected a NULL pointer for a variable length string in '" +
get_name(data) +
"'");
43 std::string output(vptr);
47 const auto fixed_length = dtype.getSize();
48 auto buffer = sanisizer::create<std::vector<char> >(fixed_length);
49 data.read(buffer.data(), dtype);
50 return std::string(buffer.begin(), buffer.begin() +
strnlen(buffer.data(), fixed_length));
60 const auto& dtype = attr.getDataType();
61 assert(dtype.getClass() == H5T_STRING);
62 assert(attr.getSpace().getSimpleExtentNdims() == 0);
67 if (dtype.isVariableStr()) {
68 const auto& dspace = attr.getSpace();
69 const auto& plist = H5::DSetMemXferPropList::DEFAULT;
71 attr.read(dtype, &buffer);
74 throw std::runtime_error(
"detected a NULL pointer for a variable length string attribute");
76 return std::string(buffer);
79 const auto len = dtype.getSize();
80 auto buffer = sanisizer::create<std::vector<char> >(len);
81 attr.read(dtype, buffer.data());
82 return std::string(buffer.begin(), buffer.begin() +
strnlen(buffer.data(), len));