summaryrefslogtreecommitdiffstats
path: root/c++
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2005-08-04 20:18:02 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2005-08-04 20:18:02 (GMT)
commit914f990f22fffb5afbf55cda856ab9a6e9db3b60 (patch)
tree1f3c1977e708bb22bd7e083b583484d85e3a8b79 /c++
parent6401dec6c2933c0418689134670d59be139b1419 (diff)
downloadhdf5-914f990f22fffb5afbf55cda856ab9a6e9db3b60.zip
hdf5-914f990f22fffb5afbf55cda856ab9a6e9db3b60.tar.gz
hdf5-914f990f22fffb5afbf55cda856ab9a6e9db3b60.tar.bz2
[svn-r11200] Purpose: Code improvement
Description: Changed CompType::getMemberClass to use H5Tget_member_class instead of going around unneccesarily. Changed "int member_num" to "unsigned member_num" of several member functions of CompType, per the C library change. Platforms tested: Linux 2.4 (heping) Linux 2.4 w/PGI (colonelk) AIX 5.1 (copper)
Diffstat (limited to 'c++')
-rw-r--r--c++/src/H5CompType.cpp41
-rw-r--r--c++/src/H5CompType.h18
2 files changed, 24 insertions, 35 deletions
diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp
index 8d99b78..2007891 100644
--- a/c++/src/H5CompType.cpp
+++ b/c++/src/H5CompType.cpp
@@ -176,7 +176,7 @@ size_t CompType::getMemberOffset( unsigned member_num ) const
}
// Returns the dimensionality of the member.
-int CompType::getMemberDims( int member_num, size_t* dims, int* perm ) const
+int CompType::getMemberDims( unsigned member_num, size_t* dims, int* perm ) const
{
throw DataTypeIException( "Error: getMemberDims is no longer supported." );
return (-1); // unreachable statement; but without it, the compiler
@@ -190,29 +190,18 @@ int CompType::getMemberDims( int member_num, size_t* dims, int* perm ) const
///\return Type class of the member
///\exception H5::DataTypeIException
// Programmer Binh-Minh Ribler - 2000
+// Modification
+// Modified to use H5Tget_member_class instead. - Jul, 2005
//--------------------------------------------------------------------------
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 )
- {
- throw DataTypeIException("CompType::getMemberClass",
- "H5Tget_member_type failed");
- }
-
- // then get its class
- H5T_class_t member_class = H5Tget_class( member_type_id );
+ H5T_class_t member_class = H5Tget_member_class(id, member_num);
if( member_class == H5T_NO_CLASS )
{
- throw DataTypeIException("CompType::getMemberClass",
- "H5Tget_class returns H5T_NO_CLASS");
+ throw DataTypeIException("CompType::getMemberClass",
+ "H5Tget_member_class returns H5T_NO_CLASS");
}
-
- // close the member datatype
- H5Tclose(member_type_id);
-
- return( member_class );
+ return(member_class);
}
// This private member function calls the C API to get the identifier
@@ -242,7 +231,7 @@ hid_t CompType::p_get_member_type(unsigned member_num) const
///\exception H5::DataTypeIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataType CompType::getMemberDataType( int member_num ) const
+DataType CompType::getMemberDataType( unsigned member_num ) const
{
DataType datatype(p_get_member_type(member_num));
return(datatype);
@@ -257,7 +246,7 @@ DataType CompType::getMemberDataType( int member_num ) const
///\exception H5::DataTypeIException
// Programmer Binh-Minh Ribler - Jul, 2005
//--------------------------------------------------------------------------
-ArrayType CompType::getMemberArrayType( int member_num ) const
+ArrayType CompType::getMemberArrayType( unsigned member_num ) const
{
ArrayType arraytype(p_get_member_type(member_num));
return(arraytype);
@@ -272,7 +261,7 @@ ArrayType CompType::getMemberArrayType( int member_num ) const
///\exception H5::DataTypeIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-EnumType CompType::getMemberEnumType( int member_num ) const
+EnumType CompType::getMemberEnumType( unsigned member_num ) const
{
EnumType enumtype(p_get_member_type(member_num));
return(enumtype);
@@ -287,7 +276,7 @@ EnumType CompType::getMemberEnumType( int member_num ) const
///\exception H5::DataTypeIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-CompType CompType::getMemberCompType( int member_num ) const
+CompType CompType::getMemberCompType( unsigned member_num ) const
{
CompType comptype(p_get_member_type(member_num));
return(comptype);
@@ -302,7 +291,7 @@ CompType CompType::getMemberCompType( int member_num ) const
///\exception H5::DataTypeIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-IntType CompType::getMemberIntType( int member_num ) const
+IntType CompType::getMemberIntType( unsigned member_num ) const
{
IntType inttype(p_get_member_type(member_num));
return(inttype);
@@ -317,7 +306,7 @@ IntType CompType::getMemberIntType( int member_num ) const
///\exception H5::DataTypeIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-FloatType CompType::getMemberFloatType( int member_num ) const
+FloatType CompType::getMemberFloatType( unsigned member_num ) const
{
FloatType floatype(p_get_member_type(member_num));
return(floatype);
@@ -332,7 +321,7 @@ FloatType CompType::getMemberFloatType( int member_num ) const
///\exception H5::DataTypeIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-StrType CompType::getMemberStrType( int member_num ) const
+StrType CompType::getMemberStrType( unsigned member_num ) const
{
StrType strtype(p_get_member_type(member_num));
return(strtype);
@@ -347,7 +336,7 @@ StrType CompType::getMemberStrType( int member_num ) const
///\exception H5::DataTypeIException
// Programmer Binh-Minh Ribler - Jul, 2005
//--------------------------------------------------------------------------
-VarLenType CompType::getMemberVarLenType( int member_num ) const
+VarLenType CompType::getMemberVarLenType( unsigned member_num ) const
{
VarLenType varlentype(p_get_member_type(member_num));
return(varlentype);
diff --git a/c++/src/H5CompType.h b/c++/src/H5CompType.h
index ae38398..d018c13 100644
--- a/c++/src/H5CompType.h
+++ b/c++/src/H5CompType.h
@@ -37,7 +37,7 @@ class H5_DLLCPP CompType : public DataType {
H5T_class_t getMemberClass( unsigned member_num ) const;
// Returns the dimensionality of the specified member.
- int getMemberDims( int member_num, size_t* dims, int* perm ) const;
+ int getMemberDims( unsigned member_num, size_t* dims, int* perm ) const;
// Returns the index of a member in this compound data type.
int getMemberIndex(const char* name) const;
@@ -51,35 +51,35 @@ class H5_DLLCPP CompType : public DataType {
// Returns the generic datatype of the specified member in
// this compound datatype.
- DataType getMemberDataType( int member_num ) const;
+ DataType getMemberDataType( unsigned member_num ) const;
// Returns the array datatype of the specified member in
// this compound datatype.
- ArrayType getMemberArrayType( int member_num ) const;
+ ArrayType getMemberArrayType( unsigned member_num ) const;
// Returns the compound datatype of the specified member in
// this compound datatype.
- CompType getMemberCompType( int member_num ) const;
+ CompType getMemberCompType( unsigned member_num ) const;
// Returns the enumeration datatype of the specified member in
// this compound datatype.
- EnumType getMemberEnumType( int member_num ) const;
+ EnumType getMemberEnumType( unsigned member_num ) const;
// Returns the integer datatype of the specified member in
// this compound datatype.
- IntType getMemberIntType( int member_num ) const;
+ IntType getMemberIntType( unsigned member_num ) const;
// Returns the floating-point datatype of the specified member in
// this compound datatype.
- FloatType getMemberFloatType( int member_num ) const;
+ FloatType getMemberFloatType( unsigned member_num ) const;
// Returns the string datatype of the specified member in
// this compound datatype.
- StrType getMemberStrType( int member_num ) const;
+ StrType getMemberStrType( unsigned member_num ) const;
// Returns the variable length datatype of the specified member in
// this compound datatype.
- VarLenType getMemberVarLenType( int member_num ) const;
+ VarLenType getMemberVarLenType( unsigned member_num ) const;
// Returns the number of members in this compound datatype.
int getNmembers() const;