|
Theoretica
Mathematical Library
|
High-level interface for managing an HDF5 file, its structure, and operations. More...
#include <hdf5.h>
Public Member Functions | |
| hdf5_file (const std::string &filename, bool write=false) | |
| Open the file persistently. | |
| void | refresh () |
| Refresh the cached tree structure from disk. | |
| void | close () |
| Close the HDF5 file immediately. | |
| const std::string & | filename () const |
| Get the name of the file. | |
| const hdf5_node & | root () const |
| Get the base node containing the entire loaded file structure. | |
| hid_t | id () const |
| Get the raw ID of the HDF5 file handle for direct API access. | |
| hdf5_node & | operator[] (const std::string &child_name) |
| Access children of the root node by reference using dictionary-like syntax. | |
| const hdf5_node & | operator[] (const std::string &child_name) const |
| Access children of the root node by const reference using dictionary-like syntax. | |
| void | create_group (const std::string &path) |
| Create a new group inside the file. | |
| void | create_group (const hdf5_node &parent, const std::string &child_name) |
| Create a new group using a parent node and a child name. | |
| void | delete_group (const std::string &path) |
| Delete a group inside the file. | |
| void | delete_group (const hdf5_node &node) |
| Delete a group referenced by a node. | |
| template<typename Vector = vec<real>> | |
| Vector | read_vec (const std::string &path) const |
| Loads a 1D dataset array into a vector from the given path inside the HDF5 file. | |
| template<typename Vector = vec<real>> | |
| Vector | read_vec (const hdf5_node &node) const |
| Loads a 1D dataset array into a vector from the given node inside the HDF5 file. | |
| template<typename Vector > | |
| void | write_vec (const std::string &path, const Vector &v) |
| Writes a 1D vector to an HDF5 dataset at the given path, overwriting if it exists. | |
| template<typename Vector > | |
| void | write_vec (const hdf5_node &node, const Vector &v) |
| Writes a 1D vector to the HDF5 dataset represented by the given node, overwriting if it exists. | |
| template<typename Matrix = mat<real>> | |
| Matrix | read_mat (const std::string &path) const |
| Read a 2D dataset array into a matrix from the given path. | |
| template<typename Matrix = mat<real>> | |
| Matrix | read_mat (const hdf5_node &node) const |
| Read a 2D dataset array into a matrix from the given node. | |
| template<typename Matrix > | |
| void | write_mat (const std::string &path, const Matrix &m) |
| Write a 2D matrix to an HDF5 dataset at the given path, overwriting if it exists. | |
| template<typename Matrix > | |
| void | write_mat (const hdf5_node &node, const Matrix &m) |
| Write a 2D matrix to an HDF5 dataset at the given node, overwriting if it exists. | |
| void | delete_dataset (const std::string &path) |
| Delete a dataset at the given path if it exists. | |
| void | delete_dataset (const hdf5_node &node) |
| Delete a dataset at the given node if it exists. | |
| template<typename Type > | |
| Type | read_attribute (const std::string &path, const std::string &attr_name) const |
| Read metadata (attribute) attached to a specific node by path. | |
| template<typename Type > | |
| Type | read_attribute (const hdf5_node &node, const std::string &attr_name) const |
| Read metadata (attribute) attached to a specific node by reference. | |
| template<typename Type > | |
| void | write_attribute (const std::string &path, const std::string &attr_name, const Type &value) |
| Write or overwrite metadata (attribute) attached to a specific node by path. | |
| template<typename Type > | |
| void | write_attribute (const hdf5_node &node, const std::string &attr_name, const Type &value) |
| Write or overwrite metadata (attribute) attached to a specific node by reference. | |
| void | delete_attribute (const std::string &path, const std::string &attr_name) |
| Delete an attribute attached to a specific node by path, if it exists. | |
| void | delete_attribute (const hdf5_node &node, const std::string &attr_name) |
| Delete an attribute attached to a specific node by path, if it exists. | |
| std::string | to_string () const |
| Converts an entire HDF5 file structure into a formatted tree string. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const hdf5_file &file) |
| Print the HDF5 file structure to a stream in a formatted tree representation. | |
High-level interface for managing an HDF5 file, its structure, and operations.
|
inlineexplicit |
Open the file persistently.
| filename | Path to the target HDF5 file |
| write | If true, opens the file with write permissions (creating it if it doesn't exist) |
|
inline |
Create a new group using a parent node and a child name.
| parent | Parent node under which the new group will be created. |
| child_name | Name of the child group. |
Create a new group inside the file.
| path | Absolute or relative group path. |
|
inline |
Delete an attribute attached to a specific node by path, if it exists.
| node | Node representing the object with the attribute |
| attr_name | Name of the attribute to delete |
|
inline |
Delete an attribute attached to a specific node by path, if it exists.
| path | Internal path to the node |
| attr_name | Name of the attribute to delete |
Delete a dataset at the given node if it exists.
| node | Node representing the dataset to delete |
Delete a dataset at the given path if it exists.
| path | Internal path to the dataset |
Delete a group referenced by a node.
| node | Node to delete. |
Delete a group inside the file.
| path | Absolute or relative group path. |
|
inline |
Get the raw ID of the HDF5 file handle for direct API access.
Access children of the root node by reference using dictionary-like syntax.
| child_name | Node name |
|
inline |
Access children of the root node by const reference using dictionary-like syntax.
| child_name | Node name |
|
inline |
Read metadata (attribute) attached to a specific node by reference.
| Type | The expected scalar type or std::string of the attribute |
| node | Node representing the object with the attribute |
| attr_name | Name of the attribute to read |
|
inline |
Read metadata (attribute) attached to a specific node by path.
| Type | The expected scalar type or std::string of the attribute |
| path | Internal path to the node |
| attr_name | Name of the attribute to read |
Read a 2D dataset array into a matrix from the given node.
| Matrix | The return container type (defaults to mat<real>). |
| node | Node representing the dataset to read |
Read a 2D dataset array into a matrix from the given path.
| Matrix | The return container type (defaults to mat<real>). |
| path | Internal path to the dataset |
Loads a 1D dataset array into a vector from the given node inside the HDF5 file.
| Vector | The return container type (defaults to vec<real>). |
| node | Node representing the dataset to read |
Loads a 1D dataset array into a vector from the given path inside the HDF5 file.
| Vector | The return container type (defaults to vec<real>). |
| path | Internal path to the dataset |
Get the base node containing the entire loaded file structure.
|
inline |
Converts an entire HDF5 file structure into a formatted tree string.
| file | The opened HDF5 file to format |
|
inline |
Write or overwrite metadata (attribute) attached to a specific node by reference.
| Type | The scalar type or std::string of the attribute |
| node | Node representing the object with the attribute |
| attr_name | Name of the attribute |
| value | The value to write |
|
inline |
Write or overwrite metadata (attribute) attached to a specific node by path.
| Type | The scalar type or std::string of the attribute |
| path | Internal path to the node |
| attr_name | Name of the attribute |
| value | The value to write |
Write a 2D matrix to an HDF5 dataset at the given node, overwriting if it exists.
| Matrix | The generic container type (deduced). Must support .rows(), .cols(), and .data(). |
| node | Node representing the dataset to write |
| m | The matrix data to write |
Write a 2D matrix to an HDF5 dataset at the given path, overwriting if it exists.
| Matrix | The generic container type (deduced). Must support .rows(), .cols(), and .data(). |
| path | Internal path to place the dataset |
| m | The matrix data to write |
Writes a 1D vector to the HDF5 dataset represented by the given node, overwriting if it exists.
| Vector | The generic container type. |
| node | HDF5 node identifying the dataset to write |
| v | The vector data to write |
Writes a 1D vector to an HDF5 dataset at the given path, overwriting if it exists.
| Vector | The generic container type. |
| path | Internal path to place the dataset |
| v | The vector data to write |
Print the HDF5 file structure to a stream in a formatted tree representation.
| os | Standard output stream |
| file | The HDF5 wrapper instance |