Class File

Class Documentation

class h5pp::File

Writes and reads data to a binary hdf5-file.

Public Functions

File()
File(const File &other)
File(const std::string &filePath_, h5pp::FilePermission permission_ = h5pp::FilePermission::RENAME, size_t logLevel_ = 2, bool logTimestamp_ = false)
File(const std::string &filePath_, unsigned int H5F_ACC_FLAGS, size_t logLevel_ = 2, bool logTimestamp_ = false)
~File()
File &operator=(const File &other)
void flush()
hid::h5f openFileHandle() const
h5pp::FilePermission getFilePermission() const
std::string getFileName() const
std::string getFilePath() const
void setFilePermission(h5pp::FilePermission permission_)
void setDriver_sec2()
void setDriver_stdio()
void setDriver_core(bool writeOnClose = true, size_t bytesPerMalloc = 10240000)
fs::path copyFileTo(const std::string &targetFilePath, const FilePermission &perm = FilePermission::COLLISION_FAIL) const
fs::path moveFileTo(const std::string &targetFilePath, const FilePermission &perm = FilePermission::COLLISION_FAIL)
void copyLinkToFile(const std::string &localLinkPath, const std::string &targetFilePath, const std::string &targetLinkPath, const FilePermission &targetFileCreatePermission = FilePermission::READWRITE) const
void copyLinkFromFile(const std::string &localLinkPath, const std::string &sourceFilePath, const std::string &sourceLinkPath)
template<typename h5x_tgt, typename = h5pp::type::sfinae::enable_if_is_h5_loc<h5x_tgt>>
void copyLinkToLocation(const std::string &localLinkPath, const h5x_tgt &targetLocationId, const std::string &targetLinkPath) const
template<typename h5x_src, typename = h5pp::type::sfinae::enable_if_is_h5_loc<h5x_src>>
void copyLinkFromLocation(const std::string &localLinkPath, const h5x_src &sourceLocationId, const std::string &sourceLinkPath)
size_t getLogLevel() const
void setLogLevel(size_t logLevelZeroToFive)
void setCompressionLevel(unsigned int compressionLevelZeroToNine)
unsigned int getCompressionLevel() const
unsigned int getCompressionLevel(std::optional<unsigned int> desiredCompressionLevel) const
void createGroup(std::string_view group_relative_name)
void resizeDataset(DsetInfo &info, const DimsType &newDimensions, std::optional<h5pp::ResizeMode> mode_override = std::nullopt)
template<typename DsetDimsType = std::initializer_list<hsize_t>, typename = h5pp::type::sfinae::enable_if_is_integral_iterable_or_num<DsetDimsType>>
DsetInfo resizeDataset(std::string_view dsetPath, const DsetDimsType &newDimensions, std::optional<h5pp::ResizeMode> mode = std::nullopt)
void createDataset(DsetInfo &info)
DsetInfo createDataset(const Options &options)
DsetInfo createDataset(std::optional<hid::h5t> h5Type, std::string_view dsetPath, const DimsType &dsetDims, std::optional<H5D_layout_t> h5Layout = std::nullopt, const OptDimsType &dsetDimsChunk = std::nullopt, const OptDimsType &dsetDimsMax = std::nullopt, std::optional<unsigned int> compression = std::nullopt)
template<typename DataType>
DsetInfo createDataset(const DataType &data, const Options &options)
template<typename DataType>
DsetInfo createDataset(const DataType &data, std::string_view dsetPath, const OptDimsType &dataDims = std::nullopt, std::optional<H5D_layout_t> h5Layout = std::nullopt, const OptDimsType &dsetDimsChunk = std::nullopt, const OptDimsType &dsetDimsMax = std::nullopt, std::optional<unsigned int> compression = std::nullopt)
template<typename DataType>
void writeDataset(const DataType &data, DsetInfo &dsetInfo, const Options &options = Options())
template<typename DataType>
void writeDataset(const DataType &data, const DataInfo &dataInfo, DsetInfo &dsetInfo)
template<typename DataType>
DsetInfo writeDataset(const DataType &data, const Options &options)
template<typename DataType>
DsetInfo writeDataset(const DataType &data, std::string_view dsetPath, const OptDimsType &dataDims = std::nullopt, std::optional<H5D_layout_t> h5Layout = std::nullopt, const OptDimsType &dsetDimsChunk = std::nullopt, const OptDimsType &dsetDimsMax = std::nullopt, std::optional<hid::h5t> h5Type = std::nullopt, std::optional<ResizeMode> resizeMode = std::nullopt, std::optional<unsigned 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

  • dsetDimsChunk: (On create) Chunking dimensions. Only valid for H5D_CHUNKED datasets

  • dsetDimsMax: (On create) Maximum dimensions. Only valid for H5D_CHUNKED datasets

  • h5Type: (On create) Type of dataset. Override automatic type detection.

  • resizeMode: Type of resizing if needed. Choose INCREASE_ONLY, RESIZE_TO_FIT,DO_NOT_RESIZE

  • compression: (On create) Compression level 0-9, 0 = off, 9 is gives best compression and is slowest

template<typename DataType>
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 &dsetDimsChunk = std::nullopt, const OptDimsType &dsetDimsMax = std::nullopt, std::optional<ResizeMode> resizeMode = std::nullopt, std::optional<unsigned 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

  • dsetDimsChunk: (On create) Chunking dimensions. Only valid for H5D_CHUNKED datasets

  • dsetDimsMax: (On create) Maximum dimensions. Only valid for H5D_CHUNKED datasets

  • resizeMode: Type of resizing if needed. Choose INCREASE_ONLY, RESIZE_TO_FIT,DO_NOT_RESIZE

  • compression: (On create) Compression level 0-9, 0 = off, 9 is gives best compression and is slowest

template<typename DataType>
DsetInfo writeDataset(const DataType &data, std::string_view dsetPath, H5D_layout_t h5Layout, const OptDimsType &dataDims = std::nullopt, const OptDimsType &dsetDimsChunk = std::nullopt, const OptDimsType &dsetDimsMax = std::nullopt, std::optional<hid::h5t> h5Type = std::nullopt, std::optional<ResizeMode> resizeMode = std::nullopt, std::optional<unsigned 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

  • dsetDimsChunk: (On create) Chunking dimensions. Only valid for H5D_CHUNKED datasets

  • dsetDimsMax: (On create) Maximum dimensions. Only valid for H5D_CHUNKED datasets

  • h5Type: (On create) Type of dataset. Override automatic type detection.

  • resizeMode: Type of resizing if needed. Choose INCREASE_ONLY, RESIZE_TO_FIT,DO_NOT_RESIZE

  • compression: (On create) Compression level 0-9, 0 = off, 9 is gives best compression and is slowest

template<typename DataType>
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>
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>
DsetInfo writeDataset_chunked(const DataType &data, std::string_view dsetPath, const OptDimsType &dataDims = std::nullopt, const OptDimsType &dsetDimsChunk = std::nullopt, const OptDimsType &dsetDimsMax = std::nullopt, std::optional<hid::h5t> h5Type = std::nullopt, std::optional<unsigned int> compression = std::nullopt)
void writeSymbolicLink(std::string_view src_path, std::string_view tgt_path)
template<typename DataType, typename = std::enable_if_t<not std::is_const_v<DataType>>>
void readDataset(DataType &data, const DataInfo &dataInfo, const DsetInfo &dsetInfo) const
template<typename DataType, typename = std::enable_if_t<not std::is_const_v<DataType>>>
DataType readDataset(const DataInfo &dataInfo, const DsetInfo &dsetInfo) const
template<typename DataType, typename = std::enable_if_t<not std::is_const_v<DataType>>>
void readDataset(DataType &data, const DsetInfo &dsetInfo, const Options &options = Options()) const
template<typename DataType, typename = std::enable_if_t<not std::is_const_v<DataType>>>
DataType readDataset(DsetInfo &dsetInfo, const Options &options = Options()) const
template<typename DataType, typename = std::enable_if_t<not std::is_const_v<DataType>>>
DataType readDataset(DsetInfo &dsetInfo, const DimsType &dataDims) const
template<typename DataType, typename = std::enable_if_t<not std::is_const_v<DataType>>>
void readDataset(DataType &data, const Options &options) const
template<typename DataType>
void readDataset(DataType &data, std::string_view dsetPath, const OptDimsType &dataDims = std::nullopt) const
template<typename DataType, typename = std::enable_if_t<not std::is_const_v<DataType>>>
DataType readDataset(std::string_view datasetPath, const OptDimsType &dataDims = std::nullopt) const
template<typename DataType>
void appendToDataset(DataType &data, const DataInfo &dataInfo, DsetInfo &dsetInfo, size_t axis)
template<typename DataType>
void appendToDataset(DataType &data, DsetInfo &dsetInfo, size_t axis, const OptDimsType &dataDims = std::nullopt)
template<typename DataType>
DsetInfo appendToDataset(DataType &data, size_t axis, const Options &options = Options())
template<typename DataType>
DsetInfo appendToDataset(DataType &data, std::string_view dsetPath, size_t axis, const OptDimsType &dataDims = std::nullopt)
void createAttribute(AttrInfo &attrInfo)
template<typename DataType>
AttrInfo createAttribute(const DataType &data, const Options &options)
template<typename DataType>
void createAttribute(const DataType &data, const DimsType &dataDims, std::string_view attrName, std::string_view linkPath)
template<typename DataType>
void writeAttribute(const DataType &data, const Options &options)
template<typename DataType>
void writeAttribute(const DataType &data, std::string_view attrName, std::string_view linkPath, const OptDimsType &dataDims = std::nullopt, std::optional<hid::h5t> h5Type = std::nullopt)
template<typename DataType, typename = std::enable_if_t<not std::is_const_v<DataType>>>
void readAttribute(DataType &data, const Options &options) const
template<typename DataType, typename = std::enable_if_t<not std::is_const_v<DataType>>>
void readAttribute(DataType &data, std::string_view attrName, std::string_view linkPath, const OptDimsType &dataDims = std::nullopt) const
template<typename DataType, typename = std::enable_if_t<not std::is_const_v<DataType>>>
DataType readAttribute(std::string_view attrName, std::string_view linkPath, const OptDimsType &dataDims = std::nullopt) const
std::vector<std::string> getAttributeNames(std::string_view linkPath) const
TableInfo createTable(const hid::h5t &h5EntryType, std::string_view tableName, std::string_view tableTitle, const std::optional<hsize_t> desiredChunkSize = std::nullopt, const std::optional<unsigned int> desiredCompressionLevel = std::nullopt)
template<typename DataType>
TableInfo appendTableEntries(const DataType &data, std::string_view tableName)
void addTableEntriesFrom(const h5pp::TableInfo &srcInfo, h5pp::TableInfo &tgtInfo, TableSelection tableSelection, const std::optional<hsize_t> desiredChunkSize = std::nullopt, const std::optional<unsigned int> desiredCompressionLevel = std::nullopt)
TableInfo addTableEntriesFrom(const h5pp::TableInfo &srcInfo, std::string_view tgtTableName, TableSelection tableSelection, const std::optional<hsize_t> desiredChunkSize = std::nullopt, const std::optional<unsigned int> desiredCompressionLevel = std::nullopt)
template<typename h5x_src, typename = h5pp::type::sfinae::enable_if_is_h5_loc<h5x_src>>
TableInfo addTableEntriesFrom(const h5x_src &srcLocation, std::string_view srcTableName, std::string_view tgtTableName, TableSelection tableSelection, const std::optional<hsize_t> desiredChunkSize = std::nullopt, const std::optional<unsigned int> desiredCompressionLevel = std::nullopt)
void addTableEntriesFrom(const h5pp::TableInfo &srcInfo, h5pp::TableInfo &tgtInfo, hsize_t srcStartEntry, hsize_t tgtStartEntry, hsize_t numEntries, const std::optional<hsize_t> desiredChunkSize = std::nullopt, const std::optional<unsigned int> desiredCompressionLevel = std::nullopt)
template<typename h5x_src, typename = h5pp::type::sfinae::enable_if_is_h5_loc<h5x_src>>
TableInfo addTableEntriesFrom(const h5pp::TableInfo &srcInfo, std::string_view tgtTableName, hsize_t srcStartEntry, hsize_t tgtStartEntry, hsize_t numEntries, const std::optional<hsize_t> desiredChunkSize = std::nullopt, const std::optional<unsigned int> desiredCompressionLevel = std::nullopt)
template<typename h5x_src, typename = h5pp::type::sfinae::enable_if_is_h5_loc<h5x_src>>
TableInfo addTableEntriesFrom(const h5x_src &srcLocation, std::string_view srcTableName, std::string_view tgtTableName, hsize_t srcStartIdx, hsize_t tgtStartIdx, hsize_t numRecords, const std::optional<hsize_t> desiredChunkSize = std::nullopt, const std::optional<unsigned int> desiredCompressionLevel = std::nullopt)
template<typename DataType>
void readTableEntries(DataType &data, std::string_view tableName, std::optional<size_t> startEntry = std::nullopt, std::optional<size_t> numEntries = std::nullopt) const
template<typename DataType>
DataType readTableEntries(std::string_view tablePath, std::optional<size_t> startEntry = std::nullopt, std::optional<size_t> numEntries = std::nullopt) const
template<typename DataType>
void readTableField(DataType &data, std::string_view tablePath, std::string_view fieldNames, std::optional<size_t> startEntry = std::nullopt, std::optional<size_t> numEntries = std::nullopt) const
template<typename DataType>
DataType readTableField(std::string_view tablePath, std::string_view fieldName, std::optional<size_t> startEntry = std::nullopt, std::optional<size_t> numEntries = std::nullopt) const
template<typename DataType>
void readTableField(DataType &data, std::string_view tablePath, std::string_view fieldNames, TableSelection tableSelection) const
template<typename DataType>
DataType readTableField(std::string_view tablePath, std::string_view fieldName, TableSelection tableSelection) const
int getDatasetRank(std::string_view datasetPath) const
std::vector<hsize_t> getDatasetDimensions(std::string_view datasetPath) const
std::optional<std::vector<hsize_t>> getDatasetMaxDimensions(std::string_view datasetPath) const
std::optional<std::vector<hsize_t>> getDatasetChunkDimensions(std::string_view datasetPath) const
bool linkExists(std::string_view link) const
std::vector<std::string> findLinks(std::string_view searchKey = "", std::string_view searchRoot = "/", long maxHits = -1, long maxDepth = -1) const
std::vector<std::string> findDatasets(std::string_view searchKey = "", std::string_view searchRoot = "/", long maxHits = -1, long maxDepth = -1) const
std::vector<std::string> findGroups(std::string_view searchKey = "", std::string_view searchRoot = "/", long maxHits = -1, long maxDepth = -1) const
DsetInfo getDatasetInfo(std::string_view dsetPath) const
AttrInfo getAttributeInfo(std::string_view linkPath, std::string_view attrName) const
TableInfo getTableInfo(std::string_view tablePath) const
TypeInfo getTypeInfoDataset(std::string_view dsetPath) const
TypeInfo getTypeInfoAttribute(std::string_view linkPath, std::string_view attrName) const
std::vector<TypeInfo> getTypeInfoAttributes(std::string_view linkPath) const
bool fileIsValid() const

Public Members

PropertyLists plists