summaryrefslogtreecommitdiffstats
path: root/c++/src
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2017-02-23 22:53:16 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2017-02-23 22:53:16 (GMT)
commitd7c6fa00da4ddb9de5501b27e5496045ccb98572 (patch)
treed13939c871fce92b84af5d716f23ab92cfd2faf8 /c++/src
parentb55626e0715204f56f192911f1a44e4a430b42b2 (diff)
downloadhdf5-d7c6fa00da4ddb9de5501b27e5496045ccb98572.zip
hdf5-d7c6fa00da4ddb9de5501b27e5496045ccb98572.tar.gz
hdf5-d7c6fa00da4ddb9de5501b27e5496045ccb98572.tar.bz2
Purpose: Add new C++ wrappers
Description: Added wrappers for H5Fget_info2, H5Inmembers, and H5Itype_exists // Gets general information about this file. void getFileInfo(H5F_info2_t& file_info) const; // Returns the number of members in a type. static hsize_t getNumMembers(H5I_type_t type); // Determines if an element type exists. static bool typeExists(H5I_type_t type); Platforms tested: Linux/32 2.6 (jam) Linux/64 (jelly) Darwin (osx1010test)
Diffstat (limited to 'c++/src')
-rw-r--r--c++/src/H5File.cpp19
-rw-r--r--c++/src/H5File.h7
-rw-r--r--c++/src/H5IdComponent.cpp66
-rw-r--r--c++/src/H5IdComponent.h6
-rw-r--r--c++/src/H5PropList.cpp2
5 files changed, 97 insertions, 3 deletions
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp
index fcf4e1c..cd97025 100644
--- a/c++/src/H5File.cpp
+++ b/c++/src/H5File.cpp
@@ -352,6 +352,25 @@ FileAccPropList H5File::getAccessPlist() const
}
//--------------------------------------------------------------------------
+// Function: H5File::getFileInfo
+///\brief Retrieves the general information of this file.
+///
+///\exception H5::FileIException
+///\par Description
+/// The retrieved information may include information about
+/// superblock extension, free space management, and shared object
+// Programmer Binh-Minh Ribler - February 2017
+//--------------------------------------------------------------------------
+void H5File::getFileInfo(H5F_info2_t& file_info) const
+{
+ herr_t ret_value = H5Fget_info2(id, &file_info);
+ if (ret_value < 0)
+ {
+ throw FileIException("H5File::getFileInfo", "H5Fget_info2 failed");
+ }
+}
+
+//--------------------------------------------------------------------------
// Function: H5File::getFreeSpace
///\brief Returns the amount of free space in the file.
///\return Amount of free space
diff --git a/c++/src/H5File.h b/c++/src/H5File.h
index dca6c67..495b4d0 100644
--- a/c++/src/H5File.h
+++ b/c++/src/H5File.h
@@ -51,8 +51,8 @@ class H5_DLLCPP H5File : public Group {
// Gets the creation property list of this file.
FileCreatPropList getCreatePlist() const;
- // Retrieves the file size of an opened file.
- hsize_t getFileSize() const;
+ // Gets general information about this file.
+ void getFileInfo(H5F_info2_t& file_info) const;
// Returns the amount of free space in the file.
hssize_t getFreeSpace() const;
@@ -70,6 +70,9 @@ class H5_DLLCPP H5File : public Group {
void getVFDHandle(const FileAccPropList& fapl, void **file_handle) const;
//void getVFDHandle(FileAccPropList& fapl, void **file_handle) const; // removed from 1.8.18 and 1.10.1
+ // Returns the file size of the HDF5 file.
+ hsize_t getFileSize() const;
+
// Determines if a file, specified by its name, is in HDF5 format
static bool isHdf5(const char* name );
static bool isHdf5(const H5std_string& name );
diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp
index f3d916a..ae60c5e 100644
--- a/c++/src/H5IdComponent.cpp
+++ b/c++/src/H5IdComponent.cpp
@@ -162,6 +162,72 @@ H5I_type_t IdComponent::getHDFObjType() const
}
//--------------------------------------------------------------------------
+// Function: getNumMembers (static)
+///\brief Returns the number of members of the given type.
+///\return Number of members
+///\Description
+/// If there is no member of the given type, getNumMembers will
+/// return 0. Valid types are:
+/// \li \c H5I_FILE (= 1)
+/// \li \c H5I_GROUP
+/// \li \c H5I_DATATYPE
+/// \li \c H5I_DATASPACE
+/// \li \c H5I_DATASET
+/// \li \c H5I_ATTR
+/// \li \c H5I_REFERENCE
+/// \li \c H5I_VFL
+/// \li \c H5I_GENPROP_CLS
+/// \li \c H5I_GENPROP_LST
+/// \li \c H5I_ERROR_CLASS
+/// \li \c H5I_ERROR_MSG
+/// \li \c H5I_ERROR_STACK
+// Programmer Binh-Minh Ribler - Feb, 2017
+//--------------------------------------------------------------------------
+hsize_t IdComponent::getNumMembers(H5I_type_t type)
+{
+ hsize_t nmembers = 0;
+ herr_t ret_value = H5Inmembers(type, &nmembers);
+ if (ret_value < 0)
+ throw IdComponentException("getNumMembers", "H5Inmembers failed");
+ else
+ return(nmembers);
+}
+
+//--------------------------------------------------------------------------
+// Function: typeExists (static)
+///\brief Queries if a given type is currently registered with the
+/// library.
+///\return true if the given type exists, and false, otherwise.
+///\Description
+/// Valid types are:
+/// \li \c H5I_FILE (= 1)
+/// \li \c H5I_GROUP
+/// \li \c H5I_DATATYPE
+/// \li \c H5I_DATASPACE
+/// \li \c H5I_DATASET
+/// \li \c H5I_ATTR
+/// \li \c H5I_REFERENCE
+/// \li \c H5I_VFL
+/// \li \c H5I_GENPROP_CLS
+/// \li \c H5I_GENPROP_LST
+/// \li \c H5I_ERROR_CLASS
+/// \li \c H5I_ERROR_MSG
+/// \li \c H5I_ERROR_STACK
+// Programmer Binh-Minh Ribler - Feb, 2017
+//--------------------------------------------------------------------------
+bool IdComponent::typeExists(H5I_type_t type)
+{
+ // Call C function
+ htri_t ret_value = H5Itype_exists(type);
+ if (ret_value > 0)
+ return true;
+ else if (ret_value == 0)
+ return false;
+ else // Raise exception when H5Itype_exists returns a negative value
+ throw IdComponentException("typeExists", "H5Itype_exists failed");
+}
+
+//--------------------------------------------------------------------------
// Function: IdComponent::operator=
///\brief Assignment operator.
///\param rhs - IN: Reference to the existing object
diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h
index d3d9b9f..70522dc 100644
--- a/c++/src/H5IdComponent.h
+++ b/c++/src/H5IdComponent.h
@@ -48,6 +48,12 @@ class H5_DLLCPP IdComponent {
// Returns an HDF5 object type of this object.
H5I_type_t getHDFObjType() const;
+ // Returns the number of members in a type.
+ static hsize_t getNumMembers(H5I_type_t type);
+
+ // Determines if an type exists.
+ static bool typeExists(H5I_type_t type);
+
// Assignment operator.
IdComponent& operator=( const IdComponent& rhs );
diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp
index f0eb847..1564a93 100644
--- a/c++/src/H5PropList.cpp
+++ b/c++/src/H5PropList.cpp
@@ -347,7 +347,7 @@ hid_t PropList::getClass() const
//--------------------------------------------------------------------------
// Function: PropList::propExist
-///\brief Query the existance of a property in a property object.
+///\brief Queries the existence of a property in a property object.
///\param name - IN: Name of property to check for - \c char pointer
///\return true if the property exists in the property object, and
/// false, otherwise.