home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / stlport / stl / _num_get.c < prev    next >
C/C++ Source or Header  |  2002-02-02  |  20KB  |  670 lines

  1. /*
  2.  * Copyright (c) 1999
  3.  * Silicon Graphics Computer Systems, Inc.
  4.  *
  5.  * Copyright (c) 1999 
  6.  * Boris Fomitchev
  7.  *
  8.  * This material is provided "as is", with absolutely no warranty expressed
  9.  * or implied. Any use is at your own risk.
  10.  *
  11.  * Permission to use or copy this software for any purpose is hereby granted 
  12.  * without fee, provided the above notices are retained on all copies.
  13.  * Permission to modify the code and to distribute modified code is granted,
  14.  * provided the above notices are retained, and a notice that the code was
  15.  * modified is included with the above copyright notice.
  16.  *
  17.  */ 
  18. #ifndef _STLP_NUM_GET_C
  19. #define _STLP_NUM_GET_C
  20.  
  21. #ifndef _STLP_INTERNAL_NUM_GET_H
  22. # include <stl/_num_get.h>
  23. #endif
  24.  
  25. # if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
  26.  
  27. #ifndef _STLP_LIMITS_H
  28. # include <stl/_limits.h>
  29. #endif
  30.  
  31. _STLP_BEGIN_NAMESPACE
  32.  
  33. extern const unsigned char __digit_val_table[];
  34.  
  35. template < class _InputIter, class _Integer, class _CharT>
  36. _InputIter _STLP_CALL
  37. _M_do_get_integer(_InputIter&, _InputIter&, ios_base&, ios_base::iostate&, _Integer&, _CharT*);
  38.  
  39. // _M_do_get_integer and its helper functions.  
  40.  
  41. inline bool _STLP_CALL __get_fdigit(char& __c, const char*)
  42.   { return __c >= '0' && __c <= '9'; }
  43.  
  44. inline bool _STLP_CALL __get_fdigit_or_sep(char& __c, char __sep, const char *)
  45.   if (__c == __sep) { 
  46.     __c = ',' ; 
  47.     return true ;
  48.   } else
  49.     return  ( __c >= '0' && __c <= '9');
  50. }
  51.  
  52. inline int _STLP_CALL
  53. __get_digit_from_table(unsigned __index)
  54. {
  55.   return (__index > 127 ? 0xFF : __digit_val_table[__index]);
  56. }
  57.  
  58. extern const char __narrow_atoms[];
  59.  
  60. template <class _InputIter, class _CharT>
  61. int 
  62. _M_get_base_or_zero(_InputIter& __in, _InputIter& __end, ios_base& __str, _CharT*)
  63. {
  64.   _CharT __atoms[5];
  65.   const ctype<_CharT>& __c_type = *(const ctype<_CharT>*)__str._M_ctype_facet();
  66.  
  67.   __c_type.widen(__narrow_atoms, __narrow_atoms + 5, __atoms);
  68.  
  69.   bool __negative = false;
  70.   _CharT __c = *__in;
  71.  
  72.   if (__c == __atoms[1] /* __xminus_char */ ) {
  73.     __negative = true;
  74.     ++__in;
  75.   }
  76.   else if (__c == __atoms[0] /* __xplus_char */ ) 
  77.     ++__in;
  78.  
  79.  
  80.   int __base;
  81.   int __valid_zero = 0;
  82.   
  83.   ios_base::fmtflags __basefield = __str.flags() & ios_base::basefield; 
  84.  
  85.   switch (__basefield) {
  86.   case ios_base::oct:
  87.     __base = 8;
  88.     break;
  89.   case ios_base::dec:
  90.     __base = 10;
  91.     break;
  92.   case ios_base::hex:
  93.     __base = 16;
  94.     if (__in != __end && *__in == __atoms[2] /* __zero_char */ ) {
  95.       ++__in;
  96.       if (__in != __end &&
  97.           (*__in == __atoms[3] /* __x_char */ || *__in == __atoms[4] /* __X_char */ ))
  98.         ++__in;
  99.       else
  100.         __valid_zero = 1; // That zero is valid by itself.
  101.     }
  102.     break;
  103.   default:
  104.     if (__in != __end && *__in == __atoms[2] /* __zero_char */ ) {
  105.       ++__in;
  106.       if (__in != __end &&
  107.           (*__in == __atoms[3] /* __x_char */ || *__in == __atoms[4] /* __X_char */ )) {
  108.         ++__in;
  109.         __base = 16;
  110.       }
  111.       else
  112.         {
  113.           __base = 8;
  114.           __valid_zero = 1; // That zero is still valid by itself.
  115.         }
  116.     }
  117.     else
  118.       __base = 10;
  119.     break;
  120.   }
  121.   return (__base << 2) | ((int)__negative << 1) | __valid_zero;
  122. }
  123.  
  124.  
  125. template <class _InputIter, class _Integer>
  126. bool _STLP_CALL
  127. __get_integer(_InputIter& __first, _InputIter& __last,
  128.           int __base, _Integer& __val, 
  129.           int __got, bool __is_negative, char __separator, const string& __grouping, const __true_type&) 
  130. {
  131.   bool __ovflow = false;
  132.   _Integer __result = 0;
  133.   bool __is_group = !__grouping.empty();
  134.   char __group_sizes[64];
  135.   int __current_group_size = 0;
  136.   char* __group_sizes_end = __group_sizes;
  137.   
  138.   _Integer __over_base = (numeric_limits<_Integer>::min)() / __STATIC_CAST(_Integer, __base);
  139.  
  140.    for ( ; __first != __last ; ++__first) {
  141.   
  142.      const char __c = *__first;
  143.      
  144.      if (__is_group && __c == __separator) {
  145.        *__group_sizes_end++ = __current_group_size;
  146.        __current_group_size = 0;
  147.        continue;
  148.      }
  149.      
  150.      int __n = __get_digit_from_table(__c);
  151.      
  152.      if (__n >= __base)
  153.        break;
  154.      
  155.      ++__got;
  156.      ++__current_group_size;
  157.      
  158.      if (__result < __over_base)
  159.        __ovflow = true;  // don't need to keep accumulating
  160.      else {
  161.        _Integer __next = __STATIC_CAST(_Integer, __base * __result - __n);
  162.        if (__result != 0)
  163.      __ovflow = __ovflow || __next >= __result;
  164.        __result = __next;
  165.      }
  166.    }
  167.  
  168.    if (__is_group && __group_sizes_end != __group_sizes) {
  169.      *__group_sizes_end++ = __current_group_size;
  170.    }
  171.  
  172.    // fbp : added to not modify value if nothing was read
  173.    if (__got > 0) {
  174.        __val = __ovflow
  175.      ? __is_negative ? (numeric_limits<_Integer>::min)()
  176.      : (numeric_limits<_Integer>::max)()
  177.      : (__is_negative ? __result : __STATIC_CAST(_Integer, -__result));
  178.    }
  179.   // overflow is being treated as failure
  180.   return ((__got > 0) && !__ovflow) && (__is_group == 0 || __valid_grouping(__group_sizes, __group_sizes_end,
  181.                                         __grouping.data(), __grouping.data()+ __grouping.size())) ;
  182. }
  183.  
  184. template <class _InputIter, class _Integer>
  185. bool _STLP_CALL
  186. __get_integer(_InputIter& __first, _InputIter& __last,
  187.           int __base, _Integer& __val, 
  188.           int __got, bool __is_negative, char __separator, const string& __grouping, const __false_type&) 
  189. {
  190.   bool __ovflow = false;
  191.   _Integer __result = 0;
  192.   bool __is_group = !__grouping.empty();
  193.   char __group_sizes[64];
  194.   int __current_group_size = 0;
  195.   char* __group_sizes_end = __group_sizes;
  196.  
  197.   _Integer  __over_base = (numeric_limits<_Integer>::max)() / __STATIC_CAST(_Integer, __base);
  198.  
  199.   for ( ; __first != __last ; ++__first) {
  200.  
  201.     const char __c = *__first;
  202.     
  203.     if (__is_group && __c == __separator) {
  204.       *__group_sizes_end++ = __current_group_size;
  205.       __current_group_size = 0;
  206.       continue;
  207.     }
  208.     
  209.     int __n = __get_digit_from_table(__c);
  210.     
  211.     if (__n >= __base)
  212.       break;
  213.     
  214.     ++__got;
  215.     ++__current_group_size;
  216.  
  217.     if (__result > __over_base)
  218.       __ovflow = true;  //don't need to keep accumulating
  219.     else {
  220.       _Integer __next = __STATIC_CAST(_Integer, __base * __result + __n);
  221.     if (__result != 0)
  222.       __ovflow = __ovflow || __next <= __result;
  223.     __result = __next;
  224.       }      
  225.   }
  226.  
  227.   if (__is_group && __group_sizes_end != __group_sizes) {
  228.       *__group_sizes_end++ = __current_group_size;
  229.   }
  230.  
  231.   // fbp : added to not modify value if nothing was read
  232.   if (__got > 0) {
  233.       __val = __ovflow
  234.     ? (numeric_limits<_Integer>::max)()
  235.     : (__is_negative ? __STATIC_CAST(_Integer, -__result) : __result);      
  236.   }
  237.   // overflow is being treated as failure
  238.   return ((__got > 0) && !__ovflow) && 
  239.     (__is_group == 0 || __valid_grouping(__group_sizes, __group_sizes_end,
  240.                      __grouping.data(), __grouping.data()+ __grouping.size())) ;
  241. }
  242.  
  243.  
  244. template <class _InputIter, class _Integer>
  245. bool _STLP_CALL
  246. __get_decimal_integer(_InputIter& __first, _InputIter& __last, _Integer& __val)
  247. {
  248.   string __grp;
  249.   return __get_integer(__first, __last, 10, __val, 0, false, ' ', __grp, __false_type());
  250. }
  251.  
  252. template <class _InputIter, class _Integer, class _CharT>
  253. _InputIter _STLP_CALL
  254. _M_do_get_integer(_InputIter& __in, _InputIter& __end, ios_base& __str,
  255.                   ios_base::iostate& __err, _Integer& __val, _CharT* __pc) 
  256. {
  257.  
  258. #if defined(__HP_aCC) && (__HP_aCC == 1)
  259.   bool _IsSigned = !((_Integer)(-1) > 0);
  260. #else
  261.   typedef typename __bool2type<numeric_limits<_Integer>::is_signed>::_Ret _IsSigned;
  262. #endif
  263.  
  264.   const numpunct<_CharT>& __numpunct = *(const numpunct<_CharT>*)__str._M_numpunct_facet();
  265.   const string& __grouping = __str._M_grouping(); // cached copy
  266.  
  267.   const int __base_or_zero = _M_get_base_or_zero(__in, __end, __str, __pc);
  268.   int  __got = __base_or_zero & 1;
  269.  
  270.   bool __result;
  271.  
  272.   if (__in == __end) {      // We may have already read a 0.  If so,
  273.  
  274.     if (__got > 0) {       // the result is 0 even if we're at eof.
  275.       __val = 0;
  276.       __result = true;
  277.     }
  278.     else
  279.       __result = false;    
  280.   } else {
  281.  
  282.     const bool __negative = __base_or_zero & 2;
  283.     const int __base = __base_or_zero >> 2;
  284.  
  285. #if defined(__HP_aCC) && (__HP_aCC == 1)
  286.      if (_IsSigned)
  287.        __result = __get_integer(__in, __end, __base,  __val, __got, __negative, __numpunct.thousands_sep(), __grouping, __true_type() );
  288.      else
  289.       __result = __get_integer(__in, __end, __base,  __val, __got, __negative, __numpunct.thousands_sep(), __grouping, __false_type() );
  290. #else
  291.     __result = __get_integer(__in, __end, __base,  __val, __got, __negative, __numpunct.thousands_sep(), __grouping, _IsSigned());
  292. # endif
  293.   }
  294.  
  295.   __err = __STATIC_CAST(ios_base::iostate, __result ? ios_base::goodbit : ios_base::failbit);
  296.  
  297.   if (__in == __end)
  298.     __err |= ios_base::eofbit;
  299.   return __in;
  300. }
  301.  
  302. // _M_read_float and its helper functions.
  303. template <class _InputIter, class _CharT>
  304. _InputIter  _STLP_CALL
  305. __copy_sign(_InputIter __first, _InputIter __last, string& __v,
  306.             _CharT __xplus, _CharT __xminus) {
  307.     if (__first != __last) {
  308.     _CharT __c = *__first;
  309.     if (__c == __xplus)
  310.       ++__first;
  311.     else if (__c == __xminus) {
  312.       __v.push_back('-');
  313.       ++__first;
  314.     }
  315.   }
  316.   return __first;
  317. }
  318.  
  319.  
  320. template <class _InputIter, class _CharT>
  321. bool _STLP_CALL
  322. __copy_digits(_InputIter& __first, _InputIter& __last,
  323.               string& __v, const _CharT* __digits)
  324. {
  325.   bool __ok = false;
  326.  
  327.   for ( ; __first != __last; ++__first) {
  328.     _CharT __c = *__first;
  329.     if (__get_fdigit(__c, __digits)) {
  330.       __v.push_back((char)__c);
  331.       __ok = true;
  332.     }
  333.     else
  334.       break;
  335.   }
  336.   return __ok;
  337. }
  338.  
  339. template <class _InputIter, class _CharT>
  340. bool _STLP_CALL
  341. __copy_grouped_digits(_InputIter& __first, _InputIter& __last,
  342.               string& __v, const _CharT * __digits,
  343.               _CharT __sep, const string& __grouping,
  344.               bool& __grouping_ok)
  345. {
  346.   bool __ok = false;
  347.   char __group_sizes[64];
  348.   char*__group_sizes_end = __group_sizes;
  349.   char __current_group_size = 0;
  350.  
  351.   for ( ; __first != __last; ++__first) {
  352.     _CharT __c = *__first;
  353.     bool __tmp = __get_fdigit_or_sep(__c, __sep, __digits);
  354.     if (__tmp) {
  355.       if (__c == ',') {
  356.         *__group_sizes_end++ = __current_group_size;
  357.         __current_group_size = 0;
  358.       }
  359.       else {
  360.         __ok = true;
  361.         __v.push_back((char)__c);
  362.         ++__current_group_size;
  363.       }
  364.     }
  365.     else
  366.       break;
  367.   }
  368.   
  369.   if (__group_sizes_end != __group_sizes)
  370.     *__group_sizes_end++ = __current_group_size;
  371.   __grouping_ok = __valid_grouping(__group_sizes, __group_sizes_end, __grouping.data(), __grouping.data() + __grouping.size());
  372.   return __ok;    
  373. }
  374.  
  375.  
  376. template <class _InputIter, class _CharT>
  377. bool _STLP_CALL
  378. _M_read_float(string& __buf, _InputIter& __in, _InputIter& __end, ios_base& __s, _CharT*)
  379. {
  380.   // Create a string, copying characters of the form 
  381.   // [+-]? [0-9]* .? [0-9]* ([eE] [+-]? [0-9]+)?
  382.  
  383.   bool __digits_before_dot /* = false */;
  384.   bool __digits_after_dot = false;
  385.   bool __ok;
  386.  
  387.   bool   __grouping_ok = true;
  388.  
  389.   const ctype<_CharT>& __ct = *(const ctype<_CharT>*)__s._M_ctype_facet();
  390.   const numpunct<_CharT>& __numpunct = *(const numpunct<_CharT>*)__s._M_numpunct_facet();
  391.   const string& __grouping = __s._M_grouping(); // cached copy
  392.  
  393.   _CharT __dot = __numpunct.decimal_point();
  394.   _CharT __sep = __numpunct.thousands_sep();
  395.  
  396.   _CharT __digits[10];
  397.   _CharT __xplus;
  398.   _CharT __xminus;
  399.  
  400.   _CharT __pow_e;
  401.   _CharT __pow_E;
  402.  
  403.   _Initialize_get_float(__ct, __xplus, __xminus, __pow_e, __pow_E, __digits);
  404.  
  405.   // Get an optional sign
  406.   __in = __copy_sign(__in, __end, __buf, __xplus, __xminus);
  407.  
  408.   // Get an optional string of digits.
  409.   if (__grouping.size() != 0)
  410.     __digits_before_dot = __copy_grouped_digits(__in, __end, __buf, __digits,
  411.                         __sep, __grouping, __grouping_ok);
  412.   else
  413.     __digits_before_dot = __copy_digits(__in, __end, __buf, __digits);
  414.  
  415.   // Get an optional decimal point, and an optional string of digits.
  416.   if (__in != __end && *__in == __dot) {
  417.     __buf.push_back('.');
  418.     ++__in;
  419.     __digits_after_dot = __copy_digits(__in, __end, __buf, __digits);
  420.   }
  421.  
  422.   // There have to be some digits, somewhere.
  423.   __ok = __digits_before_dot || __digits_after_dot;
  424.   
  425.   // Get an optional exponent.
  426.   if (__ok && __in != __end && (*__in == __pow_e || *__in == __pow_E)) {
  427.     __buf.push_back('e');
  428.     ++__in;
  429.     __in = __copy_sign(__in, __end, __buf, __xplus, __xminus);
  430.     __ok = __copy_digits(__in, __end, __buf, __digits);
  431.     // If we have an exponent then the sign 
  432.     // is optional but the digits aren't.
  433.   }
  434.   
  435.   return __ok;
  436. }
  437.  
  438. //
  439. // num_get<>, num_put<>
  440. //
  441.  
  442. # if ( _STLP_STATIC_TEMPLATE_DATA > 0 ) 
  443. template <class _CharT, class _InputIterator>
  444. locale::id num_get<_CharT, _InputIterator>::id;
  445. # else
  446.  
  447. typedef num_get<char, const char*> num_get_char;
  448. typedef num_get<char, istreambuf_iterator<char, char_traits<char> > > num_get_char_2;
  449.  
  450. __DECLARE_INSTANCE(locale::id, num_get_char::id, );
  451. __DECLARE_INSTANCE(locale::id, num_get_char_2::id, );
  452.  
  453. # ifndef _STLP_NO_WCHAR_T
  454.  
  455. typedef num_get<wchar_t, const wchar_t*> num_get_wchar_t;
  456. typedef num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > num_get_wchar_t_2;
  457.  
  458. __DECLARE_INSTANCE(locale::id, num_get_wchar_t::id, );
  459. __DECLARE_INSTANCE(locale::id, num_get_wchar_t_2::id, );
  460.  
  461. # endif
  462.  
  463. # endif /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */
  464.  
  465. # ifndef _STLP_NO_BOOL
  466. template <class _CharT, class _InputIter>
  467. _InputIter
  468. num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end,
  469.                                     ios_base& __s,
  470.                                     ios_base::iostate& __err, bool& __x) const
  471. {
  472.   if (__s.flags() & ios_base::boolalpha) {
  473.     locale __loc = __s.getloc();
  474.     const _Numpunct& __np = *(const _Numpunct*)__s._M_numpunct_facet();
  475.     //    const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc) ;
  476. //    const ctype<_CharT>& __ct =    use_facet<ctype<_CharT> >(__loc) ;
  477.  
  478.     const basic_string<_CharT> __truename  = __np.truename();
  479.     const basic_string<_CharT> __falsename = __np.falsename();
  480.     bool __true_ok  = true;
  481.     bool __false_ok = true;
  482.  
  483.     size_t __n = 0;
  484.     for ( ; __in != __end; ++__in) {
  485.       _CharT __c = *__in;
  486.       __true_ok  = __true_ok  && (__c == __truename[__n]);
  487.       __false_ok = __false_ok && (__c == __falsename[__n]);
  488.       ++__n;
  489.  
  490.       if ((!__true_ok && !__false_ok) ||
  491.           (__true_ok  && __n >= __truename.size()) ||
  492.           (__false_ok && __n >= __falsename.size())) {
  493.     ++__in;
  494.         break;
  495.       }
  496.     }
  497.     if (__true_ok  && __n < __truename.size())  __true_ok  = false;
  498.     if (__false_ok && __n < __falsename.size()) __false_ok = false;
  499.     
  500.     if (__true_ok || __false_ok) {
  501.       __err = ios_base::goodbit;
  502.       __x = __true_ok;
  503.     }
  504.     else
  505.       __err = ios_base::failbit;
  506.  
  507.     if (__in == __end)
  508.       __err |= ios_base::eofbit;
  509.  
  510.     return __in;
  511.   }
  512.  
  513.   else {
  514.     long __lx;
  515.     _InputIter __tmp = this->do_get(__in, __end, __s, __err, __lx);
  516.     if (!(__err & ios_base::failbit)) {
  517.       if (__lx == 0)
  518.         __x = false;
  519.       else if (__lx == 1)
  520.         __x = true;
  521.       else
  522.         __err |= ios_base::failbit;
  523.     }
  524.     return __tmp;
  525.   }
  526. }
  527.  
  528. # endif /* _STLP_NO_BOOL */
  529.  
  530. # ifdef _STLP_FIX_LIBRARY_ISSUES
  531. template <class _CharT, class _InputIter>  
  532. _InputIter 
  533. num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  534.                                     ios_base::iostate& __err, short& __val) const {
  535.   return _M_do_get_integer(__in, __end, __str, __err, __val, (_CharT*)0 );
  536. }
  537.  
  538. template <class _CharT, class _InputIter>  
  539. _InputIter 
  540. num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  541.                                     ios_base::iostate& __err, int& __val) const {
  542.   return _M_do_get_integer(__in, __end, __str, __err, __val, (_CharT*)0 );
  543. }
  544.  
  545. # endif
  546.  
  547. template <class _CharT, class _InputIter>  
  548. _InputIter 
  549. num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  550.                                     ios_base::iostate& __err, long& __val) const {
  551.   return _M_do_get_integer(__in, __end, __str, __err, __val, (_CharT*)0 );
  552. }
  553.  
  554. template <class _CharT, class _InputIter>  
  555. _InputIter 
  556. num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  557.                                     ios_base::iostate& __err,
  558.                                     unsigned short& __val) const {
  559.   return _M_do_get_integer(__in, __end, __str, __err, __val, (_CharT*)0 );
  560. }
  561.  
  562. template <class _CharT, class _InputIter>  
  563. _InputIter 
  564. num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  565.                                     ios_base::iostate& __err, 
  566.                                     unsigned int& __val) const {
  567.   return _M_do_get_integer(__in, __end, __str, __err, __val, (_CharT*)0 );
  568. }
  569.  
  570. template <class _CharT, class _InputIter>  
  571. _InputIter 
  572. num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  573.                                     ios_base::iostate& __err,
  574.                                     unsigned long& __val) const {
  575.   return _M_do_get_integer(__in, __end, __str, __err, __val, (_CharT*)0 );
  576. }
  577.  
  578.  
  579. template <class _CharT, class _InputIter>  
  580. _InputIter 
  581. num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  582.                                     ios_base::iostate& __err,
  583.                                     float& __val) const {
  584.   string __buf ;
  585.   bool __ok = _M_read_float(__buf, __in, __end, __str, (_CharT*)0 );
  586.   __string_to_float(__buf, __val);  
  587.   __err = __STATIC_CAST(ios_base::iostate, __ok ? ios_base::goodbit : ios_base::failbit);
  588.   if (__in == __end)
  589.     __err |= ios_base::eofbit;
  590.   return __in;
  591. }
  592.  
  593. template <class _CharT, class _InputIter>  
  594. _InputIter 
  595. num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  596.                                     ios_base::iostate& __err, 
  597.                                     double& __val) const {
  598.   string __buf ;
  599.   bool __ok = _M_read_float(__buf, __in, __end, __str, (_CharT*)0 );
  600.   __string_to_float(__buf, __val);
  601.   __err = __STATIC_CAST(ios_base::iostate, __ok ? ios_base::goodbit : ios_base::failbit);
  602.   if (__in == __end)
  603.     __err |= ios_base::eofbit;
  604.   return __in;
  605. }
  606.  
  607. #ifndef _STLP_NO_LONG_DOUBLE
  608. template <class _CharT, class _InputIter>  
  609. _InputIter 
  610. num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  611.                     ios_base::iostate& __err,
  612.                                     long double& __val) const {
  613.   string __buf ;
  614.   bool __ok = _M_read_float(__buf, __in, __end, __str, (_CharT*)0 );
  615.   __string_to_float(__buf, __val);
  616.   __err = __STATIC_CAST(ios_base::iostate, __ok ? ios_base::goodbit : ios_base::failbit);
  617.   if (__in == __end)
  618.     __err |= ios_base::eofbit;
  619.   return __in;
  620. }
  621. #endif /* _STLP_LONG_DOUBLE */
  622.  
  623. template <class _CharT, class _InputIter>  
  624. _InputIter 
  625. num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  626.                            ios_base::iostate& __err,
  627.                            void*& __p) const {
  628. # if defined(_STLP_LONG_LONG)&&!defined(__MRC__)        //*ty 12/07/2001 - MrCpp can not cast from long long to void*
  629.   unsigned _STLP_LONG_LONG __val;
  630. # else
  631.   unsigned long __val;
  632. # endif
  633.     iter_type __tmp = _M_do_get_integer(__in, __end, __str, __err, __val, (_CharT*)0 );
  634.     if (!(__err & ios_base::failbit))
  635.       __p = __REINTERPRET_CAST(void*,__val);
  636.     return __tmp;
  637.   }
  638.  
  639.  
  640. #ifdef _STLP_LONG_LONG
  641.  
  642. template <class _CharT, class _InputIter>  
  643. _InputIter 
  644. num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  645.                                     ios_base::iostate& __err,
  646.                                     _STLP_LONG_LONG& __val) const {
  647.   return _M_do_get_integer(__in, __end, __str, __err, __val, (_CharT*)0 );
  648. }
  649.  
  650. template <class _CharT, class _InputIter>  
  651. _InputIter 
  652. num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end, ios_base& __str,
  653.                                     ios_base::iostate& __err,
  654.                                     unsigned _STLP_LONG_LONG& __val) const {
  655.   return _M_do_get_integer(__in, __end, __str, __err, __val, (_CharT*)0 );
  656. }
  657.  
  658. #endif /* _STLP_LONG_LONG */
  659.  
  660. _STLP_END_NAMESPACE
  661.  
  662. # endif /* _STLP_EXPOSE_STREAM_IMPLEMENTATION */
  663.  
  664. #endif /* _STLP_NUMERIC_FACETS_C */
  665.  
  666. // Local Variables:
  667. // mode:C++
  668. // End:
  669.