|
|
reporter.hpp説明を見る。00001 /* 00002 * TOPPERS/FDMP Kernel 00003 * Toyohashi Open Platform for Embedded Real-Time Systems/ 00004 * Function Distributed Multiprocessor Kernel 00005 * 00006 * Copyright (C) 2004 by Witz Corporation, JAPAN 00007 * Copyright (C) 2005 by Takagi Nobuhisa 00008 * 00009 * 上記著作権者は,以下の (1)〜(4) の条件か,Free Software Foundation 00010 * によって公表されている GNU General Public License の Version 2 に記 00011 * 述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア 00012 * を改変したものを含む.以下同じ)を使用・複製・改変・再配布(以下, 00013 * 利用と呼ぶ)することを無償で許諾する. 00014 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 00015 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 00016 * スコード中に含まれていること. 00017 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 00018 * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 00019 * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 00020 * の無保証規定を掲載すること. 00021 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 00022 * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 00023 * と. 00024 * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 00025 * 作権表示,この利用条件および下記の無保証規定を掲載すること. 00026 * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 00027 * 報告すること. 00028 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 00029 * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 00030 * 00031 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 00032 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も 00033 * 含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直 00034 * 接的または間接的に生じたいかなる損害に関しても,その責任を負わない. 00035 * 00036 */ 00037 00048 #ifndef TOPPERS_REPORTER_HPP_ 00049 #define TOPPERS_REPORTER_HPP_ 00050 00051 #include "toppers/text_line.hpp" 00052 #include <iosfwd> 00053 #include <string> 00054 #include <boost/format.hpp> 00055 00056 namespace toppers 00057 { 00058 00063 class reporter 00064 { 00065 public: 00071 class terminator {}; 00072 00073 enum language_type 00074 { 00075 English, Japanese, 00076 number_of_languages 00077 }; 00078 00079 typedef const char* ( *translator_type )( const char* ); 00080 00081 explicit reporter( std::ostream* stream = 0 ); 00082 virtual ~reporter(); 00083 void warning( const boost::format& fmt ) const; 00084 void warning( const std::string& file, int line, const boost::format& fmt ) const; 00085 void error( const boost::format& fmt ) const; 00086 void error( const std::string& file, int line, const boost::format& fmt ) const; 00087 void fatal( const boost::format& fmt ) const; 00088 void fatal( const std::string& file, int line, const boost::format& fmt ) const; 00089 void stop( const boost::format& fmt ) const; 00090 00091 static void set_program_name( const char* name ); 00092 static void set_default_stream( std::ostream* ostr ); 00093 static const char* translate( const char* str ); 00094 static translator_type set_translator( translator_type func ); 00095 protected: 00096 void abort() const; 00097 private: 00098 std::ostream* stream_; 00099 static std::ostream* default_stream_; 00100 static translator_type translator_; 00101 static int error_count_; 00102 static std::string perhaps_error_; 00103 }; 00104 00109 inline void warning( const boost::format& fmt ) 00110 { 00111 reporter r; 00112 r.warning( fmt ); 00113 } 00120 inline void warning( const std::string& file, int line, const boost::format& fmt ) 00121 { 00122 reporter r; 00123 r.warning( file, line, fmt ); 00124 } 00125 void warning( const text_line& line, const boost::format& fmt ); 00126 00132 inline void error( const boost::format& fmt ) 00133 { 00134 reporter r; 00135 r.error( fmt ); 00136 } 00144 inline void error( const std::string& file, int line, const boost::format& fmt ) 00145 { 00146 reporter r; 00147 r.error( file, line, fmt ); 00148 } 00149 void error( const text_line& line, const boost::format& fmt ); 00150 00156 inline void fatal( const boost::format& fmt ) 00157 { 00158 reporter r; 00159 r.fatal( fmt ); 00160 } 00168 inline void fatal( const std::string& file, int line, const boost::format& fmt ) 00169 { 00170 reporter r; 00171 r.fatal( file, line, fmt ); 00172 } 00173 void fatal( const text_line& line, const boost::format& fmt ); 00174 00180 inline void stop( const boost::format& fmt ) 00181 { 00182 reporter r; 00183 r.stop( fmt ); 00184 } 00185 00186 } 00187 00193 #define rout reporter() 00194 00205 #define _(msg) boost::format(toppers::reporter::translate(msg)) 00206 00207 #endif // ! TOPPERS_REPORTER_HPP_ Copyright © 2006 by TAKAGI Nobuhisa. このページは Wed Apr 12 16:31:57 2006 に Doxygen によって生成されました。 |