summaryrefslogtreecommitdiffstats
path: root/c++
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2005-07-25 03:37:21 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2005-07-25 03:37:21 (GMT)
commitfab172d704065dba31fbf34d3fe7e56c3e63fe36 (patch)
tree59a35e3b906d509134ed4d581e134054359e999e /c++
parentf208550696646adcc6e59e339745b0433e28f770 (diff)
downloadhdf5-fab172d704065dba31fbf34d3fe7e56c3e63fe36.zip
hdf5-fab172d704065dba31fbf34d3fe7e56c3e63fe36.tar.gz
hdf5-fab172d704065dba31fbf34d3fe7e56c3e63fe36.tar.bz2
[svn-r11151] Purpose: Fix bugzilla #407 and #408
Description: PropList::copyProp has incorrect prototype; although it works, it does cause users inconvenience. Solution: Added another overloaded function with correct prototype. The old version will be removed in a future release. In the meantime, "Obsolete" will be displayed in its RM page. Also, changed several checks on the returned value of a C API from non-positive to negative because id = 0 is no longer significant, now that the C++ reference counting had been removed. Platforms tested: Linux 2.4 (heping) IRIX64 with -n32 (modi4) Linux 2.4 w/PGI (colonelk)
Diffstat (limited to 'c++')
-rw-r--r--c++/src/H5ArrayType.cpp2
-rw-r--r--c++/src/H5CommonFG.cpp10
-rw-r--r--c++/src/H5CompType.cpp4
-rw-r--r--c++/src/H5DataSet.cpp4
-rw-r--r--c++/src/H5DataSpace.cpp6
-rw-r--r--c++/src/H5DataType.cpp4
-rw-r--r--c++/src/H5EnumType.cpp4
-rw-r--r--c++/src/H5File.cpp6
-rw-r--r--c++/src/H5FloatType.cpp2
-rw-r--r--c++/src/H5IntType.cpp2
-rw-r--r--c++/src/H5PropList.cpp41
-rw-r--r--c++/src/H5PropList.h4
-rw-r--r--c++/src/H5StrType.cpp2
-rw-r--r--c++/src/H5VarLenType.cpp2
14 files changed, 65 insertions, 28 deletions
diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp
index b580660..6366752 100644
--- a/c++/src/H5ArrayType.cpp
+++ b/c++/src/H5ArrayType.cpp
@@ -92,7 +92,7 @@ ArrayType::ArrayType( const ArrayType& original ) : DataType( original )
ArrayType::ArrayType(const DataType& base_type, int ndims, const hsize_t* dims) : DataType()
{
hid_t new_type_id = H5Tarray_create(base_type.getId(), ndims, dims, NULL);
- if (new_type_id <= 0)
+ if (new_type_id < 0)
{
throw DataTypeIException("ArrayType constructor", "H5Tarray_create failed");
}
diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp
index 40558c1..9660096 100644
--- a/c++/src/H5CommonFG.cpp
+++ b/c++/src/H5CommonFG.cpp
@@ -71,7 +71,7 @@ Group CommonFG::createGroup( const char* name, size_t size_hint ) const
hid_t group_id = H5Gcreate( getLocId(), name, size_hint );
// If the creation of the group failed, throw an exception
- if( group_id <= 0 )
+ if( group_id < 0 )
{
throwException("createGroup", "H5Gcreate failed");
}
@@ -109,7 +109,7 @@ Group CommonFG::openGroup( const char* name ) const
hid_t group_id = H5Gopen( getLocId(), name );
// If the opening of the group failed, throw an exception
- if( group_id <= 0 )
+ if( group_id < 0 )
{
throwException("openGroup", "H5Gopen failed");
}
@@ -153,7 +153,7 @@ DataSet CommonFG::createDataSet( const char* name, const DataType& data_type, co
hid_t dataset_id = H5Dcreate( getLocId(), name, type_id, space_id, create_plist_id );
// If the creation of the dataset failed, throw an exception
- if( dataset_id <= 0 )
+ if( dataset_id < 0 )
{
throwException("createDataSet", "H5Dcreate failed");
}
@@ -190,7 +190,7 @@ DataSet CommonFG::openDataSet( const char* name ) const
hid_t dataset_id = H5Dopen( getLocId(), name );
// If the dataset's opening failed, throw an exception
- if( dataset_id <= 0 )
+ if( dataset_id < 0 )
{
throwException("openDataSet", "H5Dopen failed");
}
@@ -598,7 +598,7 @@ hid_t CommonFG::p_open_data_type( const char* name ) const
hid_t datatype_id = H5Topen( getLocId(), name );
// If the datatype's opening failed, throw an exception
- if( datatype_id <= 0 )
+ if( datatype_id < 0 )
{
throwException("openDataType", "H5Topen failed");
}
diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp
index 708d273..8d99b78 100644
--- a/c++/src/H5CompType.cpp
+++ b/c++/src/H5CompType.cpp
@@ -81,7 +81,7 @@ CompType::CompType( const DataSet& dataset ) : DataType()
id = H5Dget_type( dataset.getId() );
// If the datatype id is invalid, throw exception
- if( id <= 0 )
+ if( id < 0 )
{
throw DataSetIException("CompType constructor", "H5Dget_type failed");
}
@@ -195,7 +195,7 @@ H5T_class_t CompType::getMemberClass( unsigned member_num ) const
{
// get the member datatype first
hid_t member_type_id = H5Tget_member_type( id, member_num );
- if( member_type_id <= 0 )
+ if( member_type_id < 0 )
{
throw DataTypeIException("CompType::getMemberClass",
"H5Tget_member_type failed");
diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp
index e617634..765b1e5 100644
--- a/c++/src/H5DataSet.cpp
+++ b/c++/src/H5DataSet.cpp
@@ -73,7 +73,7 @@ DataSpace DataSet::getSpace() const
hid_t dataspace_id = H5Dget_space( id );
// If the dataspace id is invalid, throw an exception
- if( dataspace_id <= 0 )
+ if( dataspace_id < 0 )
{
throw DataSetIException("DataSet::getSpace", "H5Dget_space failed");
}
@@ -106,7 +106,7 @@ hid_t DataSet::p_get_type() const
DSetCreatPropList DataSet::getCreatePlist() const
{
hid_t create_plist_id = H5Dget_create_plist( id );
- if( create_plist_id <= 0 )
+ if( create_plist_id < 0 )
{
throw DataSetIException("DataSet::getCreatePlist", "H5Dget_create_plist failed");
}
diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp
index 4a51c6b..d29ba20 100644
--- a/c++/src/H5DataSpace.cpp
+++ b/c++/src/H5DataSpace.cpp
@@ -45,7 +45,7 @@ const DataSpace DataSpace::ALL( H5S_ALL );
DataSpace::DataSpace( H5S_class_t type ) : IdComponent()
{
id = H5Screate( type );
- if( id <= 0 )
+ if( id < 0 )
{
throw DataSpaceIException("DataSpace constructor", "H5Screate failed");
}
@@ -63,7 +63,7 @@ DataSpace::DataSpace( H5S_class_t type ) : IdComponent()
DataSpace::DataSpace( int rank, const hsize_t * dims, const hsize_t * maxdims) : IdComponent()
{
id = H5Screate_simple( rank, dims, maxdims );
- if( id <= 0 )
+ if( id < 0 )
{
throw DataSpaceIException("DataSpace constructor", "H5Screate_simple failed");
}
@@ -113,7 +113,7 @@ void DataSpace::copy( const DataSpace& like_space )
// call C routine to copy the dataspace
id = H5Scopy( like_space.getId() );
- if( id <= 0 )
+ if( id < 0 )
throw DataSpaceIException("DataSpace::copy", "H5Scopy failed");
}
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index 1d2a519..96aee12 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -65,7 +65,7 @@ DataType::DataType( const H5T_class_t type_class, size_t size ) : H5Object(), is
{
// Call C routine to create the new datatype
id = H5Tcreate( type_class, size );
- if( id <= 0 )
+ if( id < 0 )
{
throw DataTypeIException("DataType constructor", "H5Tcreate failed");
}
@@ -114,7 +114,7 @@ void DataType::copy( const DataType& like_type )
// call C routine to copy the datatype
id = H5Tcopy( like_type.getId() );
- if( id <= 0 )
+ if( id < 0 )
throw DataTypeIException("DataType::copy", "H5Tcopy failed");
}
diff --git a/c++/src/H5EnumType.cpp b/c++/src/H5EnumType.cpp
index 2f04d1e..9ba71bf 100644
--- a/c++/src/H5EnumType.cpp
+++ b/c++/src/H5EnumType.cpp
@@ -82,7 +82,7 @@ EnumType::EnumType( const DataSet& dataset ) : DataType()
id = H5Dget_type( dataset.getId() );
// If the datatype id is not valid, throw an exception
- if( id <= 0 )
+ if( id < 0 )
{
throw DataSetIException("EnumType constructor", "H5Dget_type failed");
}
@@ -101,7 +101,7 @@ EnumType::EnumType( const IntType& data_type ) : DataType()
id = H5Tenum_create( data_type.getId() );
// If the datatype id is not valid, throw an exception
- if( id <= 0 )
+ if( id < 0 )
{
throw DataSetIException("EnumType constructor", "H5Tenum_create failed");
}
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp
index b9adbca..985fc72 100644
--- a/c++/src/H5File.cpp
+++ b/c++/src/H5File.cpp
@@ -111,7 +111,7 @@ void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPro
hid_t create_plist_id = create_plist.getId();
hid_t access_plist_id = access_plist.getId();
id = H5Fcreate( name, flags, create_plist_id, access_plist_id );
- if( id <= 0 ) // throw an exception when open/create fail
+ if( id < 0 ) // throw an exception when open/create fail
{
throw FileIException("H5File constructor", "H5Fcreate failed");
}
@@ -121,7 +121,7 @@ void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPro
{
hid_t access_plist_id = access_plist.getId();
id = H5Fopen( name, flags, access_plist_id );
- if( id <= 0 ) // throw an exception when open/create fail
+ if( id < 0 ) // throw an exception when open/create fail
{
throw FileIException("H5File constructor", "H5Fopen failed");
}
@@ -201,7 +201,7 @@ void H5File::reOpen()
// call C routine to reopen the file - Note: not sure about this
// does id need to be closed later? which id to be the parameter?
id = H5Freopen( id );
- if( id <= 0 ) // Raise exception when H5Freopen returns a neg value
+ if( id < 0 ) // Raise exception when H5Freopen returns a neg value
throw FileIException("H5File::reOpen", "H5Freopen failed");
}
diff --git a/c++/src/H5FloatType.cpp b/c++/src/H5FloatType.cpp
index 1912edb..a5b1c51 100644
--- a/c++/src/H5FloatType.cpp
+++ b/c++/src/H5FloatType.cpp
@@ -84,7 +84,7 @@ FloatType::FloatType( const DataSet& dataset ) : AtomType()
// Calls C function H5Dget_type to get the id of the datatype
id = H5Dget_type( dataset.getId() );
- if( id <= 0 )
+ if( id < 0 )
{
throw DataSetIException("FloatType constructor", "H5Dget_type failed");
}
diff --git a/c++/src/H5IntType.cpp b/c++/src/H5IntType.cpp
index ba14de1..f161c13 100644
--- a/c++/src/H5IntType.cpp
+++ b/c++/src/H5IntType.cpp
@@ -84,7 +84,7 @@ IntType::IntType( const DataSet& dataset ) : AtomType()
// Calls C function H5Dget_type to get the id of the datatype
id = H5Dget_type( dataset.getId() );
- if( id <= 0 )
+ if( id < 0 )
{
throw DataSetIException("IntType constructor", "H5Dget_type failed");
}
diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp
index e0d0143..c4b96c7 100644
--- a/c++/src/H5PropList.cpp
+++ b/c++/src/H5PropList.cpp
@@ -67,7 +67,7 @@ PropList::PropList( const hid_t plist_id ) : IdComponent(0)
if (H5I_GENPROP_CLS == H5Iget_type(plist_id)) {
// call C routine to create the new property
id = H5Pcreate(plist_id);
- if( id <= 0 )
+ if( id < 0 )
{
throw PropListIException("PropList constructor", "H5Pcreate failed");
}
@@ -104,7 +104,7 @@ void PropList::copy( const PropList& like_plist )
// call C routine to copy the property list
id = H5Pcopy( like_plist.getId() );
- if( id <= 0 )
+ if( id < 0 )
throw PropListIException("PropList::copy", "H5Pcopy failed");
}
@@ -126,10 +126,43 @@ PropList& PropList::operator=( const PropList& rhs )
//--------------------------------------------------------------------------
// Function: PropList::copyProp
-///\brief Copies a property from one list or class to another
+///\brief Copies a property from this property list or class to another
+///\param dest - IN: Destination property list or class
+///\param name - IN: Name of the property to copy - \c char pointer
+///\exception H5::PropListIException
+// Programmer Binh-Minh Ribler - Jul, 2005
+//--------------------------------------------------------------------------
+void PropList::copyProp(PropList& dest, const char *name) const
+{
+ hid_t dst_id = dest.getId();
+ herr_t ret_value = H5Pcopy_prop(dst_id, id, name);
+ if( ret_value < 0 )
+ {
+ throw PropListIException("PropList::copyProp", "H5Pcopy_prop failed");
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: PropList::copyProp
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above function only in what arguments it
+/// accepts.
+///\param dest - IN: Destination property list or class
+///\param name - IN: Name of the property to copy - \c std::string
+// Programmer Binh-Minh Ribler - Jul, 2005
+//--------------------------------------------------------------------------
+void PropList::copyProp( PropList& dest, const string& name ) const
+{
+ copyProp( dest, name.c_str());
+}
+
+//--------------------------------------------------------------------------
+// Function: PropList::copyProp
+///\brief Copies a property from one list or class to another - Obsolete
///\param dest - IN: Destination property list or class
///\param src - IN: Source property list or class
///\param name - IN: Name of the property to copy - \c char pointer
+///\notes This member function will be removed in the next release
///\exception H5::PropListIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
@@ -149,7 +182,7 @@ void PropList::copyProp( PropList& dest, PropList& src, const char *name ) const
// Function: PropList::copyProp
///\brief This is an overloaded member function, provided for convenience.
/// It differs from the above function only in what arguments it
-/// accepts.
+/// accepts. - Obsolete
///\param dest - IN: Destination property list or class
///\param src - IN: Source property list or class
///\param name - IN: Name of the property to copy - \c std::string
diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h
index 36178eb..1d4816f 100644
--- a/c++/src/H5PropList.h
+++ b/c++/src/H5PropList.h
@@ -44,6 +44,10 @@ class H5_DLLCPP PropList : public IdComponent {
// Makes a copy of the given property list.
void copy( const PropList& like_plist );
+ // Copies a property from this property list or class to another
+ void copyProp( PropList& dest, const char* name) const;
+ void copyProp( PropList& dest, const string& name) const;
+
// Copies a property from one property list or property class to another
void copyProp( PropList& dest, PropList& src, const char* name) const;
void copyProp( PropList& dest, PropList& src, const string& name) const;
diff --git a/c++/src/H5StrType.cpp b/c++/src/H5StrType.cpp
index ed011bd..4bd946d 100644
--- a/c++/src/H5StrType.cpp
+++ b/c++/src/H5StrType.cpp
@@ -116,7 +116,7 @@ StrType::StrType( const DataSet& dataset ) : AtomType ()
// Calls C function H5Dget_type to get the id of the datatype
id = H5Dget_type( dataset.getId() );
- if( id <= 0 )
+ if( id < 0 )
{
throw DataSetIException("StrType constructor", "H5Dget_type failed");
}
diff --git a/c++/src/H5VarLenType.cpp b/c++/src/H5VarLenType.cpp
index ebe0e86..076ba12 100644
--- a/c++/src/H5VarLenType.cpp
+++ b/c++/src/H5VarLenType.cpp
@@ -65,7 +65,7 @@ VarLenType::VarLenType(const VarLenType& original) : DataType(original) {}
VarLenType::VarLenType(const DataType* base_type) : DataType()
{
id = H5Tvlen_create(base_type->getId());
- if (id <= 0)
+ if (id < 0)
{
throw DataTypeIException("VarLenType constructor",
"H5Tvlen_create returns negative value");