#include <h5cpp/all>
#include <iostream>
#include <stdexcept>
#ifndef H5_HAVE_ROS3_VFD
int main() {
std::cerr <<
"This example requires HDF5 built with ROS3 VFD support.\n"
<< "Rebuild HDF5 with --enable-ros3-vfd (and libcurl + OpenSSL).\n";
return 1;
}
#else
int main() {
try {
{
"https://rhdf5-public.s3.eu-central-1.amazonaws.com/h5ex_t_array.h5",
H5F_ACC_RDONLY,
h5::ros3{
false,
"eu-central-1",
"",
""});
for (
auto& name :
h5::ls(fd,
"/"))
std::cout <<
" /" << name <<
"\n";
hid_t dt = H5Dget_type(static_cast<hid_t>(ds));
auto npoints = H5Sget_simple_extent_npoints(H5Dget_space(static_cast<hid_t>(ds)));
H5Dread(static_cast<hid_t>(ds), dt, H5S_ALL, H5S_ALL, H5P_DEFAULT, data.data());
H5Tclose(dt);
std::cout <<
" /DS1: read " << data.size() <<
" int64s ("
<< data.size() * sizeof(int64_t) << " bytes) from S3\n";
for (int r = 0; r < 3; ++r) {
for (
int c = 0; c < 5; ++c)
std::cout << data[r*5 + c] <<
'\t';
}
}
const char* secret =
std::getenv(
"AWS_SECRET_ACCESS_KEY");
if (region && key_id && secret) {
"https://my-private-bucket.s3.us-east-1.amazonaws.com/archive/run42.h5",
H5F_ACC_RDONLY,
h5::ros3{
true, region, key_id, secret});
auto entries = h5::ls(fd, "/");
std::cout <<
"Private bucket (long-term creds):\n";
for (
auto& name : entries)
std::cout <<
" /" << name <<
"\n";
std::cout <<
" read " << temps.size() <<
" temperature values\n";
} else {
std::cout <<
"Set AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY "
"to test authenticated access.\n";
}
#if H5FD_CURR_ROS3_FAPL_T_VERSION >= 2
if (region && key_id && secret && token) {
"https://my-secure-bucket.s3.us-east-1.amazonaws.com/data.h5",
H5F_ACC_RDONLY,
h5::ros3{
true, region, key_id, secret, token});
auto entries = h5::ls(fd, "/");
std::cout <<
"Secure bucket (STS session token):\n";
for (
auto& name : entries)
std::cout <<
" /" << name <<
"\n";
}
#endif
return 1;
}
return 0;
}
#endif
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
public namespace
Definition compat.hpp:11