diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2007-11-17 23:06:41 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2007-11-17 23:06:41 +0000 |
| commit | bd06562677b313a9a4dc1706c63655bbaef0e681 (patch) | |
| tree | fb1f84c776797767b4c608becfa4c36b5f14fd82 /src/2geom/utils.h | |
| parent | fix compile warning with C++ style cast (diff) | |
| download | inkscape-bd06562677b313a9a4dc1706c63655bbaef0e681.tar.gz inkscape-bd06562677b313a9a4dc1706c63655bbaef0e681.zip | |
2geom: splice exceptions code from utils.h into exception.h
(bzr r4097)
Diffstat (limited to 'src/2geom/utils.h')
| -rw-r--r-- | src/2geom/utils.h | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/src/2geom/utils.h b/src/2geom/utils.h index cd2a9c26c..c5c579338 100644 --- a/src/2geom/utils.h +++ b/src/2geom/utils.h @@ -32,76 +32,9 @@ */ #include <cmath> -#include <stdexcept> namespace Geom { - -//####################################################################### -// Base exception class, all 2geom exceptions should be derrived from this one. -class Exception : public std::exception { -public: - Exception(const char * message, const char *file, const int line) { - msgstr = "Exception thrown: "; - msgstr += message; - msgstr += " ("; - msgstr += file; - msgstr += ":"; - msgstr += line; - msgstr += ")"; - }; - virtual ~Exception() throw() {}; // necessary to destroy the string object!!! - virtual const char * what() const throw () { return msgstr.c_str(); } -protected: - std::string msgstr; -}; - -//----------------------------------------------------------------------- -// Two main exception classes: LogicalError and RangeError. -// Logical errors are 2geom faults/bugs, RangeErrors are 'user' faults. -// This way, the 'user' can distinguish between groups of exceptions -// ('user' is the coder that uses lib2geom) -class LogicalError : public Exception { -public: - LogicalError(const char * message, const char *file, const int line) - : Exception(message, file, line) {}; -}; -#define throwLogicalError(message) throw(LogicalError(message, __FILE__, __LINE__)) - -class RangeError : public Exception { -public: - RangeError(const char * message, const char *file, const int line) - : Exception(message, file, line) {}; -}; -#define throwRangeError(message) throw(RangeError(message, __FILE__, __LINE__)) - -//----------------------------------------------------------------------- -// Special case exceptions. Best used with the defines :) - -class NotImplemented : public LogicalError { -public: - NotImplemented(const char *file, const int line) - : LogicalError("Method not implemented", file, line) {}; -}; -#define throwNotImplemented(i) throw(NotImplemented(__FILE__, __LINE__)) - -class InvariantsViolation : public LogicalError { -public: - InvariantsViolation(const char *file, const int line) - : LogicalError("Invariants violation", file, line) {}; -}; -#define throwInvariantsViolation(i) throw(InvariantsViolation(__FILE__, __LINE__)) -#define assert_invariants(e) ((e) ? (void)0 : throwInvariantsViolation()) - -class NotInvertible : public RangeError { -public: - NotInvertible(const char *file, const int line) - : RangeError("Function does not have a unique inverse", file, line) {}; -}; -#define throwNotInvertible(i) throw(NotInvertible(__FILE__, __LINE__)) - -//####################################################################### - // proper logical xor inline bool logical_xor (bool a, bool b) { return (a || b) && !(a && b); } |
