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