diff --git a/src/lib/arch/XArch.h b/src/lib/arch/XArch.h index 457c620d..8484d060 100644 --- a/src/lib/arch/XArch.h +++ b/src/lib/arch/XArch.h @@ -20,7 +20,7 @@ #include "common/common.h" #include "common/stdstring.h" -#include "common/stdexcept.h" +#include //! Generic thread exception /*! @@ -56,7 +56,7 @@ string for that error code. class XArchEval { public: XArchEval() { } - virtual ~XArchEval() _NOEXCEPT { } + virtual ~XArchEval() noexcept { } virtual std::string eval() const = 0; }; @@ -66,7 +66,7 @@ class XArch : public std::runtime_error { public: XArch(XArchEval* adopted) : std::runtime_error(adopted->eval()) { delete adopted; } XArch(const std::string& msg) : std::runtime_error(msg) { } - virtual ~XArch() _NOEXCEPT { } + virtual ~XArch() noexcept { } }; // Macro to declare XArch derived types diff --git a/src/lib/arch/unix/XArchUnix.h b/src/lib/arch/unix/XArchUnix.h index ae62f4c8..93d6d629 100644 --- a/src/lib/arch/unix/XArchUnix.h +++ b/src/lib/arch/unix/XArchUnix.h @@ -24,7 +24,7 @@ class XArchEvalUnix : public XArchEval { public: XArchEvalUnix(int error) : m_error(error) { } - virtual ~XArchEvalUnix() _NOEXCEPT { } + virtual ~XArchEvalUnix() noexcept { } virtual std::string eval() const; diff --git a/src/lib/arch/win32/XArchWindows.cpp b/src/lib/arch/win32/XArchWindows.cpp index f41c5dff..a25f019b 100644 --- a/src/lib/arch/win32/XArchWindows.cpp +++ b/src/lib/arch/win32/XArchWindows.cpp @@ -24,7 +24,7 @@ // std::string -XArchEvalWindows::eval() const throw() +XArchEvalWindows::eval() const noexcept { char* cmsg; if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | @@ -50,7 +50,7 @@ XArchEvalWindows::eval() const throw() // std::string -XArchEvalWinsock::eval() const throw() +XArchEvalWinsock::eval() const noexcept { // built-in windows function for looking up error message strings // may not look up network error messages correctly. we'll have diff --git a/src/lib/barrier/PlatformScreen.h b/src/lib/barrier/PlatformScreen.h index 82cbfaa6..f8d0cf98 100644 --- a/src/lib/barrier/PlatformScreen.h +++ b/src/lib/barrier/PlatformScreen.h @@ -20,7 +20,6 @@ #include "barrier/IPlatformScreen.h" #include "barrier/DragInformation.h" -#include "common/stdexcept.h" //! Base screen implementation /*! diff --git a/src/lib/barrier/ProtocolUtil.cpp b/src/lib/barrier/ProtocolUtil.cpp index 07e828f4..e742687f 100644 --- a/src/lib/barrier/ProtocolUtil.cpp +++ b/src/lib/barrier/ProtocolUtil.cpp @@ -539,7 +539,7 @@ ProtocolUtil::read(barrier::IStream* stream, void* vbuffer, UInt32 count) // String -XIOReadMismatch::getWhat() const throw() +XIOReadMismatch::getWhat() const noexcept { return format("XIOReadMismatch", "ProtocolUtil::readf() mismatch"); } diff --git a/src/lib/barrier/ProtocolUtil.h b/src/lib/barrier/ProtocolUtil.h index ba639ed6..9930cfc0 100644 --- a/src/lib/barrier/ProtocolUtil.h +++ b/src/lib/barrier/ProtocolUtil.h @@ -92,5 +92,5 @@ match the format. class XIOReadMismatch : public XIO { public: // XBase overrides - virtual std::string getWhat() const throw(); + virtual std::string getWhat() const noexcept; }; diff --git a/src/lib/barrier/StreamChunker.cpp b/src/lib/barrier/StreamChunker.cpp index 8b8971c0..579d02ff 100644 --- a/src/lib/barrier/StreamChunker.cpp +++ b/src/lib/barrier/StreamChunker.cpp @@ -29,9 +29,9 @@ #include "base/Log.h" #include "base/Stopwatch.h" #include "base/String.h" -#include "common/stdexcept.h" #include +#include using namespace std; diff --git a/src/lib/barrier/XBarrier.cpp b/src/lib/barrier/XBarrier.cpp index 49a015ec..7fe35778 100644 --- a/src/lib/barrier/XBarrier.cpp +++ b/src/lib/barrier/XBarrier.cpp @@ -23,8 +23,7 @@ // XBadClient // -String -XBadClient::getWhat() const throw() +String XBadClient::getWhat() const noexcept { return "XBadClient"; } @@ -41,20 +40,17 @@ XIncompatibleClient::XIncompatibleClient(int major, int minor) : // do nothing } -int -XIncompatibleClient::getMajor() const throw() +int XIncompatibleClient::getMajor() const noexcept { return m_major; } -int -XIncompatibleClient::getMinor() const throw() +int XIncompatibleClient::getMinor() const noexcept { return m_minor; } -String -XIncompatibleClient::getWhat() const throw() +String XIncompatibleClient::getWhat() const noexcept { return format("XIncompatibleClient", "incompatible client %{1}.%{2}", barrier::string::sprintf("%d", m_major).c_str(), @@ -72,14 +68,12 @@ XDuplicateClient::XDuplicateClient(const String& name) : // do nothing } -const String& -XDuplicateClient::getName() const throw() +const String& XDuplicateClient::getName() const noexcept { return m_name; } -String -XDuplicateClient::getWhat() const throw() +String XDuplicateClient::getWhat() const noexcept { return format("XDuplicateClient", "duplicate client %{1}", m_name.c_str()); } @@ -95,14 +89,12 @@ XUnknownClient::XUnknownClient(const String& name) : // do nothing } -const String& -XUnknownClient::getName() const throw() +const String& XUnknownClient::getName() const noexcept { return m_name; } -String -XUnknownClient::getWhat() const throw() +String XUnknownClient::getWhat() const noexcept { return format("XUnknownClient", "unknown client %{1}", m_name.c_str()); } @@ -118,14 +110,12 @@ XExitApp::XExitApp(int code) : // do nothing } -int -XExitApp::getCode() const throw() +int XExitApp::getCode() const noexcept { return m_code; } -String -XExitApp::getWhat() const throw() +String XExitApp::getWhat() const noexcept { return format( "XExitApp", "exiting with code %{1}", diff --git a/src/lib/barrier/XBarrier.h b/src/lib/barrier/XBarrier.h index 8b19f399..fef931e5 100644 --- a/src/lib/barrier/XBarrier.h +++ b/src/lib/barrier/XBarrier.h @@ -47,14 +47,14 @@ public: //@{ //! Get client's major version number - int getMajor() const throw(); + int getMajor() const noexcept; //! Get client's minor version number - int getMinor() const throw(); + int getMinor() const noexcept; //@} protected: - virtual std::string getWhat() const throw(); + virtual std::string getWhat() const noexcept; private: int m_major; @@ -69,18 +69,18 @@ a client that is already connected. class XDuplicateClient : public XBarrier { public: XDuplicateClient(const std::string& name); - virtual ~XDuplicateClient() _NOEXCEPT { } + virtual ~XDuplicateClient() noexcept { } //! @name accessors //@{ //! Get client's name - virtual const std::string& getName() const throw(); + virtual const std::string& getName() const noexcept; //@} protected: - virtual std::string getWhat() const throw(); + virtual std::string getWhat() const noexcept; private: std::string m_name; @@ -94,18 +94,18 @@ unknown to the server. class XUnknownClient : public XBarrier { public: XUnknownClient(const std::string& name); - virtual ~XUnknownClient() _NOEXCEPT { } + virtual ~XUnknownClient() noexcept { } //! @name accessors //@{ //! Get the client's name - virtual const std::string& getName() const throw(); + virtual const std::string& getName() const noexcept; //@} protected: - virtual std::string getWhat() const throw(); + virtual std::string getWhat() const noexcept; private: std::string m_name; @@ -120,13 +120,13 @@ exit(int). class XExitApp : public XBarrier { public: XExitApp(int code); - virtual ~XExitApp() _NOEXCEPT { } + virtual ~XExitApp() noexcept { } //! Get the exit code - int getCode() const throw(); + int getCode() const noexcept; protected: - virtual std::string getWhat() const throw(); + virtual std::string getWhat() const noexcept; private: int m_code; diff --git a/src/lib/barrier/XScreen.cpp b/src/lib/barrier/XScreen.cpp index cb8e3159..3398423d 100644 --- a/src/lib/barrier/XScreen.cpp +++ b/src/lib/barrier/XScreen.cpp @@ -22,7 +22,7 @@ // XScreenOpenFailure // -std::string XScreenOpenFailure::getWhat() const throw() +std::string XScreenOpenFailure::getWhat() const noexcept { return format("XScreenOpenFailure", "unable to open screen"); } @@ -32,7 +32,7 @@ std::string XScreenOpenFailure::getWhat() const throw() // XScreenXInputFailure // -std::string XScreenXInputFailure::getWhat() const throw() +std::string XScreenXInputFailure::getWhat() const noexcept { return ""; } @@ -48,7 +48,7 @@ XScreenUnavailable::XScreenUnavailable(double timeUntilRetry) : // do nothing } -XScreenUnavailable::~XScreenUnavailable() _NOEXCEPT +XScreenUnavailable::~XScreenUnavailable() noexcept { // do nothing } @@ -59,7 +59,7 @@ XScreenUnavailable::getRetryTime() const return m_timeUntilRetry; } -std::string XScreenUnavailable::getWhat() const throw() +std::string XScreenUnavailable::getWhat() const noexcept { return format("XScreenUnavailable", "unable to open screen"); } diff --git a/src/lib/barrier/XScreen.h b/src/lib/barrier/XScreen.h index 87879833..f8fe7a78 100644 --- a/src/lib/barrier/XScreen.h +++ b/src/lib/barrier/XScreen.h @@ -47,7 +47,7 @@ public: trying to open the screen again. */ XScreenUnavailable(double timeUntilRetry); - virtual ~XScreenUnavailable() _NOEXCEPT; + virtual ~XScreenUnavailable() noexcept; //! @name manipulators //@{ @@ -61,7 +61,7 @@ public: //@} protected: - virtual std::string getWhat() const throw(); + virtual std::string getWhat() const noexcept; private: double m_timeUntilRetry; diff --git a/src/lib/base/XBase.cpp b/src/lib/base/XBase.cpp index cb9dc2ab..cb0db2ef 100644 --- a/src/lib/base/XBase.cpp +++ b/src/lib/base/XBase.cpp @@ -38,13 +38,13 @@ XBase::XBase(const std::string& msg) : // do nothing } -XBase::~XBase() _NOEXCEPT +XBase::~XBase() noexcept { // do nothing } const char* -XBase::what() const _NOEXCEPT +XBase::what() const noexcept { const char* what = std::runtime_error::what(); if (strlen(what) == 0) { @@ -54,8 +54,7 @@ XBase::what() const _NOEXCEPT return what; } -std::string -XBase::format(const char* /*id*/, const char* fmt, ...) const throw() +std::string XBase::format(const char* /*id*/, const char* fmt, ...) const noexcept { // FIXME -- lookup message string using id as an index. set // fmt to that string if it exists. diff --git a/src/lib/base/XBase.h b/src/lib/base/XBase.h index 7f6fc6eb..59b700e5 100644 --- a/src/lib/base/XBase.h +++ b/src/lib/base/XBase.h @@ -18,7 +18,7 @@ #pragma once -#include "common/stdexcept.h" +#include #include //! Exception base class @@ -31,14 +31,14 @@ public: XBase(); //! Use \c msg as the result of what() XBase(const std::string& msg); - virtual ~XBase() _NOEXCEPT; + virtual ~XBase() noexcept; //! Reason for exception - virtual const char* what() const _NOEXCEPT; + virtual const char* what() const noexcept; protected: //! Get a human readable string describing the exception - virtual std::string getWhat() const throw() { return ""; } + virtual std::string getWhat() const noexcept { return ""; } //! Format a string /*! @@ -46,7 +46,7 @@ protected: no format can be found, then replaces positional parameters in the format string and returns the result. */ - virtual std::string format(const char* id, const char* defaultFormat, ...) const throw(); + virtual std::string format(const char* id, const char* defaultFormat, ...) const noexcept; private: mutable std::string m_what; }; @@ -62,7 +62,7 @@ class name_ : public super_ { \ public: \ name_() : super_() { } \ name_(const std::string& msg) : super_(msg) { } \ - virtual ~name_() _NOEXCEPT { } \ + virtual ~name_() noexcept { } \ } /*! @@ -76,10 +76,10 @@ class name_ : public super_ { \ public: \ name_() : super_() { } \ name_(const std::string& msg) : super_(msg) { } \ - virtual ~name_() _NOEXCEPT { } \ + virtual ~name_() noexcept { } \ \ protected: \ - virtual std::string getWhat() const throw(); \ + virtual std::string getWhat() const noexcept; \ } /*! @@ -98,9 +98,9 @@ private: \ public: \ name_() : super_(), m_state(kDone) { } \ name_(const std::string& msg) : super_(msg), m_state(kFirst) { } \ - virtual ~name_() _NOEXCEPT { } \ + virtual ~name_() noexcept { } \ \ - virtual const char* what() const _NOEXCEPT \ + virtual const char* what() const noexcept \ { \ if (m_state == kFirst) { \ m_state = kFormat; \ @@ -116,7 +116,7 @@ public: \ } \ \ protected: \ - virtual std::string getWhat() const throw(); \ + virtual std::string getWhat() const noexcept; \ \ private: \ mutable EState m_state; \ diff --git a/src/lib/client/Client.cpp b/src/lib/client/Client.cpp index 84476816..96d2c67b 100644 --- a/src/lib/client/Client.cpp +++ b/src/lib/client/Client.cpp @@ -38,11 +38,11 @@ #include "base/IEventQueue.h" #include "base/TMethodEventJob.h" #include "base/TMethodJob.h" -#include "common/stdexcept.h" #include #include #include +#include #include // diff --git a/src/lib/common/stdexcept.h b/src/lib/common/stdexcept.h deleted file mode 100644 index 2bd96b37..00000000 --- a/src/lib/common/stdexcept.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2014-2016 Symless Ltd. - * - * This package is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * found in the file LICENSE that should have accompanied this file. - * - * This package is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -// apple declares _NOEXCEPT -#ifndef _NOEXCEPT -# define _NOEXCEPT throw() -#endif diff --git a/src/lib/io/XIO.cpp b/src/lib/io/XIO.cpp index 16ea3d32..911fa87b 100644 --- a/src/lib/io/XIO.cpp +++ b/src/lib/io/XIO.cpp @@ -22,7 +22,7 @@ // XIOClosed // -std::string XIOClosed::getWhat() const throw() +std::string XIOClosed::getWhat() const noexcept { return format("XIOClosed", "already closed"); } @@ -32,7 +32,7 @@ std::string XIOClosed::getWhat() const throw() // XIOEndOfStream // -std::string XIOEndOfStream::getWhat() const throw() +std::string XIOEndOfStream::getWhat() const noexcept { return format("XIOEndOfStream", "reached end of stream"); } @@ -42,7 +42,7 @@ std::string XIOEndOfStream::getWhat() const throw() // XIOWouldBlock // -std::string XIOWouldBlock::getWhat() const throw() +std::string XIOWouldBlock::getWhat() const noexcept { return format("XIOWouldBlock", "stream operation would block"); } diff --git a/src/lib/mt/XMT.cpp b/src/lib/mt/XMT.cpp index 0b0d63e9..2274a6b6 100644 --- a/src/lib/mt/XMT.cpp +++ b/src/lib/mt/XMT.cpp @@ -22,7 +22,7 @@ // XMTThreadUnavailable // -std::string XMTThreadUnavailable::getWhat() const throw() +std::string XMTThreadUnavailable::getWhat() const noexcept { return format("XMTThreadUnavailable", "cannot create thread"); } diff --git a/src/lib/net/XSocket.cpp b/src/lib/net/XSocket.cpp index 3d4db757..eed7a26c 100644 --- a/src/lib/net/XSocket.cpp +++ b/src/lib/net/XSocket.cpp @@ -23,7 +23,7 @@ // XSocketAddress // -XSocketAddress::XSocketAddress(EError error, const std::string& hostname, int port) _NOEXCEPT : +XSocketAddress::XSocketAddress(EError error, const std::string& hostname, int port) noexcept : m_error(error), m_hostname(hostname), m_port(port) @@ -31,25 +31,22 @@ XSocketAddress::XSocketAddress(EError error, const std::string& hostname, int po // do nothing } -XSocketAddress::EError -XSocketAddress::getError() const throw() +XSocketAddress::EError XSocketAddress::getError() const noexcept { return m_error; } -std::string -XSocketAddress::getHostname() const throw() +std::string XSocketAddress::getHostname() const noexcept { return m_hostname; } -int -XSocketAddress::getPort() const throw() +int XSocketAddress::getPort() const noexcept { return m_port; } -std::string XSocketAddress::getWhat() const throw() +std::string XSocketAddress::getWhat() const noexcept { static const char* s_errorID[] = { "XSocketAddressUnknown", @@ -75,7 +72,7 @@ std::string XSocketAddress::getWhat() const throw() // XSocketIOClose // -std::string XSocketIOClose::getWhat() const throw() +std::string XSocketIOClose::getWhat() const noexcept { return format("XSocketIOClose", "close: %{1}", what()); } @@ -85,7 +82,7 @@ std::string XSocketIOClose::getWhat() const throw() // XSocketBind // -std::string XSocketBind::getWhat() const throw() +std::string XSocketBind::getWhat() const noexcept { return format("XSocketBind", "cannot bind address: %{1}", what()); } @@ -95,7 +92,7 @@ std::string XSocketBind::getWhat() const throw() // XSocketConnect // -std::string XSocketConnect::getWhat() const throw() +std::string XSocketConnect::getWhat() const noexcept { return format("XSocketConnect", "cannot connect socket: %{1}", what()); } @@ -105,7 +102,7 @@ std::string XSocketConnect::getWhat() const throw() // XSocketCreate // -std::string XSocketCreate::getWhat() const throw() +std::string XSocketCreate::getWhat() const noexcept { return format("XSocketCreate", "cannot create socket: %{1}", what()); } diff --git a/src/lib/net/XSocket.h b/src/lib/net/XSocket.h index 6e10e54b..d12278e7 100644 --- a/src/lib/net/XSocket.h +++ b/src/lib/net/XSocket.h @@ -40,24 +40,24 @@ public: kBadPort //!< The port is invalid }; - XSocketAddress(EError, const std::string& hostname, int port) _NOEXCEPT; - virtual ~XSocketAddress() _NOEXCEPT { } + XSocketAddress(EError, const std::string& hostname, int port) noexcept; + virtual ~XSocketAddress() noexcept { } //! @name accessors //@{ //! Get the error code - EError getError() const throw(); + EError getError() const noexcept; //! Get the hostname - std::string getHostname() const throw(); + std::string getHostname() const noexcept; //! Get the port - int getPort() const throw(); + int getPort() const noexcept; //@} protected: // XBase overrides - virtual std::string getWhat() const throw(); + virtual std::string getWhat() const noexcept; private: EError m_error; diff --git a/src/lib/platform/MSWindowsWatchdog.h b/src/lib/platform/MSWindowsWatchdog.h index f90c76a7..0a81521b 100644 --- a/src/lib/platform/MSWindowsWatchdog.h +++ b/src/lib/platform/MSWindowsWatchdog.h @@ -88,5 +88,5 @@ public: XMSWindowsWatchdogError(const std::string& msg) : XBarrier(msg) { } // XBase overrides - virtual std::string getWhat() const throw() { return what(); } + virtual std::string getWhat() const noexcept { return what(); } }; diff --git a/src/lib/server/Config.cpp b/src/lib/server/Config.cpp index a7e9f2d5..e3056be4 100644 --- a/src/lib/server/Config.cpp +++ b/src/lib/server/Config.cpp @@ -2271,12 +2271,12 @@ XConfigRead::XConfigRead(const ConfigReadContext& context, const char* errorFmt, // do nothing } -XConfigRead::~XConfigRead() _NOEXCEPT +XConfigRead::~XConfigRead() noexcept { // do nothing } -std::string XConfigRead::getWhat() const throw() +std::string XConfigRead::getWhat() const noexcept { return format("XConfigRead", "read error: %{1}", m_error.c_str()); } diff --git a/src/lib/server/Config.h b/src/lib/server/Config.h index 72ec4b56..c459393f 100644 --- a/src/lib/server/Config.h +++ b/src/lib/server/Config.h @@ -521,11 +521,11 @@ class XConfigRead : public XBase { public: XConfigRead(const ConfigReadContext& context, const std::string&); XConfigRead(const ConfigReadContext& contex, const char* errorFmt, const std::string& arg); - virtual ~XConfigRead() _NOEXCEPT; + virtual ~XConfigRead() noexcept; protected: // XBase overrides - virtual std::string getWhat() const throw(); + virtual std::string getWhat() const noexcept; private: std::string m_error; diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index c8e234de..234dda6c 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -43,14 +43,13 @@ #include "base/IEventQueue.h" #include "base/Log.h" #include "base/TMethodEventJob.h" -#include "common/stdexcept.h" #include #include #include #include #include - +#include // // Server // diff --git a/src/test/global/TestEventQueue.cpp b/src/test/global/TestEventQueue.cpp index d2029228..4dd01e7d 100644 --- a/src/test/global/TestEventQueue.cpp +++ b/src/test/global/TestEventQueue.cpp @@ -20,7 +20,7 @@ #include "base/Log.h" #include "base/TMethodEventJob.h" #include "base/SimpleEventQueueBuffer.h" -#include "common/stdexcept.h" +#include void TestEventQueue::raiseQuitEvent() diff --git a/src/test/integtests/net/NetworkTests.cpp b/src/test/integtests/net/NetworkTests.cpp index 4a9a9f0d..d404abc8 100644 --- a/src/test/integtests/net/NetworkTests.cpp +++ b/src/test/integtests/net/NetworkTests.cpp @@ -38,7 +38,7 @@ #include "base/TMethodEventJob.h" #include "base/TMethodJob.h" #include "base/Log.h" -#include "common/stdexcept.h" +#include #include "test/global/gtest.h" #include