36 for (
auto &x : v) s = std::max(s, x.size() + 1);
39 std::vector<char> buf;
40 buf.resize(std::max(v.size() * s, 1ul), 0x00);
43 strcpy(&buf[i * s], x.c_str());
48 auto len =
v_t{v.size(), s};
56 lv = std::max(lv, v1.size());
57 for (
auto &x : v1) s = std::max(s, x.size() + 1);
61 std::vector<char> buf;
62 buf.resize(std::max(v.size() * lv * s, 1ul), 0x00);
63 for (
int i = 0, k = 0; i < v.size(); i++)
64 for (
int j = 0; j < lv; j++, k++) {
65 if (j < v[i].size()) strcpy(&buf[k * s], v[i][j].c_str());
69 auto len =
v_t{v.size(), lv, s};
79 auto len_string = cb.
lengths[1];
83 const char *bptr = &cb.
buffer[i * len_string];
84 x = std::string(bptr, bptr + len_string);
85 x.erase(std::remove(begin(x), end(x),
'\0'), end(x));
96 auto inner_vec_size = cb.
lengths[1];
97 auto len_string = cb.
lengths[2];
99 for (
auto &v_inner : v) {
100 for (
int j = 0; j < inner_vec_size; ++j, ++i) {
102 const char *bptr = &cb.
buffer[i * len_string];
103 auto s = std::string(bptr, bptr + len_string);
104 s.erase(std::remove(begin(s), end(s),
'\0'), end(s));
105 v_inner.push_back(s);
112 void h5_write_attribute(
object obj, std::string
const &name, std::vector<std::vector<std::string>>
const &v) {
122 void h5_read_attribute(
object obj, std::string
const &name, std::vector<std::vector<std::string>> &v) {
T h5_read_attribute(object obj, std::string const &name)
Generic implementation for reading an HDF5 attribute.
void h5_write_attribute(object obj, std::string const &name, T const &x) H5_REQUIRES(std
Write a scalar to an HDF5 attribute.
void from_char_buf(char_buf const &cb, std::vector< std::string > &v)
Create a vector of strings from an h5::char_buf.
char_buf to_char_buf(std::vector< std::string > const &v)
Create an h5::char_buf from a vector of strings.
std::vector< hsize_t > v_t
Vector of h5::hsize_t used throughout the h5 library.
Stores an arbitrary number of strings in a 1-dimensional std::vector<char>.
v_t lengths
Stores the number of strings in each dimension and the max. allowed length of the strings + 1.
std::vector< char > buffer
Stores strings in a 1-dimensional vector.
Provides functions to read/write std::vector objects from/to HDF5.