diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2017-04-23 21:40:27 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2017-04-23 21:40:27 (GMT) |
commit | 326030c665c53dfb04491a92ec88e38749bfbeb0 (patch) | |
tree | 161d3ee173a6078f171db492ac23765f9314ea3c /c++/src/H5DataType.cpp | |
parent | 816fb3b0fc2043ec04805bc4853d54d2cbfd188f (diff) | |
download | hdf5-326030c665c53dfb04491a92ec88e38749bfbeb0.zip hdf5-326030c665c53dfb04491a92ec88e38749bfbeb0.tar.gz hdf5-326030c665c53dfb04491a92ec88e38749bfbeb0.tar.bz2 |
Format changes only.
Platforms tested:
Linux/32 2.6 (jam) - very minor
Diffstat (limited to 'c++/src/H5DataType.cpp')
-rw-r--r-- | c++/src/H5DataType.cpp | 292 |
1 files changed, 146 insertions, 146 deletions
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index c9a0c6b..f29978b 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -80,14 +80,14 @@ DataType::DataType(const hid_t existing_id) : H5Object(), id(existing_id) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType::DataType( const H5T_class_t type_class, size_t size ) : H5Object() +DataType::DataType(const H5T_class_t type_class, size_t size) : H5Object() { - // Call C routine to create the new datatype - id = H5Tcreate( type_class, size ); - if( id < 0 ) - { - throw DataTypeIException("DataType constructor", "H5Tcreate failed"); - } + // Call C routine to create the new datatype + id = H5Tcreate(type_class, size); + if(id < 0) + { + throw DataTypeIException("DataType constructor", "H5Tcreate failed"); + } } //-------------------------------------------------------------------------- @@ -152,7 +152,7 @@ DataType::DataType(const DataType& original) : H5Object(), id(original.id) DataType::DataType(const PredType& pred_type) : H5Object() { // call C routine to copy the datatype - id = H5Tcopy( pred_type.getId() ); + id = H5Tcopy(pred_type.getId()); if (id < 0) throw DataTypeIException("DataType constructor", "H5Tcopy failed"); } @@ -169,7 +169,7 @@ DataType::DataType(const PredType& pred_type) : H5Object() // - Replaced decRefCount with close() to let the C library // handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- -void DataType::copy( const DataType& like_type ) +void DataType::copy(const DataType& like_type) { // close the current data type before copying like_type to this object try { @@ -180,8 +180,8 @@ void DataType::copy( const DataType& like_type ) } // call C routine to copy the datatype - id = H5Tcopy( like_type.getId() ); - if( id < 0 ) + id = H5Tcopy(like_type.getId()); + if(id < 0) throw DataTypeIException(inMemFunc("copy"), "H5Tcopy failed"); } @@ -205,8 +205,8 @@ void DataType::copy(const DataSet& dset) } // call C routine to copy the datatype - id = H5Tcopy( dset.getId() ); - if( id < 0 ) + id = H5Tcopy(dset.getId()); + if(id < 0) throw DataTypeIException(inMemFunc("copy"), "H5Tcopy failed"); } @@ -229,7 +229,7 @@ void DataType::copy(const DataSet& dset) // transient datatype. // BMR - Mar, 2015 //-------------------------------------------------------------------------- -DataType& DataType::operator=( const DataType& rhs ) +DataType& DataType::operator=(const DataType& rhs) { if (this != &rhs) { @@ -247,19 +247,19 @@ DataType& DataType::operator=( const DataType& rhs ) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool DataType::operator==(const DataType& compared_type ) const +bool DataType::operator==(const DataType& compared_type) const { - // Call C routine H5Tequal to determines whether two datatype - // identifiers refer to the same datatype - htri_t ret_value = H5Tequal( id, compared_type.getId() ); - if( ret_value > 0 ) - return true; - else if( ret_value == 0 ) - return false; - else - { - throw DataTypeIException(inMemFunc("operator=="), "H5Tequal returns negative value"); - } + // Call C routine H5Tequal to determines whether two datatype + // identifiers refer to the same datatype + htri_t ret_value = H5Tequal(id, compared_type.getId()); + if(ret_value > 0) + return true; + else if(ret_value == 0) + return false; + else + { + throw DataTypeIException(inMemFunc("operator=="), "H5Tequal returns negative value"); + } } //-------------------------------------------------------------------------- @@ -278,10 +278,10 @@ bool DataType::operator==(const DataType& compared_type ) const //-------------------------------------------------------------------------- void DataType::p_commit(hid_t loc_id, const char* name) { - // Call C routine to commit the transient datatype - herr_t ret_value = H5Tcommit2(loc_id, name, id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if( ret_value < 0 ) - throw DataTypeIException(inMemFunc("p_commit"), "H5Tcommit2 failed"); + // Call C routine to commit the transient datatype + herr_t ret_value = H5Tcommit2(loc_id, name, id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if(ret_value < 0) + throw DataTypeIException(inMemFunc("p_commit"), "H5Tcommit2 failed"); } //-------------------------------------------------------------------------- @@ -295,7 +295,7 @@ void DataType::p_commit(hid_t loc_id, const char* name) //-------------------------------------------------------------------------- void DataType::commit(const H5Location& loc, const char* name) { - p_commit(loc.getId(), name); + p_commit(loc.getId(), name); } //-------------------------------------------------------------------------- @@ -326,7 +326,7 @@ void DataType::commit(const H5Location& loc, const char* name) //-------------------------------------------------------------------------- void DataType::commit(const H5Location& loc, const H5std_string& name) { - p_commit(loc.getId(), name.c_str()); + p_commit(loc.getId(), name.c_str()); } //-------------------------------------------------------------------------- @@ -359,16 +359,16 @@ void DataType::commit(const H5Location& loc, const H5std_string& name) //-------------------------------------------------------------------------- bool DataType::committed() const { - // Call C function to determine if a datatype is a named one - htri_t is_committed = H5Tcommitted( id ); - if (is_committed > 0) - return true; - else if (is_committed == 0) - return false; - else - { - throw DataTypeIException(inMemFunc("committed"), "H5Tcommitted return negative value"); - } + // Call C function to determine if a datatype is a named one + htri_t is_committed = H5Tcommitted(id); + if (is_committed > 0) + return true; + else if (is_committed == 0) + return false; + else + { + throw DataTypeIException(inMemFunc("committed"), "H5Tcommitted return negative value"); + } } //-------------------------------------------------------------------------- @@ -381,15 +381,15 @@ bool DataType::committed() const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5T_conv_t DataType::find( const DataType& dest, H5T_cdata_t **pcdata ) const +H5T_conv_t DataType::find(const DataType& dest, H5T_cdata_t **pcdata) const { - // Call C routine to find the conversion function - H5T_conv_t func = H5Tfind( id, dest.getId(), pcdata ); - if( func == NULL ) - { - throw DataTypeIException(inMemFunc("find"), "H5Tfind returns a NULL function"); - } - return( func ); + // Call C routine to find the conversion function + H5T_conv_t func = H5Tfind(id, dest.getId(), pcdata); + if(func == NULL) + { + throw DataTypeIException(inMemFunc("find"), "H5Tfind returns a NULL function"); + } + return(func); } //-------------------------------------------------------------------------- @@ -405,19 +405,19 @@ H5T_conv_t DataType::find( const DataType& dest, H5T_cdata_t **pcdata ) const ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::convert( const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist ) const +void DataType::convert(const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist) const { - // Get identifiers for C API - hid_t dest_id = dest.getId(); - hid_t plist_id = plist.getId(); + // Get identifiers for C API + hid_t dest_id = dest.getId(); + hid_t plist_id = plist.getId(); - // Call C routine H5Tconvert to convert the data - herr_t ret_value; - ret_value = H5Tconvert( id, dest_id, nelmts, buf, background, plist_id ); - if( ret_value < 0 ) - { - throw DataTypeIException(inMemFunc("convert"), "H5Tconvert failed"); - } + // Call C routine H5Tconvert to convert the data + herr_t ret_value; + ret_value = H5Tconvert(id, dest_id, nelmts, buf, background, plist_id); + if(ret_value < 0) + { + throw DataTypeIException(inMemFunc("convert"), "H5Tconvert failed"); + } } //-------------------------------------------------------------------------- @@ -436,12 +436,12 @@ void DataType::convert( const DataType& dest, size_t nelmts, void *buf, void *ba //-------------------------------------------------------------------------- void DataType::lock() const { - // Call C routine to lock the datatype - herr_t ret_value = H5Tlock( id ); - if( ret_value < 0 ) - { - throw DataTypeIException(inMemFunc("lock"), "H5Tlock failed"); - } + // Call C routine to lock the datatype + herr_t ret_value = H5Tlock(id); + if(ret_value < 0) + { + throw DataTypeIException(inMemFunc("lock"), "H5Tlock failed"); + } } //-------------------------------------------------------------------------- @@ -453,14 +453,14 @@ void DataType::lock() const //-------------------------------------------------------------------------- H5T_class_t DataType::getClass() const { - H5T_class_t type_class = H5Tget_class( id ); + H5T_class_t type_class = H5Tget_class(id); - // Return datatype class identifier if successful - if( type_class == H5T_NO_CLASS ) - { - throw DataTypeIException(inMemFunc("getClass"), "H5Tget_class returns H5T_NO_CLASS"); - } - return( type_class ); + // Return datatype class identifier if successful + if(type_class == H5T_NO_CLASS) + { + throw DataTypeIException(inMemFunc("getClass"), "H5Tget_class returns H5T_NO_CLASS"); + } + return(type_class); } //-------------------------------------------------------------------------- @@ -472,13 +472,13 @@ H5T_class_t DataType::getClass() const //-------------------------------------------------------------------------- size_t DataType::getSize() const { - // Call C routine to get the datatype size - size_t type_size = H5Tget_size( id ); - if( type_size <= 0 ) // valid data types are never zero size - { - throw DataTypeIException(inMemFunc("getSize"), "H5Tget_size returns invalid datatype size"); - } - return( type_size ); + // Call C routine to get the datatype size + size_t type_size = H5Tget_size(id); + if(type_size <= 0) // valid data types are never zero size + { + throw DataTypeIException(inMemFunc("getSize"), "H5Tget_size returns invalid datatype size"); + } + return(type_size); } //-------------------------------------------------------------------------- @@ -490,22 +490,22 @@ size_t DataType::getSize() const //-------------------------------------------------------------------------- DataType DataType::getSuper() const { - // Call C routine to get the base datatype from which the specified - // datatype is derived. - hid_t base_type_id = H5Tget_super( id ); + // Call C routine to get the base datatype from which the specified + // datatype is derived. + hid_t base_type_id = H5Tget_super(id); - // If H5Tget_super returns a valid datatype id, create and return - // the base type, otherwise, raise exception - if( base_type_id > 0 ) - { + // If H5Tget_super returns a valid datatype id, create and return + // the base type, otherwise, raise exception + if(base_type_id > 0) + { DataType base_type; base_type.p_setId(base_type_id); return(base_type); - } - else - { - throw DataTypeIException(inMemFunc("getSuper"), "H5Tget_super failed"); - } + } + else + { + throw DataTypeIException(inMemFunc("getSuper"), "H5Tget_super failed"); + } } //-------------------------------------------------------------------------- @@ -524,16 +524,16 @@ DataType DataType::getSuper() const /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5T.html#Datatype-Register // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::registerFunc( H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func ) const +void DataType::registerFunc(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const { - hid_t dest_id = dest.getId(); // get id of the destination datatype + hid_t dest_id = dest.getId(); // get id of the destination datatype - // Call C routine H5Tregister to register the conversion function - herr_t ret_value = H5Tregister( pers, name, id, dest_id, func ); - if( ret_value < 0 ) - { - throw DataTypeIException(inMemFunc("registerFunc"), "H5Tregister failed"); - } + // Call C routine H5Tregister to register the conversion function + herr_t ret_value = H5Tregister(pers, name, id, dest_id, func); + if(ret_value < 0) + { + throw DataTypeIException(inMemFunc("registerFunc"), "H5Tregister failed"); + } } //-------------------------------------------------------------------------- @@ -543,9 +543,9 @@ void DataType::registerFunc( H5T_pers_t pers, const char* name, const DataType& /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::registerFunc( H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func ) const +void DataType::registerFunc(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const { - registerFunc( pers, name.c_str(), dest, func ); + registerFunc(pers, name.c_str(), dest, func); } //-------------------------------------------------------------------------- @@ -561,16 +561,16 @@ void DataType::registerFunc( H5T_pers_t pers, const H5std_string& name, const Da ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::unregister( H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func ) const +void DataType::unregister(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const { - hid_t dest_id = dest.getId(); // get id of the dest datatype for C API + hid_t dest_id = dest.getId(); // get id of the dest datatype for C API - // Call C routine H5Tunregister to remove the conversion function - herr_t ret_value = H5Tunregister( pers, name, id, dest_id, func ); - if( ret_value < 0 ) - { - throw DataTypeIException(inMemFunc("unregister"), "H5Tunregister failed"); - } + // Call C routine H5Tunregister to remove the conversion function + herr_t ret_value = H5Tunregister(pers, name, id, dest_id, func); + if(ret_value < 0) + { + throw DataTypeIException(inMemFunc("unregister"), "H5Tunregister failed"); + } } //-------------------------------------------------------------------------- @@ -580,9 +580,9 @@ void DataType::unregister( H5T_pers_t pers, const char* name, const DataType& de /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::unregister( H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func ) const +void DataType::unregister(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const { - unregister( pers, name.c_str(), dest, func ); + unregister(pers, name.c_str(), dest, func); } //-------------------------------------------------------------------------- @@ -593,14 +593,14 @@ void DataType::unregister( H5T_pers_t pers, const H5std_string& name, const Data ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::setTag( const char* tag ) const +void DataType::setTag(const char* tag) const { - // Call C routine H5Tset_tag to tag an opaque datatype. - herr_t ret_value = H5Tset_tag( id, tag ); - if( ret_value < 0 ) - { - throw DataTypeIException(inMemFunc("setTag"), "H5Tset_tag failed"); - } + // Call C routine H5Tset_tag to tag an opaque datatype. + herr_t ret_value = H5Tset_tag(id, tag); + if(ret_value < 0) + { + throw DataTypeIException(inMemFunc("setTag"), "H5Tset_tag failed"); + } } //-------------------------------------------------------------------------- @@ -610,9 +610,9 @@ void DataType::setTag( const char* tag ) const /// argument \a name. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void DataType::setTag( const H5std_string& tag ) const +void DataType::setTag(const H5std_string& tag) const { - setTag( tag.c_str()); + setTag(tag.c_str()); } //-------------------------------------------------------------------------- @@ -624,11 +624,11 @@ void DataType::setTag( const H5std_string& tag ) const //-------------------------------------------------------------------------- H5std_string DataType::getTag() const { - char* tag_Cstr = H5Tget_tag( id ); + char* tag_Cstr = H5Tget_tag(id); // if the tag C-string returned is not NULL, convert it to C++ string // and return it, otherwise, raise an exception - if( tag_Cstr != NULL ) + if(tag_Cstr != NULL) { H5std_string tag = H5std_string(tag_Cstr); // C string to string object H5free_memory(tag_Cstr); // free the C string @@ -651,16 +651,16 @@ H5std_string DataType::getTag() const //-------------------------------------------------------------------------- bool DataType::detectClass(H5T_class_t cls) const { - htri_t ret_value = H5Tdetect_class(id, cls); - if( ret_value > 0 ) - return true; - else if( ret_value == 0 ) - return false; - else - { - throw DataTypeIException(inMemFunc("detectClass"), + htri_t ret_value = H5Tdetect_class(id, cls); + if(ret_value > 0) + return true; + else if(ret_value == 0) + return false; + else + { + throw DataTypeIException(inMemFunc("detectClass"), "H5Tdetect_class returns negative value"); - } + } } //-------------------------------------------------------------------------- @@ -673,16 +673,16 @@ bool DataType::detectClass(H5T_class_t cls) const //-------------------------------------------------------------------------- bool DataType::isVariableStr() const { - htri_t is_varlen_str = H5Tis_variable_str(id); - if( is_varlen_str == 1 ) - return true; - else if( is_varlen_str == 0 ) - return false; - else - { - throw DataTypeIException(inMemFunc("isVariableStr"), + htri_t is_varlen_str = H5Tis_variable_str(id); + if(is_varlen_str == 1) + return true; + else if(is_varlen_str == 0) + return false; + else + { + throw DataTypeIException(inMemFunc("isVariableStr"), "H5Tis_variable_str returns negative value"); - } + } } //-------------------------------------------------------------------------- @@ -699,7 +699,7 @@ bool DataType::isVariableStr() const //-------------------------------------------------------------------------- hid_t DataType::getId() const { - return(id); + return(id); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -724,8 +724,8 @@ void DataType::p_setId(const hid_t new_id) catch (Exception& close_error) { throw DataTypeIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } - // reset object's id to the given id - id = new_id; + // reset object's id to the given id + id = new_id; } #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -741,7 +741,7 @@ void DataType::close() if (p_valid_id(id)) { herr_t ret_value = H5Tclose(id); - if( ret_value < 0 ) + if(ret_value < 0) { throw DataTypeIException(inMemFunc("close"), "H5Tclose failed"); } |