Browse Source

Remove USE_NOTHROW and make ConversionException inline

sendfile
Martchus 4 years ago
parent
commit
f40a800107
  1. 4
      application/failure.cpp
  2. 4
      application/failure.h
  3. 14
      application/global.h
  4. 24
      conversion/conversionexception.cpp
  5. 34
      conversion/conversionexception.h

4
application/failure.cpp

@ -33,7 +33,7 @@ Failure::Failure(const std::string &what)
/*!
* Destroys the Failure.
*/
Failure::~Failure() USE_NOTHROW
Failure::~Failure() noexcept
{
}
@ -41,7 +41,7 @@ Failure::~Failure() USE_NOTHROW
* Returns a C-style character string describing the cause
* of the Failure.
*/
const char *Failure::what() const USE_NOTHROW
const char *Failure::what() const noexcept
{
return m_what.c_str();
}

4
application/failure.h

@ -13,9 +13,9 @@ class CPP_UTILITIES_EXPORT Failure : public std::exception {
public:
Failure();
Failure(const std::string &what);
~Failure() USE_NOTHROW;
~Failure() noexcept;
virtual const char *what() const USE_NOTHROW;
virtual const char *what() const noexcept;
private:
std::string m_what;

14
application/global.h

@ -84,20 +84,6 @@
#define LIB_HIDDEN __attribute__((visibility("hidden")))
#endif
/*!
* \def USE_NOTHROW
* \brief Marks a function as never throwing, under no circumstances.
* \remarks If the function does nevertheless throw, the behaviour is undefined.
*/
#ifndef USE_NOTHROW
#if __cplusplus >= 201103L
#define USE_NOTHROW noexcept
#else
#define USE_NOTHROW throw()
#endif
#endif
/*!
* \def DECLARE_ENUM
* \brief Declares an enum without preventing lupdate to parse the file correctly.

24
conversion/conversionexception.cpp

@ -2,31 +2,11 @@
namespace ConversionUtilities {
/*!
* \class ConversionUtilities::ConversionException
* \brief The ConversionException class is thrown by the various conversion
* functions of this library when a conversion error occurs.
*/
/*!
* \brief Constructs a new ConversionException.
*/
ConversionException::ConversionException() USE_NOTHROW : runtime_error("unable to convert")
{
}
/*!
* \brief Constructs a new ConversionException. \a what is a std::string
* describing the cause of the ConversionException.
*/
ConversionException::ConversionException(const std::string &what) USE_NOTHROW : runtime_error(what)
{
}
/*!
* \brief Destroys the ConversionException.
*/
ConversionException::~ConversionException() USE_NOTHROW
ConversionException::~ConversionException()
{
}
} // namespace ConversionUtilities

34
conversion/conversionexception.h

@ -10,17 +10,41 @@ namespace ConversionUtilities {
class CPP_UTILITIES_EXPORT ConversionException : public std::runtime_error {
public:
ConversionException() USE_NOTHROW;
ConversionException(const std::string &what) USE_NOTHROW;
ConversionException(const char *what) USE_NOTHROW;
~ConversionException() USE_NOTHROW;
ConversionException() noexcept;
ConversionException(const std::string &what) noexcept;
ConversionException(const char *what) noexcept;
~ConversionException() override;
};
/*!
* \class ConversionUtilities::ConversionException
* \brief The ConversionException class is thrown by the various conversion
* functions of this library when a conversion error occurs.
*/
/*!
* \brief Constructs a new ConversionException.
*/
inline ConversionException::ConversionException() noexcept
: runtime_error("unable to convert")
{
}
/*!
* \brief Constructs a new ConversionException. \a what is a std::string
* describing the cause of the ConversionException.
*/
inline ConversionException::ConversionException(const std::string &what) noexcept
: runtime_error(what)
{
}
/*!
* \brief Constructs a new ConversionException. \a what is a C-style string
* describing the cause of the ConversionException.
*/
inline ConversionException::ConversionException(const char *what) USE_NOTHROW : std::runtime_error(what)
inline ConversionException::ConversionException(const char *what) noexcept
: std::runtime_error(what)
{
}

Loading…
Cancel
Save