LGTM: [skip ci] fix: Inconsistent definition of copy constructor and assignment ('Rule of Two')

Remove user-defined copy constructor of Exception classes without assignment operator
This commit is contained in:
wmayer
2020-07-27 13:47:41 +02:00
parent 13fc0554a0
commit 9367e73e92
8 changed files with 8 additions and 232 deletions

View File

@@ -178,11 +178,6 @@ AbortException::AbortException()
_sErrMsg = "Aborted operation";
}
AbortException::AbortException(const AbortException &inst)
: Exception(inst)
{
}
const char* AbortException::what() const throw()
{
return Exception::what();
@@ -206,11 +201,6 @@ XMLBaseException::XMLBaseException(const std::string& sMessage)
{
}
XMLBaseException::XMLBaseException(const XMLBaseException &inst)
: Exception(inst)
{
}
// ---------------------------------------------------------
XMLParseException::XMLParseException(const char * sMessage)
@@ -228,11 +218,6 @@ XMLParseException::XMLParseException()
_sErrMsg = "XML parse exception";
}
XMLParseException::XMLParseException(const XMLParseException &inst)
: XMLBaseException(inst)
{
}
const char* XMLParseException::what() const throw()
{
return XMLBaseException::what();
@@ -255,11 +240,6 @@ XMLAttributeError::XMLAttributeError()
_sErrMsg = "XML attribute error";
}
XMLAttributeError::XMLAttributeError(const XMLAttributeError &inst)
: XMLBaseException(inst)
{
}
const char* XMLAttributeError::what() const throw()
{
return XMLBaseException::what();
@@ -373,11 +353,6 @@ FileSystemError::FileSystemError(const std::string& sMessage)
{
}
FileSystemError::FileSystemError(const FileSystemError &inst)
: Exception(inst)
{
}
// ---------------------------------------------------------
@@ -396,11 +371,6 @@ BadFormatError::BadFormatError(const std::string& sMessage)
{
}
BadFormatError::BadFormatError(const BadFormatError &inst)
: Exception(inst)
{
}
// ---------------------------------------------------------
@@ -418,6 +388,12 @@ MemoryException::MemoryException(const MemoryException &inst)
{
}
MemoryException & MemoryException::operator=(const MemoryException &inst)
{
Exception::operator = (inst);
return *this;
}
#if defined (__GNUC__)
const char* MemoryException::what() const throw()
{
@@ -443,11 +419,6 @@ AccessViolation::AccessViolation(const std::string& sMessage)
{
}
AccessViolation::AccessViolation(const AccessViolation &inst)
: Exception(inst)
{
}
// ---------------------------------------------------------
AbnormalProgramTermination::AbnormalProgramTermination()
@@ -465,11 +436,6 @@ AbnormalProgramTermination::AbnormalProgramTermination(const std::string& sMessa
{
}
AbnormalProgramTermination::AbnormalProgramTermination(const AbnormalProgramTermination &inst)
: Exception(inst)
{
}
// ---------------------------------------------------------
UnknownProgramOption::UnknownProgramOption()
@@ -487,11 +453,6 @@ UnknownProgramOption::UnknownProgramOption(const std::string& sMessage)
{
}
UnknownProgramOption::UnknownProgramOption(const UnknownProgramOption &inst)
: Exception(inst)
{
}
// ---------------------------------------------------------
ProgramInformation::ProgramInformation()
@@ -509,11 +470,6 @@ ProgramInformation::ProgramInformation(const std::string& sMessage)
{
}
ProgramInformation::ProgramInformation(const ProgramInformation &inst)
: Exception(inst)
{
}
// ---------------------------------------------------------
TypeError::TypeError()
@@ -531,11 +487,6 @@ TypeError::TypeError(const std::string& sMessage)
{
}
TypeError::TypeError(const TypeError &inst)
: Exception(inst)
{
}
PyObject *TypeError::getPyExceptionType() const {
return PyExc_TypeError;
}
@@ -557,11 +508,6 @@ ValueError::ValueError(const std::string& sMessage)
{
}
ValueError::ValueError(const ValueError &inst)
: Exception(inst)
{
}
PyObject *ValueError::getPyExceptionType() const {
return PyExc_ValueError;
}
@@ -583,11 +529,6 @@ IndexError::IndexError(const std::string& sMessage)
{
}
IndexError::IndexError(const IndexError &inst)
: Exception(inst)
{
}
PyObject *IndexError::getPyExceptionType() const {
return PyExc_IndexError;
}
@@ -609,11 +550,6 @@ NameError::NameError(const std::string& sMessage)
{
}
NameError::NameError(const NameError &inst)
: Exception(inst)
{
}
PyObject *NameError::getPyExceptionType() const {
return PyExc_NameError;
}
@@ -635,11 +571,6 @@ ImportError::ImportError(const std::string& sMessage)
{
}
ImportError::ImportError(const ImportError &inst)
: Exception(inst)
{
}
PyObject *ImportError::getPyExceptionType() const {
return PyExc_ImportError;
}
@@ -661,11 +592,6 @@ AttributeError::AttributeError(const std::string& sMessage)
{
}
AttributeError::AttributeError(const AttributeError &inst)
: Exception(inst)
{
}
PyObject *AttributeError::getPyExceptionType() const {
return PyExc_AttributeError;
}
@@ -687,11 +613,6 @@ RuntimeError::RuntimeError(const std::string& sMessage)
{
}
RuntimeError::RuntimeError(const RuntimeError &inst)
: Exception(inst)
{
}
PyObject *RuntimeError::getPyExceptionType() const {
return PyExc_RuntimeError;
}
@@ -713,11 +634,6 @@ BadGraphError::BadGraphError(const std::string& sMessage)
{
}
BadGraphError::BadGraphError(const BadGraphError &inst)
: RuntimeError(inst)
{
}
// ---------------------------------------------------------
NotImplementedError::NotImplementedError()
@@ -735,11 +651,6 @@ NotImplementedError::NotImplementedError(const std::string& sMessage)
{
}
NotImplementedError::NotImplementedError(const NotImplementedError &inst)
: Exception(inst)
{
}
PyObject *NotImplementedError::getPyExceptionType() const {
return PyExc_NotImplementedError;
}
@@ -761,11 +672,6 @@ DivisionByZeroError::DivisionByZeroError(const std::string& sMessage)
{
}
DivisionByZeroError::DivisionByZeroError(const DivisionByZeroError &inst)
: Exception(inst)
{
}
PyObject *DivisionByZeroError::getPyExceptionType() const {
return PyExc_ZeroDivisionError;
}
@@ -787,11 +693,6 @@ ReferencesError::ReferencesError(const std::string& sMessage)
{
}
ReferencesError::ReferencesError(const ReferencesError &inst)
: Exception(inst)
{
}
PyObject *ReferencesError::getPyExceptionType() const {
return PyExc_ReferenceError;
}
@@ -813,11 +714,6 @@ ExpressionError::ExpressionError(const std::string& sMessage)
{
}
ExpressionError::ExpressionError(const ExpressionError &inst)
: Exception(inst)
{
}
// ---------------------------------------------------------
ParserError::ParserError()
@@ -835,11 +731,6 @@ ParserError::ParserError(const std::string& sMessage)
{
}
ParserError::ParserError(const ParserError &inst)
: Exception(inst)
{
}
// ---------------------------------------------------------
UnicodeError::UnicodeError()
@@ -857,11 +748,6 @@ UnicodeError::UnicodeError(const std::string& sMessage)
{
}
UnicodeError::UnicodeError(const UnicodeError &inst)
: Exception(inst)
{
}
PyObject *UnicodeError::getPyExceptionType() const {
return PyExc_UnicodeError;
}
@@ -883,11 +769,6 @@ OverflowError::OverflowError(const std::string& sMessage)
{
}
OverflowError::OverflowError(const OverflowError &inst)
: Exception(inst)
{
}
PyObject *OverflowError::getPyExceptionType() const {
return PyExc_OverflowError;
}
@@ -909,11 +790,6 @@ UnderflowError::UnderflowError(const std::string& sMessage)
{
}
UnderflowError::UnderflowError(const UnderflowError &inst)
: Exception(inst)
{
}
PyObject *UnderflowError::getPyExceptionType() const {
return PyExc_ArithmeticError;
}
@@ -935,11 +811,6 @@ UnitsMismatchError::UnitsMismatchError(const std::string& sMessage)
{
}
UnitsMismatchError::UnitsMismatchError(const UnitsMismatchError &inst)
: Exception(inst)
{
}
PyObject *UnitsMismatchError::getPyExceptionType() const {
return PyExc_ArithmeticError;
}
@@ -961,12 +832,6 @@ CADKernelError::CADKernelError(const std::string& sMessage)
{
}
CADKernelError::CADKernelError(const CADKernelError &inst)
: Exception(inst)
{
}
// ---------------------------------------------------------
RestoreError::RestoreError()
@@ -984,12 +849,6 @@ RestoreError::RestoreError(const std::string& sMessage)
{
}
RestoreError::RestoreError(const RestoreError &inst)
: Exception(inst)
{
}
// ---------------------------------------------------------
#if defined(__GNUC__) && defined (FC_OS_LINUX)

View File

@@ -163,8 +163,6 @@ public:
AbortException(const char * sMessage);
/// Construction
AbortException();
/// Construction
AbortException(const AbortException &inst);
/// Destruction
virtual ~AbortException() throw() {}
@@ -183,8 +181,6 @@ public:
XMLBaseException();
XMLBaseException(const char * sMessage);
XMLBaseException(const std::string& sMessage);
/// Construction
XMLBaseException(const XMLBaseException &inst);
/// Destruction
virtual ~XMLBaseException() throw() {}
@@ -203,8 +199,6 @@ public:
XMLParseException(const std::string& sMessage);
/// Construction
XMLParseException();
/// Construction
XMLParseException(const XMLParseException &inst);
/// Destruction
virtual ~XMLParseException() throw() {}
@@ -225,8 +219,6 @@ public:
XMLAttributeError(const std::string& sMessage);
/// Construction
XMLAttributeError();
/// Construction
XMLAttributeError(const XMLAttributeError &inst);
/// Destruction
virtual ~XMLAttributeError() throw() {}
@@ -284,8 +276,6 @@ public:
FileSystemError();
FileSystemError(const char * sMessage);
FileSystemError(const std::string& sMessage);
/// Construction
FileSystemError(const FileSystemError &inst);
/// Destruction
virtual ~FileSystemError() throw() {}
};
@@ -301,8 +291,6 @@ public:
BadFormatError();
BadFormatError(const char * sMessage);
BadFormatError(const std::string& sMessage);
/// Construction
BadFormatError(const BadFormatError &inst);
/// Destruction
virtual ~BadFormatError() throw() {}
};
@@ -325,6 +313,8 @@ public:
MemoryException(const MemoryException &inst);
/// Destruction
virtual ~MemoryException() throw() {}
/// Assignment operator
MemoryException &operator=(const MemoryException &inst);
#if defined (__GNUC__)
/// Description of the exception
virtual const char* what() const throw() override;
@@ -342,8 +332,6 @@ public:
AccessViolation();
AccessViolation(const char * sMessage);
AccessViolation(const std::string& sMessage);
/// Construction
AccessViolation(const AccessViolation &inst);
/// Destruction
virtual ~AccessViolation() throw() {}
};
@@ -360,7 +348,6 @@ public:
/// Construction
AbnormalProgramTermination(const char * sMessage);
AbnormalProgramTermination(const std::string& sMessage);
AbnormalProgramTermination(const AbnormalProgramTermination &inst);
/// Destruction
virtual ~AbnormalProgramTermination() throw() {}
};
@@ -376,8 +363,6 @@ public:
UnknownProgramOption();
UnknownProgramOption(const char * sMessage);
UnknownProgramOption(const std::string& sMessage);
/// Construction
UnknownProgramOption(const UnknownProgramOption &inst);
/// Destruction
virtual ~UnknownProgramOption() throw() {}
};
@@ -393,8 +378,6 @@ public:
ProgramInformation();
ProgramInformation(const char * sMessage);
ProgramInformation(const std::string& sMessage);
/// Construction
ProgramInformation(const ProgramInformation &inst);
/// Destruction
virtual ~ProgramInformation() throw() {}
@@ -411,8 +394,6 @@ public:
TypeError();
TypeError(const char * sMessage);
TypeError(const std::string& sMessage);
/// Construction
TypeError(const TypeError &inst);
/// Destruction
virtual ~TypeError() throw() {}
virtual PyObject * getPyExceptionType() const override;
@@ -429,8 +410,6 @@ public:
ValueError();
ValueError(const char * sMessage);
ValueError(const std::string& sMessage);
/// Construction
ValueError(const ValueError &inst);
/// Destruction
virtual ~ValueError() throw() {}
virtual PyObject * getPyExceptionType() const override;
@@ -447,8 +426,6 @@ public:
IndexError();
IndexError(const char * sMessage);
IndexError(const std::string& sMessage);
/// Construction
IndexError(const IndexError &inst);
/// Destruction
virtual ~IndexError() throw() {}
virtual PyObject * getPyExceptionType() const override;
@@ -461,8 +438,6 @@ public:
NameError();
NameError(const char * sMessage);
NameError(const std::string& sMessage);
/// Construction
NameError(const NameError &inst);
/// Destruction
virtual ~NameError() throw() {}
virtual PyObject * getPyExceptionType() const override;
@@ -475,8 +450,6 @@ public:
ImportError();
ImportError(const char * sMessage);
ImportError(const std::string& sMessage);
/// Construction
ImportError(const ImportError &inst);
/// Destruction
virtual ~ImportError() throw() {}
virtual PyObject * getPyExceptionType() const override;
@@ -493,8 +466,6 @@ public:
AttributeError();
AttributeError(const char * sMessage);
AttributeError(const std::string& sMessage);
/// Construction
AttributeError(const AttributeError &inst);
/// Destruction
virtual ~AttributeError() throw() {}
virtual PyObject * getPyExceptionType() const override;
@@ -511,8 +482,6 @@ public:
RuntimeError();
RuntimeError(const char * sMessage);
RuntimeError(const std::string& sMessage);
/// Construction
RuntimeError(const RuntimeError &inst);
/// Destruction
virtual ~RuntimeError() throw() {}
virtual PyObject * getPyExceptionType() const override;
@@ -529,8 +498,6 @@ public:
BadGraphError();
BadGraphError(const char * sMessage);
BadGraphError(const std::string& sMessage);
/// Construction
BadGraphError(const BadGraphError &inst);
/// Destruction
virtual ~BadGraphError() throw() {}
};
@@ -546,8 +513,6 @@ public:
NotImplementedError();
NotImplementedError(const char * sMessage);
NotImplementedError(const std::string& sMessage);
/// Construction
NotImplementedError(const NotImplementedError &inst);
/// Destruction
virtual ~NotImplementedError() throw() {}
virtual PyObject * getPyExceptionType() const override;
@@ -564,8 +529,6 @@ public:
DivisionByZeroError();
DivisionByZeroError(const char * sMessage);
DivisionByZeroError(const std::string& sMessage);
/// Construction
DivisionByZeroError(const DivisionByZeroError &inst);
/// Destruction
virtual ~DivisionByZeroError() throw() {}
virtual PyObject * getPyExceptionType() const override;
@@ -582,8 +545,6 @@ public:
ReferencesError();
ReferencesError(const char * sMessage);
ReferencesError(const std::string& sMessage);
/// Construction
ReferencesError(const ReferencesError &inst);
/// Destruction
virtual ~ReferencesError() throw() {}
virtual PyObject * getPyExceptionType() const override;
@@ -601,8 +562,6 @@ public:
ExpressionError();
ExpressionError(const char * sMessage);
ExpressionError(const std::string& sMessage);
/// Construction
ExpressionError(const ExpressionError &inst);
/// Destruction
virtual ~ExpressionError() throw() {}
};
@@ -618,8 +577,6 @@ public:
ParserError();
ParserError(const char * sMessage);
ParserError(const std::string& sMessage);
/// Construction
ParserError(const ParserError &inst);
/// Destruction
virtual ~ParserError() throw() {}
};
@@ -635,8 +592,6 @@ public:
UnicodeError();
UnicodeError(const char * sMessage);
UnicodeError(const std::string& sMessage);
/// Construction
UnicodeError(const UnicodeError &inst);
/// Destruction
virtual ~UnicodeError() throw() {}
virtual PyObject * getPyExceptionType() const override;
@@ -653,8 +608,6 @@ public:
OverflowError();
OverflowError(const char * sMessage);
OverflowError(const std::string& sMessage);
/// Construction
OverflowError(const OverflowError &inst);
/// Destruction
virtual ~OverflowError() throw() {}
virtual PyObject * getPyExceptionType() const override;
@@ -671,8 +624,6 @@ public:
UnderflowError();
UnderflowError(const char * sMessage);
UnderflowError(const std::string& sMessage);
/// Construction
UnderflowError(const UnderflowError &inst);
/// Destruction
virtual ~UnderflowError() throw() {}
virtual PyObject * getPyExceptionType() const override;
@@ -689,8 +640,6 @@ public:
UnitsMismatchError();
UnitsMismatchError(const char * sMessage);
UnitsMismatchError(const std::string& sMessage);
/// Construction
UnitsMismatchError(const UnitsMismatchError &inst);
/// Destruction
virtual ~UnitsMismatchError() throw() {}
virtual PyObject * getPyExceptionType() const override;
@@ -708,8 +657,6 @@ public:
CADKernelError();
CADKernelError(const char * sMessage);
CADKernelError(const std::string& sMessage);
/// Construction
CADKernelError(const CADKernelError &inst);
/// Destruction
virtual ~CADKernelError() throw() {}
};
@@ -728,8 +675,6 @@ public:
RestoreError();
RestoreError(const char * sMessage);
RestoreError(const std::string& sMessage);
/// Construction
RestoreError(const RestoreError &inst);
/// Destruction
virtual ~RestoreError() throw() {}
};

View File

@@ -208,12 +208,6 @@ SystemExitException::SystemExitException()
_exitCode = errCode;
}
SystemExitException::SystemExitException(const SystemExitException &inst)
: Exception(inst), _exitCode(inst._exitCode)
{
}
// ---------------------------------------------------------
// Fixes #0000831: python print causes File descriptor error on windows

View File

@@ -145,7 +145,6 @@ class BaseExport SystemExitException : public Exception
{
public:
SystemExitException(void);
SystemExitException(const SystemExitException &inst);
virtual ~SystemExitException() throw() {}
long getExitCode(void) const { return _exitCode;}