18#ifndef _STLP_MONETARY_C
19#define _STLP_MONETARY_C
21# ifndef _STLP_INTERNAL_MONETARY_H
25#ifndef _STLP_INTERNAL_IOS_H
29#ifndef _STLP_INTERNAL_NUM_PUT_H
33#ifndef _STLP_INTERNAL_NUM_GET_H
39template <
class _CharT,
class _InputIterator>
42template <
class _CharT,
class _OutputIterator>
50template <
class _InIt1,
class _InIt2>
52 _InIt2 __str_first, _InIt2 __str_last) {
53 while ( __first !=
__last && __str_first != __str_last && *__first == *__str_first ) {
57 return make_pair(__first, __str_first == __str_last);
60template <
class _InIt,
class _OuIt,
class _CharT>
64 _CharT __point,
int __frac_digits, _CharT __sep,
65 const string& __grouping,
bool &__syntax_ok) {
69 char __group_sizes[128];
70 char* __group_sizes_end = __grouping.
empty()? 0 : __group_sizes;
71 char __current_group_size = 0;
73 while (__first !=
__last) {
75 ++__current_group_size;
76 *__out_ite++ = *__first++;
78 else if (__group_sizes_end) {
79 if (*__first == __sep) {
80 *__group_sizes_end++ = __current_group_size;
81 __current_group_size = 0;
90 if (__grouping.
empty())
93 if (__group_sizes_end != __group_sizes)
94 *__group_sizes_end++ = __current_group_size;
97 __grouping.
data(), __grouping.
data()+ __grouping.
size());
99 if (__first ==
__last || *__first != __point) {
100 for (
int __digits = 0; __digits != __frac_digits; ++__digits)
101 *__out_ite++ = _CharT(
'0');
111 *__out_ite++ = *__first++;
115 __syntax_ok = __syntax_ok && (__digits == __frac_digits);
121template <
class _CharT,
class _InputIter,
class _StrType>
124 _StrType& __digits,
bool &__is_positive, _CharT* ) {
126 __err |= ios_base::eofbit;
130 typedef _CharT char_type;
131 typedef _StrType string_type;
132 typedef _InputIter iter_type;
138 const _Punct& __punct = use_facet<_Punct>(__loc) ;
139 const _Punct_intl& __punct_intl = use_facet<_Punct_intl>(__loc) ;
140 const _Ctype& __c_type = use_facet<_Ctype>(__loc) ;
143 : __punct.neg_format();
144 string_type __ns = __intl ? __punct_intl.negative_sign()
145 : __punct.negative_sign();
146 string_type __ps = __intl ? __punct_intl.positive_sign()
147 : __punct.positive_sign();
149 bool __symbol_required = (__str.
flags() & ios_base::showbase) != 0;
153 for (__i = 0; __i < 4; ++__i) {
154 switch (__format.
field[__i]) {
157 __err = ios_base::failbit;
166 string_type __curs = __intl ? __punct_intl.curr_symbol()
167 : __punct.curr_symbol();
169 __result =
__get_string(__s, __end, __curs.begin(), __curs.end());
170 if (!__result.
second && __symbol_required)
171 __err = ios_base::failbit;
172 __s = __result.
first;
180 __is_positive =
false;
183 __err = ios_base::failbit;
190 if (*__s == __ns[0]) {
192 __is_positive =
false;
197 if (*__s == __ps[0]) {
203 if (*__s == __ns[0]) {
205 __is_positive =
false;
208 __err = ios_base::failbit;
214 char_type __point = __intl ? __punct_intl.decimal_point()
215 : __punct.decimal_point();
216 int __frac_digits = __intl ? __punct_intl.frac_digits()
217 : __punct.frac_digits();
218 string __grouping = __intl ? __punct_intl.grouping()
219 : __punct.grouping();
220 bool __syntax_ok =
true;
224 char_type __sep = __grouping.
empty() ? char_type() :
225 __intl ? __punct_intl.thousands_sep() : __punct.thousands_sep();
228 __point, __frac_digits,
230 __grouping, __syntax_ok);
233 __err |= ios_base::failbit;
235 __err = ios_base::failbit;
245 if (__ps.size() > 1) {
247 __result =
__get_string(__s, __end, __ps.begin() + 1, __ps.end());
248 __s = __result.
first;
250 __err |= ios::failbit;
252 if (!(__err & ios_base::failbit))
256 if (__ns.size() > 1) {
258 __result =
__get_string(__s, __end, __ns.begin() + 1, __ns.end());
259 __s = __result.
first;
261 __err |= ios::failbit;
263 if (!(__err & ios::failbit)) {
264 __digits = __c_type.widen(
'-');
269 __err |= ios::eofbit;
277template <
class _CharT,
class _InputIter>
283 bool __is_positive =
true;
286 if (__err == ios_base::goodbit || __err == ios_base::eofbit) {
289 if (!__is_positive) ++__b;
294 if (!__is_positive) {
302template <
class _CharT,
class _InputIter>
307 bool __is_positive =
true;
315template <
class _CharT,
class _OutputIter,
class _Str_Type,
class _Str>
317 _CharT
__fill,
const _Str& __digits,
bool __check_digits,
319 typedef _CharT char_type;
320 typedef _Str_Type string_type;
326 const _Ctype& __c_type = use_facet<_Ctype>(__loc) ;
327 const _Punct& __punct = use_facet<_Punct>(__loc) ;
328 const _Punct_intl& __punct_intl = use_facet<_Punct_intl>(__loc) ;
331 char_type
__minus = __c_type.widen(
'-');
332 char_type
__plus = __c_type.widen(
'+');
333 char_type __space = __c_type.widen(
' ');
334 char_type __zero = __c_type.widen(
'0');
335 char_type __point = __intl ? __punct_intl.decimal_point()
336 : __punct.decimal_point();
338 char_type __sep = __intl ? __punct_intl.thousands_sep()
339 : __punct.thousands_sep();
341 string __grouping = __intl ? __punct_intl.grouping()
342 : __punct.grouping();
344 int __frac_digits = __intl ? __punct_intl.frac_digits()
345 : __punct.frac_digits();
347 string_type __curr_sym = __intl ? __punct_intl.curr_symbol()
348 : __punct.curr_symbol();
354 if (__digits.empty())
357 typename string_type::const_iterator __digits_first = __digits.begin();
358 typename string_type::const_iterator __digits_last = __digits.end();
360 bool __is_negative = *__digits_first ==
__minus;
364#if !defined (__BORLANDC__)
365 string_type __sign = __intl ? __is_negative ? __punct_intl.negative_sign()
366 : __punct_intl.positive_sign()
367 : __is_negative ? __punct.negative_sign()
368 : __punct.positive_sign();
373 __sign = __punct_intl.negative_sign();
375 __sign = __punct_intl.positive_sign();
379 __sign = __punct.negative_sign();
381 __sign = __punct.positive_sign();
385 if (__check_digits) {
386 typename string_type::const_iterator __cp = __digits_first;
389 if (__cp == __digits_first)
391 __digits_last = __cp;
397 if (!__grouping.
empty()) {
398 __new_digits.assign(__digits_first, __digits_last);
400 __new_digits.size() - __frac_digits,
403 __digits_first = __new_digits.begin();
404 __digits_last = __new_digits.end();
410#if defined (_STLP_DEBUG) && (defined(__HP_aCC) && (__HP_aCC <= 1))
411 size_t __value_length =
operator -(__digits_last, __digits_first);
413 size_t __value_length = __digits_last - __digits_first;
416 size_t __length = __value_length + __sign.size();
418 if (__frac_digits != 0)
421 bool __generate_curr = (__str.
flags() & ios_base::showbase) !=0;
423 __length += __curr_sym.size();
425 : __punct_intl.pos_format())
426 : (__is_negative ? __punct.neg_format()
427 : __punct.pos_format());
444 streamsize __fill_amt = __need_fill ? __width - __length : 0;
448 if (__fill_amt != 0 &&
449 !(__fill_pos & (ios_base::left | ios_base::internal)))
452 for (
int __i = 0; __i < 4; ++__i) {
453 char __ffield = __format.
field[__i];
458 if (__fill_amt != 0 && __fill_pos == ios_base::internal)
463 __s = _STLP_STD::copy(__curr_sym.begin(), __curr_sym.end(), __s);
470 if (__frac_digits == 0) {
471 __s = _STLP_STD::copy(__digits_first, __digits_last, __s);
473 if ((
int)__value_length <= __frac_digits) {
478 __s = _STLP_STD::copy(__digits_first, __digits_last, __s);
480 __s = _STLP_STD::copy(__digits_first, __digits_last - __frac_digits, __s);
481 if (__frac_digits != 0) {
483 __s = _STLP_STD::copy(__digits_last - __frac_digits, __digits_last, __s);
492 if (__sign.size() > 1)
493 __s = _STLP_STD::copy(__sign.begin() + 1, __sign.end(), __s);
494 if (__fill_amt != 0 &&
495 !(__fill_pos & (ios_base::right | ios_base::internal)))
503template <
class _CharT,
class _OutputIter>
513template <
class _CharT,
class _OutputIter>
_STLP_INLINE_LOOP _InputIter __last
void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val, const input_iterator_tag &, _Distance *)
_STLP_MOVE_TO_PRIV_NAMESPACE _STLP_INLINE_LOOP _OutputIter __fill_n(_OutputIter __first, _Size __n, const _Tp &__val)
complex< _Tp > _STLP_CALL operator-(const complex< _Tp > &__z)
_STLP_MOVE_TO_PRIV_NAMESPACE plus< _Tp > __plus(_Tp *)
minus< _Tp > __minus(_Tp *)
#define _STLP_BASIC_IOSTRING(_CharT)
_STLP_MOVE_TO_PRIV_NAMESPACE _OutputIter __money_do_put(_OutputIter __s, bool __intl, ios_base &__str, _CharT __fill, const _Str &__digits, bool __check_digits, _Str_Type *)
_InputIter __money_do_get(_InputIter __s, _InputIter __end, bool __intl, ios_base &__str, ios_base::iostate &__err, _StrType &__digits, bool &__is_positive, _CharT *)
bool __get_monetary_value(_InIt &__first, _InIt __last, _OuIt __out_ite, const ctype< _CharT > &_c_type, _CharT __point, int __frac_digits, _CharT __sep, const string &__grouping, bool &__syntax_ok)
_STLP_MOVE_TO_PRIV_NAMESPACE pair< _InIt1, bool > __get_string(_InIt1 __first, _InIt1 __last, _InIt2 __str_first, _InIt2 __str_last)
bool _STLP_CALL __get_decimal_integer(_InputIter &__first, _InputIter &__last, _Integer &__val, _CharT *)
void _STLP_CALL __get_money_digits(_STLP_BASIC_IOSTRING(_CharT) &__buf, ios_base &__f, _STLP_LONGEST_FLOAT_TYPE __x)
pair< _T1, _T2 > _STLP_CALL make_pair(_T1 __x, _T2 __y)
const _CharT * data() const
virtual iter_type do_get(iter_type __s, iter_type __end, bool __intl, ios_base &__str, ios_base::iostate &__err, _STLP_LONGEST_FLOAT_TYPE &__units) const
#define _STLP_MOVE_TO_STD_NAMESPACE
#define __STATIC_CAST(__x, __y)
#define _STLP_LONGEST_FLOAT_TYPE
#define _STLP_BEGIN_NAMESPACE
#define _STLP_END_NAMESPACE
#define _STLP_MOVE_TO_PRIV_NAMESPACE
_STLP_BEGIN_NAMESPACE _STLP_MOVE_TO_PRIV_NAMESPACE bool _STLP_CALL __valid_grouping(const char *first1, const char *last1, const char *first2, const char *last2)
ptrdiff_t _STLP_CALL __insert_grouping(char *first, char *last, const string &grouping, char separator, char Plus, char Minus, int basechars)