H5CPP  v1.14.0
Modern C++ templates for HDF5 serial and parallel I/O
Loading...
Searching...
No Matches
h5::open

Open an existing HDF5 file at path. RAII-managed h5::fd_t returned.

unsigned flags,
const h5::fapl_t& fapl = h5::default_fapl);
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

Opens an existing HDF5 container at path. The flags argument controls the access mode (read-only vs read-write); fapl selects the file driver and tunes access-level behaviour.

Parameters

Name Type Description
path const std::string& OS file system path to an existing HDF5 container.
flags unsigned H5F_ACC_RDONLY (read-only) or H5F_ACC_RDWR (read-write).
fapl const h5::fapl_t& File-access property list. Defaults to h5::default_fapl.

Returnsh5::fd_t RAII handle.

Throws

Exception When
h5::error::io::file::open File does not exist, permission denied, magic-byte mismatch, unsupported on-disk format.
h5::error::property_list::misc Invalid fapl was supplied.

Example

// Read-only — safe default for inspection / analysis.
h5::fd_t fd = h5::open("dataset.h5", H5F_ACC_RDONLY);
auto data = h5::read<std::vector<float>>(fd, "/grid/values");
// Read-write — required if you'll be writing or appending.
h5::fd_t rw = h5::open("log.h5", H5F_ACC_RDWR);
h5::awrite(rw, "schema_version", 1.4);
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
See also
h5::create, FILE