num_put<Pt::Char, ostreambuf_iterator<Pt::Char> >::iter_type num_put<Pt::Char, ostreambuf_iterator<Pt::Char> >::do_put(iter_type s, ios_base& f, char_type fill, const void* ptr) const { std::size_t val = reinterpret_cast<std::size_t>(ptr); putHex(s, val, f.flags(), f.width(0), fill); return s; }
num_put<Pt::Char, ostreambuf_iterator<Pt::Char> >::iter_type num_put<Pt::Char, ostreambuf_iterator<Pt::Char> >::do_put(iter_type s, ios_base& f, char_type fill, bool val) const { if( 0 == (f.flags() & ios_base::boolalpha) ) return do_put(s, f, fill, static_cast<long>(val)); typedef Pt::Char char_type; const numpunct<char_type>& np = use_facet< numpunct<char_type> >( f.getloc() ); Pt::String str = val ? np.truename() : np.falsename(); streamsize width = f.width(0); if( str.size() >= static_cast<std::size_t>(width) ) { return std::copy(str.begin(), str.end(), s); } streamsize pad = width - str.size(); ios_base::fmtflags dir = f.flags() & ios_base::adjustfield; if (dir == ios_base::left) { std::copy(str.begin(), str.end(), s); std::fill_n(s, pad, fill); return s; } // right/internal padding std::fill_n(s, pad, fill); return std::copy(str.begin(), str.end(), s); }
_InputIter num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __s, ios_base::iostate& __err, bool& __x) const { if (__s.flags() & ios_base::boolalpha) { locale __loc = __s.getloc(); const _Numpunct& __np = *(const _Numpunct*)__s._M_numpunct_facet(); // const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc) ; // const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc) ; const basic_string<_CharT> __truename = __np.truename(); const basic_string<_CharT> __falsename = __np.falsename(); bool __true_ok = true; bool __false_ok = true; size_t __n = 0; for ( ; __in != __end; ++__in) { _CharT __c = *__in; __true_ok = __true_ok && (__c == __truename[__n]); __false_ok = __false_ok && (__c == __falsename[__n]); ++__n; if ((!__true_ok && !__false_ok) || (__true_ok && __n >= __truename.size()) || (__false_ok && __n >= __falsename.size())) { ++__in; break; } } if (__true_ok && __n < __truename.size()) __true_ok = false; if (__false_ok && __n < __falsename.size()) __false_ok = false; if (__true_ok || __false_ok) { __err = ios_base::goodbit; __x = __true_ok; } else __err = ios_base::failbit; if (__in == __end) __err |= ios_base::eofbit; return __in; } else { long __lx; _InputIter __tmp = this->do_get(__in, __end, __s, __err, __lx); if (!(__err & ios_base::failbit)) { if (__lx == 0) __x = false; else if (__lx == 1) __x = true; else __err |= ios_base::failbit; } return __tmp; } }
bool _STLP_CALL _M_read_float(string& __buf, _InputIter& __in, _InputIter& __end, ios_base& __s, _CharT*) { // Create a string, copying characters of the form // [+-]? [0-9]* .? [0-9]* ([eE] [+-]? [0-9]+)? bool __digits_before_dot /* = false */; bool __digits_after_dot = false; bool __ok; bool __grouping_ok = true; const ctype<_CharT>& __ct = *(const ctype<_CharT>*)__s._M_ctype_facet(); const numpunct<_CharT>& __numpunct = *(const numpunct<_CharT>*)__s._M_numpunct_facet(); const string& __grouping = __s._M_grouping(); // cached copy _CharT __dot = __numpunct.decimal_point(); _CharT __sep = __numpunct.thousands_sep(); _CharT __digits[10]; _CharT __xplus; _CharT __xminus; _CharT __pow_e; _CharT __pow_E; _Initialize_get_float(__ct, __xplus, __xminus, __pow_e, __pow_E, __digits); // Get an optional sign __in = __copy_sign(__in, __end, __buf, __xplus, __xminus); // Get an optional string of digits. if (__grouping.size() != 0) __digits_before_dot = __copy_grouped_digits(__in, __end, __buf, __digits, __sep, __grouping, __grouping_ok); else __digits_before_dot = __copy_digits(__in, __end, __buf, __digits); // Get an optional decimal point, and an optional string of digits. if (__in != __end && *__in == __dot) { __buf.push_back('.'); ++__in; __digits_after_dot = __copy_digits(__in, __end, __buf, __digits); } // There have to be some digits, somewhere. __ok = __digits_before_dot || __digits_after_dot; // Get an optional exponent. if (__ok && __in != __end && (*__in == __pow_e || *__in == __pow_E)) { __buf.push_back('e'); ++__in; __in = __copy_sign(__in, __end, __buf, __xplus, __xminus); __ok = __copy_digits(__in, __end, __buf, __digits); // If we have an exponent then the sign // is optional but the digits aren't. } return __ok; }
int __get_base_or_zero(_InputIter& __in_ite, _InputIter& __end, ios_base& __str, _CharT*) { _CharT __atoms[5]; const ctype<_CharT>& __c_type = *__STATIC_CAST(const ctype<_CharT>*, __str._M_ctype_facet()); __c_type.widen(__narrow_atoms(), __narrow_atoms() + 5, __atoms); bool __negative = false; _CharT __c = *__in_ite; if (__c == __atoms[1] /* __xminus_char */ ) { __negative = true; ++__in_ite; } else if (__c == __atoms[0] /* __xplus_char */ ) ++__in_ite; int __base; int __valid_zero = 0; ios_base::fmtflags __basefield = __str.flags() & ios_base::basefield; switch (__basefield) { case ios_base::oct: __base = 8; break; case ios_base::dec: __base = 10; break; case ios_base::hex: __base = 16; if (__in_ite != __end && *__in_ite == __atoms[2] /* __zero_char */ ) { ++__in_ite; if (__in_ite != __end && (*__in_ite == __atoms[3] /* __x_char */ || *__in_ite == __atoms[4] /* __X_char */ )) ++__in_ite; else __valid_zero = 1; // That zero is valid by itself. } break; default: if (__in_ite != __end && *__in_ite == __atoms[2] /* __zero_char */ ) { ++__in_ite; if (__in_ite != __end && (*__in_ite == __atoms[3] /* __x_char */ || *__in_ite == __atoms[4] /* __X_char */ )) { ++__in_ite; __base = 16; } else { __base = 8; __valid_zero = 1; // That zero is still valid by itself. } } else __base = 10; break; } return (__base << 2) | ((int)__negative << 1) | __valid_zero; }
_OutputIter _STLP_CALL _M_do_put_float(_OutputIter __s, ios_base& __f, _CharT __fill, _Float __x) { __iostring __buf; size_t __group_pos = __write_float(__buf, __f.flags(), (int)__f.precision(), __x); const numpunct<_CharT>& __np = *__STATIC_CAST(const numpunct<_CharT>*, __f._M_numpunct_facet()); return __put_float(__buf, __s, __f, __fill, __np.decimal_point(), __np.thousands_sep(), __group_pos, __f._M_grouping()); }
_InputIter _STLP_CALL _M_do_get_integer(_InputIter& __in, _InputIter& __end, ios_base& __str, ios_base::iostate& __err, _Integer& __val, _CharT* __pc) { #if defined(__HP_aCC) && (__HP_aCC == 1) bool _IsSigned = !((_Integer)(-1) > 0); #else typedef typename __bool2type<numeric_limits<_Integer>::is_signed>::_Ret _IsSigned; #endif const numpunct<_CharT>& __numpunct = *(const numpunct<_CharT>*)__str._M_numpunct_facet(); const string& __grouping = __str._M_grouping(); // cached copy const int __base_or_zero = _M_get_base_or_zero(__in, __end, __str, __pc); int __got = __base_or_zero & 1; bool __result; if (__in == __end) { // We may have already read a 0. If so, if (__got > 0) { // the result is 0 even if we're at eof. __val = 0; __result = true; } else __result = false; } else { const bool __negative = __base_or_zero & 2; const int __base = __base_or_zero >> 2; #if defined(__HP_aCC) && (__HP_aCC == 1) if (_IsSigned) __result = __get_integer(__in, __end, __base, __val, __got, __negative, __numpunct.thousands_sep(), __grouping, __true_type() ); else __result = __get_integer(__in, __end, __base, __val, __got, __negative, __numpunct.thousands_sep(), __grouping, __false_type() ); #else __result = __get_integer(__in, __end, __base, __val, __got, __negative, __numpunct.thousands_sep(), __grouping, _IsSigned()); # endif } __err = __STATIC_CAST(ios_base::iostate, __result ? ios_base::goodbit : ios_base::failbit); if (__in == __end) __err |= ios_base::eofbit; return __in; }
inline void __get_money_digits_aux (__iowstring &__wbuf, ios_base &__f, _STLP_LONG_DOUBLE __x) { __iostring __buf; __get_floor_digits(__buf, __x); const ctype<wchar_t>& __ct = *__STATIC_CAST(const ctype<wchar_t>*, __f._M_ctype_facet()); __convert_float_buffer(__buf, __wbuf, __ct, wchar_t(0), false); }
_OutputIter time_put<_Ch,_OutputIter>::put(_OutputIter __s, ios_base& __f, _Ch __fill, const tm* __tmb, const _Ch* __pat, const _Ch* __pat_end) const { // locale __loc = __f.getloc(); // const ctype<_Ch>& _Ct = use_facet<ctype<_Ch> >(__loc); const ctype<_Ch>& _Ct = *(ctype<_Ch>*)__f._M_ctype_facet(); while (__pat != __pat_end) { char __c = _Ct.narrow(*__pat, 0); if (__c == '%') { char __mod = 0; ++__pat; __c = _Ct.narrow(*__pat++, 0); if(__c == '#') { // MS extension __mod = __c; __c = _Ct.narrow(*__pat++, 0); } __s = do_put(__s, __f, __fill, __tmb, __c, __mod); } else *__s++ = *__pat++; } return __s; }
num_get< Pt::Char, istreambuf_iterator<Pt::Char> >::iter_type num_get< Pt::Char, istreambuf_iterator<Pt::Char> >::do_get(iter_type it, iter_type end, ios_base& stream, ios_base::iostate& state, unsigned long long& val) const { bool ok = false; switch(stream.flags() & ios_base::basefield) { case ios_base::oct: it = Pt::parseInt(it, end, val, Pt::OctalFormat<Pt::Char>(), ok); break; case ios_base::hex: it = Pt::parseInt(it, end, val, Pt::HexFormat<Pt::Char>(), ok); break; default: it = Pt::parseInt(it, end, val, Pt::DecimalFormat<Pt::Char>(), ok); break; } if( ok ) state = ios_base::goodbit; else state = ios_base::failbit; if (it == end) state |= ios_base::eofbit; return it; }
_InputIter _STLP_CALL __do_get_integer(_InputIter& __in_ite, _InputIter& __end, ios_base& __str, ios_base::iostate& __err, _Integer& __val, _CharT* /*__pc*/) { locale __loc = __str.getloc(); const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc); #if defined (__HP_aCC) && (__HP_aCC == 1) bool _IsSigned = !((_Integer)(-1) > 0); #else typedef typename is_signed<_Integer>::type::type _IsSigned; #endif const int __base_or_zero = __get_base_or_zero(__in_ite, __end, __str.flags(), __ctype); int __got = __base_or_zero & 1; bool __result; if (__in_ite == __end) { // We may have already read a 0. If so, if (__got > 0) { // the result is 0 even if we're at eof. __val = 0; __result = true; } else __result = false; } else { const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc); const bool __negative = (__base_or_zero & 2) != 0; const int __base = __base_or_zero >> 2; #if defined (__HP_aCC) && (__HP_aCC == 1) if (_IsSigned) __result = __get_integer(__in_ite, __end, __base, __val, __got, __negative, __np.thousands_sep(), __np.grouping(), __true_type() ); else __result = __get_integer(__in_ite, __end, __base, __val, __got, __negative, __np.thousands_sep(), __np.grouping(), __false_type() ); #else __result = __get_integer(__in_ite, __end, __base, __val, __got, __negative, __np.thousands_sep(), __np.grouping(), _IsSigned()); # endif } __err = __STATIC_CAST(ios_base::iostate, __result ? ios_base::goodbit : ios_base::failbit); if (__in_ite == __end) __err |= ios_base::eofbit; return __in_ite; }
_OutputIter _STLP_CALL __put_float(__iostring &__str, _OutputIter __oi, ios_base& __f, char __fill, char __decimal_point, char __sep, size_t __group_pos, const string& __grouping) { if ((__group_pos < __str.size()) && (__str[__group_pos] == '.')) { __str[__group_pos] = __decimal_point; } if (!__grouping.empty()) { __insert_grouping(__str, __group_pos, __grouping, __sep, '+', '-', 0); } return __copy_float_and_fill(__CONST_CAST(char*, __str.data()), __CONST_CAST(char*, __str.data()) + __str.size(), __oi, __f.flags(), __f.width(0), __fill, '+', '-'); }
_InputIter num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __s, ios_base::iostate& __err, bool& __x) const { if (__s.flags() & ios_base::boolalpha) { locale __loc = __s.getloc(); const _Numpunct& __np = *__STATIC_CAST(const _Numpunct*, __s._M_numpunct_facet()); // const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc) ; // const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc) ; const basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > __truename = __np.truename(); const basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > __falsename = __np.falsename(); bool __true_ok = true; bool __false_ok = true; size_t __n = 0; for ( ; __in_ite != __end; ++__in_ite) { _CharT __c = *__in_ite; __true_ok = __true_ok && (__c == __truename[__n]); __false_ok = __false_ok && (__c == __falsename[__n]); ++__n; if ((!__true_ok && !__false_ok) || (__true_ok && __n >= __truename.size()) || (__false_ok && __n >= __falsename.size())) { ++__in_ite; break; } } if (__true_ok && __n < __truename.size()) __true_ok = false; if (__false_ok && __n < __falsename.size()) __false_ok = false; if (__true_ok || __false_ok) { __err = ios_base::goodbit; __x = __true_ok; } else __err = ios_base::failbit; if (__in_ite == __end) __err |= ios_base::eofbit; return __in_ite; }
_OutputIter _STLP_CALL __put_float(__iostring &__str, _OutputIter __oi, ios_base& __f, wchar_t __fill, wchar_t __decimal_point, wchar_t __sep, size_t __group_pos, const string& __grouping) { const ctype<wchar_t>& __ct = *__STATIC_CAST(const ctype<wchar_t>*, __f._M_ctype_facet()); __iowstring __wbuf; __convert_float_buffer(__str, __wbuf, __ct, __decimal_point); if (!__grouping.empty()) { __insert_grouping(__wbuf, __group_pos, __grouping, __sep, __ct.widen('+'), __ct.widen('-'), 0); } return __copy_float_and_fill(__CONST_CAST(wchar_t*, __wbuf.data()), __CONST_CAST(wchar_t*, __wbuf.data()) + __wbuf.size(), __oi, __f.flags(), __f.width(0), __fill, __ct.widen('+'), __ct.widen('-')); }
_OuIt _STLP_CALL __put_time(char * __first, char * __last, _OuIt __out, const ios_base& __s, wchar_t) { const ctype<wchar_t>& __ct = *(ctype<wchar_t>*)__s._M_ctype_facet(); wchar_t __wbuf[64]; __ct.widen(__first, __last, __wbuf); ptrdiff_t __len = __last - __first; wchar_t * __eend = __wbuf + __len; return copy((wchar_t*)__wbuf, __eend, __out); }
_InputIter _STLP_CALL __do_get_float(_InputIter& __in_ite, _InputIter& __end, ios_base& __str, ios_base::iostate& __err, _Float& __val, _CharT* /*__pc*/) { locale __loc = __str.getloc(); const ctype<_CharT> &__ctype = use_facet<ctype<_CharT> >(__loc); const numpunct<_CharT> &__numpunct = use_facet<numpunct<_CharT> >(__loc); __iostring __buf ; bool __ok = __read_float(__buf, __in_ite, __end, __ctype, __numpunct); if (__ok) { __string_to_float(__buf, __val); __err = ios_base::goodbit; } else { __err = ios_base::failbit; } if (__in_ite == __end) __err |= ios_base::eofbit; return __in_ite; }
_InputIter num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __s, ios_base::iostate& __err, bool& __x) const { if (__s.flags() & ios_base::boolalpha) { return _STLP_PRIV __do_get_alphabool(__in_ite, __end, __s, __err, __x, (_CharT*)0); } else { long __lx; _InputIter __tmp = _STLP_PRIV __do_get_integer(__in_ite, __end, __s, __err, __lx, (_CharT*)0 ); if (!(__err & ios_base::failbit)) { if (__lx == 0) __x = false; else if (__lx == 1) __x = true; else __err |= ios_base::failbit; } return __tmp; } }
_InputIter _STLP_CALL __do_get_alphabool(_InputIter& __in_ite, _InputIter& __end, ios_base& __str, ios_base::iostate& __err, bool& __x, _CharT* /*__pc*/) { const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__str.getloc()); const basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > __truename = __np.truename(); const basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > __falsename = __np.falsename(); bool __true_ok = true; bool __false_ok = true; size_t __n = 0; for ( ; __in_ite != __end; ++__in_ite) { _CharT __c = *__in_ite; __true_ok = __true_ok && (__c == __truename[__n]); __false_ok = __false_ok && (__c == __falsename[__n]); ++__n; if ((!__true_ok && !__false_ok) || (__true_ok && __n >= __truename.size()) || (__false_ok && __n >= __falsename.size())) { ++__in_ite; break; } } if (__true_ok && __n < __truename.size()) __true_ok = false; if (__false_ok && __n < __falsename.size()) __false_ok = false; if (__true_ok || __false_ok) { __err = ios_base::goodbit; __x = __true_ok; } else __err = ios_base::failbit; if (__in_ite == __end) __err |= ios_base::eofbit; return __in_ite; }
num_put<Pt::Char, ostreambuf_iterator<Pt::Char> >::iter_type num_put<Pt::Char, ostreambuf_iterator<Pt::Char> >::do_put(iter_type s, ios_base& f, char_type fill, unsigned long long val) const { // TODO: grouping //const numpunct<char>& np = use_facet<numpunct<char> >(f.getloc()); //const string& grouping = np.grouping(); switch (f.flags() & ios_base::basefield) { case ios_base::oct: putOctal(s, val, f.flags(), f.width(0), fill); break; case ios_base::hex: putHex(s, val, f.flags(), f.width(0), fill); break; default: putDecimal(s, val, f.flags(), f.width(0), fill); break; } return s; }
num_get< Pt::Char, istreambuf_iterator<Pt::Char> >::iter_type num_get< Pt::Char, istreambuf_iterator<Pt::Char> >::do_get(iter_type it, iter_type end, ios_base& stream, ios_base::iostate& state, bool& val) const { if(stream.flags() & ios_base::boolalpha) { const numpunct<Pt::Char>& np = use_facet< numpunct<Pt::Char> >(stream.getloc()); const Pt::String truename = np.truename(); const Pt::String falsename = np.falsename(); bool true_ok = true; bool false_ok = true; std::size_t n = 0; for ( ; it != end; ++it) { Pt::Char c = *it; true_ok = true_ok && (n < truename.size()) && (c == truename[n]); false_ok = false_ok && (n < falsename.size()) && (c == falsename[n]); ++n; if( (! true_ok && ! false_ok) || (true_ok && n >= truename.size()) || (false_ok && n >= falsename.size()) ) { ++it; break; } } if (true_ok && n < truename.size()) true_ok = false; if (false_ok && n < falsename.size()) false_ok = false; if (true_ok || false_ok) { state = ios_base::goodbit; val = true_ok; } else state = ios_base::failbit; if (it == end) state |= ios_base::eofbit; } else { long l = 3; it = this->do_get(it, end, stream, state, l); if( 0 == (state & ios_base::failbit) ) { if (l == 0) val = false; else if (l == 1) val = true; else state |= ios_base::failbit; } } return it; }
num_put<Pt::Char, ostreambuf_iterator<Pt::Char> >::iter_type num_put<Pt::Char, ostreambuf_iterator<Pt::Char> >::do_put(iter_type s, ios_base& f, char_type fill, long double val) const { putFloat(s, val, f.flags(), f.width(0), fill, f.precision()); return s; }
_OutputIter _S_do_put(_OutputIter __s, bool __intl, ios_base& __str, _CharT __fill, const _Str& __digits, bool __check_digits, _Str_Type * /*__dummy*/) { typedef _CharT char_type; typedef _Str_Type string_type; typedef ctype<char_type> _Ctype; typedef moneypunct<char_type, false> _Punct; typedef moneypunct<char_type, true> _Punct_intl; locale __loc = __str.getloc(); const _Ctype& __c_type = use_facet<_Ctype>(__loc) ; const _Punct& __punct = use_facet<_Punct>(__loc) ; const _Punct_intl& __punct_intl = use_facet<_Punct_intl>(__loc) ; // some special characters char_type __minus = __c_type.widen('-'); char_type __plus = __c_type.widen('+'); char_type __space = __c_type.widen(' '); char_type __zero = __c_type.widen('0'); char_type __point = __intl ? __punct_intl.decimal_point() : __punct.decimal_point(); char_type __sep = __intl ? __punct_intl.thousands_sep() : __punct.thousands_sep(); string __grouping = __intl ? __punct_intl.grouping() : __punct.grouping(); int __frac_digits = __intl ? __punct_intl.frac_digits() : __punct.frac_digits(); string_type __curr_sym = __intl ? __punct_intl.curr_symbol() : __punct.curr_symbol(); // if there are no digits we are going to return __s. If there // are digits, but not enough to fill the frac_digits, we are // going to add zeros. I don't know whether this is right or // not. if (__digits.empty()) return __s; typename string_type::const_iterator __digits_first = __digits.begin(); typename string_type::const_iterator __digits_last = __digits.end(); bool __is_negative = *__digits_first == __minus; if (__is_negative) ++__digits_first; string_type __sign = __intl ? __is_negative ? __punct_intl.negative_sign() : __punct_intl.positive_sign() : __is_negative ? __punct.negative_sign() : __punct.positive_sign(); if (__check_digits) { typename string_type::const_iterator __cp = __digits_first; while (__cp != __digits_last && __c_type.is(ctype_base::digit, *__cp)) ++__cp; if (__cp == __digits_first) return __s; __digits_last = __cp; } // If grouping is required, we make a copy of __digits and // insert the grouping. _STLP_BASIC_IOSTRING(char_type) __new_digits; if (!__grouping.empty()) { __new_digits.assign(__digits_first, __digits_last); __insert_grouping(__new_digits, __new_digits.size() - __frac_digits, __grouping, __sep, __plus, __minus, 0); __digits_first = __new_digits.begin(); // <<-- __digits_last = __new_digits.end(); // <<-- } // Determine the amount of padding required, if any. streamsize __width = __str.width(); #if defined(_STLP_DEBUG) && (defined(__HP_aCC) && (__HP_aCC <= 1)) size_t __value_length = operator -(__digits_last, __digits_first); #else size_t __value_length = __digits_last - __digits_first; #endif size_t __length = __value_length + __sign.size(); if (__frac_digits != 0) ++__length; bool __generate_curr = (__str.flags() & ios_base::showbase) !=0; if (__generate_curr) __length += __curr_sym.size(); money_base::pattern __format = __intl ? (__is_negative ? __punct_intl.neg_format() : __punct_intl.pos_format()) : (__is_negative ? __punct.neg_format() : __punct.pos_format()); { //For the moment the following is commented for decoding reason. //No reason to add a space last if the money symbol do not have to be display //if (__format.field[3] == (char) money_base::symbol && !__generate_curr) { // if (__format.field[2] == (char) money_base::space) { // __format.field[2] = (char) money_base::none; // } //} //space can only be second or third and only once (22.2.6.3-1): if ((__format.field[1] == (char) money_base::space) || (__format.field[2] == (char) money_base::space)) ++__length; } const bool __need_fill = (((sizeof(streamsize) > sizeof(size_t)) && (__STATIC_CAST(streamsize, __length) < __width)) || ((sizeof(streamsize) <= sizeof(size_t)) && (__length < __STATIC_CAST(size_t, __width)))); streamsize __fill_amt = __need_fill ? __width - __length : 0; ios_base::fmtflags __fill_pos = __str.flags() & ios_base::adjustfield; if (__fill_amt != 0 && !(__fill_pos & (ios_base::left | ios_base::internal))) __s = __fill_n(__s, __fill_amt, __fill); for (int __i = 0; __i < 4; ++__i) { char __ffield = __format.field[__i]; switch (__ffield) { case money_base::none: if (__fill_amt != 0 && __fill_pos == ios_base::internal) __s = __fill_n(__s, __fill_amt, __fill); break; case money_base::space: *__s++ = __space; if (__fill_amt != 0 && __fill_pos == ios_base::internal) __s = __fill_n(__s, __fill_amt, __fill); break; case money_base::symbol: if (__generate_curr) __s = copy(__curr_sym.begin(), __curr_sym.end(), __s); break; case money_base::sign: if (!__sign.empty()) *__s++ = __sign[0]; break; case money_base::value: if (__frac_digits == 0) __s = copy(__digits_first, __digits_last, __s); else { if ((int)__value_length <= __frac_digits) { *__s++ = __point; __s = copy(__digits_first, __digits_last, __s); __s = __fill_n(__s, __frac_digits - __value_length, __zero); } else { __s = copy(__digits_first, __digits_last - __frac_digits, __s); if (__frac_digits != 0) { *__s++ = __point; __s = copy(__digits_last - __frac_digits, __digits_last, __s); } } } } //Close for switch } // Close for loop // Ouput rest of sign if necessary. if (__sign.size() > 1) __s = copy(__sign.begin() + 1, __sign.end(), __s); if (__fill_amt != 0 && !(__fill_pos & (ios_base::right | ios_base::internal))) __s = __fill_n(__s, __fill_amt, __fill); return __s; }
string::const_iterator _STLP_CALL __get_formatted_time _STLP_WEAK (_InIt1 __first, _InIt1 __last, string::const_iterator __format, string::const_iterator __format_end, _Ch*, const _TimeInfo& __table, const ios_base& __s, ios_base::iostate& __err, tm* __t) { const ctype<_Ch>& __ct = use_facet<ctype<_Ch> >(__s.getloc()); typedef basic_string<_Ch, char_traits<_Ch>, allocator<_Ch> > string_type; size_t offset; while (__first != __last && __format != __format_end) { offset = 0; if (*__format == '%') { ++__format; char __c = *__format; if (__c == '#') { //MS extension ++__format; __c = *__format; } switch (__c) { case 'A': offset = 7; case 'a': { size_t __index = __match(__first, __last, __table._M_dayname + offset, __table._M_dayname + offset + 7); if (__index == 7) return __format; __t->tm_wday = __STATIC_CAST(int, __index); break; } case 'B': offset = 12; case 'b': { size_t __index = __match(__first, __last, __table._M_monthname + offset, __table._M_monthname + offset + 12); if (__index == 12) return __format; __t->tm_mon = __STATIC_CAST(int, __index); break; } case 'd': { bool __pr = __get_decimal_integer(__first, __last, __t->tm_mday, __STATIC_CAST(_Ch*, 0)); if (!__pr || __t->tm_mday < 1 || __t->tm_mday > 31) { __err |= ios_base::failbit; return __format; } break; } case 'H': case 'I': { bool __pr = __get_decimal_integer(__first, __last, __t->tm_hour, __STATIC_CAST(_Ch*, 0)); if (!__pr) return __format; break; } case 'j': { bool __pr = __get_decimal_integer(__first, __last, __t->tm_yday, __STATIC_CAST(_Ch*, 0)); if (!__pr) return __format; break; } case 'm': { bool __pr = __get_decimal_integer(__first, __last, __t->tm_mon, __STATIC_CAST(_Ch*, 0)); --__t->tm_mon; if (!__pr || __t->tm_mon < 0 || __t->tm_mon > 11) { __err |= ios_base::failbit; return __format; } break; } case 'M': { bool __pr = __get_decimal_integer(__first, __last, __t->tm_min, __STATIC_CAST(_Ch*, 0)); if (!__pr) return __format; break; } case 'p': { size_t __index = __match(__first, __last, __table._M_am_pm + 0, __table._M_am_pm + 2); if (__index == 2) return __format; // 12:00 PM <=> 12:00, 12:00 AM <=> 00:00 if (__index == 1 && __t->tm_hour != 12 ) __t->tm_hour += 12; if (__index == 0 && __t->tm_hour == 12 ) __t->tm_hour = 0; break; } case 'S': { bool __pr = __get_decimal_integer(__first, __last, __t->tm_sec, __STATIC_CAST(_Ch*, 0)); if (!__pr) return __format; break; } case 'y': { bool __pr = __get_decimal_integer(__first, __last, __t->tm_year, __STATIC_CAST(_Ch*, 0)); if (!__pr) return __format; break; } case 'Y': { bool __pr = __get_decimal_integer(__first, __last, __t->tm_year, __STATIC_CAST(_Ch*, 0)); __t->tm_year -= 1900; if (!__pr) return __format; break; } default: break; } } else { if (*__first++ != __ct.widen(*__format)) break;
_InputIter _S_do_get(_InputIter __s, _InputIter __end, bool __intl, ios_base& __str, ios_base::iostate& __err, _StrType& __digits, bool &__is_positive, _CharT* /*__dummy*/) { if (__s == __end) { __err |= ios_base::eofbit; return __s; } typedef _CharT char_type; typedef _StrType string_type; typedef _InputIter iter_type; typedef moneypunct<char_type, false> _Punct; typedef moneypunct<char_type, true> _Punct_intl; typedef ctype<char_type> _Ctype; locale __loc = __str.getloc(); const _Punct& __punct = use_facet<_Punct>(__loc) ; const _Punct_intl& __punct_intl = use_facet<_Punct_intl>(__loc) ; const _Ctype& __c_type = use_facet<_Ctype>(__loc) ; money_base::pattern __format = __intl ? __punct_intl.neg_format() : __punct.neg_format(); string_type __ns = __intl ? __punct_intl.negative_sign() : __punct.negative_sign(); string_type __ps = __intl ? __punct_intl.positive_sign() : __punct.positive_sign(); int __i; bool __symbol_required = (__str.flags() & ios_base::showbase) != 0; string_type __buf; back_insert_iterator<string_type> __out_ite(__buf); for (__i = 0; __i < 4; ++__i) { switch (__format.field[__i]) { case money_base::none: if (__i == 3) { if (__c_type.is(ctype_base::space, *__s)) { __err = ios_base::failbit; return __s; } break; } while (__s != __end && __c_type.is(ctype_base::space, *__s)) ++__s; break; case money_base::space: if (!__c_type.is(ctype_base::space, *__s)) { __err = ios_base::failbit; return __s; } ++__s; while (__s != __end && __c_type.is(ctype_base::space, *__s)) ++__s; break; case money_base::symbol: { string_type __curs = __intl ? __punct_intl.curr_symbol() : __punct.curr_symbol(); pair<iter_type, bool> __result = __get_string(__s, __end, __curs.begin(), __curs.end()); if (!__result.second && __symbol_required) __err = ios_base::failbit; __s = __result.first; break; } case money_base::sign: { if (__s == __end) { if (__ps.empty()) break; if (__ns.empty()) { __is_positive = false; break; } __err = ios_base::failbit; return __s; } else { if (__ps.empty()) { if (__ns.empty()) break; if (*__s == __ns[0]) { ++__s; __is_positive = false; } break; } else { if (*__s == __ps[0]) { ++__s; break; } if (__ns.empty()) break; if (*__s == __ns[0]) { ++__s; __is_positive = false; break; } __err = ios_base::failbit; } } return __s; } case money_base::value: { char_type __point = __intl ? __punct_intl.decimal_point() : __punct.decimal_point(); int __frac_digits = __intl ? __punct_intl.frac_digits() : __punct.frac_digits(); string __grouping = __intl ? __punct_intl.grouping() : __punct.grouping(); bool __syntax_ok = true; bool __result; char_type __sep = __grouping.empty() ? char_type() : __intl ? __punct_intl.thousands_sep() : __punct.thousands_sep(); __result = __get_monetary_value(__s, __end, __out_ite, __c_type, __point, __frac_digits, __sep, __grouping, __syntax_ok); if (!__syntax_ok) __err |= ios_base::failbit; if (!__result) { __err = ios_base::failbit; return __s; } break; } // Close money_base::value case } // Close switch statement } // Close for loop if (__is_positive) { if (__ps.size() > 1) { pair<_InputIter, bool> __result = __get_string(__s, __end, __ps.begin() + 1, __ps.end()); __s = __result.first; if (!__result.second) __err |= ios::failbit; } if (!(__err & ios_base::failbit)) __digits = __buf; } else { if (__ns.size() > 1) { pair<_InputIter, bool> __result = __get_string(__s, __end, __ns.begin() + 1, __ns.end()); __s = __result.first; if (!__result.second) __err |= ios::failbit; } if (!(__err & ios::failbit)) { __digits = __c_type.widen('-'); __digits += __buf; } } if (__s == __end) __err |= ios::eofbit; return __s; }