money_get::get
通貨値を表す文字のシーケンスから数値を展開します。
iter_type get(
iter_type _First,
iter_type _Last,
bool _Intl,
ios_base& _Iosbase,
ios_base::iostate& _State,
long double& _Val
) const;
iter_type get(
iter_type _First,
iter_type _Last,
bool _Intl,
ios_base& _Iosbase,
ios_base::iostate& _State,
string_type& _Val
) const;
パラメーター
_First
変換するシーケンスの開始位置を示す入力反復子。_Last
変換するシーケンスの末尾を示す入力反復子。_Intl
シーケンスで想定される通貨記号の種類を示すブール値: true International 場合、false 各国の場合は。_Iosbase
通貨記号は省略可能であることを示す場合は書式指定フラグ; それ以外の場合は必須です_State
操作が成功したかどうかに応じてストリームの状態に適したビットマスクの要素を設定します。_Val
変換されたシーケンスを格納する文字列。
戻り値
通貨入力フィールドを超える最初の要素を示す入力反復子。
解説
両方のメンバー関数は do_get (_First,_Last,_Intl、_Iosbase、_State、_Val)。
使用例
// money_get_get.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
using namespace std;
int main( )
{
locale loc( "german_germany" );
basic_stringstream< char > psz;
psz << use_facet<moneypunct<char, 1> >(loc).curr_symbol() << "-1.000,56";
basic_stringstream< char > psz2;
psz2 << "-100056" << use_facet<moneypunct<char, 1> >(loc).curr_symbol();
ios_base::iostate st = 0;
long double fVal;
psz.flags( psz.flags( )|ios_base::showbase );
// Which forced the READING the currency symbol
psz.imbue(loc);
use_facet < money_get < char > >( loc ).
get( basic_istream<char>::_Iter( psz.rdbuf( ) ),
basic_istream<char>::_Iter( 0 ), true, psz, st, fVal );
if ( st & ios_base::failbit )
cout << "money_get(" << psz.str( ) << ", intl = 1) FAILED"
<< endl;
else
cout << "money_get(" << psz.str( ) << ", intl = 1) = "
<< fVal/100.0 << endl;
use_facet < money_get < char > >( loc ).
get(basic_istream<char>::_Iter(psz2.rdbuf( )),
basic_istream<char>::_Iter(0), false, psz2, st, fVal);
if ( st & ios_base::failbit )
cout << "money_get(" << psz2.str( ) << ", intl = 0) FAILED"
<< endl;
else
cout << "money_get(" << psz2.str( ) << ", intl = 0) = "
<< fVal/100.0 << endl;
};
出力例
Windows 2000 またはを先に実行する場合、この出力を取得します:
money_get(DEM-1.000,56, intl = 1) = -1000.56
money_get(-100056DM, intl = 0) = -1000.56
Windows XP を実行して、この出力を取得します:
money_get(EUR-1.000,56, intl = 1) = -1000.56
money_get(-100056EUR, intl = 0) = -1000.56
必要条件
ヘッダー: <locale>
名前空間: std