epoc32/include/stdapis/stlport/stl/_num_get.c
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
     1.1 --- a/epoc32/include/stdapis/stlport/stl/_num_get.c	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/stdapis/stlport/stl/_num_get.c	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,882 @@
     1.4 -_num_get.c
     1.5 +/*
     1.6 + * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
     1.7 + * Copyright (c) 1999
     1.8 + * Silicon Graphics Computer Systems, Inc.
     1.9 + *
    1.10 + * Copyright (c) 1999
    1.11 + * Boris Fomitchev
    1.12 + *
    1.13 + * This material is provided "as is", with absolutely no warranty expressed
    1.14 + * or implied. Any use is at your own risk.
    1.15 + *
    1.16 + * Permission to use or copy this software for any purpose is hereby granted
    1.17 + * without fee, provided the above notices are retained on all copies.
    1.18 + * Permission to modify the code and to distribute modified code is granted,
    1.19 + * provided the above notices are retained, and a notice that the code was
    1.20 + * modified is included with the above copyright notice.
    1.21 + *
    1.22 + */
    1.23 +#ifndef _STLP_NUM_GET_C
    1.24 +#define _STLP_NUM_GET_C
    1.25 +
    1.26 +#ifndef _STLP_INTERNAL_NUM_GET_H
    1.27 +# include <stl/_num_get.h>
    1.28 +#endif
    1.29 +
    1.30 +# if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
    1.31 +
    1.32 +#ifndef _STLP_LIMITS_H
    1.33 +# include <stl/_limits.h>
    1.34 +#endif
    1.35 +
    1.36 +_STLP_DECLSPEC  unsigned char*  __get_digit_val_table(void);
    1.37 +_STLP_DECLSPEC  char*  __get_narrow_atoms(void);
    1.38 +_STLP_BEGIN_NAMESPACE
    1.39 +
    1.40 +extern const unsigned char __digit_val_table[];
    1.41 +
    1.42 +template < class _InputIter, class _Integer, class _CharT>
    1.43 +_InputIter _STLP_CALL
    1.44 +_M_do_get_integer(_InputIter&, _InputIter&, ios_base&, ios_base::iostate&, _Integer&, _CharT*);
    1.45 +
    1.46 +// _M_do_get_integer and its helper functions.
    1.47 +
    1.48 +#ifdef	__SYMBIAN32__
    1.49 +template<class _CharT>
    1.50 +inline bool _STLP_CALL __get_fdigit(_CharT& c, const _CharT* digits)
    1.51 +  { 
    1.52 +
    1.53 +  const _CharT* p = find(digits, digits + 10, c);
    1.54 +  if (p != digits + 10) {
    1.55 +    c = (_CharT)( (_CharT)'0' + (p - digits));
    1.56 +    return true;
    1.57 +  }
    1.58 +  else
    1.59 +    return false;
    1.60 +}
    1.61 +
    1.62 +#endif
    1.63 +inline bool _STLP_CALL __get_fdigit(char& __c, const char*)
    1.64 +  { return __c >= '0' && __c <= '9'; }
    1.65 +
    1.66 +inline bool _STLP_CALL __get_fdigit_or_sep(char& __c, char __sep, const char *)
    1.67 +{
    1.68 +  if (__c == __sep) {
    1.69 +    __c = ',' ;
    1.70 +    return true ;
    1.71 +  } else
    1.72 +    return  ( __c >= '0' && __c <= '9');
    1.73 +}
    1.74 +
    1.75 +# ifndef _STLP_NO_WCHAR_T
    1.76 +
    1.77 +// Similar, except return the character itself instead of the numeric
    1.78 +// value.  Used for floating-point input.
    1.79 +inline bool  _STLP_CALL __get_fdigit(wchar_t& c, const wchar_t* digits)
    1.80 +{
    1.81 +  const wchar_t* p = find(digits, digits + 10, c);
    1.82 +  if (p != digits + 10) {
    1.83 +    c = (char)('0' + (p - digits));
    1.84 +    return true;
    1.85 +  }
    1.86 +  else
    1.87 +    return false;
    1.88 +}
    1.89 +
    1.90 +inline bool  _STLP_CALL __get_fdigit_or_sep(wchar_t& c, wchar_t sep,
    1.91 +                                     const wchar_t * digits)
    1.92 +{
    1.93 +  if (c == sep) {
    1.94 +    c = (char)',';
    1.95 +    return true;
    1.96 +  }
    1.97 +  else
    1.98 +    return __get_fdigit(c, digits);
    1.99 +}
   1.100 +#ifdef __SYMBIAN32__
   1.101 +template <class _CharT>
   1.102 +inline bool  _STLP_CALL __get_fdigit_or_sep(_CharT& c, _CharT sep,
   1.103 +                                     const _CharT * digits)
   1.104 +{
   1.105 +  if (c == sep) {
   1.106 +    c = (_CharT)',';
   1.107 +    return true;
   1.108 +  }
   1.109 +  else
   1.110 +    return __get_fdigit(c, digits);
   1.111 +}
   1.112 +
   1.113 +
   1.114 +
   1.115 +#endif
   1.116 +#endif
   1.117 +inline int _STLP_CALL
   1.118 +__get_digit_from_table(unsigned __index)
   1.119 +{
   1.120 +  return (__index > 127 ? 0xFF : __get_digit_val_table()[__index]);
   1.121 +}
   1.122 +
   1.123 +extern const char __narrow_atoms[];
   1.124 +
   1.125 +template <class _InputIter, class _CharT>
   1.126 +int
   1.127 +_M_get_base_or_zero(_InputIter& __stl_in, _InputIter& __end, ios_base& __str, _CharT*)
   1.128 +{
   1.129 +  _CharT __atoms[5];
   1.130 +  const ctype<_CharT>& __c_type = use_facet< ctype<_CharT> >(__str.getloc());
   1.131 +  // const ctype<_CharT>& __c_type = *(const ctype<_CharT>*)__str._M_ctype_facet();
   1.132 +
   1.133 +  __c_type.widen(__get_narrow_atoms(), __get_narrow_atoms() + 5, __atoms);
   1.134 +
   1.135 +  bool __negative = false;
   1.136 +  _CharT __c = *__stl_in;
   1.137 +
   1.138 +  if (__c == __atoms[1] /* __xminus_char */ ) {
   1.139 +    __negative = true;
   1.140 +    ++__stl_in;
   1.141 +  }
   1.142 +  else if (__c == __atoms[0] /* __xplus_char */ )
   1.143 +    ++__stl_in;
   1.144 +
   1.145 +
   1.146 +  int __base;
   1.147 +  int __valid_zero = 0;
   1.148 +
   1.149 +  ios_base::fmtflags __basefield = __str.flags() & ios_base::basefield;
   1.150 +
   1.151 +  switch (__basefield) {
   1.152 +  case ios_base::oct:
   1.153 +    __base = 8;
   1.154 +    break;
   1.155 +  case ios_base::dec:
   1.156 +    __base = 10;
   1.157 +    break;
   1.158 +  case ios_base::hex:
   1.159 +    __base = 16;
   1.160 +    if (__stl_in != __end && *__stl_in == __atoms[2] /* __zero_char */ ) {
   1.161 +      ++__stl_in;
   1.162 +      if (__stl_in != __end &&
   1.163 +          (*__stl_in == __atoms[3] /* __x_char */ || *__stl_in == __atoms[4] /* __X_char */ ))
   1.164 +        ++__stl_in;
   1.165 +      else
   1.166 +        __valid_zero = 1; // That zero is valid by itself.
   1.167 +    }
   1.168 +    break;
   1.169 +  default:
   1.170 +    if (__stl_in != __end && *__stl_in == __atoms[2] /* __zero_char */ ) {
   1.171 +      ++__stl_in;
   1.172 +      if (__stl_in != __end &&
   1.173 +          (*__stl_in == __atoms[3] /* __x_char */ || *__stl_in == __atoms[4] /* __X_char */ )) {
   1.174 +        ++__stl_in;
   1.175 +        __base = 16;
   1.176 +      }
   1.177 +      else
   1.178 +        {
   1.179 +          __base = 8;
   1.180 +          __valid_zero = 1; // That zero is still valid by itself.
   1.181 +        }
   1.182 +    }
   1.183 +    else
   1.184 +      __base = 10;
   1.185 +    break;
   1.186 +  }
   1.187 +  return (__base << 2) | ((int)__negative << 1) | __valid_zero;
   1.188 +}
   1.189 +
   1.190 +
   1.191 +template <class _InputIter, class _Integer>
   1.192 +bool _STLP_CALL
   1.193 +__get_integer(_InputIter& __first, _InputIter& __last,
   1.194 +	      int __base, _Integer& __val,
   1.195 +	      int __got, bool __is_negative, char __separator, const string& __grouping, const __true_type&)
   1.196 +{
   1.197 +  bool __ovflow = false;
   1.198 +  bool __valid_group = true;
   1.199 +
   1.200 +  _Integer __result = 0;
   1.201 +  bool __is_group = !__grouping.empty();
   1.202 +//  char __group_sizes[64];
   1.203 +  char __group_sizes[256] = {0}; //group sizes can be more
   1.204 +#ifdef	__SYMBIAN32__
   1.205 +int __current_group_size = __got;
   1.206 +#else
   1.207 +  int __current_group_size = 0;
   1.208 +#endif
   1.209 +  char* __group_sizes_end = __group_sizes;
   1.210 +   int prv_got = 0;
   1.211 +   
   1.212 +   
   1.213 +  _Integer __over_base = (numeric_limits<_Integer>::min)() / __STATIC_CAST(_Integer, __base);
   1.214 +
   1.215 +   for ( ; __first != __last ; ++__first) {
   1.216 +
   1.217 +     const char __c = *__first;
   1.218 +
   1.219 +     if (__is_group && __c == __separator) {
   1.220 +	 if (prv_got == __got) //no successive seperators
   1.221 +	 	return false;
   1.222 +	 prv_got = __got;
   1.223 +       *__group_sizes_end++ = __current_group_size;       
   1.224 +       __current_group_size = 0;
   1.225 +       continue;
   1.226 +     }
   1.227 +
   1.228 +     int __n = __get_digit_from_table(__c);
   1.229 +
   1.230 +     if (__n >= __base)
   1.231 +	 	break;
   1.232 +
   1.233 +     ++__got;
   1.234 +     ++__current_group_size;
   1.235 +
   1.236 +     if (__result < __over_base)
   1.237 +       __ovflow = true;  // don't need to keep accumulating
   1.238 +     else {
   1.239 +       _Integer __next = __STATIC_CAST(_Integer, __base * __result - __n);
   1.240 +       if (__result != 0)
   1.241 +#ifdef	__SYMBIAN32__
   1.242 +	if (__is_negative)
   1.243 +		__ovflow = __ovflow || __next >= __result;
   1.244 +	else
   1.245 +		__ovflow = __ovflow || (__next-1) >= __result; //For signed char, the ranges are -128 to 127, 
   1.246 +#else
   1.247 +	 __ovflow = __ovflow || __next >= __result;
   1.248 +#endif
   1.249 +       __result = __next;
   1.250 +     }
   1.251 +   }
   1.252 +
   1.253 +   if (__is_group && __group_sizes_end != __group_sizes) {
   1.254 +     *__group_sizes_end++ = __current_group_size;
   1.255 +     
   1.256 +   }
   1.257 +
   1.258 +   // fbp : added to not modify value if nothing was read
   1.259 +   if (__got > 0) {
   1.260 +       __val = __ovflow
   1.261 +	 ? __is_negative ? (numeric_limits<_Integer>::min)()
   1.262 +	 : (numeric_limits<_Integer>::max)()
   1.263 +	 : (__is_negative ? __result : __STATIC_CAST(_Integer, -__result));
   1.264 +   }
   1.265 +   __valid_group = __valid_grouping(__group_sizes, __group_sizes_end,
   1.266 +									    __grouping.data(), __grouping.data()+ __grouping.size());
   1.267 +
   1.268 +	if (__valid_group == false)
   1.269 +	__val = 0;
   1.270 +
   1.271 +  // overflow is being treated as failure
   1.272 +  return ((__got > 0) && !__ovflow) && (__is_group == 0 || __valid_group) ;
   1.273 +}
   1.274 +
   1.275 +template <class _InputIter, class _Integer>
   1.276 +bool _STLP_CALL
   1.277 +__get_integer(_InputIter& __first, _InputIter& __last,
   1.278 +	      int __base, _Integer& __val,
   1.279 +	      int __got, bool __is_negative, char __separator, const string& __grouping, const __false_type&)
   1.280 +{
   1.281 +  bool __ovflow = false;
   1.282 +  bool __valid_group = true;
   1.283 +  _Integer __result = 0;
   1.284 +  bool __is_group = !__grouping.empty();
   1.285 +//  char __group_sizes[64];
   1.286 +  char __group_sizes[256] = {0};//group sizes can be more
   1.287 +  int __current_group_size = 0;
   1.288 +  char* __group_sizes_end = __group_sizes;
   1.289 +     int prv_got = 0;
   1.290 +
   1.291 + 
   1.292 +  _Integer  __over_base = (numeric_limits<_Integer>::max)() / __STATIC_CAST(_Integer, __base);
   1.293 +
   1.294 +  for ( ; __first != __last ; ++__first) {
   1.295 +
   1.296 +    const char __c = *__first;
   1.297 +/*
   1.298 +    //if (__is_group && __c == __separator) { //no seperator at the start of number.
   1.299 +    if (__is_group && __c == __separator && __got) {
   1.300 +      // seperator should come after extracting some digits
   1.301 +      	if (!__current_group_size)
   1.302 +      		break;
   1.303 +     *__group_sizes_end++ = __current_group_size;    
   1.304 +      __current_group_size = 0;
   1.305 +      continue;
   1.306 +    }
   1.307 +*/
   1.308 +	if (__is_group && __c == __separator) {
   1.309 +	 if (prv_got == __got) //no successive seperators
   1.310 +	 	return false;
   1.311 +	 	prv_got = __got;
   1.312 +       *__group_sizes_end++ = __current_group_size;       
   1.313 +       __current_group_size = 0;
   1.314 +       continue;
   1.315 +     }
   1.316 +    int __n = __get_digit_from_table(__c);
   1.317 +
   1.318 +    if (__n >= __base)
   1.319 +    	break;
   1.320 +
   1.321 +    ++__got;
   1.322 +    ++__current_group_size;
   1.323 +
   1.324 +    if (__result > __over_base)
   1.325 +      __ovflow = true;  //don't need to keep accumulating
   1.326 +    else {
   1.327 +      _Integer __next = __STATIC_CAST(_Integer, __base * __result + __n);
   1.328 +	if (__result != 0)
   1.329 +	  __ovflow = __ovflow || __next <= __result;
   1.330 +	__result = __next;
   1.331 +      }
   1.332 +  }
   1.333 +
   1.334 +  if (__is_group && __group_sizes_end != __group_sizes) {
   1.335 +      *__group_sizes_end++ = __current_group_size;     
   1.336 +  }
   1.337 +
   1.338 +  // fbp : added to not modify value if nothing was read
   1.339 +  if (__got > 0) {
   1.340 +      __val = __ovflow
   1.341 +	? (numeric_limits<_Integer>::max)()
   1.342 +	: (__is_negative ? __STATIC_CAST(_Integer, -__result) : __result);
   1.343 +  }
   1.344 +  __valid_group =  __valid_grouping(__group_sizes, __group_sizes_end,
   1.345 +					 __grouping.data(), __grouping.data()+ __grouping.size());
   1.346 +
   1.347 +	if (__valid_group == false)
   1.348 +	__val = 0;
   1.349 +
   1.350 +  // overflow is being treated as failure
   1.351 +  return ((__got > 0) && !__ovflow) &&
   1.352 +    (__is_group == 0 ||__valid_group) ;
   1.353 +}
   1.354 +
   1.355 +
   1.356 +template <class _InputIter, class _Integer>
   1.357 +bool _STLP_CALL
   1.358 +__get_decimal_integer(_InputIter& __first, _InputIter& __last, _Integer& __val)
   1.359 +{
   1.360 +  string __grp;
   1.361 +  return __get_integer(__first, __last, 10, __val, 0, false, ' ', __grp, __false_type());
   1.362 +}
   1.363 +
   1.364 +template <class _InputIter, class _Integer, class _CharT>
   1.365 +_InputIter _STLP_CALL
   1.366 +_M_do_get_integer(_InputIter& __stl_in, _InputIter& __end, ios_base& __str,
   1.367 +                  ios_base::iostate& __err, _Integer& __val, _CharT* __pc)
   1.368 +{
   1.369 +
   1.370 +#if defined(__HP_aCC) && (__HP_aCC == 1)
   1.371 +  bool _IsSigned = !((_Integer)(-1) > 0);
   1.372 +#else
   1.373 +  typedef typename __bool2type<numeric_limits<_Integer>::is_signed>::_Ret _IsSigned;
   1.374 +#endif
   1.375 +
   1.376 +  //const numpunct<_CharT>& __numpunct = *(const numpunct<_CharT>*)__str._M_numpunct_facet();
   1.377 +  const numpunct<_CharT>& __numpunct = use_facet< numpunct<_CharT> >(__str.getloc());
   1.378 +//  const string& __grouping = __str._M_grouping(); // cached copy //stdcxx fix - 11/1/06
   1.379 +  const string& __grouping = __numpunct.grouping();
   1.380 +
   1.381 +
   1.382 +  const int __base_or_zero = _M_get_base_or_zero(__stl_in, __end, __str, __pc);
   1.383 +  int  __got = __base_or_zero & 1;
   1.384 +
   1.385 +  bool __result;
   1.386 +
   1.387 +  if (__stl_in == __end) {      // We may have already read a 0.  If so,
   1.388 +
   1.389 +    if (__got > 0) {       // the result is 0 even if we're at eof.
   1.390 +      __val = 0;
   1.391 +      __result = true;
   1.392 +    }
   1.393 +    else
   1.394 +      __result = false;
   1.395 +  } else {
   1.396 +
   1.397 +    const bool __negative = __base_or_zero & 2;
   1.398 +    const int __base = __base_or_zero >> 2;
   1.399 +
   1.400 +#if defined(__HP_aCC) && (__HP_aCC == 1)
   1.401 +     if (_IsSigned)
   1.402 +       __result = __get_integer(__stl_in, __end, __base,  __val, __got, __negative, __numpunct.thousands_sep(), __grouping, __true_type() );
   1.403 +     else
   1.404 +      __result = __get_integer(__stl_in, __end, __base,  __val, __got, __negative, __numpunct.thousands_sep(), __grouping, __false_type() );
   1.405 +#else
   1.406 +#ifdef __SYMBIAN32__
   1.407 +    _Integer __tval;
   1.408 +    __result = __get_integer(__stl_in, __end, __base,  __tval, __got, __negative, __numpunct.thousands_sep(), __grouping, _IsSigned());
   1.409 +    if(__result)
   1.410 +        __val = __tval;
   1.411 +#else
   1.412 +    __result = __get_integer(__stl_in, __end, __base,  __val, __got, __negative, __numpunct.thousands_sep(), __grouping, _IsSigned());
   1.413 +#endif    
   1.414 +# endif
   1.415 +  }
   1.416 +
   1.417 +  __err = __STATIC_CAST(ios_base::iostate, __result ? ios_base::goodbit : ios_base::failbit);
   1.418 +
   1.419 +  if (__stl_in == __end)
   1.420 +    __err |= ios_base::eofbit;
   1.421 +  return __stl_in;
   1.422 +}
   1.423 +
   1.424 +// _M_read_float and its helper functions.
   1.425 +template <class _InputIter, class _CharT>
   1.426 +_InputIter  _STLP_CALL
   1.427 +__copy_sign(_InputIter __first, _InputIter __last, string& __v,
   1.428 +            _CharT __xplus, _CharT __xminus) {
   1.429 +    if (__first != __last) {
   1.430 +    _CharT __c = *__first;
   1.431 +    if (__c == __xplus)
   1.432 +      ++__first;
   1.433 +    else if (__c == __xminus) {
   1.434 +      __v.push_back('-');
   1.435 +      ++__first;
   1.436 +    }
   1.437 +  }
   1.438 +  return __first;
   1.439 +}
   1.440 +
   1.441 +
   1.442 +template <class _InputIter, class _CharT>
   1.443 +bool _STLP_CALL
   1.444 +__copy_digits(_InputIter& __first, _InputIter& __last,
   1.445 +              string& __v, const _CharT* __digits)
   1.446 +{
   1.447 +  bool __ok = false;
   1.448 +
   1.449 +  for ( ; __first != __last; ++__first) {
   1.450 +    _CharT __c = *__first;
   1.451 +    if (__get_fdigit(__c, __digits)) {
   1.452 +      __v.push_back((char)__c);
   1.453 +      __ok = true;
   1.454 +    }
   1.455 +    else
   1.456 +      break;
   1.457 +  }
   1.458 +  return __ok;
   1.459 +}
   1.460 +
   1.461 +template <class _InputIter, class _CharT>
   1.462 +bool _STLP_CALL
   1.463 +__copy_grouped_digits(_InputIter& __first, _InputIter& __last,
   1.464 +		      string& __v, const _CharT * __digits,
   1.465 +		      _CharT __sep, const string& __grouping,
   1.466 +		      bool& __grouping_ok)
   1.467 +{
   1.468 +  bool __ok = false;
   1.469 +//  char __group_sizes[64];
   1.470 +  char __group_sizes[256] = {0};//group sizes can be more
   1.471 +  char*__group_sizes_end = __group_sizes;
   1.472 +  char __current_group_size = 0;
   1.473 +
   1.474 +  for ( ; __first != __last; ++__first) {
   1.475 +    _CharT __c = *__first;
   1.476 +    bool __tmp = __get_fdigit_or_sep(__c, __sep, __digits);
   1.477 +    if (__tmp) {
   1.478 +      if (__c == ',') { 
   1.479 +      	// seperator should come after extracting some digits
   1.480 +      	if (!__current_group_size)
   1.481 +      		break;
   1.482 +      	
   1.483 +        *__group_sizes_end++ = __current_group_size;        
   1.484 +        __current_group_size = 0;
   1.485 +      }
   1.486 +      else {
   1.487 +        __ok = true;
   1.488 +        __v.push_back((char)__c);
   1.489 +        ++__current_group_size;
   1.490 +      }
   1.491 +    }
   1.492 +    else
   1.493 +      break;
   1.494 +  }
   1.495 +
   1.496 +  if (__group_sizes_end != __group_sizes)
   1.497 +    *__group_sizes_end++ = __current_group_size;    
   1.498 +  __grouping_ok = __valid_grouping(__group_sizes, __group_sizes_end, __grouping.data(), __grouping.data() + __grouping.size());
   1.499 +  __ok = __ok & __grouping_ok; //Added, to check for valid grouping. If not valid grouping should return false.
   1.500 +  return __ok;
   1.501 +}
   1.502 +
   1.503 +
   1.504 +template <class _InputIter, class _CharT>
   1.505 +bool _STLP_CALL
   1.506 +_M_read_float(string& __buf, _InputIter& __stl_in, _InputIter& __end, ios_base& __s, _CharT*)
   1.507 +{
   1.508 +  // Create a string, copying characters of the form
   1.509 +  // [+-]? [0-9]* .? [0-9]* ([eE] [+-]? [0-9]+)?
   1.510 +
   1.511 +  bool __digits_before_dot /* = false */;
   1.512 +  bool __digits_after_dot = false;
   1.513 +  bool __ok;
   1.514 +
   1.515 +  bool   __grouping_ok = true;
   1.516 +
   1.517 +  const ctype<_CharT>& __ct = use_facet< ctype<_CharT> >(__s.getloc());
   1.518 +  // const ctype<_CharT>& __ct = *(const ctype<_CharT>*)__s._M_ctype_facet();
   1.519 +  //const numpunct<_CharT>& __numpunct = *(const numpunct<_CharT>*)__s._M_numpunct_facet();
   1.520 +  const numpunct<_CharT>& __numpunct = use_facet< numpunct<_CharT> >(__s.getloc());
   1.521 +//  const string& __grouping = __s._M_grouping(); // cached copy //stdcxx fix - 11/1/06
   1.522 +    const string& __grouping = __numpunct.grouping();
   1.523 +
   1.524 +  _CharT __dot = __numpunct.decimal_point();
   1.525 +  _CharT __sep = __numpunct.thousands_sep();
   1.526 +
   1.527 +  _CharT __digits[10];
   1.528 +  _CharT __xplus;
   1.529 +  _CharT __xminus;
   1.530 +
   1.531 +  _CharT __pow_e;
   1.532 +  _CharT __pow_E;
   1.533 +
   1.534 +  _Initialize_get_float(__ct, __xplus, __xminus, __pow_e, __pow_E, __digits);
   1.535 +
   1.536 +  // Get an optional sign
   1.537 +  __stl_in = __copy_sign(__stl_in, __end, __buf, __xplus, __xminus);
   1.538 +
   1.539 +  // Get an optional string of digits.
   1.540 +  if (__grouping.size() != 0)
   1.541 +    __digits_before_dot = __copy_grouped_digits(__stl_in, __end, __buf, __digits,
   1.542 +						__sep, __grouping, __grouping_ok);
   1.543 +  else
   1.544 +    __digits_before_dot = __copy_digits(__stl_in, __end, __buf, __digits);
   1.545 +
   1.546 +  // Get an optional decimal point, and an optional string of digits.
   1.547 +  if (__stl_in != __end && *__stl_in == __dot) {
   1.548 +    __buf.push_back('.');
   1.549 +    ++__stl_in;
   1.550 +    __digits_after_dot = __copy_digits(__stl_in, __end, __buf, __digits);
   1.551 +  }
   1.552 +
   1.553 +  // There have to be some digits, somewhere.
   1.554 +  __ok = __digits_before_dot || __digits_after_dot;
   1.555 +
   1.556 +  // Get an optional exponent.
   1.557 +  if (__ok && __stl_in != __end && (*__stl_in == __pow_e || *__stl_in == __pow_E)) {
   1.558 +    __buf.push_back('e');
   1.559 +    ++__stl_in;
   1.560 +    __stl_in = __copy_sign(__stl_in, __end, __buf, __xplus, __xminus);
   1.561 +    __ok = __copy_digits(__stl_in, __end, __buf, __digits);
   1.562 +    // If we have an exponent then the sign
   1.563 +    // is optional but the digits aren't.
   1.564 +  }
   1.565 +
   1.566 +  return __ok;
   1.567 +}
   1.568 +
   1.569 +//
   1.570 +// num_get<>, num_put<>
   1.571 +//
   1.572 +
   1.573 +# if ( _STLP_STATIC_TEMPLATE_DATA > 0 )
   1.574 +# if !defined(__LIBSTD_CPP_SYMBIAN32_WSD__) && !defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
   1.575 +template <class _CharT, class _InputIterator>
   1.576 +locale::id num_get<_CharT, _InputIterator>::id;
   1.577 +#endif
   1.578 +# else
   1.579 +
   1.580 +typedef num_get<char, const char*> num_get_char;
   1.581 +typedef num_get<char, istreambuf_iterator<char, char_traits<char> > > num_get_char_2;
   1.582 +
   1.583 +#ifndef __SYMBIAN32__
   1.584 +__DECLARE_INSTANCE(locale::id, num_get_char::id, );
   1.585 +__DECLARE_INSTANCE(locale::id, num_get_char_2::id, );
   1.586 +#endif
   1.587 +
   1.588 +# ifndef _STLP_NO_WCHAR_T
   1.589 +
   1.590 +typedef num_get<wchar_t, const wchar_t*> num_get_wchar_t;
   1.591 +typedef num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > num_get_wchar_t_2;
   1.592 +
   1.593 +#ifndef __SYMBIAN32__
   1.594 +__DECLARE_INSTANCE(locale::id, num_get_wchar_t::id, );
   1.595 +__DECLARE_INSTANCE(locale::id, num_get_wchar_t_2::id, );
   1.596 +#endif
   1.597 +
   1.598 +# endif
   1.599 +
   1.600 +# endif /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */
   1.601 +
   1.602 +# ifndef _STLP_NO_BOOL
   1.603 +template <class _CharT, class _InputIter>
   1.604 +_InputIter
   1.605 +num_get<_CharT, _InputIter>::do_get(_InputIter __stl_in, _InputIter __end,
   1.606 +                                    ios_base& __s,
   1.607 +                                    ios_base::iostate& __err, bool& __x) const
   1.608 +{
   1.609 +  if (__s.flags() & ios_base::boolalpha) {
   1.610 +    locale __loc = __s.getloc();
   1.611 +    //const _Numpunct& __np = *(const _Numpunct*)__s._M_numpunct_facet();
   1.612 +        const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc) ;
   1.613 +//    const ctype<_CharT>& __ct =    use_facet<ctype<_CharT> >(__loc) ;
   1.614 +
   1.615 +    const basic_string<_CharT> __truename  = __np.truename();
   1.616 +    const basic_string<_CharT> __falsename = __np.falsename();
   1.617 +    bool __true_ok  = true;
   1.618 +    bool __false_ok = true;
   1.619 +
   1.620 +    size_t __n = 0;
   1.621 +    for ( ; __stl_in != __end; ++__stl_in) {
   1.622 +      _CharT __c = *__stl_in;
   1.623 +      __true_ok  = __true_ok  && (__c == __truename[__n]);
   1.624 +      __false_ok = __false_ok && (__c == __falsename[__n]);
   1.625 +      ++__n;
   1.626 +
   1.627 +      if ((!__true_ok && !__false_ok) ||
   1.628 +          (__true_ok  && __n >= __truename.size()) ||
   1.629 +          (__false_ok && __n >= __falsename.size())) {
   1.630 +          
   1.631 +          if (__true_ok || __false_ok)  //if anything OK then increment, else, break
   1.632 +		++__stl_in;
   1.633 +        break;
   1.634 +      }
   1.635 +    }
   1.636 +	// stdcxx fix, Changed to check for complete true,false string
   1.637 +    if (__true_ok  && __n < __truename.size()) 
   1.638 +   {
   1.639 +	for ( ; __stl_in != __end; ++__stl_in) {
   1.640 +      		_CharT __c = *__stl_in;
   1.641 +      		__true_ok  = __true_ok  && (__c == __truename[__n]);
   1.642 +		++__n;  
   1.643 +		 if ((!__true_ok) ||(__true_ok  && __n >= __truename.size()) )
   1.644 +		 {
   1.645 +		 	if(__true_ok)
   1.646 +		 		++__stl_in;
   1.647 +          		break;
   1.648 +		 }
   1.649 +		 	
   1.650 +	}
   1.651 +	 if (__true_ok  && __n < __truename.size()) 
   1.652 +	   	__true_ok  = false;
   1.653 +    }
   1.654 +    if (__false_ok && __n < __falsename.size())
   1.655 +   {
   1.656 +
   1.657 +   		for ( ; __stl_in != __end; ++__stl_in) {
   1.658 +      		_CharT __c = *__stl_in;
   1.659 +      		__false_ok  = __false_ok  && (__c == __falsename[__n]);
   1.660 +		++__n;  
   1.661 +		 if ((!__false_ok) ||(__false_ok  && __n >= __falsename.size()) )         
   1.662 +          	{
   1.663 +			if(__false_ok)
   1.664 +				++__stl_in;
   1.665 +          		break;
   1.666 +		 }
   1.667 +		 	
   1.668 +		}
   1.669 +		if (__false_ok && __n < __falsename.size())
   1.670 +   			__false_ok = false;
   1.671 +    }
   1.672 +
   1.673 +    if (__true_ok || __false_ok) {
   1.674 +      __err = ios_base::goodbit;
   1.675 +      __x = __true_ok;
   1.676 +    }
   1.677 +    else
   1.678 +      __err = ios_base::failbit;
   1.679 +
   1.680 +    if (__stl_in == __end)
   1.681 +      __err |= ios_base::eofbit;
   1.682 +
   1.683 +    return __stl_in;
   1.684 +  }
   1.685 +
   1.686 +  else {
   1.687 +    long __lx;
   1.688 +    _InputIter __tmp = this->do_get(__stl_in, __end, __s, __err, __lx);
   1.689 +    if (!(__err & ios_base::failbit)) {
   1.690 +      if (__lx == 0)
   1.691 +        __x = false;
   1.692 +      else if (__lx == 1)
   1.693 +        __x = true;
   1.694 +      else
   1.695 +        __err |= ios_base::failbit;
   1.696 +    }
   1.697 +    return __tmp;
   1.698 +  }
   1.699 +}
   1.700 +
   1.701 +# endif /* _STLP_NO_BOOL */
   1.702 +
   1.703 +//# ifdef _STLP_FIX_LIBRARY_ISSUES
   1.704 +template <class _CharT, class _InputIter>
   1.705 +_InputIter
   1.706 +num_get<_CharT, _InputIter>::do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
   1.707 +                                    ios_base::iostate& __err, short& __val) const {
   1.708 +  return _M_do_get_integer(__stl_in, __end, __str, __err, __val, (_CharT*)0 );
   1.709 +}
   1.710 +
   1.711 +template <class _CharT, class _InputIter>
   1.712 +_InputIter
   1.713 +num_get<_CharT, _InputIter>::do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
   1.714 +                                    ios_base::iostate& __err, int& __val) const {
   1.715 +  return _M_do_get_integer(__stl_in, __end, __str, __err, __val, (_CharT*)0 );
   1.716 +}
   1.717 +
   1.718 +//# endif
   1.719 +
   1.720 +template <class _CharT, class _InputIter>
   1.721 +_InputIter
   1.722 +num_get<_CharT, _InputIter>::do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
   1.723 +                                    ios_base::iostate& __err, long& __val) const {
   1.724 +  return _M_do_get_integer(__stl_in, __end, __str, __err, __val, (_CharT*)0 );
   1.725 +}
   1.726 +
   1.727 +template <class _CharT, class _InputIter>
   1.728 +_InputIter
   1.729 +num_get<_CharT, _InputIter>::do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
   1.730 +                                    ios_base::iostate& __err,
   1.731 +                                    unsigned short& __val) const {
   1.732 +  return _M_do_get_integer(__stl_in, __end, __str, __err, __val, (_CharT*)0 );
   1.733 +}
   1.734 +
   1.735 +template <class _CharT, class _InputIter>
   1.736 +_InputIter
   1.737 +num_get<_CharT, _InputIter>::do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
   1.738 +                                    ios_base::iostate& __err,
   1.739 +                                    unsigned int& __val) const {
   1.740 +  return _M_do_get_integer(__stl_in, __end, __str, __err, __val, (_CharT*)0 );
   1.741 +}
   1.742 +
   1.743 +template <class _CharT, class _InputIter>
   1.744 +_InputIter
   1.745 +num_get<_CharT, _InputIter>::do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
   1.746 +                                    ios_base::iostate& __err,
   1.747 +                                    unsigned long& __val) const {
   1.748 +  return _M_do_get_integer(__stl_in, __end, __str, __err, __val, (_CharT*)0 );
   1.749 +}
   1.750 +
   1.751 +
   1.752 +template <class _CharT, class _InputIter>
   1.753 +_InputIter
   1.754 +num_get<_CharT, _InputIter>::do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
   1.755 +                                    ios_base::iostate& __err,
   1.756 +                                    float& __val) const {
   1.757 +  string __buf ;
   1.758 +  bool __ok = _M_read_float(__buf, __stl_in, __end, __str, (_CharT*)0 );
   1.759 +  if(__ok) //If success reading float then convert it.
   1.760 +  {
   1.761 +#ifdef __SYMBIAN32__
   1.762 +    float __tval;
   1.763 +    __ok = __string_to_float(__buf, __tval);
   1.764 +    if(__ok)
   1.765 +        __val = __tval;
   1.766 +#else
   1.767 +    __string_to_float(__buf, __val);
   1.768 +#endif    
   1.769 +  }
   1.770 +  __err = __STATIC_CAST(ios_base::iostate, __ok ? ios_base::goodbit : ios_base::failbit);
   1.771 +  if (__stl_in == __end)
   1.772 +    __err |= ios_base::eofbit;
   1.773 +  return __stl_in;
   1.774 +}
   1.775 +
   1.776 +template <class _CharT, class _InputIter>
   1.777 +_InputIter
   1.778 +num_get<_CharT, _InputIter>::do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
   1.779 +                                    ios_base::iostate& __err,
   1.780 +                                    double& __val) const {
   1.781 +  string __buf ;
   1.782 +  bool __ok = _M_read_float(__buf, __stl_in, __end, __str, (_CharT*)0 );
   1.783 +  if(__ok) //If success reading float then convert it.
   1.784 +  {
   1.785 +#ifdef __SYMBIAN32__
   1.786 +    double __tval;
   1.787 +    __ok = __string_to_float(__buf, __tval);
   1.788 +    if(__ok)
   1.789 +        __val = __tval;
   1.790 +#else
   1.791 +    __string_to_float(__buf, __val);
   1.792 +#endif    
   1.793 +  }
   1.794 +  __err = __STATIC_CAST(ios_base::iostate, __ok ? ios_base::goodbit : ios_base::failbit);
   1.795 +  if (__stl_in == __end)
   1.796 +    __err |= ios_base::eofbit;
   1.797 +  return __stl_in;
   1.798 +}
   1.799 +
   1.800 +#ifndef _STLP_NO_LONG_DOUBLE
   1.801 +template <class _CharT, class _InputIter>
   1.802 +_InputIter
   1.803 +num_get<_CharT, _InputIter>::do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
   1.804 +				    ios_base::iostate& __err,
   1.805 +                                    long double& __val) const {
   1.806 +  string __buf ;
   1.807 +  bool __ok = _M_read_float(__buf, __stl_in, __end, __str, (_CharT*)0 );
   1.808 +  if(__ok) //If success reading float then convert it.
   1.809 +  {
   1.810 +#ifdef __SYMBIAN32__
   1.811 +    long double __tval;
   1.812 +    __ok = __string_to_float(__buf, __tval);
   1.813 +    if(__ok)
   1.814 +        __val = __tval;
   1.815 +#else
   1.816 +    __string_to_float(__buf, __val);
   1.817 +#endif    
   1.818 +  }
   1.819 +  __err = __STATIC_CAST(ios_base::iostate, __ok ? ios_base::goodbit : ios_base::failbit);
   1.820 +  if (__stl_in == __end)
   1.821 +    __err |= ios_base::eofbit;
   1.822 +  return __stl_in;
   1.823 +}
   1.824 +#endif /* _STLP_NO_LONG_DOUBLE */
   1.825 +
   1.826 +template <class _CharT, class _InputIter>
   1.827 +_InputIter
   1.828 +num_get<_CharT, _InputIter>::do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
   1.829 +                           ios_base::iostate& __err,
   1.830 +                           void*& __p) const {
   1.831 +#ifdef	__SYMBIAN32__
   1.832 +	unsigned long __val;	//using only long
   1.833 +#else
   1.834 +# if defined(_STLP_LONG_LONG)&&!defined(__MRC__)		//*ty 12/07/2001 - MrCpp can not cast from long long to void*
   1.835 +  unsigned _STLP_LONG_LONG __val;
   1.836 +# else
   1.837 +  unsigned long __val;
   1.838 +# endif
   1.839 +#endif //__SYMBIAN32__
   1.840 +#ifdef __SYMBIAN32__
   1.841 +    ios_base::fmtflags __save_flags = __str.flags();
   1.842 +
   1.843 +    __str.setf(ios_base::hex, ios_base::basefield);
   1.844 +    __str.setf(ios_base::showbase);
   1.845 +    __str.setf(ios_base::internal, ios_base::adjustfield);
   1.846 +    __str.width((sizeof(void*) * 2) + 2);
   1.847 +#endif // __SYMBIAN32__
   1.848 +    iter_type __tmp = _M_do_get_integer(__stl_in, __end, __str, __err, __val, (_CharT*)0 );
   1.849 +    if (!(__err & ios_base::failbit))
   1.850 +      __p = __REINTERPRET_CAST(void*,(long)__val);
   1.851 +#ifdef __SYMBIAN32__
   1.852 +    __str.flags(__save_flags);
   1.853 +#endif //__SYMBIAN32__
   1.854 +    return __tmp;
   1.855 +  }
   1.856 +
   1.857 +
   1.858 +#ifdef _STLP_LONG_LONG
   1.859 +
   1.860 +template <class _CharT, class _InputIter>
   1.861 +_InputIter
   1.862 +num_get<_CharT, _InputIter>::do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
   1.863 +                                    ios_base::iostate& __err,
   1.864 +                                    _STLP_LONG_LONG& __val) const {
   1.865 +  return _M_do_get_integer(__stl_in, __end, __str, __err, __val, (_CharT*)0 );
   1.866 +}
   1.867 +
   1.868 +template <class _CharT, class _InputIter>
   1.869 +_InputIter
   1.870 +num_get<_CharT, _InputIter>::do_get(_InputIter __stl_in, _InputIter __end, ios_base& __str,
   1.871 +                                    ios_base::iostate& __err,
   1.872 +                                    unsigned _STLP_LONG_LONG& __val) const {
   1.873 +  return _M_do_get_integer(__stl_in, __end, __str, __err, __val, (_CharT*)0 );
   1.874 +}
   1.875 +
   1.876 +#endif /* _STLP_LONG_LONG */
   1.877 +
   1.878 +_STLP_END_NAMESPACE
   1.879 +
   1.880 +# endif /* _STLP_EXPOSE_STREAM_IMPLEMENTATION */
   1.881 +
   1.882 +#endif /* _STLP_NUMERIC_FACETS_C */
   1.883 +
   1.884 +// Local Variables:
   1.885 +// mode:C++
   1.886 +// End: