source: cfg_oil/trunk/toppers/diagnostics.hpp@ 8

Last change on this file since 8 was 8, checked in by msugi, 13 years ago

ディレクトリ構造の作成,ソース一式とReleaseビルドのコミット.

File size: 8.6 KB
Line 
1/*
2 * TOPPERS Software
3 * Toyohashi Open Platform for Embedded Real-Time Systems
4 *
5 * Copyright (C) 2007-2008 by TAKAGI Nobuhisa
6 * Copyright (C) 2010 by Meika Sugimoto
7 *
8 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
9 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
10 * •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
11 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
12 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
13 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
14 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
15 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
16ƒƒ“ƒgi—˜—p
17 * ŽÒƒ}ƒjƒ…
18ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
19 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
20 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
21 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
22 * ‚ƁD
23 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
24ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
25ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
26 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
27 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
28 * •ñ‚·‚邱‚ƁD
29 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
30 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
31 * ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
32 * —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
33 * –Ɛӂ·‚邱‚ƁD
34 *
35 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
36 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
37 * ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
38 * ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
39 * ‚̐ӔC‚𕉂í‚È‚¢D
40 *
41 */
42/*!
43 * \file toppers/diagnostics.hpp
44 * \brief f’fˆ—‚ÉŠÖ‚·‚ééŒ¾’è‹`
45 */
46#ifndef TOPPERS_DIAGNOSTICS_HPP_
47#define TOPPERS_DIAGNOSTICS_HPP_
48
49#include <stdexcept>
50#include "toppers/debug.hpp"
51#include "toppers/gettext.hpp"
52#include <boost/format.hpp>
53
54namespace toppers
55{
56
57 struct text_line;
58
59 class diagnostics_error : public std::runtime_error
60 {
61 public:
62 diagnostics_error( std::string const& msg ) : std::runtime_error( msg ) {}
63 };
64
65 class normal_exit {};
66
67 int get_error_count();
68 int increment_error_count();
69 void set_program_name( char const* name );
70 std::string const& get_program_name();
71 int set_error_abort_threshold( int thresh );
72 void warning( const char* msg );
73 void warning( text_line const& line, const char* msg );
74 void error( const char* msg );
75 void error( text_line const& line, const char* msg );
76 void fatal( const char* msg );
77 void fatal( text_line const& line, const char* msg );
78
79 template < typename T1 >
80 inline void warning( const char* str, T1 const& arg1 )
81 {
82 warning( ( boost::format( str ) % arg1 ).str().c_str() );
83 }
84
85 template < typename T1, typename T2 >
86 inline void warning( const char* str, T1 const& arg1, T2 const& arg2 )
87 {
88 warning( ( boost::format( str ) % arg1 % arg2 ).str().c_str() );
89 }
90
91 template < typename T1, typename T2, typename T3 >
92 inline void warning( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3 )
93 {
94 warning( ( boost::format( str ) % arg1 % arg2 % arg3 ).str().c_str() );
95 }
96
97 template < typename T1, typename T2, typename T3, typename T4 >
98 inline void warning( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
99 {
100 warning( ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 ).str().c_str() );
101 }
102
103 template < typename T1 >
104 inline void warning( text_line const& line, const char* str, T1 const& arg1 )
105 {
106 warning( line, ( boost::format( str ) % arg1 ).str().c_str() );
107 }
108
109 template < typename T1, typename T2 >
110 inline void warning( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2 )
111 {
112 warning( line, ( boost::format( str ) % arg1 % arg2 ).str().c_str() );
113 }
114
115 template < typename T1, typename T2, typename T3 >
116 inline void warning( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3 )
117 {
118 warning( line, ( boost::format( str ) % arg1 % arg2 % arg3 ).str().c_str() );
119 }
120
121 template < typename T1, typename T2, typename T3, typename T4 >
122 inline void warning( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
123 {
124 warning( line, ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 ).str().c_str() );
125 }
126
127 template < typename T1 >
128 inline void error( const char* str, T1 const& arg1 )
129 {
130 error( ( boost::format( str ) % arg1 ).str().c_str() );
131 }
132
133 template < typename T1, typename T2 >
134 inline void error( const char* str, T1 const& arg1, T2 const& arg2 )
135 {
136 error( ( boost::format( str ) % arg1 % arg2 ).str().c_str() );
137 }
138
139 template < typename T1, typename T2, typename T3 >
140 inline void error( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3 )
141 {
142 error( ( boost::format( str ) % arg1 % arg2 % arg3 ).str().c_str() );
143 }
144
145 template < typename T1, typename T2, typename T3, typename T4 >
146 inline void error( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
147 {
148 error( ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 ).str().c_str() );
149 }
150
151 template < typename T1, typename T2, typename T3, typename T4, typename T5 >
152 inline void error( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 , T5 const& arg5 )
153 {
154 error( ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 % arg5 ).str().c_str() );
155 }
156
157 template < typename T1 >
158 inline void error( text_line const& line, const char* str, T1 const& arg1 )
159 {
160 error( line, ( boost::format( str ) % arg1 ).str().c_str() );
161 }
162
163 template < typename T1, typename T2 >
164 inline void error( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2 )
165 {
166 error( line, ( boost::format( str ) % arg1 % arg2 ).str().c_str() );
167 }
168
169 template < typename T1, typename T2, typename T3 >
170 inline void error( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3 )
171 {
172 error( line, ( boost::format( str ) % arg1 % arg2 % arg3 ).str().c_str() );
173 }
174
175 template < typename T1, typename T2, typename T3, typename T4 >
176 inline void error( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
177 {
178 error( line, ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 ).str().c_str() );
179 }
180
181 template < typename T1 >
182 inline void fatal( const char* str, T1 const& arg1 )
183 {
184 fatal( ( boost::format( str ) % arg1 ).str().c_str() );
185 }
186
187 template < typename T1, typename T2 >
188 inline void fatal( const char* str, T1 const& arg1, T2 const& arg2 )
189 {
190 fatal( ( boost::format( str ) % arg1 % arg2 ).str().c_str() );
191 }
192
193 template < typename T1, typename T2, typename T3 >
194 inline void fatal( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3 )
195 {
196 fatal( ( boost::format( str ) % arg1 % arg2 % arg3 ).str().c_str() );
197 }
198
199 template < typename T1, typename T2, typename T3, typename T4 >
200 inline void fatal( const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
201 {
202 fatal( ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 ).str().c_str() );
203 }
204
205 template < typename T1 >
206 inline void fatal( text_line const& line, const char* str, T1 const& arg1 )
207 {
208 fatal( line, ( boost::format( str ) % arg1 ).str().c_str() );
209 }
210
211 template < typename T1, typename T2 >
212 inline void fatal( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2 )
213 {
214 fatal( line, ( boost::format( str ) % arg1 % arg2 ).str().c_str() );
215 }
216
217 template < typename T1, typename T2, typename T3 >
218 inline void fatal( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3 )
219 {
220 fatal( line, ( boost::format( str ) % arg1 % arg2 % arg3 ).str().c_str() );
221 }
222
223 template < typename T1, typename T2, typename T3, typename T4 >
224 inline void fatal( text_line const& line, const char* str, T1 const& arg1, T2 const& arg2, T3 const& arg3, T4 const& arg4 )
225 {
226 fatal( line, ( boost::format( str ) % arg1 % arg2 % arg3 % arg4 ).str().c_str() );
227 }
228
229 inline void exit()
230 {
231 throw normal_exit();
232 }
233
234#undef _
235#define _( str ) ::toppers::gettext( str ).c_str()
236
237}
238
239#endif // ! TOPPERS_DIAGNOSTICS_HPP_
240
Note: See TracBrowser for help on using the repository browser.