クラス toppers::cmdline::option_arrayコマンドラインオプション格納用コンテナ
[詳細]
#include "toppers/cmdline.hpp"
toppers::cmdline::option_arrayのコラボレーション図
[凡例]すべてのメンバ一覧
|
Public 型 |
typedef std::multimap< std::string,
std::string > | map |
typedef std::set< std::string > | set |
Public メソッド |
| option_array () |
| デフォルトコンストラクタ
|
bool | find (const std::string &key) const |
| オプションの有無判定
|
bool | find (const std::string &key, std::string &arg) const |
| オプションの有無判定及び引数の取得
|
bool | find (const std::string &key, std::vector< std::string > &args) const |
| オプションの有無判定及び引数の取得(複数対応)
|
void | insert (const std::string &key, const std::string &value) |
| オプションの挿入
|
bool | replace (const std::string &key, const std::string &value) |
| オプション引数の置換
|
void | remap_option (const std::string &old_key, const std::string &new_key) |
| コマンドラインオプションのキー変更
|
void | swap (option_array &other) throw () |
| オブジェクトの交換
|
フレンド |
class | cmdline |
説明
コマンドラインオプション格納用コンテナ
cmdline.hpp の 73 行で定義されています。
関数
bool toppers::cmdline::option_array::find |
( |
const std::string & |
key, |
|
|
std::vector< std::string > & |
args |
|
) |
const |
|
|
オプションの有無判定及び引数の取得(複数対応)
- 引数:
-
- 戻り値:
- オプションがあればtrueを返す
この関数では key で指定されたオプションが複数指定された場合に、それぞれの引数を 取得するために使用します。
cmdline.cpp の 133 行で定義されています。 00134 {
00135 std::pair<map::const_iterator, map::const_iterator> range( map_.equal_range( key ) );
00136 std::string opt_key( key );
00137 if ( range.first == range.second )
00138 {
00139 char ch = *key.rbegin();
00140 if ( ch == ':' || ch == '=' )
00141 {
00142 return false;
00143 }
00144 else
00145 {
00146 opt_key = key + ":";
00147 range = map_.equal_range( opt_key );
00148 if ( range.first == range.second )
00149 {
00150 opt_key = key + "=";
00151 range = map_.equal_range( key );
00152 if ( range.first == range.second )
00153 {
00154 return false;
00155 }
00156 }
00157 }
00158 }
00159
00160 std::vector<std::string> t;
00161 for ( map::const_iterator iter( range.first ), last( range.second ); iter != last; ++iter )
00162 {
00163 if ( iter->first == opt_key )
00164 {
00165 t.push_back( iter->second );
00166 }
00167 }
00168 args.swap( t );
00169 return true;
00170 }
|
bool toppers::cmdline::option_array::find |
( |
const std::string & |
key, |
|
|
std::string & |
arg |
|
) |
const |
|
|
オプションの有無判定及び引数の取得
- 引数:
-
- 戻り値:
- オプションがあればtrueを返す
cmdline.cpp の 96 行で定義されています。 00097 {
00098 map::const_iterator nil( map_.end() );
00099 map::const_iterator iter( map_.find( key ) );
00100 if ( iter == nil )
00101 {
00102 char ch = *key.rbegin();
00103 if ( ch == ':' || ch == '=' )
00104 {
00105 return false;
00106 }
00107 else
00108 {
00109 iter = map_.find( key + ":" );
00110 if ( iter == nil )
00111 {
00112 iter = map_.find( key + ":" );
00113 if ( iter == nil )
00114 {
00115 return false;
00116 }
00117 }
00118 }
00119 }
00120 arg = iter->second;
00121 return true;
00122 }
|
bool toppers::cmdline::option_array::find |
( |
const std::string & |
key |
) |
const |
|
|
オプションの有無判定
- 引数:
-
- 戻り値:
- オプションがあればtrueを返す
cmdline.cpp の 66 行で定義されています。 00067 {
00068 map::const_iterator nil( map_.end() );
00069 if ( map_.find( key ) == nil )
00070 {
00071 char ch = *key.rbegin();
00072 if ( ch == ':' || ch == '=' )
00073 {
00074 return false;
00075 }
00076 else
00077 {
00078 if ( map_.find( key + ":" ) == nil )
00079 {
00080 if ( map_.find( key + "=" ) == nil )
00081 {
00082 return false;
00083 }
00084 }
00085 }
00086 }
00087 return true;
00088 }
|
void toppers::cmdline::option_array::insert |
( |
const std::string & |
key, |
|
|
const std::string & |
value |
|
) |
|
|
|
オプションの挿入
- 引数:
-
| key | オプション名 |
| value | オプション引数(文字列) |
cmdline.cpp の 177 行で定義されています。 00178 {
00179 map_.insert( map::value_type( key, value ) );
00180 }
|
void toppers::cmdline::option_array::remap_option |
( |
const std::string & |
old_key, |
|
|
const std::string & |
new_key |
|
) |
|
|
|
コマンドラインオプションのキー変更
- 引数:
-
| old_key | 変更前のキー |
| new_key | 変更後のキー |
この関数はコマンドラインオプションとして登録された内容を別名で登録しなおします。 別名の同義のオプションを同じ名前に統一する場合等に使用します。
cmdline.cpp の 207 行で定義されています。 00208 {
00209 map::iterator iter( map_.find( old_key ) );
00210 if ( iter != map_.end() )
00211 {
00212 map::value_type value( new_key, iter->second );
00213 map_.erase( iter );
00214 map_.insert( value );
00215 }
00216 }
|
bool toppers::cmdline::option_array::replace |
( |
const std::string & |
key, |
|
|
const std::string & |
value |
|
) |
|
|
|
オプション引数の置換
- 引数:
-
- 戻り値:
- オプションがあればtrueを返す
cmdline.cpp の 188 行で定義されています。 00189 {
00190 map::iterator iter( map_.find( key ) );
00191 if ( iter == map_.end() )
00192 {
00193 return false;
00194 }
00195 iter->second = value;
00196 return true;
00197 }
|
void toppers::cmdline::option_array::swap |
( |
option_array & |
other |
) |
throw () |
|
|
オブジェクトの交換
- 引数:
-
cmdline.cpp の 222 行で定義されています。 00223 {
00224 map_.swap( other.map_ );
00225 set_.swap( other.set_ );
00226 }
|
このクラスの説明は次のファイルから生成されました:
Copyright © 2006 by TAKAGI Nobuhisa.
このページは Wed Apr 12 16:32:03 2006 に Doxygen によって生成されました。
|
|