123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- #ifndef __EXCEPTIONS_H
- #define __EXCEPTIONS_H 1
- #include <stdexcept>
- #include <string>
- #include <sstream>
- namespace isc {
- class Exception : public std::exception {
- public:
-
-
-
-
-
-
-
-
-
-
- Exception(const char* file, size_t line, const char* what) :
- file_(file), line_(line), what_(what) {}
-
-
-
-
-
-
- Exception(const char* file, size_t line, const std::string& what) :
- file_(file), line_(line), what_(what) {}
-
- virtual ~Exception() throw() {}
-
- private:
-
-
-
- void operator=(const Exception& src);
- public:
-
-
-
-
-
-
-
-
-
-
- virtual const char* what() const throw();
-
-
-
-
-
-
-
-
- const std::string& getMessage() const { return (what_); }
-
-
-
- const char* getFile() const { return (file_); }
-
-
-
- size_t getLine() const { return (line_); }
-
- private:
- const char* const file_;
- size_t line_;
- const std::string what_;
- };
- class OutOfRange : public Exception {
- public:
- OutOfRange(const char* file, size_t line, const char* what) :
- isc::Exception(file, line, what) {}
- };
- class InvalidParameter : public Exception {
- public:
- InvalidParameter(const char* file, size_t line, const char* what) :
- isc::Exception(file, line, what) {}
- };
- class BadValue : public Exception {
- public:
- BadValue(const char* file, size_t line, const char* what) :
- isc::Exception(file, line, what) {}
- };
- class InvalidOperation : public Exception {
- public:
- InvalidOperation(const char* file, size_t line, const char* what) :
- isc::Exception(file, line, what) {}
- };
- class Unexpected : public Exception {
- public:
- Unexpected(const char* file, size_t line, const char* what) :
- isc::Exception(file, line, what) {}
- };
- class NotImplemented : public Exception {
- public:
- NotImplemented(const char* file, size_t line, const char* what) :
- isc::Exception(file, line, what) {}
- };
- #define isc_throw(type, stream) \
- do { \
- std::ostringstream oss__; \
- oss__ << stream; \
- throw type(__FILE__, __LINE__, oss__.str().c_str()); \
- } while (1)
- #define isc_throw_1(type, stream, param1) \
- do { \
- std::ostringstream oss__; \
- oss__ << stream; \
- throw type(__FILE__, __LINE__, oss__.str().c_str(), param1); \
- } while (1)
- #define isc_throw_2(type, stream, param1, param2) \
- do { \
- std::ostringstream oss__; \
- oss__ << stream; \
- throw type(__FILE__, __LINE__, oss__.str().c_str(), param1, param2); \
- } while (1)
- }
- #endif // __EXCEPTIONS_H
|