All platforms support exceptions now, so removed the test and use of
epicsThrow macro.
This commit is contained in:
@@ -5,31 +5,13 @@
|
||||
#ifndef __EPICS_EXCEPT_H__
|
||||
#define __EPICS_EXCEPT_H__
|
||||
|
||||
#include "errlog.h"
|
||||
#include "cantProceed.h"
|
||||
|
||||
#ifdef noExceptionsFromCXX
|
||||
|
||||
// In the absence of exception support, the epicsThrow macros map
|
||||
// to functions that output all the info and call cantProceed()
|
||||
|
||||
#define epicsThrow(exc, msg) \
|
||||
cantThrow(#exc, msg)
|
||||
#define epicsThrowHere(exc, msg) \
|
||||
cantThrow(#exc, msg, __FILE__, __LINE__)
|
||||
|
||||
#else // noExceptionsFromCXX
|
||||
|
||||
// With exception support, one base class holds location information
|
||||
// and the first macro argument names the standard exception class
|
||||
|
||||
// Don't use epicsThrow, it's no longer needed and will disappear soon
|
||||
#define epicsThrow(exc, msg) \
|
||||
throw exc(msg)
|
||||
|
||||
#define epicsThrowHere(exc, msg) \
|
||||
throw locationException<exc>(msg, __FILE__, __LINE__)
|
||||
|
||||
#endif // noExceptionsFromCXX
|
||||
|
||||
class sourceLocation {
|
||||
public:
|
||||
sourceLocation (const char *fileName, int lineNumber);
|
||||
@@ -46,30 +28,11 @@ class locationException : public T, public sourceLocation {
|
||||
public:
|
||||
locationException(const char *msg, const char *fileName, int lineNumber);
|
||||
// NB: In standard exception classes the msg argument is a string&
|
||||
// I use char* here to avoid having to include <string>
|
||||
// If <T> will always be derived from std::exception then
|
||||
// locationException could provide a version of what() as well:
|
||||
// virtual const char* what() const;
|
||||
// NB: Constructing that string is tricky, as it needs storage in
|
||||
// the locationException class to hold it.
|
||||
// I've used const char* here to avoid having to include <string>
|
||||
};
|
||||
|
||||
|
||||
// cantThrow functions
|
||||
inline void cantThrow(const char *exc, const char *msg) {
|
||||
errlogPrintf("cantThrow: %s exception - %s\n", exc, msg);
|
||||
cantProceed("C++ exceptions not supported on this platform");
|
||||
}
|
||||
|
||||
inline void cantThrow(const char *exc, const char *msg,
|
||||
const char *file, int line) {
|
||||
errlogPrintf("cantThrow: %s exception at %s:%d - %s\n", exc, file, line, msg);
|
||||
cantProceed("C++ exceptions not supported on this platform");
|
||||
}
|
||||
|
||||
|
||||
/* Examples:
|
||||
* if (x<0) epicsThrow(STD_ invalid_argument, "myfunc: x<0");
|
||||
* if (status) epicsThrowHere(STD_ logic_error, "failed!");
|
||||
* try { ... } catch(sourceLocation& where) { ... }
|
||||
*/
|
||||
|
||||
@@ -197,28 +197,28 @@ inline epicsList<T>::size_type epicsList<T>::size() const {
|
||||
template <class T>
|
||||
inline T epicsList<T>::front() {
|
||||
if (empty())
|
||||
epicsThrow(STD_ logic_error, "list::front: list empty");
|
||||
throw STD_ logic_error("list::front: list empty");
|
||||
return static_cast<T>(_head.next()->payload);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const T epicsList<T>::front() const {
|
||||
if (empty())
|
||||
epicsThrow(STD_ logic_error, "list::front: list empty");
|
||||
throw STD_ logic_error("list::front: list empty");
|
||||
return static_cast<const T>(_head.next()->payload);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T epicsList<T>::back() {
|
||||
if (empty())
|
||||
epicsThrow(STD_ logic_error, "list::back: list empty");
|
||||
throw STD_ logic_error("list::back: list empty");
|
||||
return static_cast<T>(_head.prev()->payload);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const T epicsList<T>::back() const {
|
||||
if (empty())
|
||||
epicsThrow(STD_ logic_error, "list::back: list empty");
|
||||
throw STD_ logic_error("list::back: list empty");
|
||||
return static_cast<const T>(_head.prev()->payload);
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ inline void epicsList<T>::push_front(const T x) {
|
||||
template <class T>
|
||||
inline void epicsList<T>::pop_front() {
|
||||
if (empty())
|
||||
epicsThrow(STD_ logic_error, "list::pop_front: list empty");
|
||||
throw STD_ logic_error("list::pop_front: list empty");
|
||||
epicsListNode* node = _head.next();
|
||||
node->unlink();
|
||||
_count--;
|
||||
@@ -251,7 +251,7 @@ inline void epicsList<T>::push_back(const T x) {
|
||||
template <class T>
|
||||
inline void epicsList<T>::pop_back() {
|
||||
if (empty())
|
||||
epicsThrow(STD_ logic_error, "list::pop_back: list empty");
|
||||
throw STD_ logic_error("list::pop_back: list empty");
|
||||
epicsListNode* node = _head.prev();
|
||||
node->unlink();
|
||||
_count--;
|
||||
|
||||
Reference in New Issue
Block a user