diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2016-04-22 11:22:34 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2016-04-22 11:22:34 (GMT) |
commit | c37607eb58994041cbeaabdab5f1e9902794a3e9 (patch) | |
tree | b96792d17d5bce03ad862b556f137a7b06c1449d /c++/src | |
parent | c63f96d6e78cfe98de8001b662ec685467fd65df (diff) | |
download | hdf5-c37607eb58994041cbeaabdab5f1e9902794a3e9.zip hdf5-c37607eb58994041cbeaabdab5f1e9902794a3e9.tar.gz hdf5-c37607eb58994041cbeaabdab5f1e9902794a3e9.tar.bz2 |
[svn-r29759] Purpose: Code improvements
Description:
- Changed object in catch statements to reference
- Replaced old-style casts or reinterpret_cast with static_cast
- Removed unused name H5Library::need_cleanup
- Removed Exception::printError from documentation
Platforms tested:
Linux/32 2.6 (jam)
Linux/64 (platypus)
Darwin (osx1010test)
Diffstat (limited to 'c++/src')
-rw-r--r-- | c++/src/H5AbstractDs.cpp | 36 | ||||
-rw-r--r-- | c++/src/H5ArrayType.cpp | 2 | ||||
-rw-r--r-- | c++/src/H5Attribute.cpp | 8 | ||||
-rw-r--r-- | c++/src/H5CompType.cpp | 16 | ||||
-rw-r--r-- | c++/src/H5DataSet.cpp | 4 | ||||
-rw-r--r-- | c++/src/H5DataSpace.cpp | 6 | ||||
-rw-r--r-- | c++/src/H5DataType.cpp | 8 | ||||
-rw-r--r-- | c++/src/H5Exception.cpp | 9 | ||||
-rw-r--r-- | c++/src/H5File.cpp | 10 | ||||
-rw-r--r-- | c++/src/H5Group.cpp | 4 | ||||
-rw-r--r-- | c++/src/H5IdComponent.cpp | 2 | ||||
-rw-r--r-- | c++/src/H5Library.cpp | 7 | ||||
-rw-r--r-- | c++/src/H5Library.h | 5 | ||||
-rw-r--r-- | c++/src/H5Location.cpp | 16 | ||||
-rw-r--r-- | c++/src/H5PropList.cpp | 6 |
15 files changed, 64 insertions, 75 deletions
diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp index 8d88c53..6dee337 100644 --- a/c++/src/H5AbstractDs.cpp +++ b/c++/src/H5AbstractDs.cpp @@ -68,10 +68,10 @@ H5T_class_t AbstractDs::getTypeClass() const try { datatype_id = p_get_type(); // returned value is already validated } - catch (DataSetIException E) { + catch (DataSetIException& E) { throw DataTypeIException("DataSet::getTypeClass", E.getDetailMsg()); } - catch (AttributeIException E) { + catch (AttributeIException& E) { throw DataTypeIException("Attribute::getTypeClass", E.getDetailMsg()); } @@ -118,10 +118,10 @@ DataType AbstractDs::getDataType() const f_DataType_setId(&datatype, p_get_type()); return(datatype); } - catch (DataSetIException E) { + catch (DataSetIException& E) { throw DataTypeIException("DataSet::getDataType", E.getDetailMsg()); } - catch (AttributeIException E) { + catch (AttributeIException& E) { throw DataTypeIException("Attribute::getDataType", E.getDetailMsg()); } } @@ -148,10 +148,10 @@ ArrayType AbstractDs::getArrayType() const arraytype.setArrayInfo(); return(arraytype); } - catch (DataSetIException E) { + catch (DataSetIException& E) { throw DataTypeIException("DataSet::getArrayType", E.getDetailMsg()); } - catch (AttributeIException E) { + catch (AttributeIException& E) { throw DataTypeIException("Attribute::getArrayType", E.getDetailMsg()); } } @@ -175,10 +175,10 @@ CompType AbstractDs::getCompType() const f_DataType_setId(&comptype, p_get_type()); return(comptype); } - catch (DataSetIException E) { + catch (DataSetIException& E) { throw DataTypeIException("DataSet::getCompType", E.getDetailMsg()); } - catch (AttributeIException E) { + catch (AttributeIException& E) { throw DataTypeIException("Attribute::getCompType", E.getDetailMsg()); } } @@ -202,10 +202,10 @@ EnumType AbstractDs::getEnumType() const f_DataType_setId(&enumtype, p_get_type()); return(enumtype); } - catch (DataSetIException E) { + catch (DataSetIException& E) { throw DataTypeIException("DataSet::getEnumType", E.getDetailMsg()); } - catch (AttributeIException E) { + catch (AttributeIException& E) { throw DataTypeIException("Attribute::getEnumType", E.getDetailMsg()); } } @@ -229,10 +229,10 @@ IntType AbstractDs::getIntType() const f_DataType_setId(&inttype, p_get_type()); return(inttype); } - catch (DataSetIException E) { + catch (DataSetIException& E) { throw DataTypeIException("DataSet::getIntType", E.getDetailMsg()); } - catch (AttributeIException E) { + catch (AttributeIException& E) { throw DataTypeIException("Attribute::getIntType", E.getDetailMsg()); } } @@ -256,10 +256,10 @@ FloatType AbstractDs::getFloatType() const f_DataType_setId(&floatype, p_get_type()); return(floatype); } - catch (DataSetIException E) { + catch (DataSetIException& E) { throw DataTypeIException("DataSet::getFloatType", E.getDetailMsg()); } - catch (AttributeIException E) { + catch (AttributeIException& E) { throw DataTypeIException("Attribute::getFloatType", E.getDetailMsg()); } } @@ -283,10 +283,10 @@ StrType AbstractDs::getStrType() const f_DataType_setId(&strtype, p_get_type()); return(strtype); } - catch (DataSetIException E) { + catch (DataSetIException& E) { throw DataTypeIException("DataSet::getStrType", E.getDetailMsg()); } - catch (AttributeIException E) { + catch (AttributeIException& E) { throw DataTypeIException("Attribute::getStrType", E.getDetailMsg()); } } @@ -310,10 +310,10 @@ VarLenType AbstractDs::getVarLenType() const f_DataType_setId(&varlentype, p_get_type()); return(varlentype); } - catch (DataSetIException E) { + catch (DataSetIException& E) { throw DataTypeIException("DataSet::getVarLenType", E.getDetailMsg()); } - catch (AttributeIException E) { + catch (AttributeIException& E) { throw DataTypeIException("Attribute::getVarLenType", E.getDetailMsg()); } } diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp index 9731a13..37cd8c1 100644 --- a/c++/src/H5ArrayType.cpp +++ b/c++/src/H5ArrayType.cpp @@ -112,7 +112,7 @@ ArrayType& ArrayType::operator=(const ArrayType& rhs) // Note: a = b, so there are two objects with the same hdf5 id // that's why incRefCount is needed, and it is called by setId } - catch (Exception close_error) { + catch (Exception& close_error) { throw DataTypeIException(inMemFunc("operator="), close_error.getDetailMsg()); } diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index 34489fa..301aaf1 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -293,7 +293,7 @@ H5std_string Attribute::getFileName() const try { return(p_get_file_name()); } - catch (IdComponentException E) { + catch (IdComponentException& E) { throw FileIException("Attribute::getFileName", E.getDetailMsg()); } } @@ -348,7 +348,7 @@ H5std_string Attribute::getName() const H5std_string attr_name(""); // attribute name to return // Preliminary call to get the size of the attribute name - ssize_t name_size = H5Aget_name(id, (size_t)0, NULL); + ssize_t name_size = H5Aget_name(id, static_cast<size_t>(0), NULL); // If H5Aget_name failed, throw exception if (name_size < 0) @@ -630,7 +630,7 @@ void Attribute::p_setId(const hid_t new_id) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw AttributeIException("Attribute::p_setId", close_error.getDetailMsg()); } // reset object's id to the given id @@ -674,7 +674,7 @@ Attribute::~Attribute() try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { cerr << "Attribute::~Attribute - " << close_error.getDetailMsg() << endl; } } diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp index 82575d6..5668ec3 100644 --- a/c++/src/H5CompType.cpp +++ b/c++/src/H5CompType.cpp @@ -232,7 +232,7 @@ DataType CompType::getMemberDataType( unsigned member_num ) const f_DataType_setId(&datatype, p_get_member_type(member_num)); return(datatype); } - catch (DataTypeIException E) { + catch (DataTypeIException& E) { throw DataTypeIException("CompType::getMemberDataType", E.getDetailMsg()); } } @@ -254,7 +254,7 @@ ArrayType CompType::getMemberArrayType( unsigned member_num ) const arraytype.setArrayInfo(); return(arraytype); } - catch (DataTypeIException E) { + catch (DataTypeIException& E) { throw DataTypeIException("CompType::getMemberArrayType", E.getDetailMsg()); } } @@ -275,7 +275,7 @@ CompType CompType::getMemberCompType( unsigned member_num ) const f_DataType_setId(&comptype, p_get_member_type(member_num)); return(comptype); } - catch (DataTypeIException E) { + catch (DataTypeIException& E) { throw DataTypeIException("CompType::getMemberCompType", E.getDetailMsg()); } } @@ -296,7 +296,7 @@ EnumType CompType::getMemberEnumType( unsigned member_num ) const f_DataType_setId(&enumtype, p_get_member_type(member_num)); return(enumtype); } - catch (DataTypeIException E) { + catch (DataTypeIException& E) { throw DataTypeIException("CompType::getMemberEnumType", E.getDetailMsg()); } } @@ -317,7 +317,7 @@ IntType CompType::getMemberIntType( unsigned member_num ) const f_DataType_setId(&inttype, p_get_member_type(member_num)); return(inttype); } - catch (DataTypeIException E) { + catch (DataTypeIException& E) { throw DataTypeIException("CompType::getMemberIntType", E.getDetailMsg()); } } @@ -338,7 +338,7 @@ FloatType CompType::getMemberFloatType( unsigned member_num ) const f_DataType_setId(&floatype, p_get_member_type(member_num)); return(floatype); } - catch (DataTypeIException E) { + catch (DataTypeIException& E) { throw DataTypeIException("CompType::getMemberFloatType", E.getDetailMsg()); } } @@ -359,7 +359,7 @@ StrType CompType::getMemberStrType( unsigned member_num ) const f_DataType_setId(&strtype, p_get_member_type(member_num)); return(strtype); } - catch (DataTypeIException E) { + catch (DataTypeIException& E) { throw DataTypeIException("CompType::getMemberStrType", E.getDetailMsg()); } } @@ -380,7 +380,7 @@ VarLenType CompType::getMemberVarLenType( unsigned member_num ) const f_DataType_setId(&varlentype, p_get_member_type(member_num)); return(varlentype); } - catch (DataTypeIException E) { + catch (DataTypeIException& E) { throw DataTypeIException("CompType::getMemberVarLenType", E.getDetailMsg()); } } diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index 7305347..8f5ad6f 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -781,7 +781,7 @@ void DataSet::p_setId(const hid_t new_id) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw DataSetIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } // reset object's id to the given id @@ -841,7 +841,7 @@ DataSet::~DataSet() try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { cerr << "DataSet::~DataSet - " << close_error.getDetailMsg() << endl; } } diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index 690f328..7b6289c 100644 --- a/c++/src/H5DataSpace.cpp +++ b/c++/src/H5DataSpace.cpp @@ -167,7 +167,7 @@ void DataSpace::copy( const DataSpace& like_space ) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw DataSpaceIException("DataSpace::copy", close_error.getDetailMsg()); } } // end if @@ -656,7 +656,7 @@ void DataSpace::p_setId(const hid_t new_id) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw DataSpaceIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } // reset object's id to the given id @@ -700,7 +700,7 @@ DataSpace::~DataSpace() { try { close(); - } catch (Exception close_error) { + } catch (Exception& close_error) { cerr << "DataSpace::~DataSpace - " << close_error.getDetailMsg() << endl; } } diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 3e5ad0f..b7d787d 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -179,7 +179,7 @@ void DataType::copy( const DataType& like_type ) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw DataTypeIException(inMemFunc("copy"), close_error.getDetailMsg()); } @@ -204,7 +204,7 @@ void DataType::copy(const DataSet& dset) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw DataTypeIException(inMemFunc("copy"), close_error.getDetailMsg()); } @@ -723,7 +723,7 @@ void DataType::p_setId(const hid_t new_id) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw DataTypeIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } // reset object's id to the given id @@ -776,7 +776,7 @@ DataType::~DataType() { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { cerr << inMemFunc("~DataType - ") << close_error.getDetailMsg() << endl; } } diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 270b232..7b81066 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -312,14 +312,15 @@ void Exception::printErrorStack(FILE* stream, hid_t err_stack) //-------------------------------------------------------------------------- // Function: Exception::printError -///\brief Prints the error stack in a default manner. This member -/// function is replaced by the static function printErrorStack -/// and will be removed from the next major release. -///\param stream - IN: File pointer +// Purpose: Prints the error stack in a default manner. This member +// function is replaced by the static function printErrorStack +// and will be removed from the next major release. +// Parameter stream - IN: File pointer // Programmer Binh-Minh Ribler - 2000 // Description: // This function can be removed in next major release. // -BMR, 2014/04/24 +// Removed from documentation. -BMR, 2016/03/23 //-------------------------------------------------------------------------- void Exception::printError(FILE* stream) const { diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index 67dda34..e63694a 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -88,7 +88,7 @@ H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& c { try { p_get_file(name, flags, create_plist, access_plist); - } catch (FileIException open_file) { + } catch (FileIException& open_file) { throw open_file; } } @@ -113,7 +113,7 @@ H5File::H5File( const H5std_string& name, unsigned int flags, const FileCreatPro { try { p_get_file(name.c_str(), flags, create_plist, access_plist); - } catch (FileIException open_file) { + } catch (FileIException& open_file) { throw open_file; } } @@ -245,7 +245,7 @@ void H5File::openFile(const char* name, unsigned int flags, const FileAccPropLis try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw FileIException("H5File::openFile", close_error.getDetailMsg()); } @@ -294,7 +294,7 @@ void H5File::reOpen() try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw FileIException("H5File::reOpen", close_error.getDetailMsg()); } @@ -650,7 +650,7 @@ H5File::~H5File() { try { close(); - } catch (Exception close_error) { + } catch (Exception& close_error) { cerr << "H5File::~H5File - " << close_error.getDetailMsg() << endl; } } diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index f9aabcb..9d27b79 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -156,7 +156,7 @@ void Group::p_setId(const hid_t new_id) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw GroupIException("Group::p_setId", close_error.getDetailMsg()); } // reset object's id to the given id @@ -221,7 +221,7 @@ Group::~Group() try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { cerr << "Group::~Group - " << close_error.getDetailMsg() << endl; } } diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index 60735f0..4f8c4a2 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -207,7 +207,7 @@ IdComponent& IdComponent::operator=( const IdComponent& rhs ) // Note: a = b, so there are two objects with the same hdf5 id // that's why incRefCount is needed, and it is called by setId } - catch (Exception close_error) { + catch (Exception& close_error) { throw FileIException(inMemFunc("operator="), close_error.getDetailMsg()); } } diff --git a/c++/src/H5Library.cpp b/c++/src/H5Library.cpp index be80fe4..471dbad 100644 --- a/c++/src/H5Library.cpp +++ b/c++/src/H5Library.cpp @@ -37,13 +37,6 @@ namespace H5 { #endif -#ifndef DOXYGEN_SHOULD_SKIP_THIS - -// This static variable is unused, will be removed in future releases. -bool H5Library::need_cleanup = false; - -#endif // DOXYGEN_SHOULD_SKIP_THIS - //-------------------------------------------------------------------------- // Function: H5Library::open (static) ///\brief Initializes the HDF5 library. diff --git a/c++/src/H5Library.h b/c++/src/H5Library.h index 336f9c8..308881b 100644 --- a/c++/src/H5Library.h +++ b/c++/src/H5Library.h @@ -29,11 +29,6 @@ namespace H5 { */ class H5_DLLCPP H5Library { public: -#ifndef DOXYGEN_SHOULD_SKIP_THIS - static bool need_cleanup; // indicates if H5close should be called - // - unused, will be removed in future releases. -#endif // DOXYGEN_SHOULD_SKIP_THIS - // Initializes the HDF5 library. static void open(); diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index e2b68ae..c4debba 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -230,7 +230,7 @@ int H5Location::iterateAttrs( attr_operator_t user_op, unsigned *_idx, void *op_ userData->location = this; // call the C library routine H5Aiterate2 to iterate the attributes - hsize_t idx = _idx ? (hsize_t)*_idx : 0; + hsize_t idx = _idx ? static_cast<hsize_t>(*_idx) : 0; int ret_value = H5Aiterate2(getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, userAttrOpWrpr, reinterpret_cast<void *>(userData)); @@ -387,7 +387,7 @@ H5std_string H5Location::getFileName() const try { return(p_get_file_name()); } - catch (LocationException E) { + catch (LocationException& E) { throw FileIException(inMemFunc("getFileName"), E.getDetailMsg()); } } @@ -634,7 +634,7 @@ void H5Location::reference(void* ref, const char* name, const DataSpace& dataspa try { p_reference(ref, name, dataspace.getId(), ref_type); } - catch (ReferenceException E) { + catch (ReferenceException& E) { throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); } } @@ -660,7 +660,7 @@ void H5Location::reference(void* ref, const H5std_string& name, const DataSpace& try { p_reference(ref, name.c_str(), dataspace.getId(), ref_type); } - catch (ReferenceException E) { + catch (ReferenceException& E) { throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); } } @@ -684,7 +684,7 @@ void H5Location::reference(void* ref, const char* name, H5R_type_t ref_type) con try { p_reference(ref, name, -1, ref_type); } - catch (ReferenceException E) { + catch (ReferenceException& E) { throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); } } @@ -803,7 +803,7 @@ H5G_obj_t H5Location::getObjType(void *ref, H5R_type_t ref_type) const try { return(p_get_obj_type(ref, ref_type)); } - catch (ReferenceException E) { + catch (ReferenceException& E) { throw ReferenceException(inMemFunc("getObjType"), E.getDetailMsg()); } } @@ -859,7 +859,7 @@ H5O_type_t H5Location::getRefObjType(void *ref, H5R_type_t ref_type) const try { return(p_get_ref_obj_type(ref, ref_type)); } - catch (ReferenceException E) { + catch (ReferenceException& E) { throw ReferenceException(inMemFunc("getRefObjType"), E.getDetailMsg()); } } @@ -924,7 +924,7 @@ DataSpace H5Location::getRegion(void *ref, H5R_type_t ref_type) const f_DataSpace_setId(&dataspace, space_id); return(dataspace); } - catch (DataSpaceIException E) { + catch (DataSpaceIException& E) { throw ReferenceException(inMemFunc("getRegion"), E.getDetailMsg()); } } diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index b954191..6655900 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -169,7 +169,7 @@ void PropList::copy( const PropList& like_plist ) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw PropListIException(inMemFunc("copy"), close_error.getDetailMsg()); } @@ -301,7 +301,7 @@ void PropList::p_setId(const hid_t new_id) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw PropListIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } // reset object's id to the given id @@ -747,7 +747,7 @@ PropList::~PropList() try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { cerr << "PropList::~PropList - " << close_error.getDetailMsg() << endl; } } |