diff options
Diffstat (limited to 'c++/src')
-rw-r--r-- | c++/src/CMakeLists.txt | 7 | ||||
-rw-r--r-- | c++/src/H5Cpp.h | 10 | ||||
-rw-r--r-- | c++/src/H5DataSpace.cpp | 7 | ||||
-rw-r--r-- | c++/src/H5DataType.cpp | 24 | ||||
-rw-r--r-- | c++/src/H5DxferProp.cpp | 4 | ||||
-rw-r--r-- | c++/src/H5Exception.cpp | 2 | ||||
-rw-r--r-- | c++/src/H5File.cpp | 6 | ||||
-rw-r--r-- | c++/src/H5LcreatProp.cpp | 4 | ||||
-rw-r--r-- | c++/src/H5Location.cpp | 2 | ||||
-rw-r--r-- | c++/src/H5PropList.cpp | 8 |
10 files changed, 25 insertions, 49 deletions
diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt index 835d422..2a37dea 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -2,13 +2,6 @@ cmake_minimum_required (VERSION 3.12) project (HDF5_CPP_SRC CXX) #----------------------------------------------------------------------------- -# Generate configure file -#----------------------------------------------------------------------------- -configure_file (${HDF_RESOURCES_DIR}/H5cxx_config.h.in - ${HDF5_SRC_BINARY_DIR}/H5cxx_pubconf.h -) - -#----------------------------------------------------------------------------- # Define cpp Library #----------------------------------------------------------------------------- set (CPP_SOURCES diff --git a/c++/src/H5Cpp.h b/c++/src/H5Cpp.h index 9272bdb..202d584 100644 --- a/c++/src/H5Cpp.h +++ b/c++/src/H5Cpp.h @@ -48,14 +48,4 @@ #include "H5File.h" #include "H5Library.h" -/* Some C++ compilers do not have offsetof macro; define to bypass the problem - - BMR- -EIP- 2007/08/01 -*/ -#ifndef H5_CXX_HAVE_OFFSETOF -#ifdef HOFFSET -#undef HOFFSET -#endif -#define HOFFSET(TYPE, MEMBER) ((size_t) & ((TYPE *)0)->MEMBER) -#endif - #endif // H5Cpp_H diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index c20a88c..342e9fa 100644 --- a/c++/src/H5DataSpace.cpp +++ b/c++/src/H5DataSpace.cpp @@ -88,9 +88,8 @@ const DataSpace &DataSpace::ALL = *getConstant(); ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace::DataSpace(H5S_class_t type) : IdComponent() +DataSpace::DataSpace(H5S_class_t type) : IdComponent(), id{H5Screate(type)} { - id = H5Screate(type); if (id < 0) { throw DataSpaceIException("DataSpace constructor", "H5Screate failed"); } @@ -105,9 +104,9 @@ DataSpace::DataSpace(H5S_class_t type) : IdComponent() ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSpace::DataSpace(int rank, const hsize_t *dims, const hsize_t *maxdims) : IdComponent() +DataSpace::DataSpace(int rank, const hsize_t *dims, const hsize_t *maxdims) + : IdComponent(), id{H5Screate_simple(rank, dims, maxdims)} { - id = H5Screate_simple(rank, dims, maxdims); if (id < 0) { throw DataSpaceIException("DataSpace constructor", "H5Screate_simple failed"); } diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 3228dcb..cdf28cf 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -76,10 +76,9 @@ DataType::DataType(const hid_t existing_id) : H5Object(), id(existing_id), encod ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType::DataType(const H5T_class_t type_class, size_t size) : H5Object(), encoded_buf(NULL), buf_size(0) +DataType::DataType(const H5T_class_t type_class, size_t size) + : H5Object(), id{H5Tcreate(type_class, size)}, encoded_buf(NULL), buf_size(0) { - // Call C routine to create the new datatype - id = H5Tcreate(type_class, size); if (id < 0) { throw DataTypeIException("DataType constructor", "H5Tcreate failed"); } @@ -97,9 +96,10 @@ DataType::DataType(const H5T_class_t type_class, size_t size) : H5Object(), enco // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- DataType::DataType(const H5Location &loc, const void *ref, H5R_type_t ref_type, const PropList &plist) - : H5Object(), encoded_buf(NULL), buf_size(0) + : H5Object(), id{H5Location::p_dereference(loc.getId(), ref, ref_type, plist, + "constructor - by dereference")}, + encoded_buf(NULL), buf_size(0) { - id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereference"); } //-------------------------------------------------------------------------- @@ -146,10 +146,9 @@ DataType::DataType(const DataType &original) : H5Object(), id(original.id), enco // unnecessarily and will produce undefined behavior. // -BMR, Apr 2015 //-------------------------------------------------------------------------- -DataType::DataType(const PredType &pred_type) : H5Object(), encoded_buf(NULL), buf_size(0) +DataType::DataType(const PredType &pred_type) + : H5Object(), id{H5Tcopy(pred_type.getId())}, encoded_buf(NULL), buf_size(0) { - // Call C routine to copy the datatype - id = H5Tcopy(pred_type.getId()); if (id < 0) throw DataTypeIException("DataType constructor", "H5Tcopy failed"); } @@ -168,9 +167,9 @@ DataType::DataType(const PredType &pred_type) : H5Object(), encoded_buf(NULL), b // improve usability. // -BMR, Dec 2016 //-------------------------------------------------------------------------- -DataType::DataType(const H5Location &loc, const char *dtype_name) : H5Object(), encoded_buf(NULL), buf_size(0) +DataType::DataType(const H5Location &loc, const char *dtype_name) + : H5Object(), id{p_opentype(loc, dtype_name)}, encoded_buf(NULL), buf_size(0) { - id = p_opentype(loc, dtype_name); } //-------------------------------------------------------------------------- @@ -188,9 +187,8 @@ DataType::DataType(const H5Location &loc, const char *dtype_name) : H5Object(), // -BMR, Dec 2016 //-------------------------------------------------------------------------- DataType::DataType(const H5Location &loc, const H5std_string &dtype_name) - : H5Object(), encoded_buf(NULL), buf_size(0) + : H5Object(), id{p_opentype(loc, dtype_name.c_str())}, encoded_buf(NULL), buf_size(0) { - id = p_opentype(loc, dtype_name.c_str()); } //-------------------------------------------------------------------------- @@ -318,7 +316,7 @@ DataType::encode() // Allocate buffer and call C function again to encode if (buf_size > 0) { - encoded_buf = (unsigned char *)HDcalloc((size_t)1, buf_size); + encoded_buf = static_cast<unsigned char *>(HDcalloc(1, buf_size)); ret_value = H5Tencode(id, encoded_buf, &buf_size); if (ret_value < 0) { throw DataTypeIException("DataType::encode", "H5Tencode failed"); diff --git a/c++/src/H5DxferProp.cpp b/c++/src/H5DxferProp.cpp index 43ea6f4..40faac2 100644 --- a/c++/src/H5DxferProp.cpp +++ b/c++/src/H5DxferProp.cpp @@ -175,7 +175,7 @@ DSetMemXferPropList::getBuffer(void **tconv, void **bkg) const void DSetMemXferPropList::setPreserve(bool status) const { - herr_t ret_value = H5Pset_preserve(id, (hbool_t)status); + herr_t ret_value = H5Pset_preserve(id, static_cast<hbool_t>(status)); if (ret_value < 0) { throw PropListIException("DSetMemXferPropList::setPreserve", "H5Pset_preserve failed"); } @@ -314,7 +314,7 @@ DSetMemXferPropList::getDataTransform() const H5std_string expression; // Preliminary call to get the expression's length - ssize_t exp_len = H5Pget_data_transform(id, NULL, (size_t)0); + ssize_t exp_len = H5Pget_data_transform(id, NULL, 0); // If H5Pget_data_transform returns a negative value, raise an exception if (exp_len < 0) { diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 6769439..a42c151 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -25,7 +25,7 @@ const char Exception::DEFAULT_MSG[] = "No detailed information provided"; ///\brief Default constructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Exception::Exception() +Exception::Exception() : detail_message{""}, func_name{""} { } diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index 9a6f191..f92171b 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -165,9 +165,8 @@ H5File::p_get_file(const char *name, unsigned int flags, const FileCreatPropList // constructor is needed by the library in order to return // an object, H5File doesn't need it. -BMR (HDFFV-8766 partially) //-------------------------------------------------------------------------- -H5File::H5File(hid_t existing_id) : Group() +H5File::H5File(hid_t existing_id) : Group(), id{existing_id} { - id = existing_id; incRefCount(); // increment number of references to this id } @@ -180,9 +179,8 @@ H5File::H5File(hid_t existing_id) : Group() ///\param original - IN: H5File instance to copy // December 2000 //-------------------------------------------------------------------------- -H5File::H5File(const H5File &original) : Group(original) +H5File::H5File(const H5File &original) : Group(original), id{original.getId()} { - id = original.getId(); incRefCount(); // increment number of references to this id } diff --git a/c++/src/H5LcreatProp.cpp b/c++/src/H5LcreatProp.cpp index 63fe861..3851d56 100644 --- a/c++/src/H5LcreatProp.cpp +++ b/c++/src/H5LcreatProp.cpp @@ -121,7 +121,7 @@ LinkCreatPropList::LinkCreatPropList(const hid_t plist_id) : PropList(plist_id) void LinkCreatPropList::setCreateIntermediateGroup(bool crt_intmd_group) const { - herr_t ret_value = H5Pset_create_intermediate_group(id, (unsigned)crt_intmd_group); + herr_t ret_value = H5Pset_create_intermediate_group(id, static_cast<unsigned>(crt_intmd_group)); // Throw exception if H5Pset_create_intermediate_group returns failure if (ret_value < 0) { throw PropListIException("setCreateIntermediateGroup", "H5Pset_create_intermediate_group failed"); @@ -146,7 +146,7 @@ LinkCreatPropList::getCreateIntermediateGroup() const throw PropListIException("getCreateIntermediateGroup", "H5Pget_create_intermediate_group failed"); } - return ((bool)crt_intmd_group); + return static_cast<bool>(crt_intmd_group); } //-------------------------------------------------------------------------- diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index 065de0c..bb754a2 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -351,7 +351,7 @@ H5Location::getComment(const char *name, size_t buf_size) const H5std_string comment; // Preliminary call to get the comment's length - ssize_t comment_len = H5Oget_comment_by_name(getId(), name, NULL, (size_t)0, H5P_DEFAULT); + ssize_t comment_len = H5Oget_comment_by_name(getId(), name, NULL, 0, H5P_DEFAULT); // If H5Oget_comment_by_name returns a negative value, raise an exception if (comment_len < 0) { diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index 8b45f79..46e4931 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -113,11 +113,8 @@ PropList::PropList(const PropList &original) : IdComponent(), id(original.id) // property's id to H5P_DEFAULT. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PropList::PropList(const hid_t plist_id) : IdComponent() +PropList::PropList(const hid_t plist_id) : IdComponent(), id{H5P_DEFAULT} { - if (plist_id <= 0) - id = H5P_DEFAULT; - H5I_type_t id_type = H5Iget_type(plist_id); switch (id_type) { case H5I_GENPROP_CLS: @@ -633,11 +630,12 @@ PropList::setProperty(const char *name, void *value) const void PropList::setProperty(const char *name, const char *charptr) const { - herr_t ret_value = H5Pset(id, name, (const void *)charptr); + herr_t ret_value = H5Pset(id, name, static_cast<const void *>(charptr)); if (ret_value < 0) { throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); } } + //-------------------------------------------------------------------------- // Function: PropList::setProperty ///\brief This is an overloaded member function, provided for convenience. |