#include <h5cpp/all>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <memory>
#include <vector>
int main() {
auto check = [](const char* label, bool ok) {
std::cout << (ok ?
"✔ ok " :
"✘ failed") <<
" " << label <<
"\n";
};
{
h5::current_dims{10, 20}, h5::max_dims{10, H5S_UNLIMITED},
h5::create_path | h5::utf8,
h5::chunk{2, 3} | h5::fill_value<short>{42} | h5::fletcher32
| h5::shuffle | h5::nbit | h5::gzip{9},
h5::default_dapl);
| h5::fletcher32 | h5::shuffle | h5::nbit | h5::gzip{9};
h5::current_dims{10, 20}, h5::max_dims{10, H5S_UNLIMITED}, dcpl);
h5::current_dims{10, 20}, h5::max_dims{10, H5S_UNLIMITED},
h5::default_lcpl, dcpl, h5::default_dapl);
h5::max_dims{10, H5S_UNLIMITED},
h5::max_dims{H5S_UNLIMITED},
h5::chunk{10} | h5::gzip{9});
}
double src[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
h5::count{1, 8}, h5::offset{0, 2});
{
bool ok = true;
for (int i = 0; ok && i < 10; ++i) ok = (buf[i] == want[i]);
check("read offset{0,2} count{1,8} -> buf[0..7] (tail zero-init)", ok);
}
h5::count{1, 3});
{
bool ok = true;
for (int i = 0; ok && i < 10; ++i) ok = (buf[i] == want[i]);
check("read into buf+4: buf[4..6] = first 3 of file", ok);
}
{
for (int i = 0; i < 16; ++i) out[i] = i * i;
bool ok = true;
for (int i = 0; ok && i < 16; ++i) ok = (back[i] == i * i);
check("write/read int32[16] (squares)", ok);
}
return 0;
}
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