从一个表示货币值的字符序列提取一个数值。
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
要求
标头: <locale>
命名空间: std