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