williamr@2: /* williamr@4: * Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. williamr@2: * williamr@2: * Copyright (c) 1999 williamr@2: * Silicon Graphics Computer Systems, Inc. williamr@2: * williamr@4: * Copyright (c) 1999 williamr@2: * Boris Fomitchev williamr@2: * williamr@2: * This material is provided "as is", with absolutely no warranty expressed williamr@2: * or implied. Any use is at your own risk. williamr@2: * williamr@4: * Permission to use or copy this software for any purpose is hereby granted williamr@2: * without fee, provided the above notices are retained on all copies. williamr@2: * Permission to modify the code and to distribute modified code is granted, williamr@2: * provided the above notices are retained, and a notice that the code was williamr@2: * modified is included with the above copyright notice. williamr@2: * williamr@4: */ williamr@2: #ifndef _STLP_MONETARY_C williamr@2: #define _STLP_MONETARY_C williamr@2: williamr@2: # ifndef _STLP_INTERNAL_MONETARY_H williamr@2: # include williamr@2: # endif williamr@2: williamr@2: #ifndef _STLP_INTERNAL_IOS_H williamr@2: # include williamr@2: #endif williamr@2: williamr@2: #ifndef _STLP_INTERNAL_NUM_PUT_H williamr@2: # include williamr@2: #endif williamr@2: williamr@2: #ifndef _STLP_INTERNAL_NUM_GET_H williamr@2: # include williamr@2: #endif williamr@2: williamr@2: _STLP_BEGIN_NAMESPACE williamr@2: williamr@4: #if (_STLP_STATIC_TEMPLATE_DATA > 0) williamr@4: #if !defined(__SYMBIAN32__WSD__) williamr@4: williamr@4: # if !defined (__BORLANDC__) && (defined (__SYMBIAN32__) && defined(_STLP_DESIGNATED_DLL)) williamr@2: template williamr@2: locale::id money_get<_CharT, _InputIterator>::id; williamr@2: williamr@2: template williamr@2: locale::id money_put<_CharT, _OutputIterator>::id; williamr@4: # endif williamr@4: williamr@4: # if ((defined (__CYGWIN__) || defined (__MINGW32__)) && \ williamr@4: defined (_STLP_USE_DYNAMIC_LIB) && !defined (__BUILDING_STLPORT)) || (defined (__SYMBIAN32__) && defined(_STLP_DESIGNATED_DLL)) williamr@4: /* williamr@4: * Under cygwin, when STLport is used as a shared library, the id needs williamr@4: * to be specified as imported otherwise they will be duplicated in the williamr@4: * calling executable. williamr@4: */ williamr@4: #if defined (__SYMBIAN32__) williamr@4: template <> williamr@4: locale::id money_get > >::id; //_STLP_DECLSPEC removed; data should not be exported in symbian. williamr@4: /* williamr@4: template <> williamr@4: _STLP_DECLSPEC locale::id money_get::id; williamr@4: */ williamr@4: williamr@4: template <> williamr@4: locale::id money_put > >::id; williamr@4: template <> williamr@4: locale::id money_put::id; williamr@4: williamr@4: # if !defined (_STLP_NO_WCHAR_T) williamr@4: template <> williamr@4: locale::id money_get > >::id; williamr@4: template <> williamr@4: locale::id money_get::id; williamr@4: williamr@4: template <> williamr@4: locale::id money_put > >::id; williamr@4: template <> williamr@4: locale::id money_put::id; williamr@4: # endif /* _STLP_NO_WCHAR_T */ williamr@4: williamr@4: #else williamr@4: template <> williamr@4: _STLP_DECLSPEC locale::id money_get > >::id; williamr@4: /* williamr@4: template <> williamr@4: _STLP_DECLSPEC locale::id money_get::id; williamr@4: */ williamr@4: williamr@4: template <> williamr@4: _STLP_DECLSPEC locale::id money_put > >::id; williamr@4: template <> williamr@4: _STLP_DECLSPEC locale::id money_put::id; williamr@4: williamr@4: # if !defined (_STLP_NO_WCHAR_T) williamr@4: template <> williamr@4: _STLP_DECLSPEC locale::id money_get > >::id; williamr@4: template <> williamr@4: _STLP_DECLSPEC locale::id money_get::id; williamr@4: williamr@4: template <> williamr@4: _STLP_DECLSPEC locale::id money_put > >::id; williamr@4: template <> williamr@4: _STLP_DECLSPEC locale::id money_put::id; williamr@4: # endif /* _STLP_NO_WCHAR_T */ williamr@4: williamr@2: #endif williamr@2: williamr@4: #endif /* (defined (__CYGWIN__) || defined (__MINGW32__)) */ williamr@4: #endif /* __SYMBIAN32__WSD__ */ williamr@4: williamr@4: #else /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */ williamr@4: williamr@4: //typedef money_get money_get_char; williamr@4: //typedef money_put money_put_char; williamr@2: typedef money_get > > money_get_char_2; williamr@2: typedef money_put > > money_put_char_2; williamr@2: williamr@4: //__DECLARE_INSTANCE(locale::id, money_get_char::id, ); williamr@4: //__DECLARE_INSTANCE(locale::id, money_put_char::id, ); williamr@2: __DECLARE_INSTANCE(locale::id, money_get_char_2::id, ); williamr@2: __DECLARE_INSTANCE(locale::id, money_put_char_2::id, ); williamr@2: williamr@4: # ifndef _STLP_NO_WCHAR_T williamr@2: williamr@4: //typedef money_get money_get_wchar_t; williamr@4: //typedef money_get > > money_get_wchar_t_2; williamr@2: typedef money_put money_put_wchar_t; williamr@2: typedef money_put > > money_put_wchar_t_2; williamr@2: williamr@4: //__DECLARE_INSTANCE(locale::id, money_get_wchar_t::id, ); williamr@4: //__DECLARE_INSTANCE(locale::id, money_put_wchar_t::id, ); williamr@2: __DECLARE_INSTANCE(locale::id, money_get_wchar_t_2::id, ); williamr@2: __DECLARE_INSTANCE(locale::id, money_put_wchar_t_2::id, ); williamr@2: williamr@4: # endif /* _STLP_NO_WCHAR_T */ williamr@4: #endif /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */ williamr@2: williamr@2: // money_get facets williamr@2: williamr@4: _STLP_MOVE_TO_PRIV_NAMESPACE williamr@2: williamr@2: // helper functions for do_get williamr@2: template williamr@4: pair<_InIt1, bool> __get_string( _InIt1 __first, _InIt1 __last, williamr@4: _InIt2 __str_first, _InIt2 __str_last) { williamr@4: while ( __first != __last && __str_first != __str_last && *__first == *__str_first ) { williamr@4: ++__first; williamr@4: ++__str_first; williamr@4: } williamr@4: return make_pair(__first, __str_first == __str_last); williamr@2: } williamr@2: williamr@2: template williamr@2: bool williamr@4: __get_monetary_value(_InIt& __first, _InIt __last, _OuIt __out_ite, williamr@2: const ctype<_CharT>& _c_type, williamr@4: _CharT __point, int __frac_digits, _CharT __sep, williamr@4: const string& __grouping, bool &__syntax_ok) { williamr@2: if (__first == __last || !_c_type.is(ctype_base::digit, *__first)) williamr@2: return false; williamr@2: williamr@2: char __group_sizes[128]; williamr@4: char* __group_sizes_end = __grouping.empty()? 0 : __group_sizes; williamr@2: char __current_group_size = 0; williamr@2: williamr@2: while (__first != __last) { williamr@2: if (_c_type.is(ctype_base::digit, *__first)) { williamr@2: ++__current_group_size; williamr@4: *__out_ite++ = *__first++; williamr@2: } williamr@2: else if (__group_sizes_end) { williamr@2: if (*__first == __sep) { williamr@4: *__group_sizes_end++ = __current_group_size; williamr@4: __current_group_size = 0; williamr@4: ++__first; williamr@2: } williamr@2: else break; williamr@2: } williamr@2: else williamr@2: break; williamr@2: } williamr@2: williamr@4: if (__grouping.empty()) williamr@2: __syntax_ok = true; williamr@2: else { williamr@2: if (__group_sizes_end != __group_sizes) williamr@4: *__group_sizes_end++ = __current_group_size; williamr@4: williamr@2: __syntax_ok = __valid_grouping(__group_sizes, __group_sizes_end, williamr@4: __grouping.data(), __grouping.data()+ __grouping.size()); williamr@4: williamr@2: if (__first == __last || *__first != __point) { williamr@2: for (int __digits = 0; __digits != __frac_digits; ++__digits) williamr@4: *__out_ite++ = _CharT('0'); williamr@2: return true; // OK not to have decimal point williamr@2: } williamr@2: } williamr@2: williamr@4: ++__first; williamr@2: williamr@4: int __digits = 0; williamr@2: williamr@4: while (__first != __last && _c_type.is(ctype_base::digit, *__first)) { williamr@4: *__out_ite++ = *__first++; williamr@4: ++__digits; williamr@2: } williamr@2: williamr@4: __syntax_ok = __syntax_ok && (__digits == __frac_digits); williamr@2: williamr@2: return true; williamr@2: } williamr@2: williamr@2: williamr@4: template williamr@4: _InputIter __money_do_get(_InputIter __s, _InputIter __end, bool __intl, williamr@4: ios_base& __str, ios_base::iostate& __err, williamr@4: _StrType& __digits, bool &__is_positive, _CharT* /*__dummy*/) { williamr@2: if (__s == __end) { williamr@2: __err |= ios_base::eofbit; williamr@2: return __s; williamr@2: } williamr@2: williamr@4: typedef _CharT char_type; williamr@4: typedef _StrType string_type; williamr@4: typedef _InputIter iter_type; williamr@4: typedef moneypunct _Punct; williamr@4: typedef moneypunct _Punct_intl; williamr@4: typedef ctype _Ctype; williamr@2: williamr@2: locale __loc = __str.getloc(); williamr@2: const _Punct& __punct = use_facet<_Punct>(__loc) ; williamr@2: const _Punct_intl& __punct_intl = use_facet<_Punct_intl>(__loc) ; williamr@4: const _Ctype& __c_type = use_facet<_Ctype>(__loc) ; williamr@4: williamr@2: money_base::pattern __format = __intl ? __punct_intl.neg_format() williamr@2: : __punct.neg_format(); williamr@2: string_type __ns = __intl ? __punct_intl.negative_sign() williamr@2: : __punct.negative_sign(); williamr@2: string_type __ps = __intl ? __punct_intl.positive_sign() williamr@2: : __punct.positive_sign(); williamr@2: int __i; williamr@4: bool __symbol_required = (__str.flags() & ios_base::showbase) != 0; williamr@2: string_type __buf; williamr@4: back_insert_iterator __out_ite(__buf); williamr@2: williamr@2: for (__i = 0; __i < 4; ++__i) { williamr@2: switch (__format.field[__i]) { williamr@4: case money_base::none: williamr@2: if (__i == 3) { williamr@4: if (__c_type.is(ctype_base::space, *__s)) { williamr@2: __err = ios_base::failbit; williamr@2: return __s; williamr@2: } williamr@4: break; williamr@2: } williamr@2: while (__s != __end && __c_type.is(ctype_base::space, *__s)) williamr@2: ++__s; williamr@2: break; williamr@4: case money_base::space: williamr@2: if (!__c_type.is(ctype_base::space, *__s)) { williamr@2: __err = ios_base::failbit; williamr@2: return __s; williamr@2: } williamr@2: ++__s; williamr@2: while (__s != __end && __c_type.is(ctype_base::space, *__s)) williamr@2: ++__s; williamr@2: break; williamr@2: case money_base::symbol: { williamr@2: string_type __curs = __intl ? __punct_intl.curr_symbol() williamr@4: : __punct.curr_symbol(); williamr@2: pair williamr@2: __result = __get_string(__s, __end, __curs.begin(), __curs.end()); williamr@2: if (!__result.second && __symbol_required) williamr@2: __err = ios_base::failbit; williamr@2: __s = __result.first; williamr@2: break; williamr@2: } williamr@2: case money_base::sign: { williamr@2: if (__s == __end) { williamr@4: if (__ps.empty()) williamr@2: break; williamr@4: if (__ns.empty()) { williamr@2: __is_positive = false; williamr@2: break; williamr@2: } williamr@2: __err = ios_base::failbit; williamr@2: return __s; williamr@2: } williamr@2: else { williamr@4: if (__ps.empty()) { williamr@4: if (__ns.empty()) williamr@2: break; williamr@2: if (*__s == __ns[0]) { williamr@2: ++__s; williamr@2: __is_positive = false; williamr@2: } williamr@4: break; williamr@4: } williamr@2: else { williamr@2: if (*__s == __ps[0]) { williamr@2: ++__s; williamr@2: break; williamr@2: } williamr@4: if (__ns.empty()) williamr@2: break; williamr@2: if (*__s == __ns[0]) { williamr@2: ++__s; williamr@2: __is_positive = false; williamr@2: break; williamr@2: } williamr@2: __err = ios_base::failbit; williamr@2: } williamr@2: } williamr@2: return __s; williamr@2: } williamr@2: case money_base::value: { williamr@4: char_type __point = __intl ? __punct_intl.decimal_point() williamr@4: : __punct.decimal_point(); williamr@2: int __frac_digits = __intl ? __punct_intl.frac_digits() williamr@2: : __punct.frac_digits(); williamr@2: string __grouping = __intl ? __punct_intl.grouping() williamr@2: : __punct.grouping(); williamr@2: bool __syntax_ok = true; williamr@2: williamr@2: bool __result; williamr@2: williamr@4: char_type __sep = __grouping.empty() ? char_type() : williamr@4: __intl ? __punct_intl.thousands_sep() : __punct.thousands_sep(); williamr@2: williamr@4: __result = __get_monetary_value(__s, __end, __out_ite, __c_type, williamr@2: __point, __frac_digits, williamr@2: __sep, williamr@4: __grouping, __syntax_ok); williamr@2: williamr@2: if (!__syntax_ok) williamr@2: __err |= ios_base::failbit; williamr@2: if (!__result) { williamr@2: __err = ios_base::failbit; williamr@2: return __s; williamr@2: } williamr@2: break; williamr@4: williamr@2: } // Close money_base::value case williamr@2: } // Close switch statement williamr@2: } // Close for loop williamr@2: williamr@2: if (__is_positive) { williamr@2: if (__ps.size() > 1) { williamr@2: pair<_InputIter, bool> williamr@2: __result = __get_string(__s, __end, __ps.begin() + 1, __ps.end()); williamr@2: __s = __result.first; williamr@2: if (!__result.second) williamr@4: __err |= ios::failbit; williamr@2: } williamr@2: if (!(__err & ios_base::failbit)) williamr@2: __digits = __buf; williamr@2: } williamr@2: else { williamr@2: if (__ns.size() > 1) { williamr@2: pair<_InputIter, bool> williamr@2: __result = __get_string(__s, __end, __ns.begin() + 1, __ns.end()); williamr@2: __s = __result.first; williamr@2: if (!__result.second) williamr@4: __err |= ios::failbit; williamr@2: } williamr@4: if (!(__err & ios::failbit)) { williamr@4: __digits = __c_type.widen('-'); williamr@4: __digits += __buf; williamr@2: } williamr@2: } williamr@2: if (__s == __end) williamr@2: __err |= ios::eofbit; williamr@2: williamr@2: return __s; williamr@2: } williamr@2: williamr@4: _STLP_MOVE_TO_STD_NAMESPACE williamr@4: williamr@4: //===== methods ====== williamr@4: template williamr@4: _InputIter williamr@4: money_get<_CharT, _InputIter>::do_get(_InputIter __s, _InputIter __end, bool __intl, williamr@4: ios_base& __str, ios_base::iostate& __err_, williamr@4: _STLP_LONGEST_FLOAT_TYPE& __units) const { williamr@4: ios_base::iostate __err = 0; williamr@4: string_type __buf; williamr@4: bool __is_positive = true; williamr@4: __s = _STLP_PRIV __money_do_get(__s, __end, __intl, __str, __err, __buf, __is_positive, (_CharT*)0); williamr@4: williamr@4: if (__err == ios_base::goodbit || __err == ios_base::eofbit) { williamr@4: typename string_type::iterator __b = __buf.begin(), __e = __buf.end(); williamr@4: williamr@4: if (!__is_positive) ++__b; williamr@4: // Can't use atold, since it might be wchar_t. Don't get confused by name below : williamr@4: // it's perfectly capable of reading long double. williamr@4: _STLP_PRIV __get_decimal_integer(__b, __e, __units, (_CharT*)0); williamr@4: williamr@4: if (!__is_positive) { williamr@4: __units = -__units; williamr@4: } williamr@4: } williamr@4: if ( (__err & ios_base::failbit == 1) || (__err & ios_base::eofbit == 1) ) { williamr@4: __err_ |= __err; williamr@4: } williamr@4: return __s; williamr@4: } williamr@4: williamr@4: template williamr@4: _InputIter williamr@4: money_get<_CharT, _InputIter>::do_get(iter_type __s, iter_type __end, bool __intl, williamr@4: ios_base& __str, ios_base::iostate& __err, williamr@4: string_type& __digits) const { williamr@4: bool __is_positive = true; williamr@4: return _STLP_PRIV __money_do_get(__s, __end, __intl, __str, __err, __digits, __is_positive, (_CharT*)0); williamr@4: } williamr@4: williamr@2: // money_put facets williamr@2: williamr@4: _STLP_MOVE_TO_PRIV_NAMESPACE williamr@4: williamr@4: template williamr@4: _OutputIter __money_do_put(_OutputIter __s, bool __intl, ios_base& __str, williamr@4: _CharT __fill, const _Str& __digits, bool __check_digits, williamr@4: _Str_Type * /*__dummy*/) { williamr@4: typedef _CharT char_type; williamr@4: typedef _Str_Type string_type; williamr@4: typedef ctype _Ctype; williamr@4: typedef moneypunct _Punct; williamr@4: typedef moneypunct _Punct_intl; williamr@2: williamr@2: locale __loc = __str.getloc(); williamr@4: const _Ctype& __c_type = use_facet<_Ctype>(__loc) ; williamr@2: const _Punct& __punct = use_facet<_Punct>(__loc) ; williamr@2: const _Punct_intl& __punct_intl = use_facet<_Punct_intl>(__loc) ; williamr@2: williamr@2: // some special characters williamr@2: char_type __minus = __c_type.widen('-'); williamr@2: char_type __plus = __c_type.widen('+'); williamr@2: char_type __space = __c_type.widen(' '); williamr@2: char_type __zero = __c_type.widen('0'); williamr@4: char_type __point = __intl ? __punct_intl.decimal_point() williamr@4: : __punct.decimal_point(); williamr@2: williamr@2: char_type __sep = __intl ? __punct_intl.thousands_sep() williamr@4: : __punct.thousands_sep(); williamr@2: williamr@2: string __grouping = __intl ? __punct_intl.grouping() williamr@4: : __punct.grouping(); williamr@4: williamr@4: int __frac_digits = __intl ? __punct_intl.frac_digits() williamr@2: : __punct.frac_digits(); williamr@2: williamr@4: string_type __curr_sym = __intl ? __punct_intl.curr_symbol() williamr@2: : __punct.curr_symbol(); williamr@2: williamr@4: // if there are no digits we are going to return __s. If there williamr@4: // are digits, but not enough to fill the frac_digits, we are williamr@4: // going to add zeros. I don't know whether this is right or williamr@4: // not. williamr@4: if (__digits.empty()) williamr@2: return __s; williamr@2: williamr@2: typename string_type::const_iterator __digits_first = __digits.begin(); williamr@2: typename string_type::const_iterator __digits_last = __digits.end(); williamr@2: williamr@2: bool __is_negative = *__digits_first == __minus; williamr@2: if (__is_negative) williamr@2: ++__digits_first; williamr@2: williamr@4: #if !defined (__BORLANDC__) williamr@4: string_type __sign = __intl ? __is_negative ? __punct_intl.negative_sign() williamr@4: : __punct_intl.positive_sign() williamr@4: : __is_negative ? __punct.negative_sign() williamr@4: : __punct.positive_sign(); williamr@4: #else williamr@4: string_type __sign; williamr@4: if (__intl) { williamr@4: if (__is_negative) williamr@4: __sign = __punct_intl.negative_sign(); williamr@4: else williamr@4: __sign = __punct_intl.positive_sign(); williamr@4: } williamr@4: else { williamr@4: if (__is_negative) williamr@4: __sign = __punct.negative_sign(); williamr@4: else williamr@4: __sign = __punct.positive_sign(); williamr@4: } williamr@4: #endif williamr@4: williamr@4: if (__check_digits) { williamr@4: typename string_type::const_iterator __cp = __digits_first; williamr@4: while (__cp != __digits_last && __c_type.is(ctype_base::digit, *__cp)) williamr@4: ++__cp; williamr@4: if (__cp == __digits_first) williamr@4: return __s; williamr@4: __digits_last = __cp; williamr@4: } williamr@2: williamr@2: // If grouping is required, we make a copy of __digits and williamr@2: // insert the grouping. williamr@4: _STLP_BASIC_IOSTRING(char_type) __new_digits; williamr@4: if (!__grouping.empty()) { williamr@4: __new_digits.assign(__digits_first, __digits_last); williamr@4: __insert_grouping(__new_digits, williamr@4: __new_digits.size() - __frac_digits, williamr@4: __grouping, williamr@4: __sep, __plus, __minus, 0); williamr@4: __digits_first = __new_digits.begin(); // <<-- williamr@4: __digits_last = __new_digits.end(); // <<-- williamr@2: } williamr@2: williamr@4: // Determine the amount of padding required, if any. williamr@4: streamsize __width = __str.width(); williamr@2: williamr@4: #if defined (_STLP_DEBUG) && (defined(__HP_aCC) && (__HP_aCC <= 1)) williamr@2: size_t __value_length = operator -(__digits_last, __digits_first); williamr@2: #else williamr@2: size_t __value_length = __digits_last - __digits_first; williamr@2: #endif williamr@2: williamr@4: size_t __length = __value_length + __sign.size(); williamr@4: williamr@2: if (__frac_digits != 0) williamr@2: ++__length; williamr@2: williamr@2: bool __generate_curr = (__str.flags() & ios_base::showbase) !=0; williamr@2: if (__generate_curr) williamr@2: __length += __curr_sym.size(); williamr@4: money_base::pattern __format = __intl ? (__is_negative ? __punct_intl.neg_format() williamr@4: : __punct_intl.pos_format()) williamr@4: : (__is_negative ? __punct.neg_format() williamr@4: : __punct.pos_format()); williamr@2: { williamr@4: //For the moment the following is commented for decoding reason. williamr@4: //No reason to add a space last if the money symbol do not have to be display williamr@4: //if (__format.field[3] == (char) money_base::symbol && !__generate_curr) { williamr@4: // if (__format.field[2] == (char) money_base::space) { williamr@4: // __format.field[2] = (char) money_base::none; williamr@4: // } williamr@4: //} williamr@4: //space can only be second or third and only once (22.2.6.3-1): williamr@4: if ((__format.field[1] == (char) money_base::space) || williamr@4: (__format.field[2] == (char) money_base::space)) williamr@4: ++__length; williamr@2: } williamr@2: williamr@4: const bool __need_fill = (((sizeof(streamsize) > sizeof(size_t)) && (__STATIC_CAST(streamsize, __length) < __width)) || williamr@4: ((sizeof(streamsize) <= sizeof(size_t)) && (__length < __STATIC_CAST(size_t, __width)))); williamr@4: streamsize __fill_amt = __need_fill ? __width - __length : 0; williamr@2: williamr@2: ios_base::fmtflags __fill_pos = __str.flags() & ios_base::adjustfield; williamr@2: williamr@2: if (__fill_amt != 0 && williamr@2: !(__fill_pos & (ios_base::left | ios_base::internal))) williamr@4: __s = __fill_n(__s, __fill_amt, __fill); williamr@4: williamr@2: for (int __i = 0; __i < 4; ++__i) { williamr@2: char __ffield = __format.field[__i]; williamr@4: switch (__ffield) { williamr@4: case money_base::none: williamr@4: if (__fill_amt != 0 && __fill_pos == ios_base::internal) williamr@4: __s = __fill_n(__s, __fill_amt, __fill); williamr@4: break; williamr@4: case money_base::space: williamr@4: if( !__need_fill ) williamr@4: { williamr@4: *__s++ = __space; williamr@4: } williamr@4: else williamr@4: { williamr@4: *__s++ = __fill; williamr@4: } williamr@4: if (__fill_amt != 0 && __fill_pos == ios_base::internal) williamr@4: __s = __fill_n(__s, __fill_amt, __fill); williamr@4: break; williamr@4: case money_base::symbol: williamr@4: if (__generate_curr) williamr@4: __s = copy(__curr_sym.begin(), __curr_sym.end(), __s); williamr@4: break; williamr@4: case money_base::sign: williamr@4: if (!__sign.empty()) williamr@4: *__s++ = __sign[0]; williamr@4: break; williamr@4: case money_base::value: williamr@4: if (__frac_digits == 0) { williamr@2: __s = copy(__digits_first, __digits_last, __s); williamr@4: } else { williamr@4: if ((int)__value_length <= __frac_digits) { williamr@4: // if we see '9' here, we should out 0.09 williamr@4: *__s++ = __zero; // integer part is zero williamr@4: *__s++ = __point; // decimal point williamr@4: __s = __fill_n(__s, __frac_digits - __value_length, __zero); // zeros williamr@4: __s = copy(__digits_first, __digits_last, __s); // digits williamr@4: } else { williamr@4: __s = copy(__digits_first, __digits_last - __frac_digits, __s); williamr@4: if (__frac_digits != 0) { williamr@4: *__s++ = __point; williamr@4: __s = copy(__digits_last - __frac_digits, __digits_last, __s); williamr@4: } williamr@2: } williamr@2: } williamr@4: break; williamr@4: } //Close for switch williamr@2: } // Close for loop williamr@2: williamr@2: // Ouput rest of sign if necessary. williamr@2: if (__sign.size() > 1) williamr@2: __s = copy(__sign.begin() + 1, __sign.end(), __s); williamr@4: if (__fill_amt != 0 && williamr@4: !(__fill_pos & (ios_base::right | ios_base::internal))) williamr@4: __s = __fill_n(__s, __fill_amt, __fill); williamr@4: williamr@2: return __s; williamr@2: } williamr@2: williamr@4: _STLP_MOVE_TO_STD_NAMESPACE williamr@2: williamr@4: template williamr@4: _OutputIter williamr@4: money_put<_CharT, _OutputIter> williamr@4: ::do_put(_OutputIter __s, bool __intl, ios_base& __str, williamr@4: char_type __fill, _STLP_LONGEST_FLOAT_TYPE __units) const { williamr@4: _STLP_BASIC_IOSTRING(char_type) __digits; williamr@4: _STLP_PRIV __get_money_digits(__digits, __str, __units); williamr@4: return _STLP_PRIV __money_do_put(__s, __intl, __str, __fill, __digits, false, __STATIC_CAST(string_type*, 0)); williamr@2: } williamr@2: williamr@4: template williamr@4: _OutputIter williamr@4: money_put<_CharT, _OutputIter> williamr@4: ::do_put(_OutputIter __s, bool __intl, ios_base& __str, williamr@4: char_type __fill, const string_type& __digits) const { williamr@4: return _STLP_PRIV __money_do_put(__s, __intl, __str, __fill, __digits, true, __STATIC_CAST(string_type*, 0)); williamr@2: } williamr@2: williamr@2: _STLP_END_NAMESPACE williamr@2: williamr@4: #endif /* _STLP_MONETARY_C */ williamr@2: williamr@4: // Local Variables: williamr@4: // mode:C++ williamr@4: // End: