📄 _num_get.c
字号:
char __group_sizes[64]; char*__group_sizes_end = __group_sizes; char __current_group_size = 0; for ( ; __first != __last; ++__first) { _CharT __c = *__first; bool __tmp = __get_fdigit_or_sep(__c, __sep, __digits); if (__tmp) { if (__c == ',') { *__group_sizes_end++ = __current_group_size; __current_group_size = 0; } else { __ok = true; __v.push_back((char)__c); ++__current_group_size; } } else break; } if (__group_sizes_end != __group_sizes) *__group_sizes_end++ = __current_group_size; __grouping_ok = __valid_grouping(__group_sizes, __group_sizes_end, __grouping.data(), __grouping.data() + __grouping.size()); return __ok;}template <class _InputIter, class _CharT>bool _STLP_CALL__read_float(__iostring& __buf, _InputIter& __in_ite, _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 = *__STATIC_CAST(const ctype<_CharT>*, __s._M_ctype_facet()); const numpunct<_CharT>& __numpunct = *__STATIC_CAST(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_ite = __copy_sign(__in_ite, __end, __buf, __xplus, __xminus); // Get an optional string of digits. if (!__grouping.empty()) __digits_before_dot = __copy_grouped_digits(__in_ite, __end, __buf, __digits, __sep, __grouping, __grouping_ok); else __digits_before_dot = __copy_digits(__in_ite, __end, __buf, __digits); // Get an optional decimal point, and an optional string of digits. if (__in_ite != __end && *__in_ite == __dot) { __buf.push_back('.'); ++__in_ite; __digits_after_dot = __copy_digits(__in_ite, __end, __buf, __digits); } // There have to be some digits, somewhere. __ok = __digits_before_dot || __digits_after_dot; // Get an optional exponent. if (__ok && __in_ite != __end && (*__in_ite == __pow_e || *__in_ite == __pow_E)) { __buf.push_back('e'); ++__in_ite; __in_ite = __copy_sign(__in_ite, __end, __buf, __xplus, __xminus); __ok = __copy_digits(__in_ite, __end, __buf, __digits); // If we have an exponent then the sign // is optional but the digits aren't. } return __ok;}_STLP_MOVE_TO_STD_NAMESPACE//// num_get<>, num_put<>//#if ( _STLP_STATIC_TEMPLATE_DATA > 0 )# if !defined (__BORLANDC__)template <class _CharT, class _InputIterator>locale::id num_get<_CharT, _InputIterator>::id;# endif# if (defined (__CYGWIN__) || defined (__MINGW32__)) && \ defined (_STLP_USE_DYNAMIC_LIB) && !defined (__BUILDING_STLPORT)/* * Under cygwin, when STLport is used as a shared library, the id needs * to be specified as imported otherwise they will be duplicated in the * calling executable. */template <>_STLP_DECLSPEC locale::id num_get<char, istreambuf_iterator<char, char_traits<char> > >::id;/*template <>_STLP_DECLSPEC locale::id num_get<char, const char*>::id;*/# if !defined (STLP_NO_WCHAR_T)template <>_STLP_DECLSPEC locale::id num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;/*template <>_STLP_DECLSPEC locale::id num_get<wchar_t, const wchar_t*>::id;*/# endif# endif /* __CYGWIN__ && _STLP_USE_DYNAMIC_LIB */#else /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) *///typedef num_get<char, const char*> num_get_char;typedef num_get<char, istreambuf_iterator<char, char_traits<char> > > num_get_char_2;//__DECLARE_INSTANCE(locale::id, num_get_char::id, );__DECLARE_INSTANCE(locale::id, num_get_char_2::id, );# if !defined (_STLP_NO_WCHAR_T)//typedef num_get<wchar_t, const wchar_t*> num_get_wchar_t;typedef num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > num_get_wchar_t_2;//__DECLARE_INSTANCE(locale::id, num_get_wchar_t::id, );__DECLARE_INSTANCE(locale::id, num_get_wchar_t_2::id, );# endif#endif /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */#if !defined (_STLP_NO_BOOL)template <class _CharT, class _InputIter>_InputIternum_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> __truename = __np.truename(); const basic_string<_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; } else { long __lx; _InputIter __tmp = this->do_get(__in_ite, __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; }}#endif /* _STLP_NO_BOOL */#if defined (_STLP_FIX_LIBRARY_ISSUES)template <class _CharT, class _InputIter>_InputIternum_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, ios_base::iostate& __err, short& __val) const{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }template <class _CharT, class _InputIter>_InputIternum_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, ios_base::iostate& __err, int& __val) const{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }#endiftemplate <class _CharT, class _InputIter>_InputIternum_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, ios_base::iostate& __err, long& __val) const{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }template <class _CharT, class _InputIter>_InputIternum_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, ios_base::iostate& __err, unsigned short& __val) const{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }template <class _CharT, class _InputIter>_InputIternum_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, ios_base::iostate& __err, unsigned int& __val) const{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }template <class _CharT, class _InputIter>_InputIternum_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, ios_base::iostate& __err, unsigned long& __val) const{ return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }template <class _CharT, class _InputIter>_InputIternum_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, ios_base::iostate& __err, float& __val) const { _STLP_PRIV __iostring __buf ; bool __ok = _STLP_PRIV __read_float(__buf, __in_ite, __end, __str, (_CharT*)0 ); _STLP_PRIV __string_to_float(__buf, __val); __err = __STATIC_CAST(ios_base::iostate, __ok ? ios_base::goodbit : ios_base::failbit); if (__in_ite == __end) __err |= ios_base::eofbit; return __in_ite;}template <class _CharT, class _InputIter>_InputIternum_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, ios_base::iostate& __err, double& __val) const { _STLP_PRIV __iostring __buf ; bool __ok = _STLP_PRIV __read_float(__buf, __in_ite, __end, __str, (_CharT*)0 ); _STLP_PRIV __string_to_float(__buf, __val); __err = __STATIC_CAST(ios_base::iostate, __ok ? ios_base::goodbit : ios_base::failbit); if (__in_ite == __end) __err |= ios_base::eofbit; return __in_ite;}#if !defined (_STLP_NO_LONG_DOUBLE)template <class _CharT, class _InputIter>_InputIternum_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, ios_base::iostate& __err, long double& __val) const { _STLP_PRIV __iostring __buf ; bool __ok = _STLP_PRIV __read_float(__buf, __in_ite, __end, __str, (_CharT*)0 ); _STLP_PRIV __string_to_float(__buf, __val); __err = __STATIC_CAST(ios_base::iostate, __ok ? ios_base::goodbit : ios_base::failbit); if (__in_ite == __end) __err |= ios_base::eofbit; return __in_ite;}#endif /* _STLP_NO_LONG_DOUBLE */template <class _CharT, class _InputIter>_InputIternum_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, ios_base::iostate& __err, void*& __p) const {#if defined (_STLP_LONG_LONG) && !defined (__MRC__) //*ty 12/07/2001 - MrCpp can not cast from long long to void* unsigned _STLP_LONG_LONG __val;#else unsigned long __val;#endif iter_type __tmp = _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); if (!(__err & ios_base::failbit)) __p = __REINTERPRET_CAST(void*,__val); return __tmp; }#if defined (_STLP_LONG_LONG)template <class _CharT, class _InputIter>_InputIternum_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, ios_base::iostate& __err, _STLP_LONG_LONG& __val) const { return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 );}template <class _CharT, class _InputIter>_InputIternum_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str, ios_base::iostate& __err, unsigned _STLP_LONG_LONG& __val) const { return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 );}#endif /* _STLP_LONG_LONG */_STLP_END_NAMESPACE#endif /* _STLP_NUMERIC_FACETS_C */// Local Variables:// mode:C++// End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -