API Reference
class h5pp::File
-
class File
Writes and reads data to a binary hdf5-file.
Public Functions
-
template<typename DataType>
inline TableInfo appendTableRecords(const DataType &data, std::string_view tablePath, std::optional<hsize_t> extent = std::nullopt)
-
template<typename DataType>
inline TableInfo appendTableRecords(const DataType &data, TableInfo &info, std::optional<hsize_t> extent = std::nullopt)
-
inline void appendTableRecords(const h5pp::TableInfo &srcInfo, h5pp::TableInfo &tgtInfo, TableSelection srcSelection = TableSelection::ALL)
-
inline void appendTableRecords(const h5pp::TableInfo &srcInfo, hsize_t offset, hsize_t extent, h5pp::TableInfo &tgtInfo)
-
inline TableInfo appendTableRecords(const h5pp::TableInfo &srcInfo, std::string_view tgtTablePath, TableSelection srcSelection = TableSelection::ALL, Options options = Options())
-
template<typename h5x_src>
inline TableInfo appendTableRecords(const h5x_src &srcLocation, std::string_view srcTablePath, std::string_view tgtTablePath, TableSelection srcSelection = TableSelection::ALL, Options options = Options())
-
template<typename DataType>
inline void appendToDataset(const DataType &data, const DataInfo &dataInfo, DsetInfo &dsetInfo, size_t axis)
-
template<typename DataType>
inline void appendToDataset(const DataType &data, DsetInfo &dsetInfo, size_t axis, const OptDimsType &dataDims = std::nullopt)
-
template<typename DataType>
inline DsetInfo appendToDataset(const DataType &data, size_t axis, const Options &options = Options())
-
template<typename DataType>
inline DsetInfo appendToDataset(const DataType &data, std::string_view dsetPath, size_t axis, const OptDimsType &dataDims = std::nullopt)
-
template<typename h5x>
inline bool attributeExists(const h5x &link, std::string_view attrName) const
-
inline bool attributeExists(std::string_view linkPath, std::string_view attrName) const
-
inline fs::path copyFileTo(const h5pp::fs::path &targetFilePath, const FileAccess &perm = FileAccess::COLLISION_FAIL) const
Make a copy of this file at a different path.
No change to the current file.
- Parameters:
targetFilePath – Copy to this path
perm – File access permission at the new path
-
inline void copyLinkFromFile(std::string_view localLinkPath, const h5pp::fs::path &sourceFilePath, std::string_view sourceLinkPath)
Copy a link (dataset/table/group) from another file into this.
- Parameters:
localLinkPath – Path to link in this file
sourceFilePath – Path to file to copy from
sourceLinkPath – Path to link in the source file
-
template<typename h5x_src>
inline void copyLinkFromLocation(std::string_view localLinkPath, const h5x_src &sourceLocationId, std::string_view sourceLinkPath) Copy a link (dataset/table/group) from any hid::h5x location (group or file) into this file
- Parameters:
localLinkPath – Path to link in this file
sourceLocationId – Source hid::h5x location handle
sourceLinkPath – Path to link in the source file
-
inline void copyLinkToFile(std::string_view localLinkPath, const h5pp::fs::path &targetFilePath, std::string_view targetLinkPath, const FileAccess &perm = FileAccess::READWRITE) const
Copy a link (dataset/table/group) into another file.
- Parameters:
localLinkPath – Path to link in this file
targetFilePath – Path to file to copy into
targetLinkPath – Path to link in the target file
perm – File access permission at the target path
-
template<typename h5x_tgt>
inline void copyLinkToLocation(std::string_view localLinkPath, const h5x_tgt &targetLocationId, std::string_view targetLinkPath) const Copy a link (dataset/table/group) from this file to any hid::h5x location (group or file).
- Parameters:
localLinkPath – Path to link in this file
targetLocationId – Target hid::h5x location handle (group or file)
targetLinkPath – Path to link in the target file
-
inline void copyTableRecords(const h5pp::TableInfo &srcInfo, h5pp::TableInfo &tgtInfo, TableSelection tableSelection, hsize_t tgtOffset)
-
inline void copyTableRecords(const h5pp::TableInfo &srcInfo, hsize_t srcOffset, hsize_t srcExtent, h5pp::TableInfo &tgtInfo, hsize_t tgtOffset)
-
inline TableInfo copyTableRecords(const h5pp::TableInfo &srcInfo, hsize_t srcOffset, hsize_t srcExtent, std::string_view tgtTablePath, hsize_t tgtOffset, Options options = Options())
-
inline TableInfo copyTableRecords(const h5pp::TableInfo &srcInfo, std::string_view tgtTablePath, hsize_t tgtOffset, TableSelection srcSelection = TableSelection::ALL, Options options = Options())
-
template<typename h5x_src>
inline TableInfo copyTableRecords(const h5x_src &srcLocation, std::string_view srcTablePath, hsize_t srcOffset, hsize_t srcExtent, std::string_view tgtTablePath, hsize_t tgtOffset, Options options = Options())
-
template<typename h5x_src>
inline TableInfo copyTableRecords(const h5x_src &srcLocation, std::string_view srcTablePath, std::string_view tgtTablePath, hsize_t tgtOffset, TableSelection srcSelection = TableSelection::ALL, Options options = Options())
-
inline TableInfo copyTableRecords(std::string_view srcTablePath, hsize_t srcOffset, hsize_t srcExtent, std::string_view tgtTablePath, hsize_t tgtOffset, const Options &options = Options())
-
inline void createAttribute(AttrInfo &attrInfo, const Options &options = Options())
-
template<typename DataType>
inline AttrInfo createAttribute(const DataType &data, AttrInfo &attrInfo, const Options &options = Options())
-
template<typename DataType>
inline AttrInfo createAttribute(const DataType &data, const DimsType &dataDims, std::string_view linkPath, std::string_view attrName)
-
template<typename DataType>
inline AttrInfo createAttribute(const DataType &data, const Options &options)
-
template<typename DataType>
inline DsetInfo createDataset(const DataType &data, const Options &options)
-
template<typename DataType>
inline DsetInfo createDataset(const DataType &data, std::string_view dsetPath, const OptDimsType &dataDims = std::nullopt, std::optional<H5D_layout_t> h5Layout = std::nullopt, const OptDimsType &dsetChunkDims = std::nullopt, const OptDimsType &dsetMaxDims = std::nullopt, const std::optional<int> compression = std::nullopt)
-
inline DsetInfo createDataset(const Options &options)
-
inline void createDataset(DsetInfo &info)
-
inline DsetInfo createDataset(std::string_view dsetPath, const hid::h5t &h5Type, H5D_layout_t h5Layout, const DimsType &dsetDims, const OptDimsType &dsetChunkDims = std::nullopt, const OptDimsType &dsetMaxDims = std::nullopt, const std::optional<int> compression = std::nullopt)
-
inline void createExternalLink(std::string_view targetFilePath, std::string_view targetLinkPath, std::string_view softLinkPath)
- Parameters:
targetFilePath – Path to an external hdf5 file with the desired link. If relative, it is relative to the current file
targetLinkPath – Full path to link within the external file
softLinkPath – Full path to the new soft link created within this file
-
inline void createGroup(std::string_view group_relative_name)
-
inline void createHardLink(std::string_view targetLinkPath, std::string_view hardLinkPath)
-
inline void createSoftLink(std::string_view targetLinkPath, std::string_view softLinkPath)
-
inline TableInfo createTable(const hid::h5t &h5Type, std::string_view tablePath, std::string_view tableTitle, const OptDimsType &chunkDims = std::nullopt, std::optional<int> compression = std::nullopt)
-
inline void createTable(TableInfo &info, const Options &options = Options())
-
inline void deleteAttribute(std::string_view linkPath, std::string_view attrName)
-
inline void deleteLink(std::string_view linkPath)
-
inline bool fieldExists(std::string_view tablePath, const NamesOrIndices &fields) const
-
File() = default
Default constructor
-
template<typename LogLevelType = LogLevel>
inline explicit File(h5pp::fs::path filePath_, h5pp::FileAccess fileAccess_ = h5pp::FileAccess::RENAME, LogLevelType logLevel_ = LogLevel::info, bool logTimestamp_ = false, const PropertyLists &plists_ = PropertyLists()) - Parameters:
filePath_ – Path a new file
fileAccess_ – Set file access permission in case of collision
logLevel_ – Logging verbosity level 0 (most) to 6 (least).
logTimestamp_ – True prepends a timestamp to log output
-
template<typename LogLevelType = LogLevel>
inline explicit File(h5pp::fs::path filePath_, unsigned int H5F_ACC_FLAGS, LogLevelType logLevel_ = LogLevel::info, bool logTimestamp_ = false, const PropertyLists &plists_ = PropertyLists()) - Parameters:
filePath_ – Path a new file
H5F_ACC_FLAGS – Set HDF5 access flag for new files
logLevel_ – Logging verbosity level 0 (most) to 6 (least).
logTimestamp_ – True prepends a timestamp to log output
-
inline bool fileIsValid() const
-
inline std::vector<std::string> findDatasets(std::string_view searchKey = "", std::string_view searchRoot = "/", long maxHits = -1, long maxDepth = -1, bool followSymlinks = false) const
-
inline std::vector<std::string> findGroups(std::string_view searchKey = "", std::string_view searchRoot = "/", long maxHits = -1, long maxDepth = -1, bool followSymlinks = false) const
-
inline std::vector<std::string> findLinks(std::string_view searchKey = "", std::string_view searchRoot = "/", long maxHits = -1, long maxDepth = -1, bool followSymlinks = false) const
-
inline void flush()
Flush the HDF5 internal file cache using H5Fflush
-
inline AttrInfo getAttributeInfo(std::string_view linkPath, std::string_view attrName) const
-
inline std::vector<std::string> getAttributeNames(std::string_view linkPath) const
-
inline int getCompressionLevel() const
Get current default compression level
-
inline int getCompressionLevel(const std::optional<int> compression) const
Get a valid compression level given an optionally suggested level.
Example 1: Passing compression > 9 returns 9 if ZLIB compression is enabled.
Example 2: If compression == std::nullopt, the current compression level is returned.
- Parameters:
compression – Suggested compression level
-
inline std::optional<std::vector<hsize_t>> getDatasetChunkDimensions(std::string_view datasetPath) const
-
inline std::vector<hsize_t> getDatasetDimensions(std::string_view datasetPath) const
-
inline DsetInfo getDatasetInfo(std::string_view dsetPath) const
-
inline std::optional<std::vector<hsize_t>> getDatasetMaxDimensions(std::string_view datasetPath) const
-
inline int getDatasetRank(std::string_view datasetPath) const
-
inline h5pp::FileAccess getFileAccess() const
Gets the current file access permission
-
inline FileHandleToken getFileHandleToken()
-
inline std::string getFileName() const
Gets the current file name
-
inline std::string getFilePath() const
Gets the full path to the current file
-
inline h5pp::FileAccess getFilePermission() const
-
template<typename InfoType>
inline InfoType getInfo(std::string_view linkPath, std::string_view attrName) const
-
inline LinkInfo getLinkInfo(std::string_view linkPath) const
-
inline LogLevel getLogLevel() const
Get the current log level
From 0 (highest) to 6 (off)
-
inline TableFieldInfo getTableFieldInfo(std::string_view tablePath) const
-
inline TableInfo getTableInfo(std::string_view tablePath) const
-
inline TypeInfo getTypeInfoAttribute(std::string_view linkPath, std::string_view attrName) const
-
inline std::vector<TypeInfo> getTypeInfoAttributes(std::string_view linkPath) const
-
inline TypeInfo getTypeInfoDataset(std::string_view dsetPath) const
-
inline bool linkExists(std::string_view linkPath) const
-
inline fs::path moveFileTo(const h5pp::fs::path &targetFilePath, const FileAccess &perm = FileAccess::COLLISION_FAIL)
Move the current file to a new path.
The current file is re-opened at the new path.
- Parameters:
targetFilePath – The new path
perm – File access permission at the new path
-
inline void moveLinkFromFile(std::string_view localLinkPath, const h5pp::fs::path &sourceFilePath, std::string_view sourceLinkPath)
Move a link (dataset/table/group) from another file into this.
NOTE: The link is deleted from the other file, but the storage space is not recovered. This is a fundamental limitation of HDF5.
- Parameters:
localLinkPath – Path to link in this file
sourceFilePath – Path to file to copy from
sourceLinkPath – Path to link in the source file
-
template<typename h5x_src>
inline void moveLinkFromLocation(std::string_view localLinkPath, const h5x_src &sourceLocationId, std::string_view sourceLinkPath, LocationMode locMode = LocationMode::DETECT) Move a link (dataset/table/group) from this file to any hid::h5x location (group or file).
NOTE: The link is deleted from the target location, but the storage space is not recovered. This is a fundamental limitation of HDF5.
- Parameters:
localLinkPath – Path to link in this file
sourceLocationId – Source hid::h5x location handle (group or file)
sourceLinkPath – Path to link in the source file
locMode – Specify whether targetLocationId is in this file or another
-
inline void moveLinkToFile(std::string_view localLinkPath, const h5pp::fs::path &targetFilePath, std::string_view targetLinkPath, const FileAccess &perm = FileAccess::READWRITE) const
Move a link (dataset/table/group) into another file.
NOTE: The link is deleted from this file, but the storage space is not recovered. This is a fundamental limitation of HDF5.
- Parameters:
localLinkPath – Path to link in this file
targetFilePath – Path to file to move into
targetLinkPath – Path to link in the target file
perm – File access permission at the target path
-
template<typename h5x_tgt>
inline void moveLinkToLocation(std::string_view localLinkPath, const h5x_tgt &targetLocationId, std::string_view targetLinkPath, LocationMode locMode = LocationMode::DETECT) const Move a link (dataset/table/group) from this file to any hid::h5x location (group or file).
NOTE: The link is deleted from the target location, but the storage space is not recovered. This is a fundamental limitation of HDF5.
- Parameters:
localLinkPath – Path to link in this file
targetLocationId – Target hid::h5x location handle (group or file)
targetLinkPath – Path to link in the target file
locMode – Specify whether targetLocationId is in this file or another
-
inline hid::h5f openFileHandle() const
Returns an HDF5 file handle
The file permission is set when initializing h5pp::File.
Use
h5pp::setKeepFileOpened()
to keep a cached handle. Useh5pp::setKeepFileClosed()
to close the cached handle.
-
template<typename DataType>
inline void readAttribute(DataType &data, const h5pp::AttrInfo &attrInfo, const Options &options = Options()) const
-
template<typename DataType>
inline void readAttribute(DataType &data, std::string_view linkPath, std::string_view attrName, const OptDimsType &dataDims = std::nullopt, std::optional<hid::h5t> h5Type = std::nullopt) const
-
template<typename DataType>
inline DataType readAttribute(std::string_view linkPath, std::string_view attrName, const OptDimsType &dataDims = std::nullopt, std::optional<hid::h5t> h5Type = std::nullopt) const
-
template<typename DataType>
inline DataType readDataset(const DsetInfo &dsetInfo, const DimsType &dataDims) const
-
template<typename DataType>
inline DataType readDataset(const DsetInfo &dsetInfo, const Options &options = Options()) const
-
template<typename DataType>
inline DataType readDataset(DataInfo &dataInfo, const DsetInfo &dsetInfo) const
-
template<typename DataType>
inline void readDataset(DataType &data, const DsetInfo &dsetInfo, const Options &options = Options()) const
-
template<typename DataType>
inline void readDataset(DataType &data, DataInfo &dataInfo, const DsetInfo &dsetInfo) const
-
template<typename DataType>
inline void readDataset(DataType &data, std::string_view dsetPath, const OptDimsType &dataDims = std::nullopt, std::optional<hid::h5t> h5Type = std::nullopt) const
-
template<typename DataType>
inline DataType readDataset(std::string_view dsetPath, const OptDimsType &dataDims = std::nullopt, std::optional<hid::h5t> h5Type = std::nullopt) const
-
template<typename DataType>
inline DataType readDataset(std::string_view dsetPath, const Options &options) const
-
template<typename DataType>
inline void readHyperslab(DataType &data, std::string_view dsetPath, const Hyperslab &hyperslab) const
-
template<typename DataType>
inline DataType readHyperslab(std::string_view dsetPath, const Hyperslab &hyperslab) const
-
template<typename DataType>
inline DataType readTableField(const TableInfo &info, const hid::h5t &fieldId) const
-
template<typename DataType>
inline DataType readTableField(const TableInfo &info, const hid::h5t &fieldId, hsize_t offset, hsize_t extent) const
-
template<typename DataType>
inline DataType readTableField(const TableInfo &info, const hid::h5t &fieldId, TableSelection tableSelection) const
-
template<typename DataType>
inline void readTableField(DataType &data, const TableInfo &info, const NamesOrIndices &fields, std::optional<hsize_t> offset = std::nullopt, std::optional<hsize_t> extent = std::nullopt) const
-
template<typename DataType>
inline void readTableField(DataType &data, std::string_view tablePath, const NamesOrIndices &fields) const
-
template<typename DataType>
inline TableInfo readTableField(DataType &data, std::string_view tablePath, const NamesOrIndices &fields, std::optional<hsize_t> offset = std::nullopt, std::optional<hsize_t> extent = std::nullopt) const
-
template<typename DataType>
inline void readTableField(DataType &data, std::string_view tablePath, const NamesOrIndices &fields, TableSelection tableSelection) const
-
template<typename DataType>
inline DataType readTableField(std::string_view tablePath, const NamesOrIndices &fields) const
-
template<typename DataType>
inline DataType readTableField(std::string_view tablePath, const NamesOrIndices &fields, std::optional<hsize_t> offset = std::nullopt, std::optional<hsize_t> extent = std::nullopt) const
-
template<typename DataType>
inline DataType readTableField(std::string_view tablePath, const NamesOrIndices &fields, TableSelection tableSelection) const
-
template<typename DataType>
inline TableInfo readTableRecords(DataType &data, std::string_view tablePath, std::optional<hsize_t> offset = std::nullopt, std::optional<hsize_t> extent = std::nullopt) const
-
template<typename DataType>
inline TableInfo readTableRecords(DataType &data, std::string_view tablePath, TableSelection tableSelection) const
-
template<typename DataType>
inline DataType readTableRecords(std::string_view tablePath, h5pp::TableSelection tableSelection) const
-
template<typename DataType>
inline DataType readTableRecords(std::string_view tablePath, std::optional<hsize_t> offset = std::nullopt, std::optional<hsize_t> extent = std::nullopt) const
-
inline void resizeDataset(DsetInfo &info, const DimsType &newDimensions, std::optional<h5pp::ResizePolicy> mode_override = std::nullopt)
-
inline DsetInfo resizeDataset(std::string_view dsetPath, const DimsType &newDimensions, std::optional<h5pp::ResizePolicy> mode = std::nullopt)
-
inline void setCloseDegree(H5F_close_degree_t degree)
Sets how HDF5 will close a file internally
From the HDF5 documentation:
H5F_close_degree_t
::H5F_CLOSE_DEFAULT
: Use the degree pre-defined by underlining VFLH5F_CLOSE_WEAK
: file closes only after all opened objects are closedH5F_CLOSE_SEMI
: if no opened objects, file is close; otherwise, file close failsH5F_CLOSE_STRONG
: if there are opened objects, close them first, then close file
-
inline void setCompressionLevel(unsigned int compressionZeroToNine)
Set compression level
Uses ZLIB compression level 0 (off) to 9 (highest) Levels 2 to 5 are recommended for good performance/compression ratio
- Parameters:
compressionZeroToNine – Compression level
-
inline void setDriver_core(bool writeOnClose = false, size_t bytesPerMalloc = 10240000)
Sets the HDF5 file driver to
H5FD_CORE
H5FD_CORE
: This driver performs I/O directly to memory and can be used to create small temporary files that never exist on permanent storage.- Parameters:
writeOnClose – Optionally save to storage when the file is closed.
bytesPerMalloc – Size, in bytes, of memory increments.
-
inline void setDriver_sec2()
Sets the HDF5 file driver to
H5FD_SEC2
H5FD_SEC2
: This is the default driver which uses Posix file-system functions like read and write to perform I/O to a single file.
-
inline void setDriver_stdio()
Sets the HDF5 file driver to
H5FD_STDIO
H5FD_STDIO
: This driver uses functions from ‘stdio.h’ to perform buffered I/O to a single file.
-
inline void setFileAccess(h5pp::FileAccess fileAccess_)
Sets the default file access permission
-
inline void setFilePermission(h5pp::FileAccess fileAccess_)
-
inline void setKeepFileClosed() const
Close a cached file handle if it exists
-
inline void setKeepFileOpened() const
-
template<typename LogLevelType>
inline void setLogLevel(LogLevelType logLevelZeroToSix) const Set console log level
From 0 (highest) to 6 (off)
-
inline void vlenDisableReclaimsTracking()
Disable tracking of variable-length data allocations (users should call H5Treclaim or free manually)
-
inline void vlenDropReclaims() const
Drop all tracked claims to allocated variable-length data (users should call H5Treclaim or free manually)
-
inline void vlenEnableReclaimsTracking()
Enable tracking of variable-length data allocations (e.g. when reading tables containgin H5T_VLEN members)
-
inline void vlenReclaim() const
Calls H5Treclaim(…) on any data that HDF5 may have allocated for variable-length data during the last reads
-
template<typename DataType>
inline AttrInfo writeAttribute(const DataType &data, const Options &options)
-
template<typename DataType>
inline void writeAttribute(const DataType &data, DataInfo &dataInfo, AttrInfo &attrInfo, const Options &options = Options())
-
template<typename DataType>
inline AttrInfo writeAttribute(const DataType &data, std::string_view linkPath, std::string_view attrName, const OptDimsType &dataDims = std::nullopt, std::optional<hid::h5t> h5Type = std::nullopt)
-
template<typename DataType>
inline DsetInfo writeDataset(const DataType &data, const Options &options)
-
template<typename DataType>
inline void writeDataset(const DataType &data, DataInfo &dataInfo, DsetInfo &dsetInfo, const Options &options = Options())
-
template<typename DataType>
inline void writeDataset(const DataType &data, DsetInfo &dsetInfo, const Options &options = Options())
-
template<typename DataType>
inline DsetInfo writeDataset(const DataType &data, std::string_view dsetPath, const OptDimsType &dataDims = std::nullopt, std::optional<H5D_layout_t> h5Layout = std::nullopt, const OptDimsType &dsetChunkDims = std::nullopt, const OptDimsType &dsetMaxDims = std::nullopt, std::optional<hid::h5t> h5Type = std::nullopt, std::optional<ResizePolicy> resizePolicy = std::nullopt, const std::optional<int> compression = std::nullopt) - Parameters:
data – Eigen, stl-like object or pointer to data buffer
dsetPath – Path to HDF5 dataset relative to the file root
dataDims – Data dimensions hint. Required for pointer data
h5Layout – (On create) Layout of dataset. Choose between H5D_CHUNKED,H5D_COMPACT and H5D_CONTIGUOUS
dsetChunkDims – (On create) Chunking dimensions. Only valid for H5D_CHUNKED datasets
dsetMaxDims – (On create) Maximum dimensions. Only valid for H5D_CHUNKED datasets
h5Type – (On create) Type of dataset. Override automatic type detection.
resizePolicy – Type of resizing if needed. Choose GROW, FIT,OFF
compression – (On create) Compression level 0-9, 0 = off, 9 is gives best compression and is slowest
-
template<typename DataType>
inline DsetInfo writeDataset(const DataType &data, std::string_view dsetPath, H5D_layout_t h5Layout, const OptDimsType &dataDims = std::nullopt, const OptDimsType &dsetChunkDims = std::nullopt, const OptDimsType &dsetMaxDims = std::nullopt, std::optional<hid::h5t> h5Type = std::nullopt, std::optional<ResizePolicy> resizePolicy = std::nullopt, const std::optional<int> compression = std::nullopt) - Parameters:
data – Eigen, stl-like object or pointer to data buffer
dsetPath – Path to HDF5 dataset relative to the file root
h5Layout – (On create) Layout of dataset. Choose between H5D_CHUNKED,H5D_COMPACT and H5D_CONTIGUOUS
dataDims – Data dimensions hint. Required for pointer data
dsetChunkDims – (On create) Chunking dimensions. Only valid for H5D_CHUNKED datasets
dsetMaxDims – (On create) Maximum dimensions. Only valid for H5D_CHUNKED datasets
h5Type – (On create) Type of dataset. Override automatic type detection.
resizePolicy – Type of resizing if needed. Choose GROW, FIT, OFF
compression – (On create) Compression level 0-9, 0 = off, 9 is gives best compression and is slowest
-
template<typename DataType>
inline DsetInfo writeDataset(const DataType &data, std::string_view dsetPath, hid::h5t &h5Type, const OptDimsType &dataDims = std::nullopt, std::optional<H5D_layout_t> h5Layout = std::nullopt, const OptDimsType &dsetChunkDims = std::nullopt, const OptDimsType &dsetMaxDims = std::nullopt, std::optional<ResizePolicy> resizePolicy = std::nullopt, const std::optional<int> compression = std::nullopt) - Parameters:
data – Eigen, stl-like object or pointer to data buffer
dsetPath – Path to HDF5 dataset relative to the file root
h5Type – (On create) Type of dataset. Override automatic type detection.
dataDims – Data dimensions hint. Required for pointer data
h5Layout – (On create) Layout of dataset. Choose between H5D_CHUNKED,H5D_COMPACT and H5D_CONTIGUOUS
dsetChunkDims – (On create) Chunking dimensions. Only valid for H5D_CHUNKED datasets
dsetMaxDims – (On create) Maximum dimensions. Only valid for H5D_CHUNKED datasets
resizePolicy – Type of resizing if needed. Choose GROW, FIT, OFF
compression – (On create) Compression level 0-9, 0 = off, 9 is gives best compression and is slowest
-
template<typename DataType>
inline DsetInfo writeDataset_chunked(const DataType &data, std::string_view dsetPath, const OptDimsType &dataDims = std::nullopt, const OptDimsType &dsetChunkDims = std::nullopt, const OptDimsType &dsetMaxDims = std::nullopt, std::optional<hid::h5t> h5Type = std::nullopt, const std::optional<int> compression = std::nullopt)
-
template<typename DataType>
inline DsetInfo writeDataset_compact(const DataType &data, std::string_view dsetPath, const OptDimsType &dataDims = std::nullopt, std::optional<hid::h5t> h5Type = std::nullopt)
-
template<typename DataType>
inline DsetInfo writeDataset_compressed(const DataType &data, std::string_view dsetPath, const std::optional<int> compression = 3)
-
template<typename DataType>
inline DsetInfo writeDataset_contiguous(const DataType &data, std::string_view dsetPath, const OptDimsType &dataDims = std::nullopt, std::optional<hid::h5t> h5Type = std::nullopt)
-
template<typename DataType>
inline DsetInfo writeHyperslab(const DataType &data, std::string_view dsetPath, const Hyperslab &hyperslab) - Parameters:
data – Eigen, stl-like object or pointer to data buffer
dsetPath – Path to HDF5 dataset relative to the file root
hyperslab – Write data to a hyperslab selection
Public Members
-
PropertyLists plists = PropertyLists()
-
struct FileHandleToken
Open and keep a cached file handle
This is useful for quick batch operations where opening and closing the file handle would introduce a large performance penalty.
-
template<typename DataType>
enum h5pp::FileAccess
-
enum class h5pp::FileAccess
File access permissions
See the original file access permissions in the HDF5 Documentation for H5F_CREATE and H5F_OPEN.
h5pp
offers more flags for file access permissions than HDF5. The new flags are primarily intended to prevent accidental loss of data, but also to clarify intent and avoid mutually exclusive options.The flags are listed in the order of increasing “danger” that they pose to previously existing files.
Enumerator
File exists
No file exists
Comment
READONLY
Open with read-only access
Throw error
Never writes to disk, fails if the file is not found
COLLISION_FAIL
Throw error
Create new file
Never deletes existing files and fails if it already exists
RENAME
defaultCreate renamed file
Create new file
Never deletes existing files. Invents a new filename to avoid collision by appending “-#” (#=1,2,3…) to the stem of the filename
READWRITE
Open with read-write access
Create new file
Never deletes existing files, but is allowed to open/modify
BACKUP
Rename existing file and create new
Create new file
Avoids collision by backing up the existing file, appending
.bak_#
(#
=1,2,3…) to the filenameREPLACE
Truncate (overwrite)
Create new file
Deletes the existing file and create a new one in place
When a new file is created, the intermediate directories are always created automatically.
When a new file is created,
READWRITE
access to it is implied.
Values:
-
enumerator READONLY
-
enumerator COLLISION_FAIL
-
enumerator RENAME
-
enumerator READWRITE
-
enumerator BACKUP
-
enumerator REPLACE
enum h5pp::TableSelection
enum h5pp::ResizePolicy
-
enum class h5pp::ResizePolicy
Set policy for modifying dataset dimensions when overwriting.
Values:
-
enumerator FIT
Overwriting a dataset will shrink or grow existing dimensions to fit new data (default on H5D_CHUNKED)
-
enumerator GROW
Overwriting a dataset will may grow existing dimensions, but never shrink, to fit new data (works only on H5D_CHUNKED)
-
enumerator OFF
Overwriting a dataset will not modify existing dimensions
-
enumerator FIT
enum h5pp::LocationMode
-
enum class h5pp::LocationMode
Specify whether the target location is on the same file or a different one when copying objects.
Values:
-
enumerator SAME_FILE
Interpret source and target location id’s as being on the same file
-
enumerator OTHER_FILE
Interpret source and target location id’s as being on different files
-
enumerator DETECT
Use H5Iget_file_id() to check. This is the default, but avoid when known.
-
enumerator SAME_FILE