fixed: extending std::runtime_error instead, as std::exception ctor is undefined. also fixed some mac warnings from inheriting runtime_error.

This commit is contained in:
Nick Bolton 2014-03-14 20:33:18 +00:00
parent ab529fae41
commit d5b25069be
18 changed files with 68 additions and 41 deletions

View File

@ -23,15 +23,16 @@
//
const char*
XArch::what() const throw()
XArch::what() const _NOEXCEPT
{
const char* what = std::runtime_error::what();
try {
if (m_what.empty() && m_eval != NULL) {
m_what = m_eval->eval();
if (strlen(what) == 0 && m_eval != NULL) {
return m_eval->eval().c_str();
}
}
catch (...) {
// ignore
}
return m_what.c_str();
return what;
}

View File

@ -20,6 +20,7 @@
#include "common/common.h"
#include "common/stdstring.h"
#include "common/stdexcept.h"
//! Generic thread exception
/*!
@ -63,19 +64,17 @@ public:
};
//! Generic exception architecture dependent library
class XArch : public std::exception {
class XArch : public std::runtime_error {
public:
XArch(XArchEval* adoptedEvaluator) : m_eval(adoptedEvaluator) { }
XArch(const std::string& msg) : m_eval(NULL), m_what(msg) { }
XArch(const XArch& e) : m_eval(e.m_eval != NULL ? e.m_eval->clone() : NULL),
m_what(e.m_what) { }
~XArch() { delete m_eval; }
XArch(XArchEval* adoptedEvaluator) : std::runtime_error(""), m_eval(adoptedEvaluator) { }
XArch(const std::string& msg) : std::runtime_error(msg), m_eval(NULL) { }
XArch(const XArch& e) : std::runtime_error(e.what()), m_eval(e.m_eval != NULL ? e.m_eval->clone() : NULL) { }
~XArch() _NOEXCEPT { delete m_eval; }
const char* what() const throw();
virtual const char* what() const _NOEXCEPT;
private:
XArchEval* m_eval;
mutable std::string m_what;
};
// Macro to declare XArch derived types

View File

@ -27,29 +27,30 @@
//
XBase::XBase() :
m_what()
std::runtime_error("")
{
// do nothing
}
XBase::XBase(const CString& msg) :
m_what(msg)
std::runtime_error(msg)
{
// do nothing
}
XBase::~XBase()
XBase::~XBase() _NOEXCEPT
{
// do nothing
}
const char*
XBase::what() const
XBase::what() const _NOEXCEPT
{
if (m_what.empty()) {
m_what = getWhat();
const char* what = std::runtime_error::what();
if (strlen(what) == 0) {
return getWhat().c_str();
}
return m_what.c_str();
return what;
}
CString

View File

@ -19,21 +19,22 @@
#pragma once
#include "base/String.h"
#include "common/stdexcept.h"
//! Exception base class
/*!
This is the base class of most exception types.
*/
class XBase : public std::exception {
class XBase : public std::runtime_error {
public:
//! Use getWhat() as the result of what()
XBase();
//! Use \c msg as the result of what()
XBase(const CString& msg);
virtual ~XBase();
virtual ~XBase() _NOEXCEPT;
//! Reason for exception
virtual const char* what() const;
virtual const char* what() const _NOEXCEPT;
protected:
//! Get a human readable string describing the exception
@ -47,9 +48,6 @@ protected:
*/
virtual CString format(const char* id,
const char* defaultFormat, ...) const throw();
private:
mutable CString m_what;
};
/*!
@ -63,6 +61,7 @@ class name_ : public super_ { \
public: \
name_() : super_() { } \
name_(const CString& msg) : super_(msg) { } \
virtual ~name_() _NOEXCEPT { } \
}
/*!
@ -76,6 +75,7 @@ class name_ : public super_ { \
public: \
name_() : super_() { } \
name_(const CString& msg) : super_(msg) { } \
virtual ~name_() _NOEXCEPT { } \
\
protected: \
virtual CString getWhat() const throw(); \
@ -97,8 +97,9 @@ private: \
public: \
name_() : super_(), m_state(kDone) { } \
name_(const CString& msg) : super_(msg), m_state(kFirst) { } \
virtual ~name_() _NOEXCEPT { } \
\
virtual const char* what() const \
virtual const char* what() const _NOEXCEPT \
{ \
if (m_state == kFirst) { \
m_state = kFormat; \

View File

@ -37,12 +37,12 @@
#include "base/IEventQueue.h"
#include "base/TMethodEventJob.h"
#include "base/TMethodJob.h"
#include "common/stdexcept.h"
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <stdexcept>
//
// CClient

View File

@ -0,0 +1,23 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2014 Bolton Software 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 COPYING 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 <http://www.gnu.org/licenses/>.
*/
#include <stdexcept>
// apple declares _NOEXCEPT
#ifndef _NOEXCEPT
# define _NOEXCEPT throw()
#endif

View File

@ -24,7 +24,7 @@
//
XSocketAddress::XSocketAddress(EError error,
const CString& hostname, int port) throw() :
const CString& hostname, int port) _NOEXCEPT :
m_error(error),
m_hostname(hostname),
m_port(port)

View File

@ -41,7 +41,8 @@ public:
kBadPort //!< The port is invalid
};
XSocketAddress(EError, const CString& hostname, int port) throw();
XSocketAddress(EError, const CString& hostname, int port) _NOEXCEPT;
virtual ~XSocketAddress() _NOEXCEPT { }
//! @name accessors
//@{

View File

@ -2313,7 +2313,7 @@ XConfigRead::XConfigRead(const CConfigReadContext& context,
// do nothing
}
XConfigRead::~XConfigRead()
XConfigRead::~XConfigRead() _NOEXCEPT
{
// do nothing
}

View File

@ -534,7 +534,7 @@ public:
XConfigRead(const CConfigReadContext& context, const CString&);
XConfigRead(const CConfigReadContext& context,
const char* errorFmt, const CString& arg);
~XConfigRead();
virtual ~XConfigRead() _NOEXCEPT;
protected:
// XBase overrides

View File

@ -38,12 +38,12 @@
#include "base/IEventQueue.h"
#include "base/Log.h"
#include "base/TMethodEventJob.h"
#include "common/stdexcept.h"
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <stdexcept>
//
// CServer

View File

@ -24,10 +24,10 @@
#include "base/EventTypes.h"
#include "base/Log.h"
#include "base/Stopwatch.h"
#include "common/stdexcept.h"
#include <fstream>
#include <sstream>
#include <stdexcept>
#define PAUSE_TIME_HACK 0.1

View File

@ -16,11 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#pragma once
#include "synergy/IPlatformScreen.h"
#include <stdexcept>
#include "common/stdexcept.h"
//! Base screen implementation
/*!

View File

@ -50,7 +50,7 @@ XScreenUnavailable::XScreenUnavailable(double timeUntilRetry) :
// do nothing
}
XScreenUnavailable::~XScreenUnavailable()
XScreenUnavailable::~XScreenUnavailable() _NOEXCEPT
{
// do nothing
}

View File

@ -47,7 +47,7 @@ public:
trying to open the screen again.
*/
XScreenUnavailable(double timeUntilRetry);
virtual ~XScreenUnavailable();
virtual ~XScreenUnavailable() _NOEXCEPT;
//! @name manipulators
//@{

View File

@ -63,6 +63,7 @@ a client that is already connected.
class XDuplicateClient : public XSynergy {
public:
XDuplicateClient(const CString& name);
virtual ~XDuplicateClient() _NOEXCEPT { }
//! @name accessors
//@{
@ -88,6 +89,7 @@ unknown to the server.
class XUnknownClient : public XSynergy {
public:
XUnknownClient(const CString& name);
virtual ~XUnknownClient() _NOEXCEPT { }
//! @name accessors
//@{
@ -114,6 +116,7 @@ exit(int).
class XExitApp : public XSynergy {
public:
XExitApp(int code);
virtual ~XExitApp() _NOEXCEPT { }
//! Get the exit code
int getCode() const throw();

View File

@ -20,8 +20,7 @@
#include "base/Log.h"
#include "base/TMethodEventJob.h"
#include "base/SimpleEventQueueBuffer.h"
#include <stdexcept>
#include "common/stdexcept.h"
void
CTestEventQueue::raiseQuitEvent()

View File

@ -37,9 +37,9 @@
#include "base/TMethodEventJob.h"
#include "base/TMethodJob.h"
#include "base/Log.h"
#include "common/stdexcept.h"
#include "test/global/gtest.h"
#include <stdexcept>
#include <sstream>
#include <fstream>
#include <iostream>