OSDN Git Service

マルチプロジェクト型にレポジトリを変更するために移動した
[toppersasp4lpc/asp.git] / asp / cfg / toppers / diagnostics.hpp
1 /*
2  *  TOPPERS Software
3  *      Toyohashi Open Platform for Embedded Real-Time Systems
4  *
5  *  Copyright (C) 2007-2008 by TAKAGI Nobuhisa
6  * 
7  *  上記著作権者は,以下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェ
8  *  ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
9  *  変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
10  *  (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
11  *      権表示,この利用条件および下記の無保証規定が,そのままの形でソー
12  *      スコード中に含まれていること.
13  *  (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
14  *      用できる形で再配布する場合には,再配布に伴うドキュメント(利用
15  *      者マニュアルなど)に,上記の著作権表示,この利用条件および下記
16  *      の無保証規定を掲載すること.
17  *  (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
18  *      用できない形で再配布する場合には,次のいずれかの条件を満たすこ
19  *      と.
20  *    (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
21  *        作権表示,この利用条件および下記の無保証規定を掲載すること.
22  *    (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
23  *        報告すること.
24  *  (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
25  *      害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
26  *      また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
27  *      由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
28  *      免責すること.
29  * 
30  *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
31  *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
32  *  に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
33  *  アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
34  *  の責任を負わない.
35  * 
36  */
37 /*!
38  *  \file   toppers/diagnostics.hpp
39  *  \brief  診断処理に関する宣言定義
40  */
41 #ifndef TOPPERS_DIAGNOSTICS_HPP_
42 #define TOPPERS_DIAGNOSTICS_HPP_
43
44 #include <stdexcept>
45 #include "toppers/debug.hpp"
46 #include "toppers/gettext.hpp"
47 #include <boost/format.hpp>
48
49 namespace toppers
50 {
51
52   struct text_line;
53
54   class diagnostics_error : public std::runtime_error
55   {
56   public:
57     diagnostics_error( std::string const& msg ) : std::runtime_error( msg ) {}
58   };
59
60   class normal_exit {};
61
62   int get_error_count();
63   int increment_error_count();
64   void set_program_name( char const* name );
65   std::string const& get_program_name();
66   int set_error_abort_threshold( int thresh );
67   void warning( const char* msg );
68   void warning( text_line const& line, const char* msg );
69   void error( const char* msg );
70   void error( text_line const& line, const char* msg );
71   void fatal( const char* msg );
72   void fatal( text_line const& line, const char* msg );
73
74   template < typename T1 >
75     inline void warning( const char* str, T1 const& arg1 )
76   {
77     warning( ( boost::format( str ) % arg1 ).str().c_str() );
78   }
79
80   template < typename T1, typename T2 >
81     inline void warning( const char* str, T1 const& arg1, T2 const& arg2 )
82   {
83     warning( ( boost::format( str ) % arg1 % arg2 ).str().c_str() );
84   }
85
86   template < typename T1, typename T2, typename T3 >
87     inline void warning( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3 )
88   {
89     warning( ( boost::format( str ) % arg1 % arg2 % arg3 ).str().c_str() );
90   }
91
92   template < typename T1, typename T2, typename T3, typename T4 >
93     inline void warning( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
94   {
95     warning( ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 ).str().c_str() );
96   }
97
98   template < typename T1 >
99     inline void warning( text_line const& line, const char* str, T1 const& arg1 )
100   {
101     warning( line, ( boost::format( str ) % arg1 ).str().c_str() );
102   }
103
104   template < typename T1, typename T2 >
105     inline void warning( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2 )
106   {
107     warning( line, ( boost::format( str ) % arg1 % arg2 ).str().c_str() );
108   }
109
110   template < typename T1, typename T2, typename T3 >
111     inline void warning( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3 )
112   {
113     warning( line, ( boost::format( str ) % arg1 % arg2 % arg3 ).str().c_str() );
114   }
115
116   template < typename T1, typename T2, typename T3, typename T4 >
117     inline void warning( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
118   {
119     warning( line, ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 ).str().c_str() );
120   }
121
122   template < typename T1 >
123     inline void error( const char* str, T1 const& arg1 )
124   {
125     error( ( boost::format( str ) % arg1 ).str().c_str() );
126   }
127
128   template < typename T1, typename T2 >
129     inline void error( const char* str, T1 const& arg1, T2 const& arg2 )
130   {
131     error( ( boost::format( str ) % arg1 % arg2 ).str().c_str() );
132   }
133
134   template < typename T1, typename T2, typename T3 >
135     inline void error( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3 )
136   {
137     error( ( boost::format( str ) % arg1 % arg2 % arg3 ).str().c_str() );
138   }
139
140   template < typename T1, typename T2, typename T3, typename T4 >
141     inline void error( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
142   {
143     error( ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 ).str().c_str() );
144   }
145
146   template < typename T1 >
147     inline void error( text_line const& line, const char* str, T1 const& arg1 )
148   {
149     error( line, ( boost::format( str ) % arg1 ).str().c_str() );
150   }
151
152   template < typename T1, typename T2 >
153     inline void error( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2 )
154   {
155     error( line, ( boost::format( str ) % arg1 % arg2 ).str().c_str() );
156   }
157
158   template < typename T1, typename T2, typename T3 >
159     inline void error( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3 )
160   {
161     error( line, ( boost::format( str ) % arg1 % arg2 % arg3 ).str().c_str() );
162   }
163
164   template < typename T1, typename T2, typename T3, typename T4 >
165     inline void error( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
166   {
167     error( line, ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 ).str().c_str() );
168   }
169
170   template < typename T1 >
171     inline void fatal( const char* str, T1 const& arg1 )
172   {
173     fatal( ( boost::format( str ) % arg1 ).str().c_str() );
174   }
175
176   template < typename T1, typename T2 >
177     inline void fatal( const char* str, T1 const& arg1, T2 const& arg2 )
178   {
179     fatal( ( boost::format( str ) % arg1 % arg2 ).str().c_str() );
180   }
181
182   template < typename T1, typename T2, typename T3 >
183     inline void fatal( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3 )
184   {
185     fatal( ( boost::format( str ) % arg1 % arg2 % arg3 ).str().c_str() );
186   }
187
188   template < typename T1, typename T2, typename T3, typename T4 >
189     inline void fatal( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
190   {
191     fatal( ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 ).str().c_str() );
192   }
193
194   template < typename T1 >
195     inline void fatal( text_line const& line, const char* str, T1 const& arg1 )
196   {
197     fatal( line, ( boost::format( str ) % arg1 ).str().c_str() );
198   }
199
200   template < typename T1, typename T2 >
201     inline void fatal( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2 )
202   {
203     fatal( line, ( boost::format( str ) % arg1 % arg2 ).str().c_str() );
204   }
205
206   template < typename T1, typename T2, typename T3 >
207     inline void fatal( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3 )
208   {
209     fatal( line, ( boost::format( str ) % arg1 % arg2 % arg3 ).str().c_str() );
210   }
211
212   template < typename T1, typename T2, typename T3, typename T4 >
213     inline void fatal( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
214   {
215     fatal( line, ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 ).str().c_str() );
216   }
217
218   inline void exit()
219   {
220     throw normal_exit();
221   }
222
223 #undef  _
224 #define _( str )  ::toppers::gettext( str ).c_str()
225
226 }
227
228 #endif  // ! TOPPERS_DIAGNOSTICS_HPP_
229