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,如果,国际 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
要求
页眉: <区域设置>
命名空间: std