00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __EXCEPTIONS_H
00018 #define __EXCEPTIONS_H 1
00019
00020 #include <string>
00021
00022 namespace isc {
00023 namespace dns {
00024
00032 class Exception {
00033 public:
00037
00038
00039
00040
00041
00042
00043
00044 Exception(const char* file, size_t line, const char* what) :
00045 file_(file), line_(line), what_(what) {}
00047 virtual ~Exception() {}
00049 private:
00053 void operator=(const Exception& src);
00054
00055 public:
00059
00060
00061
00062
00063 const std::string& getMessage() const { return (what_); }
00064
00068 const char* getFile() const { return (file_); }
00069
00073 size_t getLine() const { return (line_); }
00074
00075 private:
00076 const char* const file_;
00077 size_t line_;
00078 const std::string what_;
00079 };
00080
00085 class OutOfRange : public Exception {
00086 public:
00087 OutOfRange(const char* file, size_t line, const char* what) :
00088 isc::dns::Exception(file, line, what) {}
00089 };
00090
00094 #define dns_throw(type, args...) throw type(__FILE__, __LINE__, args)
00095
00096 }
00097 }
00098 #endif // __EXCEPTIONS_H
00099
00100
00101
00102