summaryrefslogtreecommitdiffstats
path: root/c++/src/H5Location.cpp
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2017-09-12 19:46:06 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2017-09-12 19:46:06 (GMT)
commitc7b27a76749fa0c299fd33299ac59b36348ada5f (patch)
treefc76e85d0e10252df420cee6ecf7bcc74b288560 /c++/src/H5Location.cpp
parentff2c10c3f0f2174545e608dfbf668a05ad8d0f10 (diff)
downloadhdf5-c7b27a76749fa0c299fd33299ac59b36348ada5f.zip
hdf5-c7b27a76749fa0c299fd33299ac59b36348ada5f.tar.gz
hdf5-c7b27a76749fa0c299fd33299ac59b36348ada5f.tar.bz2
New overloaded functions and tests
Description: - Added VarLenType::VarLenType(const DataType& base_type) - Marked VarLenType::VarLenType(const DataType* base_type) deprecated - Added a static wrapper for H5Tdetect_class for PredType static bool DataType::detectClass(const PredType& pred_type, ...) - Removed the deprecated function Exception::printError() from code - Miscellaneous improvements in comments - Added test functions test_detect_type_class() and test_vltype() Platforms tested: Linux/32 2.6 (jam) Linux/64 (jelly) Darwin (osx1010test)
Diffstat (limited to 'c++/src/H5Location.cpp')
-rw-r--r--c++/src/H5Location.cpp67
1 files changed, 37 insertions, 30 deletions
diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp
index 9f2d7d5..35a4828 100644
--- a/c++/src/H5Location.cpp
+++ b/c++/src/H5Location.cpp
@@ -93,7 +93,7 @@ bool H5Location::exists(const char* name, const LinkAccPropList& lapl) const
return false;
else // Raise exception when H5Lexists returns a negative value
{
- throwException("exists", "H5Lexists failed");
+ throw LocationException(inMemFunc("exists"), "H5Lexists failed");
}
}
@@ -118,7 +118,7 @@ bool H5Location::exists(const H5std_string& name, const LinkAccPropList& lapl) c
/// which can be either of these values:
/// \li \c H5F_SCOPE_GLOBAL - Flushes the entire virtual file
/// \li \c H5F_SCOPE_LOCAL - Flushes only the specified file
-///\exception H5::Exception
+///\exception H5::LocationException
///\par Description
/// This location is used to identify the file to be flushed.
// Programmer Binh-Minh Ribler - 2012
@@ -147,8 +147,8 @@ H5std_string H5Location::getFileName() const
try {
return(p_get_file_name());
}
- catch (LocationException& E) {
- throw FileIException(inMemFunc("getFileName"), E.getDetailMsg());
+ catch (IdComponentException& E) {
+ throw LocationException(inMemFunc("getFileName"), E.getDetailMsg());
}
}
@@ -495,7 +495,7 @@ hid_t H5Location::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_ty
hid_t temp_id = H5Rdereference2(loc_id, plist_id, ref_type, ref);
if (temp_id < 0)
{
- throw ReferenceException(inMemFunc(from_func), "H5Rdereference failed");
+ throw ReferenceException(inMemFunc(from_func), "H5Rdereference2 failed");
}
return(temp_id);
@@ -557,7 +557,7 @@ void H5Location::dereference(const H5Location& loc, const void* ref, H5R_type_t
/// \li \c H5G_TYPE Object - is a named datatype
/// \li \c H5G_LINK - Object is a symbolic link.
/// \li \c H5G_UDLINK - Object is a user-defined link.
-///\exception H5::ReferenceException
+///\exception H5::LocationException
// Programmer Binh-Minh Ribler - May, 2004
// Modification
// Sep 2012: Moved up from H5File, Group, DataSet, and DataType
@@ -717,19 +717,21 @@ DataSpace H5Location::getRegion(void *ref, H5R_type_t ref_type) const
// ***Updated: after HDFFV-9920, methods in classes H5Location and Group
// use throwException to distinguish the FileIException and GroupIException.
// CommonFG is no longer used in the library. Aug 18, 2016 -BMR
+// H5Location::throwException is changed to throw LocationException for any
+// subclass that is not H5File or Group. Aug 14, 2017 -BMR
// ***Note: following the changes in HDFFV-9920, some of the methods could
// throw different exceptions, but for backward-compatibility, throwException
// is kept in those methods as well. Sep 17, 2016 -BMR
+//
//--------------------------------------------------------------------------
// Function: H5Location::createGroup
-///\brief Creates a new group at this location which can be a file
-/// or another group.
+///\brief Creates a new group at this location.
///\param name - IN: Name of the group to create
///\param size_hint - IN: Indicates the number of bytes to reserve for
/// the names that will appear in the group
///\return Group instance
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
///\par Description
/// The optional \a size_hint specifies how much file space to
/// reserve for storing the names that will appear in this new
@@ -793,7 +795,7 @@ Group H5Location::createGroup(const H5std_string& name, size_t size_hint) const
/// or another group.
///\param name - IN: Name of the group to open
///\return Group instance
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
Group H5Location::openGroup(const char* name) const
@@ -834,7 +836,7 @@ Group H5Location::openGroup(const H5std_string& name) const
///\param data_space - IN: Dataspace for the dataset
///\param create_plist - IN: Creation properly list for the dataset
///\return DataSet instance
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
DataSet H5Location::createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist) const
@@ -874,7 +876,7 @@ DataSet H5Location::createDataSet(const H5std_string& name, const DataType& data
///\brief Opens an existing dataset at this location.
///\param name - IN: Name of the dataset to open
///\return DataSet instance
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
DataSet H5Location::openDataSet(const char* name) const
@@ -915,7 +917,7 @@ DataSet H5Location::openDataSet(const H5std_string& name) const
///\param curr_name - IN: Name of the existing object if link is a hard
/// link; can be anything for the soft link
///\param new_name - IN: New name for the object
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
///\par Description
/// Note that both names are interpreted relative to the
/// specified location.
@@ -968,7 +970,7 @@ void H5Location::link(H5L_type_t link_type, const H5std_string& curr_name, const
// Function: H5Location::unlink
///\brief Removes the specified name at this location.
///\param name - IN: Name of the object to be removed
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
// Programmer Binh-Minh Ribler - 2000
// Modification
// 2007: QAK modified to use H5L APIs - BMR
@@ -997,7 +999,7 @@ void H5Location::unlink(const H5std_string& name) const
///\brief Renames an object at this location.
///\param src - IN: Object's original name
///\param dst - IN: Object's new name
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
///\note
/// Exercise care in moving groups as it is possible to render
/// data in a file inaccessible with H5Location::move. Please refer
@@ -1033,7 +1035,7 @@ void H5Location::move(const H5std_string& src, const H5std_string& dst) const
///\param name - IN: Name of the object
///\param follow_link - IN: Link flag
///\param statbuf - OUT: Buffer to return information about the object
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
///\par Description
/// For more information, please refer to the C layer Reference
/// Manual at:
@@ -1093,7 +1095,7 @@ void H5Location::getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const
///\param name - IN: Symbolic link to the object
///\param size - IN: Maximum number of characters of value to be returned
///\return Name of the object
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
H5std_string H5Location::getLinkval(const char* name, size_t size) const
@@ -1219,7 +1221,7 @@ void H5Location::mount(const H5std_string& name, const H5File& child, const Prop
// Function: H5Location::unmount
///\brief Unmounts the specified file.
///\param name - IN: Name of the file to unmount
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void H5Location::unmount(const char* name) const
@@ -1255,7 +1257,7 @@ void H5Location::unmount(const H5std_string& name) const
///\return The return value of the first operator that returns non-zero,
/// or zero if all members were processed with no operator
/// returning non-zero.
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
int H5Location::iterateElems(const char* name, int *idx, H5G_iterate_t op , void* op_data)
@@ -1304,7 +1306,7 @@ hsize_t H5Location::getNumObjs() const
/// object's index.
///\param idx - IN: Transient index of the object
///\return Object name
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
///\par Description
/// The value of idx can be any nonnegative number less than the
/// total number of objects in the group, which is returned by
@@ -1346,7 +1348,7 @@ H5std_string H5Location::getObjnameByIdx(hsize_t idx) const
///\param name - IN/OUT: Retrieved name of the object
///\param size - IN: Length to retrieve
///\return Actual size of the object name or 0, if object has no name
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
///\par Description
/// The value of idx can be any nonnegative number less than the
/// total number of objects in the group, which is returned by
@@ -1402,7 +1404,7 @@ ssize_t H5Location::getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size
/// \li \c H5O_TYPE_NAMED_DATATYPE
/// Refer to the C API documentation for more details:
/// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5O.html#Object-GetInfo
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
/// Exception will be thrown when:
/// - an error returned by the C API
/// - object type is not one of the valid values above
@@ -1443,7 +1445,7 @@ H5O_type_t H5Location::childObjType(const char* objname) const
///\brief Returns the type of an object in this group, given the
/// object's name.
///\param objname - IN: Name of the object (H5std_string&)
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
// Programmer Binh-Minh Ribler - April, 2014
//--------------------------------------------------------------------------
H5O_type_t H5Location::childObjType(const H5std_string& objname) const
@@ -1468,7 +1470,7 @@ H5O_type_t H5Location::childObjType(const H5std_string& objname) const
/// \li \c H5O_TYPE_NAMED_DATATYPE
/// Refer to the C API documentation for more details:
/// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5O.html#Object-GetInfo
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
/// Exception will be thrown when:
/// - an error returned by the C API
/// - object type is not one of the valid values above
@@ -1519,7 +1521,7 @@ H5O_type_t H5Location::childObjType(hsize_t index, H5_index_t index_type, H5_ite
///\return Object version, which can have the following values:
/// \li \c H5O_VERSION_1
/// \li \c H5O_VERSION_2
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
/// Exception will be thrown when:
/// - an error returned by the C API
/// - version number is not one of the valid values above
@@ -1553,7 +1555,7 @@ unsigned H5Location::childObjVersion(const char* objname) const
///\brief Returns the type of an object in this group, given the
/// object's name.
///\param objname - IN: Name of the object (H5std_string&)
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
// Programmer Binh-Minh Ribler - April, 2014
//--------------------------------------------------------------------------
unsigned H5Location::childObjVersion(const H5std_string& objname) const
@@ -1571,7 +1573,7 @@ unsigned H5Location::childObjVersion(const H5std_string& objname) const
/// object's index.
///\param idx - IN: Transient index of the object
///\return Object type
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
// Programmer Binh-Minh Ribler - January, 2003
//--------------------------------------------------------------------------
H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx) const
@@ -1591,7 +1593,7 @@ H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx) const
///\param idx - IN: Transient index of the object
///\param type_name - OUT: Object type in text
///\return Object type
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
// Programmer Binh-Minh Ribler - May, 2010
// Modification
// Modified to use the other function. -BMR, 2016/03/07
@@ -1609,7 +1611,7 @@ H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, char* type_name) const
///\param idx - IN: Transient index of the object
///\param type_name - OUT: Object type in text
///\return Object type
-///\exception H5::FileIException or H5::GroupIException
+///\exception H5::FileIException/H5::GroupIException/H5::LocationException
// Programmer Binh-Minh Ribler - January, 2003
//--------------------------------------------------------------------------
H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const
@@ -1642,10 +1644,15 @@ H5G_obj_t H5Location::getObjTypeByIdx(hsize_t idx, H5std_string& type_name) cons
///\param msg - Message describing the failure
///\exception H5::GroupIException
// Programmer Binh-Minh Ribler - 2000
+// Modification
+// August 2017 - BMR
+// Keep Group::throwException and H5File::throwException to
+// maintain backward compatibility. For other subclasses, throw
+// LocationException.
//--------------------------------------------------------------------------
void H5Location::throwException(const H5std_string& func_name, const H5std_string& msg) const
{
- throwException(func_name, msg);
+ throw LocationException(inMemFunc(func_name.c_str()), msg);
}
//--------------------------------------------------------------------------