📄 _money.cc
字号:
_C_put_money_sub (__pbuf, __pbuf + __size, __neg, __fill);
// delete only if allocated
if (__pbuf != __wide_buf)
delete[] __pbuf;
}
template <class _CharT>
void __rw_money_writer_base_1<_CharT>::_C_put_money
(const string_type& __digits, _CharT __fill)
{
const _CharT *punct =
__rw_digit_map<_CharT>::_C_get_digit_map(writer._C_ctyp)
._C_get_punct();
const _CharT *__start = __digits.c_str();
bool __neg;
if (*__start==punct[__rw_digit_map_base::_C_minus]) {
__neg=true;
__start++;
} else
__neg=false;
const _CharT *end=writer._C_ctyp.scan_not(_STD::ctype_base::digit,
__start,
__digits.c_str()+__digits.length());
_C_put_money_sub(__start, end, __neg, __fill);
}
// -------------------------------------------------------------------------
// Template __rw_money_writer_base_2<_CharT, _OutputIter> member templates.
// -------------------------------------------------------------------------
template <class _CharT, class _OutputIter>
void __rw_money_writer_base_2<_CharT, _OutputIter>::_C_put_money_sub
(const _CharT *__begin, const _CharT *__end, bool __neg, _CharT __fill)
{
const _STD::money_base::pattern *__pat;
const string_type *__sign;
if (__neg) {
__pat = &this->_C_get_neg_format();
__sign = &this->_C_get_negative_sign();
} else {
__pat = &this->_C_get_pos_format();
__sign = &this->_C_get_positive_sign();
}
int __frac_dig = this->_C_get_frac_digits();
int __int_dig = int (__end - __begin) - __frac_dig;
int __ungrp;
int __pad;
if (__int_dig<0) {
__pad = -__int_dig;
__int_dig = 0;
} else
__pad = 0;
_CharT __sep = _CharT ();
if (__int_dig > 0) {
__ungrp = this->_C_calc_groups (__int_dig, this->_C_get_grouping ());
if (this->_C_num_groups)
__sep = this->_C_get_thousands_sep();
} else
__ungrp = 0;
const char *__p;
const char *__pend = __pat->field + sizeof __pat->field;
int __l_fill = 0; // left fill
int __i_fill = 0; // internal fill
int __r_fill = 0; // right fill
if (this->_C_width) {
int __n=0;
for (__p=__pat->field; __p<__pend; __p++) {
switch (*__p) {
case _STD::money_base::space:
__n++;
break;
case _STD::money_base::symbol:// save pptr pos
if (this->_C_flags& ios_base::showbase)
__n+=int(this->_C_get_curr_symbol().length());
break;
case _STD::money_base::sign:
__n += int (__sign->length());
break;
case _STD::money_base::value:
__n+=__int_dig+this->_C_num_groups;
if (__frac_dig)
__n+=__frac_dig+1;
break;
}
}
if ((__n-=this->_C_width)>0) {
switch (this->_C_adjust) {
case __rw_digit_writer_base::_C_left:
__r_fill=__n;
break;
case __rw_digit_writer_base::_C_internal:
__i_fill=__n;
break;
default:
__l_fill=__n;
}
}
this->_C_width=0;
}
if (__l_fill)
do *this->_C_out++=__fill;
while (--__l_fill);
const _CharT *__schar = __sign->c_str();
for (__p=__pat->field; __p<__pend; __p++)
switch (*__p) {
case _STD::money_base::symbol:
if (this->_C_flags& ios_base::showbase)
this->_C_put_keyword (this->_C_get_curr_symbol(), __fill);
break;
case _STD::money_base::sign:
if (*__schar)
*this->_C_out++=*__schar++;
break;
case _STD::money_base::value:
while (__ungrp--)
*this->_C_out++=*__begin++;
while (this->_C_num_groups--) {
*this->_C_out++=__sep;
while ((*this->_C_group)--)
*this->_C_out++=*__begin++;
this->_C_group++;
}
if (__frac_dig) {
*this->_C_out++=this->_C_get_decimal_point();
while (__pad--) {
__frac_dig--;
*this->_C_out++=this->_C_ctyp.widen('0');
}
while (__frac_dig-->0)
*this->_C_out++=*__begin++;
}
break;
case _STD::money_base::space:
if (!__i_fill) {
*this->_C_out++=this->_C_ctyp.widen(' ');
break;
}
// Fall through ...
case _STD::money_base::none:
if (__i_fill)
do *this->_C_out++=__fill;
while (--__i_fill);
break;
}
while (*__schar)
*this->_C_out++=*__schar++;
if (__r_fill+=__i_fill) {
do *this->_C_out++=__fill;
while (--__r_fill);
}
}
_RWSTD_NAMESPACE_END // __rw
_RWSTD_NAMESPACE_BEGIN (std)
// ------------------------------------------------------
// Facet money_get<_CharT, _InputIter> member templates.
// ------------------------------------------------------
template <class _CharT, class _InputIter>
locale::id money_get<_CharT, _InputIter>::id;
// Warning -- these functions do not input actual monetary value; they just
// input numbers that represent monetary value.
template <class _CharT, class _InputIter>
_InputIter money_get<_CharT, _InputIter>::
do_get (_InputIter __begin, _InputIter __end, bool __intl, ios_base& __flags,
ios_base::iostate& __err, long double& __units) const {
_RW::__rw_money_reader<_CharT, _InputIter> __reader (__begin, __end,
__flags,__intl);
long double __val = __reader._C_parse (__reader._C_get_money_digits(),
0.0L);
__err = ios_base::goodbit;
if (__reader._C_error)
__err = ios_base::failbit;
else
__units = __val;
if (__reader.eof ())
__err |= ios_base::eofbit;
return __begin;
}
template <class _CharT, class _InputIter>
_InputIter money_get<_CharT, _InputIter>::
do_get (_InputIter __begin, _InputIter __end, bool __intl, ios_base &__flags,
ios_base::iostate &__err, string_type &__digits) const
{
_RW::__rw_money_reader<_CharT, _InputIter> reader(__begin, __end,
__flags, __intl);
__err = ios_base::goodbit;
if (reader._C_error)
__err = ios_base::failbit;
else
reader._C_get_money_string (__digits, reader._C_get_money_digits());
if (reader.eof ())
__err |= ios_base::eofbit;
return __begin;
}
// -------------------------------------------------------
// Facet money_put<_CharT, _OutputIter> member templates.
// -------------------------------------------------------
template <class _CharT, class _OutputIter>
locale::id money_put<_CharT, _OutputIter>::id;
template <class _CharT, class _OutputIter>
_OutputIter money_put<_CharT, _OutputIter>::
do_put (_OutputIter __it, bool __intl, ios_base& __flags, _CharT __fill,
#ifndef _RWSTD_NO_LONG_DOUBLE
long double __quant) const __softfp
#else
double __quant) const __softfp
#endif
{
_RW::__rw_money_writer<_CharT, _OutputIter> __writer(__it, __flags, __intl);
__writer._C_digitize(__quant);
__writer._C_put_money(__fill);
return __it;
}
template <class _CharT, class _OutputIter>
_OutputIter money_put<_CharT, _OutputIter>::do_put
(_OutputIter __it, bool __intl, ios_base& __flags, _CharT __fill,
const string_type& __digits) const {
_RW::__rw_money_writer<_CharT, _OutputIter> __writer(__it, __flags, __intl);
__writer._C_put_money (__digits, __fill);
return __it;
}
// ----------------------------------------------
// Facet moneypunct<_CharT, Intl> member templates.
// ----------------------------------------------
template <class _CharT, bool _Intl>
locale::id moneypunct<_CharT, _Intl>::id;
#ifndef _RWSTD_NO_STATIC_CONST_MEMBER_INIT
template <class _CharT, bool _Intl>
const bool moneypunct<_CharT, _Intl>::intl;
#endif
template <class _CharT, bool _Intl>
_CharT moneypunct<_CharT, _Intl>::do_decimal_point () const {
return this->_C_dp;
}
template <class _CharT, bool _Intl>
_CharT moneypunct<_CharT, _Intl>::do_thousands_sep () const {
return this->_C_ts;
}
template <class _CharT, bool _Intl>
string moneypunct<_CharT, _Intl>::do_grouping () const {
return this->_C_gr;
}
template <class _CharT, bool _Intl>
_TYPENAME moneypunct<_CharT, _Intl>::string_type
moneypunct<_CharT, _Intl>::do_curr_symbol () const {
return this->_C_cs;
}
template <class _CharT, bool _Intl>
_TYPENAME moneypunct<_CharT, _Intl>::string_type
moneypunct<_CharT, _Intl>::do_positive_sign () const {
return this->_C_ps;
}
template <class _CharT, bool _Intl>
_TYPENAME moneypunct<_CharT, _Intl>::string_type
moneypunct<_CharT, _Intl>::do_negative_sign () const {
return this->_C_ns;
}
template <class _CharT, bool _Intl>
int moneypunct<_CharT, _Intl>::do_frac_digits () const {
return this->_C_fd;
}
template <class _CharT, bool _Intl>
money_base::pattern
moneypunct<_CharT, _Intl>::do_pos_format () const {
return this->_C_pf;
}
template <class _CharT, bool _Intl>
money_base::pattern
moneypunct<_CharT, _Intl>::do_neg_format () const {
return this->_C_nf;
}
template <class _CharT, bool _Intl>
void moneypunct<_CharT, _Intl>::_C_initfacet (const locale&)
{
this->_C_dp = do_decimal_point();
this->_C_ts = do_thousands_sep();
this->_C_gr = do_grouping();
this->_C_cs = do_curr_symbol();
this->_C_ps = do_positive_sign();
this->_C_ns = do_negative_sign();
this->_C_fd = do_frac_digits();
this->_C_pf = do_pos_format();
this->_C_nf = do_neg_format();
}
_RWSTD_NAMESPACE_END // std
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -