クラス toppers::reporter

処理経過の報告クラス [詳細]

#include "toppers/reporter.hpp"

toppers::reporterのコラボレーション図

Collaboration graph
[凡例]
すべてのメンバ一覧

Public 型

typedef const char *(* translator_type )(const char *)
enum  language_type { English, Japanese, number_of_languages }

Public メソッド

 reporter (std::ostream *stream=0)
 コンストラクタ
virtual ~reporter ()
 デストラクタ
void warning (const boost::format &fmt) const
 警告
void warning (const std::string &file, int line, const boost::format &fmt) const
 警告(行番号あり)
void error (const boost::format &fmt) const
 エラー
void error (const std::string &file, int line, const boost::format &fmt) const
 エラー(行番号あり)
void fatal (const boost::format &fmt) const
 致命的エラー
void fatal (const std::string &file, int line, const boost::format &fmt) const
 致命的エラー(行番号あり)
void stop (const boost::format &fmt) const
 プログラムの停止

Static Public メソッド

static void set_program_name (const char *name)
 プログラム名の設定
static void set_default_stream (std::ostream *ostr)
 既定の出力先の設定
static const char * translate (const char *str)
 メッセージ文字列の翻訳
static translator_type set_translator (translator_type func)
 翻訳関数の登録

Protected メソッド

void abort () const
 異常終了

関連する関数

(これらはメソッドでないことに注意)

 rout
 reporter()の記述を簡便化するためのマクロ
 _(msg)
 多言語対応を可能にするための書式化文字列変換マクロ

構成

class  terminator
 エラー発生時の例外クラス [詳細]

説明

処理経過の報告クラス

reporter.hpp63 行で定義されています。


コンストラクタとデストラクタ

toppers::reporter::reporter std::ostream *  stream = 0  )  [explicit]
 

コンストラクタ

引数:
stream メッセージの出力先

reporter.cpp80 行で定義されています。

00080                                          : stream_( stream )
00081   {
00082     if ( stream_ == 0 )
00083     { 
00084       stream_ = default_stream_;
00085     }
00086   }


関数

void toppers::reporter::abort  )  const [protected]
 

異常終了

既存オブジェクトのデストラクタを呼び出せるように例外を送出することで、 プログラムを終了させます。 main関数はtoppersreporter::terminatorをcatchした上で、適切にプログラムを 終了させてください。

例外:
toppers::reporter::terminator 

reporter.cpp239 行で定義されています。

参照元 error()fatal()stop().

00240   { 
00241     throw terminator(); 
00242   }

void toppers::reporter::error const std::string &  file,
int  line,
const boost::format &  fmt
const
 

エラー(行番号あり)

引数:
file エラーが発生したファイル名
line エラーが発生した行番号
fmt 出力メッセージ
例外:
toppers::reporter::terminator 

reporter.cpp137 行で定義されています。

参照先 _abort().

00138   {
00139     *stream_ << program_name << ": " << file << ':' << line << ": " << _( "error: " ) << fmt << std::endl;
00140     if ( --error_count_ <= 0 )
00141     {
00142       abort();
00143     }
00144   }

関数の呼び出しグラフ:

void toppers::reporter::error const boost::format &  fmt  )  const
 

エラー

引数:
fmt 出力メッセージ
例外:
toppers::reporter::terminator 

reporter.cpp121 行で定義されています。

参照先 _abort().

参照元 toppers::error().

00122   {
00123     *stream_ << program_name << ": " << _( "error: " ) << fmt << std::endl;
00124     if ( --error_count_ <= 0 )
00125     {
00126       abort();
00127     }
00128   }

関数の呼び出しグラフ:

void toppers::reporter::fatal const std::string &  file,
int  line,
const boost::format &  fmt
const
 

致命的エラー(行番号あり)

引数:
file 致命的エラーが発生したファイル名
line 致命的エラーが発生した行番号
fmt 出力メッセージ
例外:
toppers::reporter::terminator 

reporter.cpp164 行で定義されています。

参照先 _abort().

00165   {
00166     *stream_ << program_name << ": " << file << ':' << line << ": " << _( "fatal error: " ) << fmt << std::endl;
00167     abort();
00168   }

関数の呼び出しグラフ:

void toppers::reporter::fatal const boost::format &  fmt  )  const
 

致命的エラー

引数:
fmt 出力メッセージ
例外:
toppers::reporter::terminator 

reporter.cpp151 行で定義されています。

参照先 _abort().

参照元 toppers::fatal().

00152   {
00153     *stream_ << program_name << ": " << _( "fatal error: " ) << fmt << std::endl;
00154     abort();
00155   }

関数の呼び出しグラフ:

void toppers::reporter::set_default_stream std::ostream *  ostr  )  [static]
 

既定の出力先の設定

引数:
ostr 出力ストリーム

reporter.cpp194 行で定義されています。

00195   { 
00196     default_stream_ = ostr; 
00197   }

void toppers::reporter::set_program_name const char *  name  )  [static]
 

プログラム名の設定

引数:
name プログラム名

reporter.cpp185 行で定義されています。

参照元 chk_init().

00186   {
00187     program_name = name;
00188   }

reporter::translator_type toppers::reporter::set_translator translator_type  func  )  [static]
 

翻訳関数の登録

引数:
func 登録する翻訳関数へのポインタ
戻り値:
以前に登録されていた翻訳関数へのポインタを返す
参照:
translate

reporter.cpp222 行で定義されています。

参照元 set_language().

00223   {
00224     translator_type prev = translator_;
00225     translator_ = func;
00226     return prev;
00227   }

void toppers::reporter::stop const boost::format &  fmt  )  const
 

プログラムの停止

引数:
fmt 出力メッセージ
例外:
toppers::reporter::terminator 

reporter.cpp175 行で定義されています。

参照先 abort().

参照元 toppers::stop().

00176   {
00177     *stream_ << program_name << ": " << fmt << std::endl;
00178     abort();
00179   }

関数の呼び出しグラフ:

const char * toppers::reporter::translate const char *  str  )  [static]
 

メッセージ文字列の翻訳

引数:
str 翻訳対象の文字列
戻り値:
翻訳後の文字列を返す
参照:
_, set_translator
_()マクロにおいて、書式化文字列を翻訳するために呼び出されます。

reporter.cpp207 行で定義されています。

00208   {
00209     if ( translator_ != 0 )
00210     { 
00211       return ( *translator_ ) ( str ); 
00212     }
00213     return str;
00214   }

void toppers::reporter::warning const std::string &  file,
int  line,
const boost::format &  fmt
const
 

警告(行番号あり)

引数:
file 警告が発生したファイル名
line 警告が発生した行番号
fmt 出力メッセージ

reporter.cpp111 行で定義されています。

参照先 _.

00112   { 
00113     *stream_ << program_name << ": " << file << ':' << line << ": " << _( "warning: " ) << fmt << std::endl; 
00114   }

void toppers::reporter::warning const boost::format &  fmt  )  const
 

警告

引数:
fmt 出力メッセージ

reporter.cpp100 行で定義されています。

参照先 _.

参照元 toppers::warning().

00101   { 
00102     *stream_ << program_name << ": " << _( "warning: " ) << fmt << std::endl; 
00103   }


フレンドと関連する関数

_ msg   )  [related]
 

多言語対応を可能にするための書式化文字列変換マクロ

引数:
msg boost::formatに対する書式化文字列
戻り値:
boost::formatの一時オブジェクト
文字列に対してこのマクロを適用することで、各国語への翻訳が可能になります。 実際に翻訳されるかどうかは、 reporter::set_translator で登録した関数に依存 します。

reporter.hpp205 行で定義されています。

参照元 error()fatal()warning().

rout [related]
 

reporter()の記述を簡便化するためのマクロ

戻り値:
toppers::reporterの一時オブジェクト

reporter.hpp193 行で定義されています。


このクラスの説明は次のファイルから生成されました:
Copyright © 2006 by TAKAGI Nobuhisa.
このページは Wed Apr 12 16:32:03 2006 に Doxygen によって生成されました。