#include <iostream>
#include <string>
#include <vector>
#include <h5cpp/all>
namespace {
int errors = 0;
template <class A, class B>
void check(const char* tag, const A& expected, const B& got) {
const bool ok = (expected == got);
if (!ok) ++errors;
<< tag << "\n";
}
}
int main() {
{
check("std::string scalar (VLEN)", greeting, back);
}
{
check("non-ASCII UTF-8 content (Greek / Japanese / emoji / math)",
utf8, back);
}
{
h5::utils::get_test_data<std::string>(20);
check("std::vector<std::string> dataset (20 rows)", rows, back);
}
{
h5::offset{5}, h5::count{8});
check("partial IO via offset=5, count=8 (contiguous slice)",
expected, sub);
}
{
check("scalar std::string attribute",
check("ASCII attribute under UTF-8 cset",
}
{
check("std::vector<std::string> attribute (4 tags)", tags, back);
}
{
check("ds[\"name\"] = string operator-= sugar",
}
{
std::cout <<
"\npretty-print of /bulk/rows via h5cpp's STL streamer:\n ";
}
<< (errors == 0 ? "✔ all checks passed"
: "✘ some checks failed")
<< ", errors=" << errors << "\n";
return errors;
}
h5::at_t create(const hid_t &parent, const std::string &path, args_t &&... args)
Create a new attribute of element type T on a parent HDF5 object.
Definition H5Acreate.hpp:100
T aread(const hid_t &ds, const std::string &name, const h5::acpl_t &acpl=h5::default_acpl)
Read an attribute by name and return its value as type T.
Definition H5Aread.hpp:76
h5::at_t open(const hid_t &parent, const std::string &path, const h5::acpl_t &acpl=h5::default_acpl)
Open an existing attribute by name on a parent HDF5 object.
Definition H5Aopen.hpp:56
void awrite(const h5::at_t &attr, const T *ptr)
Low-level attribute write — copies elements from ptr into an already-open h5::at_t.
Definition H5Awrite.hpp:47
h5::gr_t write(const LOC &parent, const std::string &path, const T &src)
Write a sparse matrix or vector as a CSC group.
Definition H5Dsparse.hpp:185