Help us improve by taking our short survey: https://www.hdfgroup.org/website-survey/

| HDF5 Last Updated on 2025-11-11 The HDF5 Field Guide

- Main Page
- Getting started
- User Guide
- Reference Manual
- Cookbook
- Technical Notes
- RFCs
- Specifications
- Glossary
- Full-Text Search
- About

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions
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
virtual H5std_string | fromClass () const override
| Returns this class name.
FileAccPropList | getAccessPlist () const
FileCreatPropList | getCreatePlist () const
void | getFileInfo (H5F_info2_t &file_info) const
unsigned long | getFileNum () const
hsize_t | getFileSize () const
hssize_t | getFreeSpace () const
virtual hid_t | getId () const override
virtual hid_t | getLocId () const override
ssize_t | getObjCount (unsigned types=H5F_OBJ_ALL) const
void | getObjIDs (unsigned types, size_t max_objs, hid_t *oid_list) const
void | getVFDHandle (const FileAccPropList &fapl, void **file_handle) const
void | getVFDHandle (void **file_handle) const
| H5File ()
| H5File (const char *name, unsigned int flags, const FileAccPropList &access_plist)
| H5File (const char *name, unsigned int flags, const FileCreatPropList &create_plist=FileCreatPropList::DEFAULT, const FileAccPropList &access_plist=FileAccPropList::DEFAULT)
| H5File (const H5File &original)
| H5File (const H5std_string &name, unsigned int flags, const FileAccPropList &access_plist)
| H5File (const H5std_string &name, unsigned int flags, const FileCreatPropList &create_plist=FileCreatPropList::DEFAULT, const FileAccPropList &access_plist=FileAccPropList::DEFAULT)
| H5File (hid_t existing_id)
void | openFile (const char *name, unsigned int flags, const FileAccPropList &access_plist=FileAccPropList::DEFAULT)
void | openFile (const H5std_string &name, unsigned int flags, const FileAccPropList &access_plist=FileAccPropList::DEFAULT)
void | reOpen ()
void | reopen ()
virtual void | throwException (const H5std_string &func_name, const H5std_string &msg) const override
| For subclasses, H5File and Group, to throw appropriate exception.
virtual | ~H5File () override
Public Member Functions inherited from Group
void | closeObjId (hid_t obj_id) const
hsize_t | getNumObjs () const
hid_t | getObjId (const char *name, const PropList &plist=PropList::DEFAULT) const
hid_t | getObjId (const H5std_string &name, const PropList &plist=PropList::DEFAULT) const
| Group ()
| Group (const Group &original)
| Group (const H5Location &loc, const void *ref, H5R_type_t ref_type=H5R_OBJECT, const PropList &plist=PropList::DEFAULT)
| Group (const hid_t group_id)
Group & | operator= (const Group &original)
virtual | ~Group () override
Public Member Functions inherited from H5Object
bool | attrExists (const char *name) const
bool | attrExists (const H5std_string &name) const
Attribute | createAttribute (const char *name, const DataType &type, const DataSpace &space, const PropList &create_plist=PropList::DEFAULT) const
Attribute | createAttribute (const H5std_string &name, const DataType &type, const DataSpace &space, const PropList &create_plist=PropList::DEFAULT) const
int | getNumAttrs () const
H5std_string | getObjName () const
ssize_t | getObjName (char *obj_name, size_t buf_size=0) const
ssize_t | getObjName (H5std_string &obj_name, size_t len=0) const
int | iterateAttrs (attr_operator_t user_op, unsigned *idx=NULL, void *op_data=NULL)
unsigned | objVersion () const
Attribute | openAttribute (const char *name) const
Attribute | openAttribute (const H5std_string &name) const
Attribute | openAttribute (const unsigned int idx) const
void | removeAttr (const char *name) const
void | removeAttr (const H5std_string &name) const
void | renameAttr (const char *oldname, const char *newname) const
void | renameAttr (const H5std_string &oldname, const H5std_string &newname) const
void | visit (H5_index_t idx_type, H5_iter_order_t order, visit_operator_t user_op, void *op_data, unsigned int fields)
Public Member Functions inherited from H5Location
H5O_type_t | childObjType (const char *objname) const
H5O_type_t | childObjType (const H5std_string &objname) const
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
unsigned | childObjVersion (const char *objname) const
unsigned | childObjVersion (const H5std_string &objname) const
void | copyLink (const char *src_name, const char *dst_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
void | copyLink (const char *src_name, const Group &dst, const char *dst_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
void | copyLink (const H5std_string &src_name, const Group &dst, const H5std_string &dst_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
void | copyLink (const H5std_string &src_name, const H5std_string &dst_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
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
DataSet | createDataSet (const H5std_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
Group | createGroup (const char *name, const LinkCreatPropList &lcpl) const
Group | createGroup (const char *name, size_t size_hint=0) const
Group | createGroup (const H5std_string &name, const LinkCreatPropList &lcpl) const
Group | createGroup (const H5std_string &name, size_t size_hint=0) const
void | dereference (const H5Location &loc, const void *ref, H5R_type_t ref_type=H5R_OBJECT, const PropList &plist=PropList::DEFAULT)
bool | exists (const char *name, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
bool | exists (const H5std_string &name, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
void | flush (H5F_scope_t scope) const
ssize_t | getComment (const char *name, size_t buf_size, char *comment) const
H5std_string | getComment (const char *name, size_t buf_size=0) const
H5std_string | getComment (const H5std_string &name, size_t buf_size=0) const
H5std_string | getFileName () const
H5L_info2_t | getLinkInfo (const char *link_name, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
H5L_info2_t | getLinkInfo (const H5std_string &link_name, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
H5std_string | getLinkval (const char *link_name, size_t size=0) const
H5std_string | getLinkval (const H5std_string &link_name, size_t size=0) const
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
void | getNativeObjinfo (const char *name, H5O_native_info_t &objinfo, unsigned fields=H5O_NATIVE_INFO_HDR, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
void | getNativeObjinfo (const H5std_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
void | getNativeObjinfo (const H5std_string &name, H5O_native_info_t &objinfo, unsigned fields=H5O_NATIVE_INFO_HDR, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
void | getNativeObjinfo (H5O_native_info_t &objinfo, unsigned fields=H5O_NATIVE_INFO_HDR) const
hsize_t | getNumObjs () const
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
void | getObjinfo (const char *name, bool follow_link, H5G_stat_t &statbuf) const
void | getObjinfo (const char *name, H5G_stat_t &statbuf) const
void | getObjinfo (const char *name, H5O_info2_t &objinfo, unsigned fields=H5O_INFO_BASIC, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
void | getObjinfo (const H5std_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
void | getObjinfo (const H5std_string &name, bool follow_link, H5G_stat_t &statbuf) const
void | getObjinfo (const H5std_string &name, H5G_stat_t &statbuf) const
void | getObjinfo (const H5std_string &name, H5O_info2_t &objinfo, unsigned fields=H5O_INFO_BASIC, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
void | getObjinfo (H5O_info2_t &objinfo, unsigned fields=H5O_INFO_BASIC) const
H5std_string | getObjnameByIdx (hsize_t idx) const
ssize_t | getObjnameByIdx (hsize_t idx, char *name, size_t size) const
ssize_t | getObjnameByIdx (hsize_t idx, H5std_string &name, size_t size) const
H5G_obj_t | getObjType (void *ref, H5R_type_t ref_type=H5R_OBJECT) const
H5G_obj_t | getObjTypeByIdx (hsize_t idx) const
H5G_obj_t | getObjTypeByIdx (hsize_t idx, char *type_name) const
H5G_obj_t | getObjTypeByIdx (hsize_t idx, H5std_string &type_name) const
H5O_type_t | getRefObjType (void *ref, H5R_type_t ref_type=H5R_OBJECT) const
DataSpace | getRegion (void *ref, H5R_type_t ref_type=H5R_DATASET_REGION) const
| H5Location ()
int | iterateElems (const char *name, int *idx, H5G_iterate_t op, void *op_data)
int | iterateElems (const H5std_string &name, int *idx, H5G_iterate_t op, void *op_data)
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
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
void | link (const char *target_name, const char *link_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
void | link (const H5std_string &curr_name, const Group &new_loc, const H5std_string &new_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
void | link (const H5std_string &curr_name, const hid_t same_loc, const H5std_string &new_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
void | link (const H5std_string &target_name, const H5std_string &link_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
void | link (H5L_type_t link_type, const char *curr_name, const char *new_name) const
void | link (H5L_type_t link_type, const H5std_string &curr_name, const H5std_string &new_name) const
void | mount (const char *name, const H5File &child, const PropList &plist) const
void | mount (const H5std_string &name, const H5File &child, const PropList &plist) const
void | move (const char *src, const char *dst) const
void | move (const H5std_string &src, const H5std_string &dst) const
void | moveLink (const char *src_name, const char *dst_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
void | moveLink (const char *src_name, const Group &dst, const char *dst_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
void | moveLink (const H5std_string &src_name, const Group &dst, const H5std_string &dst_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
void | moveLink (const H5std_string &src_name, const H5std_string &dst_name, const LinkCreatPropList &lcpl=LinkCreatPropList::DEFAULT, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
bool | nameExists (const char *name, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
bool | nameExists (const H5std_string &name, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
DataSet | openDataSet (const char *name, const DSetAccPropList &dapl=DSetAccPropList::DEFAULT) const
DataSet | openDataSet (const H5std_string &name, const DSetAccPropList &dapl=DSetAccPropList::DEFAULT) const
Group | openGroup (const char *name) const
Group | openGroup (const H5std_string &name) const
void | reference (void *ref, const char *name, const DataSpace &dataspace, H5R_type_t ref_type=H5R_DATASET_REGION) const
void | reference (void *ref, const char *name, H5R_type_t ref_type=H5R_OBJECT) const
void | reference (void *ref, const H5std_string &name, const DataSpace &dataspace, H5R_type_t ref_type=H5R_DATASET_REGION) const
void | reference (void *ref, const H5std_string &name, H5R_type_t ref_type=H5R_OBJECT) const
void | removeComment (const char *name) const
void | removeComment (const H5std_string &name) const
void | setComment (const char *comment) const
void | setComment (const char *name, const char *comment) const
void | setComment (const H5std_string &comment) const
void | setComment (const H5std_string &name, const H5std_string &comment) const
void | unlink (const char *link_name, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
void | unlink (const H5std_string &link_name, const LinkAccPropList &lapl=LinkAccPropList::DEFAULT) const
void | unmount (const char *name) const
void | unmount (const H5std_string &name) const
Public Member Functions inherited from IdComponent
void | decRefCount () const
void | decRefCount (const hid_t obj_id) const
int | getCounter () const
int | getCounter (const hid_t obj_id) const
H5I_type_t | getHDFObjType () const
void | incRefCount () const
void | incRefCount (const hid_t obj_id) const
H5std_string | inMemFunc (const char *func_name) const
IdComponent & | operator= (const IdComponent &rhs)
void | setId (const hid_t new_id)
virtual | ~IdComponent ()=default
Public Member Functions inherited from CommonFG
| CommonFG ()
ArrayType | openArrayType (const char *name) const
ArrayType | openArrayType (const H5std_string &name) const
CompType | openCompType (const char *name) const
CompType | openCompType (const H5std_string &name) const
DataType | openDataType (const char *name) const
DataType | openDataType (const H5std_string &name) const
EnumType | openEnumType (const char *name) const
EnumType | openEnumType (const H5std_string &name) const
FloatType | openFloatType (const char *name) const
FloatType | openFloatType (const H5std_string &name) const
IntType | openIntType (const char *name) const
IntType | openIntType (const H5std_string &name) const
StrType | openStrType (const char *name) const
StrType | openStrType (const H5std_string &name) const
VarLenType | openVarLenType (const char *name) const
VarLenType | openVarLenType (const H5std_string &name) const
virtual | ~CommonFG ()=default

## Static Public Member Functions
static bool | isAccessible (const char *name, const FileAccPropList &access_plist=FileAccPropList::DEFAULT)
static bool | isAccessible (const H5std_string &name, const FileAccPropList &access_plist=FileAccPropList::DEFAULT)
static bool | isHdf5 (const char *name)
static bool | isHdf5 (const H5std_string &name)
Static Public Member Functions inherited from IdComponent
static H5I_type_t | getHDFObjType (const hid_t obj_id)
static hsize_t | getNumMembers (H5I_type_t type)
static bool | isValid (hid_t an_id)
static bool | typeExists (H5I_type_t type)

## Protected Member Functions
virtual void | p_setId (const hid_t new_id) override
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 ()
H5std_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

## 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 )

## ◆ H5File() [2/7]

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

## ◆ H5File() [3/7]

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

## ◆ H5File() [4/7]

H5File | ( | const H5std_string & | name,
|  | unsigned int | flags,
|  | const FileAccPropList & | access_plist )

## ◆ H5File() [5/7]

H5File | ( | hid_t | existing_id | ) |

## ◆ H5File() [6/7]

H5File | ( |  | ) |

## ◆ H5File() [7/7]

H5File | ( | const H5File & | original | ) |

## ◆ ~H5File()

virtual ~H5File | ( |  | ) |
| override virtual

## Member Function Documentation

## ◆ close()

virtual void close | ( |  | ) |
| override virtual

Reimplemented from Group.

## ◆ fromClass()

virtual H5std_string fromClass | ( |  | ) | const
| override virtual

Returns this class name.

Reimplemented from Group.

## ◆ getAccessPlist()

FileAccPropList getAccessPlist | ( |  | ) | const

## ◆ getCreatePlist()

FileCreatPropList getCreatePlist | ( |  | ) | const

## ◆ getFileInfo()

void getFileInfo | ( | H5F_info2_t & | file_info | ) | const

## ◆ getFileNum()

unsigned long getFileNum | ( |  | ) | const

## ◆ getFileSize()

hsize_t getFileSize | ( |  | ) | const

## ◆ getFreeSpace()

hssize_t getFreeSpace | ( |  | ) | const

## ◆ getId()

virtual hid_t getId | ( |  | ) | const
| override virtual

Reimplemented from Group.

## ◆ getLocId()

virtual hid_t getLocId | ( |  | ) | const
| override virtual

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

## ◆ getObjIDs()

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

## ◆ getVFDHandle() [1/2]

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

## ◆ getVFDHandle() [2/2]

void getVFDHandle | ( | void ** | file_handle | ) | const

## ◆ isAccessible() [1/2]

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

## ◆ isAccessible() [2/2]

static bool isAccessible | ( | const H5std_string & | name,
|  | const FileAccPropList & | access_plist = FileAccPropList::DEFAULT )
| static

## ◆ isHdf5() [1/2]

static bool isHdf5 | ( | const char * | name | ) |
| static

## ◆ isHdf5() [2/2]

static bool isHdf5 | ( | const H5std_string & | name | ) |
| static

## ◆ openFile() [1/2]

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

## ◆ openFile() [2/2]

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

## ◆ p_setId()

virtual void p_setId | ( | const hid_t | new_id | ) |
| override protected virtual

Reimplemented from Group.

## ◆ reOpen()

void reOpen | ( |  | ) |

## ◆ reopen()

void reopen | ( |  | ) |

## ◆ throwException()

virtual void throwException | ( | const H5std_string & | func_name,
|  | const H5std_string & | msg ) const
| override virtual

For subclasses, H5File and Group, to throw appropriate exception.

Reimplemented from Group.

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

- c++/src/H5File.h