HDF5File
Represents an HDF5 file handle.
Use this class to create, read and write datasets. Datasets are addressed by path, with optional group segments (e.g. "group/data"). New datasets are compressed by default (deflate level 4).") .example(R"(var f = HDF5File("data.h5", "w") f.write("/answer", 42) var value = f.read("/answer", as_integer)
Constructors
HDF5File(const string path) -> HDF5File
Opens an HDF5 file in read/write mode, creating it if needed.
Parameters
- path: File path.
Example
var f = HDF5File("data.h5")
HDF5File(const string path, const string mode) -> HDF5File
Opens an HDF5 file with an explicit mode.
Modes:
- "r": read-only
- "r+": read/write (existing file)
- "w": truncate and overwrite
- "w-" or "x": create, fail if it exists
- "a": read/write, create if missing (default)
Parameters
- path: File path.
- mode: File open mode.
Example
var f = HDF5File("data.h5", "w")
Members
| Name | Description |
|---|---|
| compression_enabled | Returns whether dataset compression is enabled for new datasets (level > 0). |
| compression_level | Returns the compression level used for new datasets (0-9). |
| create_group | Creates a group (including intermediate groups). |
| delete_attribute | Deletes an attribute and returns the file for chaining. |
| delete_dataset | Deletes a dataset. |
| delete_group | Deletes a group. |
| exists | Checks whether a dataset or group exists at the given path. |
| group | Opens or creates a group. |
| has_attribute | Checks whether an attribute exists on a file, group, or dataset. |
| is_dataset | Checks whether a path is a dataset. |
| is_group | Checks whether a path is a group. |
| list_attributes | Lists attribute names for a file, group, or dataset. |
| list_datasets | Lists datasets in the root group. |
| list_groups | Lists groups in the root group. |
| list_objects | Lists objects in the root group. |
| move | Moves or renames an object. |
| object_type | Returns the object type at a path. |
| open_group | Opens an existing group. |
| rank | Returns dataset rank. |
| read | Reads a real scalar dataset. |
| read_attribute | Reads a string scalar attribute. |
| set_compression_level | Sets dataset compression level (0-9) for newly created datasets. Level 0 disables compression. |
| shape | Returns dataset dimensions. |
| size | Returns dataset element count. |
| write | Writes a real list dataset. |
| write_attribute | Writes an attribute and returns the file for chaining. |