Help us improve by taking our short survey: https://www.hdfgroup.org/website-survey/
HDF5 Last Updated on 2025-12-13
The HDF5 Field Guide
Loading...
Searching...
No Matches
H5File Class Reference

#include <c++/src/H5File.h>

Detailed Description

Class H5File represents an HDF5 file and inherits from class Group as file is a root group.

+ Inheritance diagram for H5File:

Public Member Functions

virtual void close () override
 Closes this HDF5 file.
 
virtual std::string fromClass () const override
 Returns this class name.
 
FileAccPropList getAccessPlist () const
 Returns a copy of the access property list of this file.
 
FileCreatPropList getCreatePlist () const
 Returns a copy of the creation property list of this file.
 
void getFileInfo (H5F_info2_t &file_info) const
 Retrieves the general information of this file.
 
unsigned long getFileNum () const
 Returns the file number of the HDF5 file.
 
hsize_t getFileSize () const
 Returns the file size of the HDF5 file.
 
hssize_t getFreeSpace () const
 Returns the amount of free space in the file.
 
virtual hid_t getId () const override
 Get the id of this file.
 
virtual hid_t getLocId () const override
 
ssize_t getObjCount (unsigned types=H5F_OBJ_ALL) const
 Returns the number of opened object IDs (files, datasets, groups and datatypes) in the same file.
 
void getObjIDs (unsigned types, size_t max_objs, hid_t *oid_list) const
 Retrieves a list of opened object IDs (files, datasets, groups and datatypes) in the same file.
 
void getVFDHandle (const FileAccPropList &fapl, void **file_handle) const
 Returns the pointer to the file handle of the low-level file driver.
 
void getVFDHandle (void **file_handle) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
 
 H5File ()
 Default constructor: creates a stub H5File object.
 
 H5File (const char *name, unsigned int flags, const FileAccPropList &access_plist)
 Opens an HDF5 file using a non-default access property list.
 
 H5File (const char *name, unsigned int flags, const FileCreatPropList &create_plist=FileCreatPropList::DEFAULT, const FileAccPropList &access_plist=FileAccPropList::DEFAULT)
 Creates or opens an HDF5 file depending on the parameter flags.
 
 H5File (const H5File &original)
 Copy constructor: same HDF5 object as original H5File object.
 
 H5File (const std::string &name, unsigned int flags, const FileAccPropList &access_plist)
 This is another overloaded constructor. It differs from the above constructor only in the type of the name argument.
 
 H5File (const std::string &name, unsigned int flags, const FileCreatPropList &create_plist=FileCreatPropList::DEFAULT, const FileAccPropList &access_plist=FileAccPropList::DEFAULT)
 This is another overloaded constructor. It differs from the above constructor only in the type of the name argument.
 
 H5File (hid_t existing_id)
 Creates an H5File object using an existing file id.
 
void openFile (const char *name, unsigned int flags, const FileAccPropList &access_plist=FileAccPropList::DEFAULT)
 Opens an HDF5 file.
 
void openFile (const std::string &name, unsigned int flags, const FileAccPropList &access_plist=FileAccPropList::DEFAULT)
 This is an overloaded member function, provided for convenience. It takes an H5std_string for name.
 
void reOpen ()
 Reopens this file.
 
void reopen ()
 
virtual void throwException (const std::string &func_name, const std::string &msg) const override
 Throws file exception - initially implemented for CommonFG.
 
virtual ~H5File () override
 Properly terminates access to this file.
 
- Public Member Functions inherited from Group
void closeObjId (hid_t obj_id) const
 Closes an object, which was opened with Group::getObjId.
 
hsize_t getNumObjs () const
 Returns the number of objects in this group.
 
hid_t getObjId (const char *name, const PropList &plist=PropList::DEFAULT) const
 Opens an object via object header.
 
hid_t getObjId (const std::string &name, const PropList &plist=PropList::DEFAULT) const
 This is an overloaded member function, provided for convenience. It takes a reference to a H5std_string for the object's name.
 
 Group ()
 Default constructor: creates a stub Group.
 
 Group (const Group &original)
 Copy constructor: same HDF5 object as original.
 
 Group (const H5Location &loc, const void *ref, H5R_type_t ref_type=H5R_OBJECT, const PropList &plist=PropList::DEFAULT)
 Given a reference, ref, to an hdf5 group, creates a Group object.
 
 Group (const hid_t group_id)
 Creates a Group object using the id of an existing group.
 
Groupoperator= (const Group &original)
 
virtual ~Group () override
 Properly terminates access to this group.
 
- Public Member Functions inherited from H5Object
bool attrExists (const char *name) const
 Checks whether the named attribute exists at this location.
 
bool attrExists (const std::string &name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes a reference to an H5std_string for name.
 
Attribute createAttribute (const char *name, const DataType &type, const DataSpace &space, const PropList &create_plist=PropList::DEFAULT) const
 Creates an attribute for a group, dataset, or named datatype.
 
Attribute createAttribute (const std::string &name, const DataType &type, const DataSpace &space, const PropList &create_plist=PropList::DEFAULT) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes a reference to an H5std_string for name.
 
int getNumAttrs () const
 Returns the number of attributes attached to this HDF5 object.
 
std::string getObjName () const
 Returns the name of this object as an H5std_string.
 
ssize_t getObjName (char *obj_name, size_t buf_size=0) const
 Given an id, returns the type of the object.
 
ssize_t getObjName (std::string &obj_name, size_t len=0) const
 Gets the name of this object, returning its length.
 
int iterateAttrs (attr_operator_t user_op, unsigned *idx=NULL, void *op_data=NULL)
 Iterates a user's function over all the attributes of an H5 object, which may be a group, dataset or named datatype.
 
unsigned objVersion () const
 Returns the header version of this HDF5 object.
 
Attribute openAttribute (const char *name) const
 Opens an attribute given its name.
 
Attribute openAttribute (const std::string &name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes a reference to an H5std_string for name.
 
Attribute openAttribute (const unsigned int idx) const
 Opens an attribute given its index.
 
void removeAttr (const char *name) const
 Removes the named attribute from this object.
 
void removeAttr (const std::string &name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes a reference to an H5std_string for name.
 
void renameAttr (const char *oldname, const char *newname) const
 Renames the named attribute from this object.
 
void renameAttr (const std::string &oldname, const std::string &newname) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes a reference to an H5std_string for the names.
 
void visit (H5_index_t idx_type, H5_iter_order_t order, visit_operator_t user_op, void *op_data, unsigned int fields)
 Recursively visits all HDF5 objects accessible from this object.
 
- Public Member Functions inherited from H5Location
H5O_type_t childObjType (const char *objname) const
 Returns the type of an object in this file/group, given the object's name.
 
H5O_type_t childObjType (const std::string &objname) const
 This is an overloaded member function, provided for convenience. It takes an H5std_string for the object's name.
 
H5O_type_t childObjType (hsize_t index, H5_index_t index_type=H5_INDEX_NAME, H5_iter_order_t order=H5_ITER_INC, const char *objname=".") const
 Returns the type of an object in this file/group, given the object's index and its type and order.
 
unsigned childObjVersion (const char *objname) const
 Returns the object header version of an object in this file/group, given the object's name.
 
unsigned childObjVersion (const std::string &objname) const
 This is an overloaded member function, provided for convenience. It takes an H5std_string for the object's name.
 
void copyLink (const char *src_name, const char *dst_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 Copies a link from a group in the same location.
 
void copyLink (const char *src_name, const Group &dst, const char *dst_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 Copies a link from one group to another.
 
void copyLink (const std::string &src_name, const Group &dst, const std::string &dst_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for src_name and dst_name.
 
void copyLink (const std::string &src_name, const std::string &dst_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for src_name and dst_name.
 
DataSet createDataSet (const char *name, const DataType &data_type, const DataSpace &data_space, const DSetCreatPropList &create_plist=DSetCreatPropList::DEFAULT, const DSetAccPropList &dapl=DSetAccPropList::DEFAULT, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT) const
 Creates a new dataset at this location.
 
DataSet createDataSet (const std::string &name, const DataType &data_type, const DataSpace &data_space, const DSetCreatPropList &create_plist=DSetCreatPropList::DEFAULT, const DSetAccPropList &dapl=DSetAccPropList::DEFAULT, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
Group createGroup (const char *name, const LinkCreatPropList &lcpl) const
 Creates a new group at this location, which can be a file, group, dataset, attribute, or named datatype.
 
Group createGroup (const char *name, size_t size_hint=0) const
 Creates a new group at this location, which can be a file, group, dataset, attribute, or named datatype.
 
Group createGroup (const std::string &name, const LinkCreatPropList &lcpl) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
Group createGroup (const std::string &name, size_t size_hint=0) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
void dereference (const H5Location &loc, const void *ref, H5R_type_t ref_type=H5R_OBJECT, const PropList &plist=PropList::DEFAULT)
 Dereferences a reference into an HDF5 object, given an HDF5 object.
 
bool exists (const char *name, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 Deprecated in favor of nameExists.
 
bool exists (const std::string &name, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 Deprecated in favor of nameExists.
 
void flush (H5F_scope_t scope) const
 Flushes all buffers associated with a location to disk.
 
ssize_t getComment (const char *name, size_t buf_size, char *comment) const
 Retrieves the comment for this location, returning its length.
 
std::string getComment (const char *name, size_t buf_size=0) const
 Returns the comment as string for this location, returning its length.
 
std::string getComment (const std::string &name, size_t buf_size=0) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
std::string getFileName () const
 Gets the name of the file, in which an HDF5 object at this location belongs.
 
H5L_info2_t getLinkInfo (const char *link_name, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 Returns the information of the named link.
 
H5L_info2_t getLinkInfo (const std::string &link_name, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for link_name.
 
std::string getLinkval (const char *link_name, size_t size=0) const
 Returns the name of the object that the symbolic link points to.
 
std::string getLinkval (const std::string &link_name, size_t size=0) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
void getNativeObjinfo (const char *grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, H5O_native_info_t &objinfo, unsigned fields=H5O_NATIVE_INFO_HDR, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 Retrieves native information about an HDF5 object given its index.
 
void getNativeObjinfo (const char *name, H5O_native_info_t &objinfo, unsigned fields=H5O_NATIVE_INFO_HDR, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 Retrieves native information about an HDF5 object given its name.
 
void getNativeObjinfo (const std::string &grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, H5O_native_info_t &objinfo, unsigned fields=H5O_NATIVE_INFO_HDR, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes a reference to an H5std_string for grp_name.
 
void getNativeObjinfo (const std::string &name, H5O_native_info_t &objinfo, unsigned fields=H5O_NATIVE_INFO_HDR, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes a reference to an H5std_string for name.
 
void getNativeObjinfo (H5O_native_info_t &objinfo, unsigned fields=H5O_NATIVE_INFO_HDR) const
 Retrieves native information about an HDF5 object.
 
hsize_t getNumObjs () const
 Deprecated - moved to H5::Group in 1.10.2.
 
void getObjinfo (const char *grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, H5O_info2_t &objinfo, unsigned fields=H5O_INFO_BASIC, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 Retrieves information about an HDF5 object given its index.
 
void getObjinfo (const char *name, bool follow_link, H5G_stat_t &statbuf) const
 Returns information about an object.
 
void getObjinfo (const char *name, H5G_stat_t &statbuf) const
 This is an overloaded member function, provided for convenience. It differs from the above functions in that it doesn't have the parameter follow_link.
 
void getObjinfo (const char *name, H5O_info2_t &objinfo, unsigned fields=H5O_INFO_BASIC, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 Retrieves information about an HDF5 object given its name.
 
void getObjinfo (const std::string &grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, H5O_info2_t &objinfo, unsigned fields=H5O_INFO_BASIC, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes a reference to an H5std_string for name.
 
void getObjinfo (const std::string &name, bool follow_link, H5G_stat_t &statbuf) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
void getObjinfo (const std::string &name, H5G_stat_t &statbuf) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
void getObjinfo (const std::string &name, H5O_info2_t &objinfo, unsigned fields=H5O_INFO_BASIC, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes a reference to an H5std_string for name.
 
void getObjinfo (H5O_info2_t &objinfo, unsigned fields=H5O_INFO_BASIC) const
 Retrieves information about an HDF5 object.
 
std::string getObjnameByIdx (hsize_t idx) const
 Returns the name of an object in this group, given the object's index.
 
ssize_t getObjnameByIdx (hsize_t idx, char *name, size_t size) const
 Retrieves the name of an object in this group, given the object's index.
 
ssize_t getObjnameByIdx (hsize_t idx, std::string &name, size_t size) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
H5G_obj_t getObjType (void *ref, H5R_type_t ref_type=H5R_OBJECT) const
 Retrieves the type of object that an object reference points to.
 
H5G_obj_t getObjTypeByIdx (hsize_t idx) const
 Returns the type of an object in this group, given the object's index. (Deprecated)
 
H5G_obj_t getObjTypeByIdx (hsize_t idx, char *type_name) const
 This is an overloaded member function, provided for convenience. It differs from the above function because it also provides the returned object type in text (char*) (Deprecated)
 
H5G_obj_t getObjTypeByIdx (hsize_t idx, std::string &type_name) const
 This is an overloaded member function, provided for convenience. It differs from the above function because it also provides the returned object type in text (H5std_string&) (Deprecated)
 
H5O_type_t getRefObjType (void *ref, H5R_type_t ref_type=H5R_OBJECT) const
 Retrieves the type of object that an object reference points to.
 
DataSpace getRegion (void *ref, H5R_type_t ref_type=H5R_DATASET_REGION) const
 Retrieves a dataspace with the region pointed to selected.
 
 H5Location ()
 
int iterateElems (const char *name, int *idx, H5G_iterate_t op, void *op_data)
 Iterates a user's function over the entries of a group.
 
int iterateElems (const std::string &name, int *idx, H5G_iterate_t op, void *op_data)
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
void link (const char *curr_name, const Group &new_loc, const char *new_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 Creates a hard link from new_name to curr_name.
 
void link (const char *curr_name, const hid_t same_loc, const char *new_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 Creates a hard link from new_name to curr_name - can be used to pass in H5L_SAME_LOC.
 
void link (const char *target_name, const char *link_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 Creates a soft link from link_name to target_name.
 
void link (const std::string &curr_name, const Group &new_loc, const std::string &new_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for curr_name and new_name.
 
void link (const std::string &curr_name, const hid_t same_loc, const std::string &new_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for curr_name and new_name.
 
void link (const std::string &target_name, const std::string &link_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for target_name and link_name.
 
void link (H5L_type_t link_type, const char *curr_name, const char *new_name) const
 Creates a link of the specified type from new_name to curr_name.
 
void link (H5L_type_t link_type, const std::string &curr_name, const std::string &new_name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for curr_name and new_name.
 
void mount (const char *name, const H5File &child, const PropList &plist) const
 Mounts the file child onto this group.
 
void mount (const std::string &name, const H5File &child, const PropList &plist) const
 This is an overloaded member function, provided for convenience. It takes an H5std_string for name.
 
void move (const char *src, const char *dst) const
 Renames an object at this location. - Deprecated in favor of moveLink()
 
void move (const std::string &src, const std::string &dst) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for src and dst. - Deprecated in favor of moveLink()
 
void moveLink (const char *src_name, const char *dst_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 Renames a link in this group.
 
void moveLink (const char *src_name, const Group &dst, const char *dst_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 Renames a link in this group and moves it to a new location.
 
void moveLink (const std::string &src_name, const Group &dst, const std::string &dst_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for src_name and dst_name.
 
void moveLink (const std::string &src_name, const std::string &dst_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for src_name and dst_name.
 
bool nameExists (const char *name, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 Checks if a link of a given name exists in a location.
 
bool nameExists (const std::string &name, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 Checks if a link of a given name exists in a location.
 
DataSet openDataSet (const char *name, const DSetAccPropList &dapl=DSetAccPropList::DEFAULT) const
 Opens an existing dataset at this location.
 
DataSet openDataSet (const std::string &name, const DSetAccPropList &dapl=DSetAccPropList::DEFAULT) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
Group openGroup (const char *name) const
 Opens an existing group in a location which can be a file or another group.
 
Group openGroup (const std::string &name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
void reference (void *ref, const char *name, const DataSpace &dataspace, H5R_type_t ref_type=H5R_DATASET_REGION) const
 Creates a reference to an HDF5 object or a dataset region.
 
void reference (void *ref, const char *name, H5R_type_t ref_type=H5R_OBJECT) const
 This is an overloaded function, provided for your convenience. It differs from the above function in that it does not take a DataSpace object and the reference type must be specified.
 
void reference (void *ref, const std::string &name, const DataSpace &dataspace, H5R_type_t ref_type=H5R_DATASET_REGION) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
void reference (void *ref, const std::string &name, H5R_type_t ref_type=H5R_OBJECT) const
 This is an overloaded function, provided for your convenience. It differs from the above function in that it takes an H5std_string for the object's name.
 
void removeComment (const char *name) const
 Removes the comment from an object specified by its name.
 
void removeComment (const std::string &name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
void setComment (const char *comment) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it doesn't take an object name.
 
void setComment (const char *name, const char *comment) const
 Sets or resets the comment for an object specified by its name.
 
void setComment (const std::string &comment) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for comment.
 
void setComment (const std::string &name, const std::string &comment) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name and comment.
 
void unlink (const char *link_name, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 Removes the specified link from this group.
 
void unlink (const std::string &link_name, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
void unmount (const char *name) const
 Unmounts the specified file.
 
void unmount (const std::string &name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
- Public Member Functions inherited from IdComponent
void decRefCount () const
 Decrement reference counter for the id of this object.
 
void decRefCount (const hid_t obj_id) const
 Decrement reference counter for a given id.
 
int getCounter () const
 Returns the reference counter for the id of this object.
 
int getCounter (const hid_t obj_id) const
 Returns the reference counter for a given id.
 
H5I_type_t getHDFObjType () const
 Returns the type of the object. It is an overloaded function of the above function.
 
void incRefCount () const
 Increment reference counter for the id of this object.
 
void incRefCount (const hid_t obj_id) const
 Increment reference counter for a given id.
 
std::string inMemFunc (const char *func_name) const
 Makes and returns string "<class-name>::<func_name>".
 
IdComponentoperator= (const IdComponent &rhs)
 Assignment operator.
 
void setId (const hid_t new_id)
 Sets the identifier of this object to a new value.
 
virtual ~IdComponent ()=default
 
- Public Member Functions inherited from CommonFG
 CommonFG ()
 Default constructor.
 
ArrayType openArrayType (const char *name) const
 Opens the named array datatype at this location.
 
ArrayType openArrayType (const std::string &name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
CompType openCompType (const char *name) const
 Opens the named compound datatype at this location.
 
CompType openCompType (const std::string &name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
DataType openDataType (const char *name) const
 Opens the named generic datatype at this location.
 
DataType openDataType (const std::string &name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
EnumType openEnumType (const char *name) const
 Opens the named enumeration datatype at this location.
 
EnumType openEnumType (const std::string &name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
FloatType openFloatType (const char *name) const
 Opens the named floating-point datatype at this location.
 
FloatType openFloatType (const std::string &name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
IntType openIntType (const char *name) const
 Opens the named integer datatype at this location.
 
IntType openIntType (const std::string &name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
StrType openStrType (const char *name) const
 Opens the named string datatype at this location.
 
StrType openStrType (const std::string &name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
VarLenType openVarLenType (const char *name) const
 Opens the named variable length datatype at this location.
 
VarLenType openVarLenType (const std::string &name) const
 This is an overloaded member function, provided for convenience. It differs from the above function in that it takes an H5std_string for name.
 
virtual ~CommonFG ()=default
 

Static Public Member Functions

static bool isAccessible (const char *name, const FileAccPropList &access_plist=FileAccPropList::DEFAULT)
 Determines whether a file can be accessed as HDF5. (Static)
 
static bool isAccessible (const std::string &name, const FileAccPropList &access_plist=FileAccPropList::DEFAULT)
 This is an overloaded member function, provided for convenience. It takes an H5std_string for name. (Static)
 
static bool isHdf5 (const char *name)
 Determines whether a file in HDF5 format. (Static)
 
static bool isHdf5 (const std::string &name)
 This is an overloaded member function, provided for convenience. It takes an H5std_string for name. (Static)
 
- Static Public Member Functions inherited from IdComponent
static H5I_type_t getHDFObjType (const hid_t obj_id)
 Given an id, returns the type of the object.
 
static hsize_t getNumMembers (H5I_type_t type)
 Returns the number of members of the given type.
 
static bool isValid (hid_t an_id)
 Checks if the given ID is valid.
 
static bool typeExists (H5I_type_t type)
 Queries if a given type is currently registered with the library.
 

Protected Member Functions

virtual void p_setId (const hid_t new_id) override
 Sets the identifier of this object to a new value.
 
- Protected Member Functions inherited from H5Object
 H5Object ()
 
virtual ~H5Object () override=default
 
- Protected Member Functions inherited from H5Location
hid_t p_dereference (hid_t loc_id, const void *ref, H5R_type_t ref_type, const PropList &plist, const char *from_func)
 
H5G_obj_t p_get_obj_type (void *ref, H5R_type_t ref_type) const
 
H5O_type_t p_get_ref_obj_type (void *ref, H5R_type_t ref_type) const
 
void p_reference (void *ref, const char *name, hid_t space_id, H5R_type_t ref_type) const
 
virtual ~H5Location () override=default
 
- Protected Member Functions inherited from IdComponent
 IdComponent ()
 Default constructor.
 
std::string p_get_file_name () const
 

Additional Inherited Members

- Static Protected Member Functions inherited from IdComponent
static bool p_valid_id (const hid_t obj_id)
 
- Static Protected Attributes inherited from IdComponent
static bool H5dontAtexit_called = false
 

Constructor & Destructor Documentation

◆ H5File() [1/7]

H5File ( const char * name,
unsigned int flags,
const FileCreatPropList & create_plist = FileCreatPropList::DEFAULT,
const FileAccPropList & access_plist = FileAccPropList::DEFAULT )

Creates or opens an HDF5 file depending on the parameter flags.

Parameters
name- IN: Name of the file
flags- IN: File access flags
create_plist- IN: File creation property list, used when modifying default file meta-data. Default to FileCreatPropList::DEFAULT
access_plist- IN: File access property list. Default to FileAccPropList::DEFAULT
Description
Valid values of flags include:
  • H5F_ACC_TRUNC - Truncate file, if it already exists, erasing all data previously stored in the file.
  • H5F_ACC_EXCL - Fail if file already exists. H5F_ACC_TRUNC and H5F_ACC_EXCL are mutually exclusive
  • H5F_ACC_RDONLY - Open file as read-only, if it already exists, and fail, otherwise
  • H5F_ACC_RDWR - Open file for read/write, if it already exists, and fail, otherwise
For info on file creation in the case of an already-open file, please refer to the Special case section of the H5Fcreate API in the C Reference Manual.

◆ H5File() [2/7]

H5File ( const std::string & name,
unsigned int flags,
const FileCreatPropList & create_plist = FileCreatPropList::DEFAULT,
const FileAccPropList & access_plist = FileAccPropList::DEFAULT )

This is another overloaded constructor. It differs from the above constructor only in the type of the name argument.

Parameters
name- IN: Name of the file - H5std_string
flags- IN: File access flags
create_plist- IN: File creation property list, used when modifying default file meta-data. Default to FileCreatPropList::DEFAULT
access_plist- IN: File access property list. Default to FileAccPropList::DEFAULT

◆ H5File() [3/7]

H5File ( const char * name,
unsigned int flags,
const FileAccPropList & access_plist )

Opens an HDF5 file using a non-default access property list.

Parameters
name- IN: Name of the file
flags- IN: File access flags
access_plist- IN: File access property list.
Description
Valid values of flags include:
  • H5F_ACC_RDONLY - Open file as read-only, if it already exists, and fail, otherwise
  • H5F_ACC_RDWR - Open file for read/write, if it already exists, and fail, otherwise

◆ H5File() [4/7]

H5File ( const std::string & name,
unsigned int flags,
const FileAccPropList & access_plist )

This is another overloaded constructor. It differs from the above constructor only in the type of the name argument.

Parameters
name- IN: Name of the file - H5std_string
flags- IN: File access flags
access_plist- IN: File access property list

◆ H5File() [5/7]

H5File ( hid_t existing_id)

Creates an H5File object using an existing file id.

Parameters
existing_id- IN: Id of an existing file

◆ H5File() [6/7]

H5File ( )

Default constructor: creates a stub H5File object.

◆ H5File() [7/7]

H5File ( const H5File & original)

Copy constructor: same HDF5 object as original H5File object.

Parameters
original- IN: H5File instance to copy

◆ ~H5File()

~H5File ( )
overridevirtual

Properly terminates access to this file.

Member Function Documentation

◆ close()

void close ( )
overridevirtual

Closes this HDF5 file.

Exceptions
H5::FileIException

Reimplemented from Group.

◆ fromClass()

virtual std::string fromClass ( ) const
overridevirtual

Returns this class name.

Reimplemented from Group.

◆ getAccessPlist()

FileAccPropList getAccessPlist ( ) const

Returns a copy of the access property list of this file.

Returns
FileAccPropList object
Exceptions
H5::FileIException

◆ getCreatePlist()

FileCreatPropList getCreatePlist ( ) const

Returns a copy of the creation property list of this file.

Returns
FileCreatPropList object
Exceptions
H5::FileIException

◆ getFileInfo()

void getFileInfo ( H5F_info2_t & file_info) const

Retrieves the general information of this file.

Exceptions
H5::FileIException
Description
The retrieved information may include information about superblock extension, free space management, and shared object

◆ getFileNum()

unsigned long getFileNum ( ) const

Returns the file number of the HDF5 file.

Returns
File number
Exceptions
H5::FileIException
Description
This function is called after an existing file is opened in order to retrieve the unique 'file number' for the file.

◆ getFileSize()

hsize_t getFileSize ( ) const

Returns the file size of the HDF5 file.

Returns
File size
Exceptions
H5::FileIException
Description
This function is called after an existing file is opened in order to learn the true size of the underlying file.

◆ getFreeSpace()

hssize_t getFreeSpace ( ) const

Returns the amount of free space in the file.

Returns
Amount of free space
Exceptions
H5::FileIException

◆ getId()

hid_t getId ( ) const
overridevirtual

Get the id of this file.

Returns
File identifier

Reimplemented from Group.

◆ getLocId()

hid_t getLocId ( ) const
overridevirtual

For subclasses, H5File and Group, to return the correct object id, i.e. file or group id.

Reimplemented from Group.

◆ getObjCount()

ssize_t getObjCount ( unsigned types = H5F_OBJ_ALL) const

Returns the number of opened object IDs (files, datasets, groups and datatypes) in the same file.

Parameters
types- Type of object to retrieve the count
Returns
Number of opened object IDs
Exceptions
H5::FileIException
Description
The valid values for types include:
  • H5F_OBJ_FILE - Files only
  • H5F_OBJ_DATASET - Datasets only
  • H5F_OBJ_GROUP - Groups only
  • H5F_OBJ_DATATYPE - Named datatypes only
  • H5F_OBJ_ATTR - Attributes only
  • H5F_OBJ_ALL - All of the above, i.e., H5F_OBJ_FILE | H5F_OBJ_DATASET | H5F_OBJ_GROUP | H5F_OBJ_DATATYPE | H5F_OBJ_ATTR
Multiple object types can be combined with the logical OR operator (|).

◆ getObjIDs()

void getObjIDs ( unsigned types,
size_t max_objs,
hid_t * oid_list ) const

Retrieves a list of opened object IDs (files, datasets, groups and datatypes) in the same file.

Parameters
types- Type of object to retrieve the count
max_objs- Maximum number of object identifiers to place into obj_id_list.
oid_list- List of open object identifiers
Exceptions
H5::FileIException
Description
The valid values for types include:
  • H5F_OBJ_FILE - Files only
  • H5F_OBJ_DATASET - Datasets only
  • H5F_OBJ_GROUP - Groups only
  • H5F_OBJ_DATATYPE - Named datatypes only
  • H5F_OBJ_ATTR - Attributes only
  • H5F_OBJ_ALL - All of the above, i.e., H5F_OBJ_FILE | H5F_OBJ_DATASET | H5F_OBJ_GROUP | H5F_OBJ_DATATYPE | H5F_OBJ_ATTR
Multiple object types can be combined with the logical OR operator (|).

◆ getVFDHandle() [1/2]

void getVFDHandle ( const FileAccPropList & fapl,
void ** file_handle ) const

Returns the pointer to the file handle of the low-level file driver.

Parameters
fapl- File access property list
file_handle- Pointer to the file handle being used by the low-level virtual file driver
Exceptions
H5::FileIException
Description
For the FAMILY or MULTI drivers, fapl should be defined through the property list functions: FileAccPropList::setFamilyOffset for the FAMILY driver and FileAccPropList::setMultiType for the MULTI driver.

The obtained file handle is dynamic and is valid only while the file remains open; it will be invalid if the file is closed and reopened or opened during a subsequent session.

◆ getVFDHandle() [2/2]

void getVFDHandle ( void ** file_handle) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.

Parameters
file_handle- Pointer to the file handle being used by the low-level virtual file driver
Exceptions
H5::FileIException

◆ isAccessible() [1/2]

bool isAccessible ( const char * name,
const FileAccPropList & access_plist = FileAccPropList::DEFAULT )
static

Determines whether a file can be accessed as HDF5. (Static)

Parameters
name- IN: Name of the file
access_plist- IN: File access property list. Default to FileAccPropList::DEFAULT
Returns
true if the file can be accessed as HDF5, and false, otherwise
Exceptions
H5::FileIException

◆ isAccessible() [2/2]

bool isAccessible ( const std::string & name,
const FileAccPropList & access_plist = FileAccPropList::DEFAULT )
static

This is an overloaded member function, provided for convenience. It takes an H5std_string for name. (Static)

Parameters
name- IN: Name of the file - H5std_string
access_plist- IN: File access property list. Default to FileAccPropList::DEFAULT

◆ isHdf5() [1/2]

bool isHdf5 ( const char * name)
static

Determines whether a file in HDF5 format. (Static)

Parameters
name- IN: Name of the file
Returns
true if the file is in HDF5 format, and false, otherwise
Exceptions
H5::FileIException

◆ isHdf5() [2/2]

bool isHdf5 ( const std::string & name)
static

This is an overloaded member function, provided for convenience. It takes an H5std_string for name. (Static)

Parameters
name- IN: Name of the file - H5std_string

◆ openFile() [1/2]

void openFile ( const char * name,
unsigned int flags,
const FileAccPropList & access_plist = FileAccPropList::DEFAULT )

Opens an HDF5 file.

Parameters
name- IN: Name of the file
flags- IN: File access flags
access_plist- IN: File access property list. Default to FileAccPropList::DEFAULT
Description
Valid values of flags include: H5F_ACC_RDWR: Open with read/write access. If the file is currently open for read-only access then it will be reopened. Absence of this flag implies read-only access.

H5F_ACC_RDONLY: Open with read only access. - default

◆ openFile() [2/2]

void openFile ( const std::string & name,
unsigned int flags,
const FileAccPropList & access_plist = FileAccPropList::DEFAULT )

This is an overloaded member function, provided for convenience. It takes an H5std_string for name.

Parameters
name- IN: Name of the file - H5std_string
flags- IN: File access flags
access_plist- IN: File access property list. Default to FileAccPropList::DEFAULT

◆ p_setId()

void p_setId ( const hid_t new_id)
overrideprotectedvirtual

Sets the identifier of this object to a new value.

Exceptions
H5::IdComponentExceptionwhen the attempt to close the HDF5 object fails

Reimplemented from Group.

◆ reOpen()

void reOpen ( )

Reopens this file.

Exceptions
H5::FileIException

◆ reopen()

void reopen ( )

◆ throwException()

void throwException ( const std::string & func_name,
const std::string & msg ) const
overridevirtual

Throws file exception - initially implemented for CommonFG.

Parameters
func_name- Name of the function where failure occurs
msg- Message describing the failure
Exceptions
H5::FileIException

Reimplemented from Group.


The documentation for this class was generated from the following files: