/home/ntakagi/work/STLport-5.1.5/stlport/stl/_num_get.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1999
00003  * Silicon Graphics Computer Systems, Inc.
00004  *
00005  * Copyright (c) 1999
00006  * Boris Fomitchev
00007  *
00008  * This material is provided "as is", with absolutely no warranty expressed
00009  * or implied. Any use is at your own risk.
00010  *
00011  * Permission to use or copy this software for any purpose is hereby granted
00012  * without fee, provided the above notices are retained on all copies.
00013  * Permission to modify the code and to distribute modified code is granted,
00014  * provided the above notices are retained, and a notice that the code was
00015  * modified is included with the above copyright notice.
00016  *
00017  */
00018 #ifndef _STLP_NUM_GET_C
00019 #define _STLP_NUM_GET_C
00020 
00021 #ifndef _STLP_INTERNAL_NUM_GET_H
00022 #  include <stl/_num_get.h>
00023 #endif
00024 
00025 #ifndef _STLP_INTERNAL_LIMITS
00026 #  include <stl/_limits.h>
00027 #endif
00028 
00029 _STLP_BEGIN_NAMESPACE
00030 
00031 _STLP_MOVE_TO_PRIV_NAMESPACE
00032 
00033 _STLP_DECLSPEC unsigned char _STLP_CALL __digit_val_table(unsigned);
00034 _STLP_DECLSPEC const char* _STLP_CALL __narrow_atoms();
00035 
00036 template < class _InputIter, class _Integer, class _CharT>
00037 _InputIter _STLP_CALL
00038 __do_get_integer(_InputIter&, _InputIter&, ios_base&, ios_base::iostate&, _Integer&, _CharT*);
00039 
00040 // __do_get_integer and its helper functions.
00041 
00042 inline bool _STLP_CALL __get_fdigit(char __c, const char*)
00043 { return __c >= '0' && __c <= '9'; }
00044 
00045 inline bool _STLP_CALL __get_fdigit_or_sep(char& __c, char __sep, const char *__digits) {
00046   if (__c == __sep) {
00047     __c = ',' ;
00048     return true ;
00049   }
00050   else
00051     return  __get_fdigit(__c, __digits);
00052 }
00053 
00054 inline int _STLP_CALL
00055 __get_digit_from_table(unsigned __index)
00056 { return (__index > 127 ? 0xFF : __digit_val_table(__index)); }
00057 
00058 template <class _InputIter, class _CharT>
00059 int
00060 __get_base_or_zero(_InputIter& __in_ite, _InputIter& __end, ios_base& __str, _CharT*) {
00061   _CharT __atoms[5];
00062   const ctype<_CharT>& __c_type = *__STATIC_CAST(const ctype<_CharT>*, __str._M_ctype_facet());
00063 
00064   __c_type.widen(__narrow_atoms(), __narrow_atoms() + 5, __atoms);
00065 
00066   bool __negative = false;
00067   _CharT __c = *__in_ite;
00068 
00069   if (__c == __atoms[1] /* __xminus_char */ ) {
00070     __negative = true;
00071     ++__in_ite;
00072   }
00073   else if (__c == __atoms[0] /* __xplus_char */ )
00074     ++__in_ite;
00075 
00076   int __base;
00077   int __valid_zero = 0;
00078 
00079   ios_base::fmtflags __basefield = __str.flags() & ios_base::basefield;
00080 
00081   switch (__basefield) {
00082   case ios_base::oct:
00083     __base = 8;
00084     break;
00085   case ios_base::dec:
00086     __base = 10;
00087     break;
00088   case ios_base::hex:
00089     __base = 16;
00090     if (__in_ite != __end && *__in_ite == __atoms[2] /* __zero_char */ ) {
00091       ++__in_ite;
00092       if (__in_ite != __end &&
00093           (*__in_ite == __atoms[3] /* __x_char */ || *__in_ite == __atoms[4] /* __X_char */ ))
00094         ++__in_ite;
00095       else
00096         __valid_zero = 1; // That zero is valid by itself.
00097     }
00098     break;
00099   default:
00100     if (__in_ite != __end && *__in_ite == __atoms[2] /* __zero_char */ ) {
00101       ++__in_ite;
00102       if (__in_ite != __end &&
00103           (*__in_ite == __atoms[3] /* __x_char */ || *__in_ite == __atoms[4] /* __X_char */ )) {
00104         ++__in_ite;
00105         __base = 16;
00106       }
00107       else
00108         {
00109           __base = 8;
00110           __valid_zero = 1; // That zero is still valid by itself.
00111         }
00112     }
00113     else
00114       __base = 10;
00115     break;
00116   }
00117   return (__base << 2) | ((int)__negative << 1) | __valid_zero;
00118 }
00119 
00120 
00121 template <class _InputIter, class _Integer, class _CharT>
00122 bool _STLP_CALL
00123 __get_integer(_InputIter& __first, _InputIter& __last,
00124               int __base, _Integer& __val,
00125               int __got, bool __is_negative, _CharT __separator, const string& __grouping, const __true_type& /*_IsSigned*/) {
00126   bool __ovflow = false;
00127   _Integer __result = 0;
00128   bool __is_group = !__grouping.empty();
00129   char __group_sizes[64];
00130   char __current_group_size = 0;
00131   char* __group_sizes_end = __group_sizes;
00132 
00133   _Integer __over_base = (numeric_limits<_Integer>::min)() / __STATIC_CAST(_Integer, __base);
00134 
00135    for ( ; __first != __last ; ++__first) {
00136 
00137      const _CharT __c = *__first;
00138 
00139      if (__is_group && __c == __separator) {
00140        *__group_sizes_end++ = __current_group_size;
00141        __current_group_size = 0;
00142        continue;
00143      }
00144 
00145      int __n = __get_digit_from_table(__c);
00146 
00147      if (__n >= __base)
00148        break;
00149 
00150      ++__got;
00151      ++__current_group_size;
00152 
00153      if (__result < __over_base)
00154        __ovflow = true;  // don't need to keep accumulating
00155      else {
00156        _Integer __next = __STATIC_CAST(_Integer, __base * __result - __n);
00157        if (__result != 0)
00158          __ovflow = __ovflow || __next >= __result;
00159        __result = __next;
00160      }
00161    }
00162 
00163    if (__is_group && __group_sizes_end != __group_sizes) {
00164      *__group_sizes_end++ = __current_group_size;
00165    }
00166 
00167    // fbp : added to not modify value if nothing was read
00168    if (__got > 0) {
00169        __val = __ovflow ? __is_negative ? (numeric_limits<_Integer>::min)()
00170                                         : (numeric_limits<_Integer>::max)()
00171                         : __is_negative ? __result
00172                                         : __STATIC_CAST(_Integer, -__result);
00173    }
00174   // overflow is being treated as failure
00175   return ((__got > 0) && !__ovflow) &&
00176           (__is_group == 0 ||
00177            __valid_grouping(__group_sizes, __group_sizes_end,
00178                             __grouping.data(), __grouping.data()+ __grouping.size()));
00179 }
00180 
00181 template <class _InputIter, class _Integer, class _CharT>
00182 bool _STLP_CALL
00183 __get_integer(_InputIter& __first, _InputIter& __last,
00184               int __base, _Integer& __val,
00185               int __got, bool __is_negative, _CharT __separator, const string& __grouping, const __false_type& /*_IsSigned*/) {
00186   bool __ovflow = false;
00187   _Integer __result = 0;
00188   bool __is_group = !__grouping.empty();
00189   char __group_sizes[64];
00190   char __current_group_size = 0;
00191   char* __group_sizes_end = __group_sizes;
00192 
00193   _Integer  __over_base = (numeric_limits<_Integer>::max)() / __STATIC_CAST(_Integer, __base);
00194 
00195   for ( ; __first != __last ; ++__first) {
00196 
00197     const _CharT __c = *__first;
00198 
00199     if (__is_group && __c == __separator) {
00200       *__group_sizes_end++ = __current_group_size;
00201       __current_group_size = 0;
00202       continue;
00203     }
00204 
00205     int __n = __get_digit_from_table(__c);
00206 
00207     if (__n >= __base)
00208       break;
00209 
00210     ++__got;
00211     ++__current_group_size;
00212 
00213     if (__result > __over_base)
00214       __ovflow = true;  //don't need to keep accumulating
00215     else {
00216       _Integer __next = __STATIC_CAST(_Integer, __base * __result + __n);
00217       if (__result != 0)
00218         __ovflow = __ovflow || __next <= __result;
00219         __result = __next;
00220       }
00221   }
00222 
00223   if (__is_group && __group_sizes_end != __group_sizes) {
00224       *__group_sizes_end++ = __current_group_size;
00225   }
00226 
00227   // fbp : added to not modify value if nothing was read
00228   if (__got > 0) {
00229       __val = __ovflow ? (numeric_limits<_Integer>::max)()
00230                        : (__is_negative ? __STATIC_CAST(_Integer, -__result)
00231                                         : __result);
00232   }
00233 
00234   // overflow is being treated as failure
00235   return ((__got > 0) && !__ovflow) &&
00236           (__is_group == 0 ||
00237            __valid_grouping(__group_sizes, __group_sizes_end,
00238                             __grouping.data(), __grouping.data()+ __grouping.size()));
00239 }
00240 
00241 
00242 template <class _InputIter, class _Integer, class _CharT>
00243 bool _STLP_CALL
00244 __get_decimal_integer(_InputIter& __first, _InputIter& __last, _Integer& __val, _CharT* /*dummy*/) {
00245   string __grp;
00246   //Here there is no grouping so separator is not important, we just pass the default charater.
00247   return __get_integer(__first, __last, 10, __val, 0, false, _CharT() /*separator*/, __grp, __false_type());
00248 }
00249 
00250 template <class _InputIter, class _Integer, class _CharT>
00251 _InputIter _STLP_CALL
00252 __do_get_integer(_InputIter& __in_ite, _InputIter& __end, ios_base& __str,
00253                  ios_base::iostate& __err, _Integer& __val, _CharT* __pc) {
00254 #if defined (__HP_aCC) && (__HP_aCC == 1)
00255   bool _IsSigned = !((_Integer)(-1) > 0);
00256 #else
00257   typedef typename __bool2type<numeric_limits<_Integer>::is_signed>::_Ret _IsSigned;
00258 #endif
00259 
00260   const numpunct<_CharT>& __numpunct = *__STATIC_CAST(const numpunct<_CharT>*, __str._M_numpunct_facet());
00261   const string& __grouping = __str._M_grouping(); // cached copy
00262 
00263   const int __base_or_zero = __get_base_or_zero(__in_ite, __end, __str, __pc);
00264   int  __got = __base_or_zero & 1;
00265 
00266   bool __result;
00267 
00268   if (__in_ite == __end) {      // We may have already read a 0.  If so,
00269 
00270     if (__got > 0) {       // the result is 0 even if we're at eof.
00271       __val = 0;
00272       __result = true;
00273     }
00274     else
00275       __result = false;
00276   }
00277   else {
00278     const bool __negative = (__base_or_zero & 2) != 0;
00279     const int __base = __base_or_zero >> 2;
00280 
00281 #if defined (__HP_aCC) && (__HP_aCC == 1)
00282     if (_IsSigned)
00283       __result = __get_integer(__in_ite, __end, __base,  __val, __got, __negative, __numpunct.thousands_sep(), __grouping, __true_type() );
00284     else
00285       __result = __get_integer(__in_ite, __end, __base,  __val, __got, __negative, __numpunct.thousands_sep(), __grouping, __false_type() );
00286 #else
00287     __result = __get_integer(__in_ite, __end, __base,  __val, __got, __negative, __numpunct.thousands_sep(), __grouping, _IsSigned());
00288 # endif
00289   }
00290 
00291   __err = __STATIC_CAST(ios_base::iostate, __result ? ios_base::goodbit : ios_base::failbit);
00292 
00293   if (__in_ite == __end)
00294     __err |= ios_base::eofbit;
00295   return __in_ite;
00296 }
00297 
00298 // __read_float and its helper functions.
00299 template <class _InputIter, class _CharT>
00300 _InputIter  _STLP_CALL
00301 __copy_sign(_InputIter __first, _InputIter __last, __iostring& __v,
00302             _CharT __xplus, _CharT __xminus) {
00303   if (__first != __last) {
00304     _CharT __c = *__first;
00305     if (__c == __xplus)
00306       ++__first;
00307     else if (__c == __xminus) {
00308       __v.push_back('-');
00309       ++__first;
00310     }
00311   }
00312   return __first;
00313 }
00314 
00315 
00316 template <class _InputIter, class _CharT>
00317 bool _STLP_CALL
00318 __copy_digits(_InputIter& __first, _InputIter __last,
00319               __iostring& __v, const _CharT* __digits) {
00320   bool __ok = false;
00321 
00322   for ( ; __first != __last; ++__first) {
00323     _CharT __c = *__first;
00324     if (__get_fdigit(__c, __digits)) {
00325       __v.push_back((char)__c);
00326       __ok = true;
00327     }
00328     else
00329       break;
00330   }
00331   return __ok;
00332 }
00333 
00334 template <class _InputIter, class _CharT>
00335 bool _STLP_CALL
00336 __copy_grouped_digits(_InputIter& __first, _InputIter __last,
00337                       __iostring& __v, const _CharT * __digits,
00338                       _CharT __sep, const string& __grouping,
00339                       bool& __grouping_ok) {
00340   bool __ok = false;
00341   char __group_sizes[64];
00342   char*__group_sizes_end = __group_sizes;
00343   char __current_group_size = 0;
00344 
00345   for ( ; __first != __last; ++__first) {
00346     _CharT __c = *__first;
00347     bool __tmp = __get_fdigit_or_sep(__c, __sep, __digits);
00348     if (__tmp) {
00349       if (__c == ',') {
00350         *__group_sizes_end++ = __current_group_size;
00351         __current_group_size = 0;
00352       }
00353       else {
00354         __ok = true;
00355         __v.push_back((char)__c);
00356         ++__current_group_size;
00357       }
00358     }
00359     else
00360       break;
00361   }
00362 
00363   if (__group_sizes_end != __group_sizes)
00364     *__group_sizes_end++ = __current_group_size;
00365   __grouping_ok = __valid_grouping(__group_sizes, __group_sizes_end, __grouping.data(), __grouping.data() + __grouping.size());
00366   return __ok;
00367 }
00368 
00369 
00370 template <class _InputIter, class _CharT>
00371 bool _STLP_CALL
00372 __read_float(__iostring& __buf, _InputIter& __in_ite, _InputIter& __end, ios_base& __s, _CharT*) {
00373   // Create a string, copying characters of the form
00374   // [+-]? [0-9]* .? [0-9]* ([eE] [+-]? [0-9]+)?
00375 
00376   bool __digits_before_dot /* = false */;
00377   bool __digits_after_dot = false;
00378   bool __ok;
00379 
00380   bool   __grouping_ok = true;
00381 
00382   const ctype<_CharT>& __ct = *__STATIC_CAST(const ctype<_CharT>*, __s._M_ctype_facet());
00383   const numpunct<_CharT>& __numpunct = *__STATIC_CAST(const numpunct<_CharT>*, __s._M_numpunct_facet());
00384   const string& __grouping = __s._M_grouping(); // cached copy
00385 
00386   _CharT __dot = __numpunct.decimal_point();
00387   _CharT __sep = __numpunct.thousands_sep();
00388 
00389   _CharT __digits[10];
00390   _CharT __xplus;
00391   _CharT __xminus;
00392 
00393   _CharT __pow_e;
00394   _CharT __pow_E;
00395 
00396   _Initialize_get_float(__ct, __xplus, __xminus, __pow_e, __pow_E, __digits);
00397 
00398   // Get an optional sign
00399   __in_ite = __copy_sign(__in_ite, __end, __buf, __xplus, __xminus);
00400 
00401   // Get an optional string of digits.
00402   if (!__grouping.empty())
00403     __digits_before_dot = __copy_grouped_digits(__in_ite, __end, __buf, __digits,
00404                                                 __sep, __grouping, __grouping_ok);
00405   else
00406     __digits_before_dot = __copy_digits(__in_ite, __end, __buf, __digits);
00407 
00408   // Get an optional decimal point, and an optional string of digits.
00409   if (__in_ite != __end && *__in_ite == __dot) {
00410     __buf.push_back('.');
00411     ++__in_ite;
00412     __digits_after_dot = __copy_digits(__in_ite, __end, __buf, __digits);
00413   }
00414 
00415   // There have to be some digits, somewhere.
00416   __ok = __digits_before_dot || __digits_after_dot;
00417 
00418   // Get an optional exponent.
00419   if (__ok && __in_ite != __end && (*__in_ite == __pow_e || *__in_ite == __pow_E)) {
00420     __buf.push_back('e');
00421     ++__in_ite;
00422     __in_ite = __copy_sign(__in_ite, __end, __buf, __xplus, __xminus);
00423     __ok = __copy_digits(__in_ite, __end, __buf, __digits);
00424     // If we have an exponent then the sign
00425     // is optional but the digits aren't.
00426   }
00427 
00428   return __ok;
00429 }
00430 
00431 _STLP_MOVE_TO_STD_NAMESPACE
00432 
00433 //
00434 // num_get<>, num_put<>
00435 //
00436 
00437 #if ( _STLP_STATIC_TEMPLATE_DATA > 0 )
00438 #  if !defined (__BORLANDC__)
00439 template <class _CharT, class _InputIterator>
00440 locale::id num_get<_CharT, _InputIterator>::id;
00441 #  endif
00442 
00443 #  if (defined (__CYGWIN__) || defined (__MINGW32__)) && \
00444        defined (_STLP_USE_DYNAMIC_LIB) && !defined (__BUILDING_STLPORT)
00445 /*
00446  * Under cygwin, when STLport is used as a shared library, the id needs
00447  * to be specified as imported otherwise they will be duplicated in the
00448  * calling executable.
00449  */
00450 template <>
00451 _STLP_DECLSPEC locale::id num_get<char, istreambuf_iterator<char, char_traits<char> > >::id;
00452 /*
00453 template <>
00454 _STLP_DECLSPEC locale::id num_get<char, const char*>::id;
00455 */
00456 
00457 #    if !defined (STLP_NO_WCHAR_T)
00458 template <>
00459 _STLP_DECLSPEC locale::id num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
00460 /*
00461 template <>
00462 _STLP_DECLSPEC locale::id num_get<wchar_t, const wchar_t*>::id;
00463 */
00464 #    endif
00465 
00466 #  endif /* __CYGWIN__ && _STLP_USE_DYNAMIC_LIB */
00467 
00468 #else /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */
00469 
00470 //typedef num_get<char, const char*> num_get_char;
00471 typedef num_get<char, istreambuf_iterator<char, char_traits<char> > > num_get_char_2;
00472 
00473 //__DECLARE_INSTANCE(locale::id, num_get_char::id, );
00474 __DECLARE_INSTANCE(locale::id, num_get_char_2::id, );
00475 
00476 #  if !defined (_STLP_NO_WCHAR_T)
00477 
00478 //typedef num_get<wchar_t, const wchar_t*> num_get_wchar_t;
00479 typedef num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > num_get_wchar_t_2;
00480 
00481 //__DECLARE_INSTANCE(locale::id, num_get_wchar_t::id, );
00482 __DECLARE_INSTANCE(locale::id, num_get_wchar_t_2::id, );
00483 
00484 #  endif
00485 
00486 #endif /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */
00487 
00488 #if !defined (_STLP_NO_BOOL)
00489 template <class _CharT, class _InputIter>
00490 _InputIter
00491 num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end,
00492                                     ios_base& __s,
00493                                     ios_base::iostate& __err, bool& __x) const {
00494   if (__s.flags() & ios_base::boolalpha) {
00495     locale __loc = __s.getloc();
00496     const _Numpunct& __np = *__STATIC_CAST(const _Numpunct*, __s._M_numpunct_facet());
00497     //    const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc) ;
00498 //    const ctype<_CharT>& __ct =    use_facet<ctype<_CharT> >(__loc) ;
00499 
00500     const basic_string<_CharT> __truename  = __np.truename();
00501     const basic_string<_CharT> __falsename = __np.falsename();
00502     bool __true_ok  = true;
00503     bool __false_ok = true;
00504 
00505     size_t __n = 0;
00506     for ( ; __in_ite != __end; ++__in_ite) {
00507       _CharT __c = *__in_ite;
00508       __true_ok  = __true_ok  && (__c == __truename[__n]);
00509       __false_ok = __false_ok && (__c == __falsename[__n]);
00510       ++__n;
00511 
00512       if ((!__true_ok && !__false_ok) ||
00513           (__true_ok  && __n >= __truename.size()) ||
00514           (__false_ok && __n >= __falsename.size())) {
00515         ++__in_ite;
00516         break;
00517       }
00518     }
00519     if (__true_ok  && __n < __truename.size())  __true_ok  = false;
00520     if (__false_ok && __n < __falsename.size()) __false_ok = false;
00521 
00522     if (__true_ok || __false_ok) {
00523       __err = ios_base::goodbit;
00524       __x = __true_ok;
00525     }
00526     else
00527       __err = ios_base::failbit;
00528 
00529     if (__in_ite == __end)
00530       __err |= ios_base::eofbit;
00531 
00532     return __in_ite;
00533   }
00534 
00535   else {
00536     long __lx;
00537     _InputIter __tmp = this->do_get(__in_ite, __end, __s, __err, __lx);
00538     if (!(__err & ios_base::failbit)) {
00539       if (__lx == 0)
00540         __x = false;
00541       else if (__lx == 1)
00542         __x = true;
00543       else
00544         __err |= ios_base::failbit;
00545     }
00546     return __tmp;
00547   }
00548 }
00549 
00550 #endif /* _STLP_NO_BOOL */
00551 
00552 #if defined (_STLP_FIX_LIBRARY_ISSUES)
00553 template <class _CharT, class _InputIter>
00554 _InputIter
00555 num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
00556                                     ios_base::iostate& __err, short& __val) const
00557 { return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }
00558 
00559 template <class _CharT, class _InputIter>
00560 _InputIter
00561 num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
00562                                     ios_base::iostate& __err, int& __val) const
00563 { return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }
00564 
00565 #endif
00566 
00567 template <class _CharT, class _InputIter>
00568 _InputIter
00569 num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
00570                                     ios_base::iostate& __err, long& __val) const
00571 { return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }
00572 
00573 template <class _CharT, class _InputIter>
00574 _InputIter
00575 num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
00576                                     ios_base::iostate& __err,
00577                                     unsigned short& __val) const
00578 { return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }
00579 
00580 template <class _CharT, class _InputIter>
00581 _InputIter
00582 num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
00583                                     ios_base::iostate& __err,
00584                                     unsigned int& __val) const
00585 { return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }
00586 
00587 template <class _CharT, class _InputIter>
00588 _InputIter
00589 num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
00590                                     ios_base::iostate& __err,
00591                                     unsigned long& __val) const
00592 { return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 ); }
00593 
00594 
00595 template <class _CharT, class _InputIter>
00596 _InputIter
00597 num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
00598                                     ios_base::iostate& __err,
00599                                     float& __val) const {
00600   _STLP_PRIV __iostring __buf ;
00601   bool __ok = _STLP_PRIV __read_float(__buf, __in_ite, __end, __str, (_CharT*)0 );
00602   _STLP_PRIV __string_to_float(__buf, __val);
00603   __err = __STATIC_CAST(ios_base::iostate, __ok ? ios_base::goodbit : ios_base::failbit);
00604   if (__in_ite == __end)
00605     __err |= ios_base::eofbit;
00606   return __in_ite;
00607 }
00608 
00609 template <class _CharT, class _InputIter>
00610 _InputIter
00611 num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
00612                                     ios_base::iostate& __err,
00613                                     double& __val) const {
00614   _STLP_PRIV __iostring __buf ;
00615   bool __ok = _STLP_PRIV __read_float(__buf, __in_ite, __end, __str, (_CharT*)0 );
00616   _STLP_PRIV __string_to_float(__buf, __val);
00617   __err = __STATIC_CAST(ios_base::iostate, __ok ? ios_base::goodbit : ios_base::failbit);
00618   if (__in_ite == __end)
00619     __err |= ios_base::eofbit;
00620   return __in_ite;
00621 }
00622 
00623 #if !defined (_STLP_NO_LONG_DOUBLE)
00624 template <class _CharT, class _InputIter>
00625 _InputIter
00626 num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
00627                                     ios_base::iostate& __err,
00628                                     long double& __val) const {
00629   _STLP_PRIV __iostring __buf ;
00630   bool __ok = _STLP_PRIV __read_float(__buf, __in_ite, __end, __str, (_CharT*)0 );
00631   _STLP_PRIV __string_to_float(__buf, __val);
00632   __err = __STATIC_CAST(ios_base::iostate, __ok ? ios_base::goodbit : ios_base::failbit);
00633   if (__in_ite == __end)
00634     __err |= ios_base::eofbit;
00635   return __in_ite;
00636 }
00637 #endif /* _STLP_NO_LONG_DOUBLE */
00638 
00639 template <class _CharT, class _InputIter>
00640 _InputIter
00641 num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
00642                            ios_base::iostate& __err,
00643                            void*& __p) const {
00644 #if defined (_STLP_LONG_LONG) && !defined (__MRC__)    //*ty 12/07/2001 - MrCpp can not cast from long long to void*
00645   unsigned _STLP_LONG_LONG __val;
00646 #else
00647   unsigned long __val;
00648 #endif
00649     iter_type __tmp = _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 );
00650     if (!(__err & ios_base::failbit))
00651       __p = __REINTERPRET_CAST(void*,__val);
00652     return __tmp;
00653   }
00654 
00655 #if defined (_STLP_LONG_LONG)
00656 template <class _CharT, class _InputIter>
00657 _InputIter
00658 num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
00659                                     ios_base::iostate& __err,
00660                                     _STLP_LONG_LONG& __val) const {
00661   return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 );
00662 }
00663 
00664 template <class _CharT, class _InputIter>
00665 _InputIter
00666 num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end, ios_base& __str,
00667                                     ios_base::iostate& __err,
00668                                     unsigned _STLP_LONG_LONG& __val) const {
00669   return _STLP_PRIV __do_get_integer(__in_ite, __end, __str, __err, __val, (_CharT*)0 );
00670 }
00671 #endif /* _STLP_LONG_LONG */
00672 
00673 _STLP_END_NAMESPACE
00674 
00675 #endif /* _STLP_NUMERIC_FACETS_C */
00676 
00677 // Local Variables:
00678 // mode:C++
00679 // End:



Generated on Mon Mar 10 15:32:31 2008 by  doxygen 1.5.1