Added C++11 override keyword where appropriate (#433)

Added H5_OVERRIDE macro for compatibility with both C++11 and older.
This commit is contained in:
Sean McBride 2021-03-10 12:52:48 -05:00 committed by GitHub
parent 20c452fe5c
commit 7501f96ab9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 32 deletions

View File

@ -43,7 +43,7 @@ class H5_DLLCPP DataSpace : public IdComponent {
DataSpace &operator=(const DataSpace &rhs);
// Closes this dataspace.
virtual void close();
virtual void close() H5_OVERRIDE;
// Makes copy of an existing dataspace.
void copy(const DataSpace &like_space);
@ -115,13 +115,13 @@ class H5_DLLCPP DataSpace : public IdComponent {
///\brief Returns this class name.
virtual H5std_string
fromClass() const
fromClass() const H5_OVERRIDE
{
return ("DataSpace");
}
// Gets the dataspace id.
virtual hid_t getId() const;
virtual hid_t getId() const H5_OVERRIDE;
// Deletes the global constant
static void deleteConstants();
@ -133,7 +133,7 @@ class H5_DLLCPP DataSpace : public IdComponent {
protected:
// Sets the dataspace id.
virtual void p_setId(const hid_t new_id);
virtual void p_setId(const hid_t new_id) H5_OVERRIDE;
#endif // DOXYGEN_SHOULD_SKIP_THIS

View File

@ -90,84 +90,84 @@ class H5_DLLCPP FileIException : public Exception {
public:
FileIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
FileIException();
virtual ~FileIException() throw();
virtual ~FileIException() throw() H5_OVERRIDE;
};
class H5_DLLCPP GroupIException : public Exception {
public:
GroupIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
GroupIException();
virtual ~GroupIException() throw();
virtual ~GroupIException() throw() H5_OVERRIDE;
};
class H5_DLLCPP DataSpaceIException : public Exception {
public:
DataSpaceIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
DataSpaceIException();
virtual ~DataSpaceIException() throw();
virtual ~DataSpaceIException() throw() H5_OVERRIDE;
};
class H5_DLLCPP DataTypeIException : public Exception {
public:
DataTypeIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
DataTypeIException();
virtual ~DataTypeIException() throw();
virtual ~DataTypeIException() throw() H5_OVERRIDE;
};
class H5_DLLCPP ObjHeaderIException : public Exception {
public:
ObjHeaderIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
ObjHeaderIException();
virtual ~ObjHeaderIException() throw();
virtual ~ObjHeaderIException() throw() H5_OVERRIDE;
};
class H5_DLLCPP PropListIException : public Exception {
public:
PropListIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
PropListIException();
virtual ~PropListIException() throw();
virtual ~PropListIException() throw() H5_OVERRIDE;
};
class H5_DLLCPP DataSetIException : public Exception {
public:
DataSetIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
DataSetIException();
virtual ~DataSetIException() throw();
virtual ~DataSetIException() throw() H5_OVERRIDE;
};
class H5_DLLCPP AttributeIException : public Exception {
public:
AttributeIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
AttributeIException();
virtual ~AttributeIException() throw();
virtual ~AttributeIException() throw() H5_OVERRIDE;
};
class H5_DLLCPP ReferenceException : public Exception {
public:
ReferenceException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
ReferenceException();
virtual ~ReferenceException() throw();
virtual ~ReferenceException() throw() H5_OVERRIDE;
};
class H5_DLLCPP LibraryIException : public Exception {
public:
LibraryIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
LibraryIException();
virtual ~LibraryIException() throw();
virtual ~LibraryIException() throw() H5_OVERRIDE;
};
class H5_DLLCPP LocationException : public Exception {
public:
LocationException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
LocationException();
virtual ~LocationException() throw();
virtual ~LocationException() throw() H5_OVERRIDE;
};
class H5_DLLCPP IdComponentException : public Exception {
public:
IdComponentException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
IdComponentException();
virtual ~IdComponentException() throw();
virtual ~IdComponentException() throw() H5_OVERRIDE;
}; // end of IdComponentException
} // namespace H5

View File

@ -39,7 +39,7 @@ class H5_DLLCPP H5File : public Group {
const FileAccPropList &access_plist = FileAccPropList::DEFAULT);
// Close this file.
virtual void close();
virtual void close() H5_OVERRIDE;
// Gets a copy of the access property list of this file.
FileAccPropList getAccessPlist() const;
@ -96,16 +96,16 @@ class H5_DLLCPP H5File : public Group {
///\brief Returns this class name.
virtual H5std_string
fromClass() const
fromClass() const H5_OVERRIDE
{
return ("H5File");
}
// Throw file exception.
virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const;
virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const H5_OVERRIDE;
// For CommonFG to get the file id.
virtual hid_t getLocId() const;
virtual hid_t getLocId() const H5_OVERRIDE;
// Default constructor
H5File();
@ -114,7 +114,7 @@ class H5_DLLCPP H5File : public Group {
H5File(const H5File &original);
// Gets the HDF5 file id.
virtual hid_t getId() const;
virtual hid_t getId() const H5_OVERRIDE;
// H5File destructor.
virtual ~H5File();
@ -122,7 +122,7 @@ class H5_DLLCPP H5File : public Group {
protected:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Sets the HDF5 file id.
virtual void p_setId(const hid_t new_id);
virtual void p_setId(const hid_t new_id) H5_OVERRIDE;
#endif // DOXYGEN_SHOULD_SKIP_THIS
private:

View File

@ -24,20 +24,20 @@ namespace H5 {
class H5_DLLCPP Group : public H5Object, public CommonFG {
public:
// Close this group.
virtual void close();
virtual void close() H5_OVERRIDE;
///\brief Returns this class name.
virtual H5std_string
fromClass() const
fromClass() const H5_OVERRIDE
{
return ("Group");
}
// Throw group exception.
virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const;
virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const H5_OVERRIDE;
// for CommonFG to get the file id.
virtual hid_t getLocId() const;
virtual hid_t getLocId() const H5_OVERRIDE;
// Creates a group by way of dereference.
Group(const H5Location &loc, const void *ref, H5R_type_t ref_type = H5R_OBJECT,
@ -63,10 +63,10 @@ class H5_DLLCPP Group : public H5Object, public CommonFG {
Group(const Group &original);
// Gets the group id.
virtual hid_t getId() const;
virtual hid_t getId() const H5_OVERRIDE;
// Destructor
virtual ~Group();
virtual ~Group() H5_OVERRIDE;
// Creates a copy of an existing group using its id.
Group(const hid_t group_id);
@ -74,7 +74,7 @@ class H5_DLLCPP Group : public H5Object, public CommonFG {
protected:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Sets the group id.
virtual void p_setId(const hid_t new_id);
virtual void p_setId(const hid_t new_id) H5_OVERRIDE;
#endif // DOXYGEN_SHOULD_SKIP_THIS
private:

View File

@ -24,3 +24,10 @@
* magic number as prefix and checksum as suffix for all chunks.
*/
#define H5O_VERSION_2 2
// Define H5_OVERRIDE to override for C++11.
#if defined(__cplusplus) && (201103L <= __cplusplus)
#define H5_OVERRIDE override
#else
#define H5_OVERRIDE
#endif

View File

@ -106,7 +106,7 @@ class H5_DLLCPP H5Object : public H5Location {
void removeAttr(const H5std_string &name) const;
// Returns an identifier.
virtual hid_t getId() const = 0;
virtual hid_t getId() const H5_OVERRIDE = 0;
// Gets the name of this HDF5 object, i.e., Group, DataSet, or
// DataType.
@ -122,10 +122,10 @@ class H5_DLLCPP H5Object : public H5Location {
// Sets the identifier of this object to a new value. - this one
// doesn't increment reference count
virtual void p_setId(const hid_t new_id) = 0;
virtual void p_setId(const hid_t new_id) H5_OVERRIDE = 0;
// Noop destructor.
virtual ~H5Object();
virtual ~H5Object() H5_OVERRIDE;
#endif // DOXYGEN_SHOULD_SKIP_THIS