Skip to content

Commit

Permalink
Formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier committed Mar 14, 2024
1 parent 5c52ff3 commit 364b1f0
Show file tree
Hide file tree
Showing 26 changed files with 550 additions and 612 deletions.
5 changes: 5 additions & 0 deletions cpp/include/Ice/Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ namespace Ice
*/
static std::string_view ice_staticId() noexcept;

/**
* Throws this exception.
*/
virtual void ice_throw() const = 0;

/// \cond STREAM
virtual void _write(::Ice::OutputStream*) const;
virtual void _read(::Ice::InputStream*);
Expand Down
20 changes: 4 additions & 16 deletions cpp/include/Ice/ExceptionHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,18 @@

namespace Ice
{
class LocalException;

/**
* Helper template for the implementation of Ice::LocalException. It implements ice_id.
* Helper template for the implementation of Ice::UserException. It implements ice_id and ice_throw.
* \headerfile Ice/Ice.h
*/
template<typename T, typename B> class LocalExceptionHelper : public IceUtil::ExceptionHelper<T, B>
template<typename T, typename B> class UserExceptionHelper : public B
{
public:
using IceUtil::ExceptionHelper<T, B>::ExceptionHelper;
using B::B;

std::string ice_id() const override { return std::string{T::ice_staticId()}; }
};

/**
* Helper template for the implementation of Ice::UserException. It implements ice_id.
* \headerfile Ice/Ice.h
*/
template<typename T, typename B> class UserExceptionHelper : public IceUtil::ExceptionHelper<T, B>
{
public:
using IceUtil::ExceptionHelper<T, B>::ExceptionHelper;

std::string ice_id() const override { return std::string{T::ice_staticId()}; }
void ice_throw() const override { throw static_cast<const T&>(*this); }

protected:
/// \cond STREAM
Expand Down
12 changes: 7 additions & 5 deletions cpp/include/Ice/IconvStringConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,36 @@ namespace Ice
* Indicates that Iconv does not support the code.
* \headerfile Ice/Ice.h
*/
class ICE_API IconvInitializationException : public IceUtil::ExceptionHelper<IconvInitializationException>
class ICE_API IconvInitializationException : public IceUtil::Exception
{
public:
using IceUtil::Exception::Exception;

/**
* Constructs the exception with a reason. The file and line number are required.
* @param file The file name in which the exception was raised, typically __FILE__.
* @param line The line number at which the exception was raised, typically __LINE__.
* @param reason More detail about the failure.
*/
IconvInitializationException(const char* file, int line, const std::string& reason);
IconvInitializationException(const char* file, int line, std::string reason) noexcept;

/**
* Obtains the Slice type ID of this exception.
* @return The fully-scoped type ID.
*/
virtual std::string ice_id() const;
std::string ice_id() const override;

/**
* Prints a description of this exception to the given stream.
* @param str The output stream.
*/
virtual void ice_print(std::ostream& str) const;
void ice_print(std::ostream& str) const override;

/**
* Obtains the reason for the failure.
* @return The reason.
*/
std::string reason() const;
std::string reason() const noexcept;

private:
std::string _reason;
Expand Down
3 changes: 0 additions & 3 deletions cpp/include/Ice/LocalException.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ namespace Ice
public:
using Exception::Exception;

// temporary
void ice_throw() const final { assert(false); }

/**
* Obtains the Slice type ID of this exception.
* @return The fully-scoped type ID.
Expand Down
24 changes: 15 additions & 9 deletions cpp/include/IceSSL/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,14 @@ namespace IceSSL
* Thrown if the certificate cannot be read.
* \headerfile IceSSL/IceSSL.h
*/
class ICESSL_API CertificateReadException : public IceUtil::ExceptionHelper<CertificateReadException>
class ICESSL_API CertificateReadException : public Ice::Exception
{
public:
CertificateReadException(const char*, int, const std::string&);
using Ice::Exception::Exception;

virtual std::string ice_id() const;
CertificateReadException(const char*, int, std::string) noexcept;

std::string ice_id() const override;

/** The reason for the exception. */
std::string reason;
Expand All @@ -167,12 +169,14 @@ namespace IceSSL
* Thrown if the certificate cannot be encoded.
* \headerfile IceSSL/IceSSL.h
*/
class ICESSL_API CertificateEncodingException : public IceUtil::ExceptionHelper<CertificateEncodingException>
class ICESSL_API CertificateEncodingException : public Ice::Exception
{
public:
CertificateEncodingException(const char*, int, const std::string&);
using Ice::Exception::Exception;

CertificateEncodingException(const char*, int, std::string) noexcept;

virtual std::string ice_id() const;
std::string ice_id() const override;

/** The reason for the exception. */
std::string reason;
Expand All @@ -185,12 +189,14 @@ namespace IceSSL
* This exception is thrown if a distinguished name cannot be parsed.
* \headerfile IceSSL/IceSSL.h
*/
class ICESSL_API ParseException : public IceUtil::ExceptionHelper<ParseException>
class ICESSL_API ParseException : public Ice::Exception
{
public:
ParseException(const char*, int, const std::string&);
using Ice::Exception::Exception;

ParseException(const char*, int, std::string) noexcept;

virtual std::string ice_id() const;
std::string ice_id() const override;

/** The reason for the exception. */
std::string reason;
Expand Down
7 changes: 4 additions & 3 deletions cpp/include/IceUtil/CtrlCHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ namespace IceUtil
*
* \headerfile Ice/Ice.h
*/
class ICE_API CtrlCHandlerException : public ExceptionHelper<CtrlCHandlerException>
class ICE_API CtrlCHandlerException final : public Exception
{
public:
CtrlCHandlerException(const char*, int);
virtual std::string ice_id() const;
using Exception::Exception;

std::string ice_id() const final;
};
}

Expand Down
58 changes: 20 additions & 38 deletions cpp/include/IceUtil/Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ namespace IceUtil
*/
virtual const char* what() const noexcept;

/**
* Throws this exception.
*/
virtual void ice_throw() const = 0;

/**
* Returns the name of the file where this exception was constructed.
* @return The file name.
Expand Down Expand Up @@ -84,41 +79,26 @@ namespace IceUtil

ICE_API std::ostream& operator<<(std::ostream&, const Exception&);

/**
* Helper template for the implementation of Ice::Exception.
* It implements ice_throw.
* \headerfile Ice/Ice.h
*/
// We generate a text graph, because the inheritance graph for this type has too many nodes.
/// \inheritancegraph{TEXT}
template<typename E, typename B = Exception> class ExceptionHelper : public B
{
public:
using B::B;

virtual void ice_throw() const override { throw static_cast<const E&>(*this); }
};

/**
* This exception indicates that a function was called with an illegal parameter
* value. It is used only by the Slice to C++98 mapping; std::invalid_argument is
* used by the Slice to C++11 mapping.
* \headerfile Ice/Ice.h
*/
class ICE_API IllegalArgumentException : public ExceptionHelper<IllegalArgumentException>
class ICE_API IllegalArgumentException : public Exception
{
public:
IllegalArgumentException(const char*, int);
IllegalArgumentException(const char*, int, const std::string&);
using Exception::Exception;
IllegalArgumentException(const char*, int, std::string) noexcept;

virtual std::string ice_id() const;
virtual void ice_print(std::ostream&) const;
std::string ice_id() const override;
void ice_print(std::ostream&) const override;

/**
* Provides the reason this exception was thrown.
* @return The reason.
*/
std::string reason() const;
std::string reason() const noexcept;

private:
const std::string _reason;
Expand All @@ -128,20 +108,20 @@ namespace IceUtil
* This exception indicates the failure of a string conversion.
* \headerfile Ice/Ice.h
*/
class ICE_API IllegalConversionException : public ExceptionHelper<IllegalConversionException>
class ICE_API IllegalConversionException : public Exception
{
public:
IllegalConversionException(const char*, int);
IllegalConversionException(const char*, int, const std::string&);
using Exception::Exception;
IllegalConversionException(const char*, int, std::string) noexcept;

virtual std::string ice_id() const;
virtual void ice_print(std::ostream&) const;
std::string ice_id() const override;
void ice_print(std::ostream&) const override;

/**
* Provides the reason this exception was thrown.
* @return The reason.
*/
std::string reason() const;
std::string reason() const noexcept;

private:
const std::string _reason;
Expand All @@ -151,25 +131,27 @@ namespace IceUtil
* This exception indicates the failure to lock a file.
* \headerfile Ice/Ice.h
*/
class ICE_API FileLockException : public ExceptionHelper<FileLockException>
class ICE_API FileLockException : public Exception
{
public:
FileLockException(const char*, int, int, const std::string&);
using Exception::Exception;

FileLockException(const char*, int, int, std::string) noexcept;

virtual std::string ice_id() const;
virtual void ice_print(std::ostream&) const;
std::string ice_id() const override;
void ice_print(std::ostream&) const override;

/**
* Returns the path to the file.
* @return The file path.
*/
std::string path() const;
const std::string& path() const noexcept;

/**
* Returns the error number for the failed locking attempt.
* @return The error number.
*/
int error() const;
int error() const noexcept;

private:
const int _error;
Expand Down
22 changes: 12 additions & 10 deletions cpp/include/IceUtil/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,27 @@

namespace IceUtilInternal
{
class ICE_API APIException : public IceUtil::ExceptionHelper<APIException>
class ICE_API APIException : public IceUtil::Exception
{
public:
APIException(const char*, int, const ::std::string&);
virtual ::std::string ice_id() const;
virtual void ice_print(std::ostream&) const;
::std::string reason;
using IceUtil::Exception::Exception;
APIException(const char*, int, std::string) noexcept;
std::string ice_id() const override;
void ice_print(std::ostream&) const override;
std::string reason;
};

ICE_API ::std::ostream& operator<<(::std::ostream&, const APIException&);

class ICE_API BadOptException : public IceUtil::ExceptionHelper<BadOptException>
class ICE_API BadOptException : public IceUtil::Exception
{
public:
BadOptException(const char*, int, const ::std::string&);
virtual ::std::string ice_id() const;
virtual void ice_print(std::ostream&) const;
using IceUtil::Exception::Exception;
BadOptException(const char*, int, std::string) noexcept;
std::string ice_id() const override;
void ice_print(std::ostream&) const override;

::std::string reason;
std::string reason;
};

ICE_API ::std::ostream& operator<<(::std::ostream&, const BadOptException&);
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/Ice/IconvStringConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ using namespace std;
using namespace Ice;
using namespace IceUtil;

IconvInitializationException::IconvInitializationException(const char* file, int line, const string& reason)
: ExceptionHelper<IconvInitializationException>(file, line),
_reason(reason)
IconvInitializationException::IconvInitializationException(const char* file, int line, string reason) noexcept
: Exception(file, line),
_reason(std::move(reason))
{
}

Expand All @@ -30,7 +30,7 @@ IconvInitializationException::ice_id() const
}

string
IconvInitializationException::reason() const
IconvInitializationException::reason() const noexcept
{
return _reason;
}
Expand Down
18 changes: 9 additions & 9 deletions cpp/src/IceSSL/CertificateI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ const CertificateOID IceSSL::certificateOIDS[] = {
{"0.9.2342.19200300.100.1.25", "DC"}};
const int IceSSL::certificateOIDSSize = sizeof(IceSSL::certificateOIDS) / sizeof(CertificateOID);

CertificateReadException::CertificateReadException(const char* file, int line, const string& r)
: IceUtil::ExceptionHelper<CertificateReadException>(file, line),
reason(r)
CertificateReadException::CertificateReadException(const char* file, int line, string r) noexcept
: Exception(file, line),
reason(std::move(r))
{
}

Expand All @@ -52,9 +52,9 @@ CertificateReadException::ice_id() const
return "::IceSSL::CertificateReadException";
}

CertificateEncodingException::CertificateEncodingException(const char* file, int line, const string& r)
: IceUtil::ExceptionHelper<CertificateEncodingException>(file, line),
reason(r)
CertificateEncodingException::CertificateEncodingException(const char* file, int line, string r) noexcept
: Exception(file, line),
reason(std::move(r))
{
}

Expand All @@ -64,9 +64,9 @@ CertificateEncodingException::ice_id() const
return "::IceSSL::CertificateEncodingException";
}

ParseException::ParseException(const char* file, int line, const string& r)
: IceUtil::ExceptionHelper<ParseException>(file, line),
reason(r)
ParseException::ParseException(const char* file, int line, string r) noexcept
: Exception(file, line),
reason(std::move(r))
{
}

Expand Down
Loading

0 comments on commit 364b1f0

Please sign in to comment.