318 {
319 typedef _CharT char_type;
320 typedef _Str_Type string_type;
324
326 const _Ctype& __c_type = use_facet<_Ctype>(__loc) ;
327 const _Punct& __punct = use_facet<_Punct>(__loc) ;
328 const _Punct_intl& __punct_intl = use_facet<_Punct_intl>(__loc) ;
329
330
331 char_type
__minus = __c_type.widen(
'-');
332 char_type
__plus = __c_type.widen(
'+');
333 char_type __space = __c_type.widen(' ');
334 char_type __zero = __c_type.widen('0');
335 char_type __point = __intl ? __punct_intl.decimal_point()
336 : __punct.decimal_point();
337
338 char_type __sep = __intl ? __punct_intl.thousands_sep()
339 : __punct.thousands_sep();
340
341 string __grouping = __intl ? __punct_intl.grouping()
342 : __punct.grouping();
343
344 int __frac_digits = __intl ? __punct_intl.frac_digits()
345 : __punct.frac_digits();
346
347 string_type __curr_sym = __intl ? __punct_intl.curr_symbol()
348 : __punct.curr_symbol();
349
350
351
352
353
354 if (__digits.empty())
355 return __s;
356
357 typename string_type::const_iterator __digits_first = __digits.begin();
358 typename string_type::const_iterator __digits_last = __digits.end();
359
360 bool __is_negative = *__digits_first ==
__minus;
361 if (__is_negative)
362 ++__digits_first;
363
364#if !defined (__BORLANDC__)
365 string_type __sign = __intl ? __is_negative ? __punct_intl.negative_sign()
366 : __punct_intl.positive_sign()
367 : __is_negative ? __punct.negative_sign()
368 : __punct.positive_sign();
369#else
370 string_type __sign;
371 if (__intl) {
372 if (__is_negative)
373 __sign = __punct_intl.negative_sign();
374 else
375 __sign = __punct_intl.positive_sign();
376 }
377 else {
378 if (__is_negative)
379 __sign = __punct.negative_sign();
380 else
381 __sign = __punct.positive_sign();
382 }
383#endif
384
385 if (__check_digits) {
386 typename string_type::const_iterator __cp = __digits_first;
388 ++__cp;
389 if (__cp == __digits_first)
390 return __s;
391 __digits_last = __cp;
392 }
393
394
395
397 if (!__grouping.
empty()) {
398 __new_digits.assign(__digits_first, __digits_last);
400 __new_digits.size() - __frac_digits,
401 __grouping,
403 __digits_first = __new_digits.begin();
404 __digits_last = __new_digits.end();
405 }
406
407
409
410#if defined (_STLP_DEBUG) && (defined(__HP_aCC) && (__HP_aCC <= 1))
411 size_t __value_length =
operator -(__digits_last, __digits_first);
412#else
413 size_t __value_length = __digits_last - __digits_first;
414#endif
415
416 size_t __length = __value_length + __sign.size();
417
418 if (__frac_digits != 0)
419 ++__length;
420
421 bool __generate_curr = (__str.
flags() & ios_base::showbase) !=0;
422 if (__generate_curr)
423 __length += __curr_sym.size();
425 : __punct_intl.pos_format())
426 : (__is_negative ? __punct.neg_format()
427 : __punct.pos_format());
428 {
429
430
431
432
433
434
435
436
439 ++__length;
440 }
441
444 streamsize __fill_amt = __need_fill ? __width - __length : 0;
445
447
448 if (__fill_amt != 0 &&
449 !(__fill_pos & (ios_base::left | ios_base::internal)))
451
452 for (int __i = 0; __i < 4; ++__i) {
453 char __ffield = __format.
field[__i];
454 switch (__ffield) {
456 *__s++ = __space;
458 if (__fill_amt != 0 && __fill_pos == ios_base::internal)
460 break;
462 if (__generate_curr)
463 __s = _STLP_STD::copy(__curr_sym.begin(), __curr_sym.end(), __s);
464 break;
466 if (!__sign.empty())
467 *__s++ = __sign[0];
468 break;
470 if (__frac_digits == 0) {
471 __s = _STLP_STD::copy(__digits_first, __digits_last, __s);
472 } else {
473 if ((int)__value_length <= __frac_digits) {
474
475 *__s++ = __zero;
476 *__s++ = __point;
478 __s = _STLP_STD::copy(__digits_first, __digits_last, __s);
479 } else {
480 __s = _STLP_STD::copy(__digits_first, __digits_last - __frac_digits, __s);
481 if (__frac_digits != 0) {
482 *__s++ = __point;
483 __s = _STLP_STD::copy(__digits_last - __frac_digits, __digits_last, __s);
484 }
485 }
486 }
487 break;
488 }
489 }
490
491
492 if (__sign.size() > 1)
493 __s = _STLP_STD::copy(__sign.begin() + 1, __sign.end(), __s);
494 if (__fill_amt != 0 &&
495 !(__fill_pos & (ios_base::right | ios_base::internal)))
497
498 return __s;
499}
void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val, const input_iterator_tag &, _Distance *)
_STLP_MOVE_TO_PRIV_NAMESPACE _STLP_INLINE_LOOP _OutputIter __fill_n(_OutputIter __first, _Size __n, const _Tp &__val)
complex< _Tp > _STLP_CALL operator-(const complex< _Tp > &__z)
_STLP_MOVE_TO_PRIV_NAMESPACE plus< _Tp > __plus(_Tp *)
minus< _Tp > __minus(_Tp *)
#define _STLP_BASIC_IOSTRING(_CharT)
#define __STATIC_CAST(__x, __y)
ptrdiff_t _STLP_CALL __insert_grouping(char *first, char *last, const string &grouping, char separator, char Plus, char Minus, int basechars)