OSDN Git Service

lexerに関係するソースをsrc/lexer配下に移動。
[simplecms/utakata.git] / src / exception_std.h
1 // exception_std
2 //
3 // utakata内で標準的に利用される、汎用的な例外を定義します。
4 // ここで定義されている例外は、全てexception::Exceptionから派生し、
5 // exception_macro.hのマクロが適用可能となっています。
6 //
7 // ここで定義されている汎用例外は以下となります。
8 //
9 // exception::NullException
10 //    -> NULLであってはならない場合に送出される例外です。
11 // exception::OutOfRangeException
12 //    -> 範囲外である場合に送出される例外です。
13 #ifndef _UTAKATA_SRC_EXCEPTION_STD_H_
14 #define _UTAKATA_SRC_EXCEPTION_STD_H_
15
16 #include <string>
17 #include "src/exception.h"
18
19 namespace utakata {
20
21 namespace unicode {
22 class UniString;
23 }
24
25 namespace exception {
26
27 class NullException : public exception::Exception {
28   // NULLであることが想定外である場合に送出される例外です。
29  public:
30   NullException(const unicode::UniString& message, const ExceptionInfo& info) :
31       Exception(message, info) {}
32
33   NullException(const Exception& prev, const unicode::UniString& message,
34             const ExceptionInfo& info) :
35       Exception(prev, message, info) {}
36
37   virtual const char* what() const throw() {return "NullException";}
38 };
39
40 class OutOfRangeException : public exception::Exception {
41   // 引数などが範囲外である場合などに送出される例外です。
42  public:
43   OutOfRangeException(const unicode::UniString& message,
44                       const ExceptionInfo& info)
45       : Exception(message, info) {}
46
47   OutOfRangeException(const Exception& prev, const unicode::UniString& message,
48                       const ExceptionInfo& info)
49       : Exception(prev, message, info) {}
50
51   virtual const char* what() const throw() {return "OutOfRangeException";}
52 };
53
54 }
55 }
56
57 #endif /* _UTAKATA_SRC_EXCEPTION_STD_H_ */
58