Archive class for reading and writing data to HDF5 files.
More...
#include <Archive.h>
|
| PBAT_API | Archive (std::filesystem::path const &filepath, HighFive::File::AccessMode flags=HighFive::File::OpenOrCreate) |
| | Construct a new Archive object from a filepath to an HDF5 file.
|
| |
| PBAT_API bool | IsUsable () const |
| | Check if the archive is usable.
|
| |
| PBAT_API Archive | GetOrCreateGroup (std::string const &path) |
| | Get or create a group at the given path.
|
| |
| PBAT_API Archive | operator[] (std::string const &path) |
| | Get a group or create it if it does not exist.
|
| |
| PBAT_API Archive | operator[] (std::string const &path) const |
| | Get a group if it exists.
|
| |
| PBAT_API bool | HasGroup (std::string const &path) const |
| | Check if a group exists at the given path.
|
| |
| template<class T> |
| void | WriteData (std::string const &path, T const &data) |
| | Write data to the archive.
|
| |
| template<class T> |
| void | WriteMetaData (std::string const &key, T const &value) |
| | Write metadata to the archive.
|
| |
| template<class T> |
| T | ReadData (std::string const &path) const |
| | Read data from the archive.
|
| |
| template<class T> |
| T | ReadMetaData (std::string const &key) const |
| | Read metadata from the archive.
|
| |
| PBAT_API void | Unlink (std::string const &path) |
| | Unlink a dataset or group from the archive.
|
| |
| PBAT_API std::optional< std::string > | GetPath () const |
| | Get the path of the current HDF5 object.
|
| |
|
| using | Object |
| | HDF5 object type.
|
| |
Archive class for reading and writing data to HDF5 files.
◆ Object
Initial value:
std::variant<std::monostate, HighFive::File, HighFive::Group>
HDF5 object type.
◆ Archive() [1/2]
| pbat::io::Archive::Archive |
( |
std::filesystem::path const & | filepath, |
|
|
HighFive::File::AccessMode | flags = HighFive::File::OpenOrCreate ) |
Construct a new Archive object from a filepath to an HDF5 file.
- Parameters
-
| filepath | Path to the HDF5 file. |
| flags | Access mode for the file (default is OpenOrCreate). |
◆ Archive() [2/2]
| pbat::io::Archive::Archive |
( |
Object | obj | ) |
|
|
protected |
Construct a new Archive object from an HDF5 object.
- Parameters
-
| obj | HDF5 object (file or group). |
◆ GetOrCreateGroup()
| Archive pbat::io::Archive::GetOrCreateGroup |
( |
std::string const & | path | ) |
|
Get or create a group at the given path.
- Parameters
-
- Returns
- Archive object representing the group.
- Exceptions
-
| std::runtime_error | if a non-group object of the same name already exists. |
| HighFive::GroupException | if the group cannot be created or fetched. |
◆ GetPath()
| std::optional< std::string > pbat::io::Archive::GetPath |
( |
| ) |
const |
Get the path of the current HDF5 object.
- Returns
- Path of the current HDF5 object.
◆ HasGroup()
| bool pbat::io::Archive::HasGroup |
( |
std::string const & | path | ) |
const |
Check if a group exists at the given path.
- Parameters
-
- Returns
- true if the group exists, false otherwise.
◆ IsUsable()
| bool pbat::io::Archive::IsUsable |
( |
| ) |
const |
Check if the archive is usable.
- Returns
- true if the archive is usable, false otherwise.
◆ operator[]() [1/2]
| Archive pbat::io::Archive::operator[] |
( |
std::string const & | path | ) |
|
Get a group or create it if it does not exist.
- Parameters
-
- Returns
- Archive object representing the group.
- Exceptions
-
| std::runtime_error | if a non-group object of the same name already exists. |
| HighFive::GroupException | if the group cannot be created or fetched. |
◆ operator[]() [2/2]
| Archive pbat::io::Archive::operator[] |
( |
std::string const & | path | ) |
const |
Get a group if it exists.
- Parameters
-
- Returns
- Archive object representing the group.
- Exceptions
-
| HighFive::GroupException | if the group does not exist. |
◆ ReadData()
template<class T>
| T pbat::io::Archive::ReadData |
( |
std::string const & | path | ) |
const |
|
inline |
Read data from the archive.
- Template Parameters
-
| T | Type of the data to read. |
- Parameters
-
- Returns
- Data read from the dataset.
- Exceptions
-
| HighFive::DataSetException | if the dataset cannot be read. |
◆ ReadMetaData()
template<class T>
| T pbat::io::Archive::ReadMetaData |
( |
std::string const & | key | ) |
const |
|
inline |
Read metadata from the archive.
- Template Parameters
-
| T | Type of the metadata to read. |
- Parameters
-
| key | Name of the attribute. |
- Returns
- Metadata read from the attribute.
- Exceptions
-
| HighFive::AttributeException | if the attribute cannot be read. |
◆ Unlink()
| void pbat::io::Archive::Unlink |
( |
std::string const & | path | ) |
|
Unlink a dataset or group from the archive.
- Parameters
-
| path | Path to the dataset or group. |
- Exceptions
-
| HighFive::GroupException | if the dataset or group cannot be unlinked. |
◆ WriteData()
template<class T>
| void pbat::io::Archive::WriteData |
( |
std::string const & | path, |
|
|
T const & | data ) |
|
inline |
Write data to the archive.
- Template Parameters
-
| T | Type of the data to write. |
- Parameters
-
| path | Path to the dataset. |
| data | Data to write. |
- Exceptions
-
| HighFive::DataSetException | if the dataset cannot be created or written to. |
◆ WriteMetaData()
template<class T>
| void pbat::io::Archive::WriteMetaData |
( |
std::string const & | key, |
|
|
T const & | value ) |
|
inline |
Write metadata to the archive.
- Template Parameters
-
| T | Type of the metadata to write. |
- Parameters
-
| key | Name the attribute. |
| value | Metadata to write. |
- Exceptions
-
| HighFive::AttributeException | if the attribute cannot be created or written to. |
The documentation for this class was generated from the following files:
- C:/git/PhysicsBasedAnimationToolkit/source/pbat/io/Archive.h
- C:/git/PhysicsBasedAnimationToolkit/source/pbat/io/Archive.cpp