diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2016-03-07 15:42:30 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2016-03-07 15:42:30 (GMT) |
commit | b346cb0599da3b46f892365ad2ebd1e55ea173f3 (patch) | |
tree | a2c63f1639133b35138e171852118e2180d9c367 /c++/src/H5ArrayType.cpp | |
parent | 3247df1224d2f226a03144fb556b2a3435794871 (diff) | |
download | hdf5-b346cb0599da3b46f892365ad2ebd1e55ea173f3.zip hdf5-b346cb0599da3b46f892365ad2ebd1e55ea173f3.tar.gz hdf5-b346cb0599da3b46f892365ad2ebd1e55ea173f3.tar.bz2 |
[svn-r29306] Purpose: Add function
Description:
Added member function ArrayType::operator= because ArrayType has
pointer data members.
Platforms tested:
Linux/32 2.6 (jam)
Linux/64 (platypus)
Darwin (osx1010test)
Diffstat (limited to 'c++/src/H5ArrayType.cpp')
-rw-r--r-- | c++/src/H5ArrayType.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp index 0f09631..5792467 100644 --- a/c++/src/H5ArrayType.cpp +++ b/c++/src/H5ArrayType.cpp @@ -93,6 +93,44 @@ ArrayType::ArrayType(const DataType& base_type, int ndims, const hsize_t* dims) } //-------------------------------------------------------------------------- +// Function: ArrayType::operator= +///\brief Assignment operator +///\param rhs - IN: Reference to the existing array datatype +///\return Reference to ArrayType instance +///\exception H5::DataTypeIException +/// std::bad_alloc +// Description +// Closes the id on the lhs object first with setId, then copies +// each data member from the rhs object. +// Programmer Binh-Minh Ribler - Mar 2016 +// Modification +//-------------------------------------------------------------------------- +ArrayType& ArrayType::operator=(const ArrayType& rhs) +{ + if (this != &rhs) + { + // handling references to this id + try { + setId(rhs.id); + // 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) { + throw DataTypeIException(inMemFunc("operator="), close_error.getDetailMsg()); + } + + // Copy the rank of the rhs array + rank = rhs.rank; + + // Allocate space then copy the dimensions from the rhs array + dimensions = new hsize_t[rank]; + for (int i = 0; i < rank; i++) + dimensions[i] = rhs.dimensions[i]; + } + return(*this); +} + +//-------------------------------------------------------------------------- // Function: ArrayType::setArrayInfo ///\brief Retrieves the rank and dimensions from the array datatype /// and store the info in this ArrayType object. |