1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/tools/stlport/stl/_num_put.c Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,552 @@
1.4 +/*
1.5 + * Copyright (c) 1999
1.6 + * Silicon Graphics Computer Systems, Inc.
1.7 + *
1.8 + * Copyright (c) 1999
1.9 + * Boris Fomitchev
1.10 + *
1.11 + * This material is provided "as is", with absolutely no warranty expressed
1.12 + * or implied. Any use is at your own risk.
1.13 + *
1.14 + * Permission to use or copy this software for any purpose is hereby granted
1.15 + * without fee, provided the above notices are retained on all copies.
1.16 + * Permission to modify the code and to distribute modified code is granted,
1.17 + * provided the above notices are retained, and a notice that the code was
1.18 + * modified is included with the above copyright notice.
1.19 + *
1.20 + */
1.21 +#ifndef _STLP_NUM_PUT_C
1.22 +#define _STLP_NUM_PUT_C
1.23 +
1.24 +#ifndef _STLP_INTERNAL_NUM_PUT_H
1.25 +# include <stl/_num_put.h>
1.26 +#endif
1.27 +
1.28 +#ifndef _STLP_INTERNAL_LIMITS
1.29 +# include <stl/_limits.h>
1.30 +#endif
1.31 +
1.32 +_STLP_BEGIN_NAMESPACE
1.33 +
1.34 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.35 +
1.36 +// __do_put_float and its helper functions. Strategy: write the output
1.37 +// to a buffer of char, transform the buffer to _CharT, and then copy
1.38 +// it to the output.
1.39 +
1.40 +//----------------------------------------------------------------------
1.41 +// num_put facet
1.42 +
1.43 +template <class _CharT, class _OutputIter>
1.44 +_OutputIter _STLP_CALL
1.45 +__copy_float_and_fill(const _CharT* __first, const _CharT* __last,
1.46 + _OutputIter __oi,
1.47 + ios_base::fmtflags __flags,
1.48 + streamsize __width, _CharT __fill,
1.49 + _CharT __xplus, _CharT __xminus) {
1.50 + if (__width <= __last - __first)
1.51 + return copy(__first, __last, __oi);
1.52 + else {
1.53 + streamsize __pad = __width - (__last - __first);
1.54 + ios_base::fmtflags __dir = __flags & ios_base::adjustfield;
1.55 +
1.56 + if (__dir == ios_base::left) {
1.57 + __oi = copy(__first, __last, __oi);
1.58 + return __fill_n(__oi, __pad, __fill);
1.59 + }
1.60 + else if (__dir == ios_base::internal && __first != __last &&
1.61 + (*__first == __xplus || *__first == __xminus)) {
1.62 + *__oi++ = *__first++;
1.63 + __oi = __fill_n(__oi, __pad, __fill);
1.64 + return copy(__first, __last, __oi);
1.65 + }
1.66 + else {
1.67 + __oi = __fill_n(__oi, __pad, __fill);
1.68 + return copy(__first, __last, __oi);
1.69 + }
1.70 + }
1.71 +}
1.72 +
1.73 +#if !defined (_STLP_NO_WCHAR_T)
1.74 +// Helper routine for wchar_t
1.75 +template <class _OutputIter>
1.76 +_OutputIter _STLP_CALL
1.77 +__put_float(__iostring &__str, _OutputIter __oi,
1.78 + ios_base& __f, wchar_t __fill,
1.79 + wchar_t __decimal_point, wchar_t __sep,
1.80 + size_t __group_pos, const string& __grouping) {
1.81 + const ctype<wchar_t>& __ct = *__STATIC_CAST(const ctype<wchar_t>*, __f._M_ctype_facet());
1.82 +
1.83 + __iowstring __wbuf;
1.84 + __convert_float_buffer(__str, __wbuf, __ct, __decimal_point);
1.85 +
1.86 + if (!__grouping.empty()) {
1.87 + __insert_grouping(__wbuf, __group_pos, __grouping,
1.88 + __sep, __ct.widen('+'), __ct.widen('-'), 0);
1.89 + }
1.90 +
1.91 + return __copy_float_and_fill(__CONST_CAST(wchar_t*, __wbuf.data()),
1.92 + __CONST_CAST(wchar_t*, __wbuf.data()) + __wbuf.size(), __oi,
1.93 + __f.flags(), __f.width(0), __fill, __ct.widen('+'), __ct.widen('-'));
1.94 +}
1.95 +#endif /* WCHAR_T */
1.96 +
1.97 +// Helper routine for char
1.98 +template <class _OutputIter>
1.99 +_OutputIter _STLP_CALL
1.100 +__put_float(__iostring &__str, _OutputIter __oi,
1.101 + ios_base& __f, char __fill,
1.102 + char __decimal_point, char __sep,
1.103 + size_t __group_pos, const string& __grouping) {
1.104 + if ((__group_pos < __str.size()) && (__str[__group_pos] == '.')) {
1.105 + __str[__group_pos] = __decimal_point;
1.106 + }
1.107 +
1.108 + if (!__grouping.empty()) {
1.109 + __insert_grouping(__str, __group_pos,
1.110 + __grouping, __sep, '+', '-', 0);
1.111 + }
1.112 +
1.113 + return __copy_float_and_fill(__CONST_CAST(char*, __str.data()),
1.114 + __CONST_CAST(char*, __str.data()) + __str.size(), __oi,
1.115 + __f.flags(), __f.width(0), __fill, '+', '-');
1.116 +}
1.117 +
1.118 +template <class _CharT, class _OutputIter, class _Float>
1.119 +_OutputIter _STLP_CALL
1.120 +__do_put_float(_OutputIter __s, ios_base& __f,
1.121 + _CharT __fill, _Float __x) {
1.122 + __iostring __buf;
1.123 +
1.124 + size_t __group_pos = __write_float(__buf, __f.flags(), (int)__f.precision(), __x);
1.125 +
1.126 + const numpunct<_CharT>& __np = *__STATIC_CAST(const numpunct<_CharT>*, __f._M_numpunct_facet());
1.127 +
1.128 + return __put_float(__buf, __s, __f, __fill,
1.129 + __np.decimal_point(), __np.thousands_sep(),
1.130 + __group_pos, __f._M_grouping());
1.131 +}
1.132 +
1.133 +inline void __get_money_digits_aux (__iostring &__buf, ios_base &, _STLP_LONGEST_FLOAT_TYPE __x)
1.134 +{ __get_floor_digits(__buf, __x); }
1.135 +
1.136 +#if !defined (_STLP_NO_WCHAR_T)
1.137 +inline void __get_money_digits_aux (__iowstring &__wbuf, ios_base &__f, _STLP_LONGEST_FLOAT_TYPE __x) {
1.138 + __iostring __buf;
1.139 + __get_floor_digits(__buf, __x);
1.140 +
1.141 + const ctype<wchar_t>& __ct = *__STATIC_CAST(const ctype<wchar_t>*, __f._M_ctype_facet());
1.142 + __convert_float_buffer(__buf, __wbuf, __ct, wchar_t(0), false);
1.143 +}
1.144 +#endif
1.145 +
1.146 +template <class _CharT>
1.147 +void _STLP_CALL __get_money_digits(_STLP_BASIC_IOSTRING(_CharT) &__buf, ios_base& __f, _STLP_LONGEST_FLOAT_TYPE __x)
1.148 +{ __get_money_digits_aux(__buf, __f, __x); }
1.149 +
1.150 +// _M_do_put_integer and its helper functions.
1.151 +
1.152 +template <class _CharT, class _OutputIter>
1.153 +_OutputIter _STLP_CALL
1.154 +__copy_integer_and_fill(const _CharT* __buf, ptrdiff_t __len,
1.155 + _OutputIter __oi,
1.156 + ios_base::fmtflags __flg, streamsize __wid, _CharT __fill,
1.157 + _CharT __xplus, _CharT __xminus) {
1.158 + if (__len >= __wid)
1.159 + return copy(__buf, __buf + __len, __oi);
1.160 + else {
1.161 + //casting numeric_limits<ptrdiff_t>::max to streamsize only works is ptrdiff_t is signed or streamsize representation
1.162 + //is larger than ptrdiff_t one.
1.163 + _STLP_STATIC_ASSERT((sizeof(streamsize) > sizeof(ptrdiff_t)) ||
1.164 + (sizeof(streamsize) == sizeof(ptrdiff_t)) && numeric_limits<ptrdiff_t>::is_signed)
1.165 + ptrdiff_t __pad = __STATIC_CAST(ptrdiff_t, (min) (__STATIC_CAST(streamsize, (numeric_limits<ptrdiff_t>::max)()),
1.166 + __STATIC_CAST(streamsize, __wid - __len)));
1.167 + ios_base::fmtflags __dir = __flg & ios_base::adjustfield;
1.168 +
1.169 + if (__dir == ios_base::left) {
1.170 + __oi = copy(__buf, __buf + __len, __oi);
1.171 + return __fill_n(__oi, __pad, __fill);
1.172 + }
1.173 + else if (__dir == ios_base::internal && __len != 0 &&
1.174 + (__buf[0] == __xplus || __buf[0] == __xminus)) {
1.175 + *__oi++ = __buf[0];
1.176 + __oi = __fill_n(__oi, __pad, __fill);
1.177 + return copy(__buf + 1, __buf + __len, __oi);
1.178 + }
1.179 + else if (__dir == ios_base::internal && __len >= 2 &&
1.180 + (__flg & ios_base::showbase) &&
1.181 + (__flg & ios_base::basefield) == ios_base::hex) {
1.182 + *__oi++ = __buf[0];
1.183 + *__oi++ = __buf[1];
1.184 + __oi = __fill_n(__oi, __pad, __fill);
1.185 + return copy(__buf + 2, __buf + __len, __oi);
1.186 + }
1.187 + else {
1.188 + __oi = __fill_n(__oi, __pad, __fill);
1.189 + return copy(__buf, __buf + __len, __oi);
1.190 + }
1.191 + }
1.192 +}
1.193 +
1.194 +#if !defined (_STLP_NO_WCHAR_T)
1.195 +// Helper function for wchar_t
1.196 +template <class _OutputIter>
1.197 +_OutputIter _STLP_CALL
1.198 +__put_integer(char* __buf, char* __iend, _OutputIter __s,
1.199 + ios_base& __f,
1.200 + ios_base::fmtflags __flags, wchar_t __fill) {
1.201 + locale __loc = __f.getloc();
1.202 + // const ctype<wchar_t>& __ct = use_facet<ctype<wchar_t> >(__loc);
1.203 + const ctype<wchar_t>& __ct = *__STATIC_CAST(const ctype<wchar_t>*, __f._M_ctype_facet());
1.204 +
1.205 + wchar_t __xplus = __ct.widen('+');
1.206 + wchar_t __xminus = __ct.widen('-');
1.207 +
1.208 + wchar_t __wbuf[64];
1.209 + __ct.widen(__buf, __iend, __wbuf);
1.210 + ptrdiff_t __len = __iend - __buf;
1.211 + wchar_t* __eend = __wbuf + __len;
1.212 +
1.213 + // const numpunct<wchar_t>& __np = use_facet<numpunct<wchar_t> >(__loc);
1.214 + // const string& __grouping = __np.grouping();
1.215 +
1.216 + const numpunct<wchar_t>& __np = *__STATIC_CAST(const numpunct<wchar_t>*, __f._M_numpunct_facet());
1.217 + const string& __grouping = __f._M_grouping();
1.218 +
1.219 + if (!__grouping.empty()) {
1.220 + int __basechars;
1.221 + if (__flags & ios_base::showbase)
1.222 + switch (__flags & ios_base::basefield) {
1.223 + case ios_base::hex: __basechars = 2; break;
1.224 + case ios_base::oct: __basechars = 1; break;
1.225 + default: __basechars = 0;
1.226 + }
1.227 + else
1.228 + __basechars = 0;
1.229 +
1.230 + __len = __insert_grouping(__wbuf, __eend, __grouping, __np.thousands_sep(),
1.231 + __xplus, __xminus, __basechars);
1.232 + }
1.233 +
1.234 + return __copy_integer_and_fill((wchar_t*)__wbuf, __len, __s,
1.235 + __flags, __f.width(0), __fill, __xplus, __xminus);
1.236 +}
1.237 +#endif
1.238 +
1.239 +// Helper function for char
1.240 +template <class _OutputIter>
1.241 +_OutputIter _STLP_CALL
1.242 +__put_integer(char* __buf, char* __iend, _OutputIter __s,
1.243 + ios_base& __f, ios_base::fmtflags __flags, char __fill) {
1.244 + char __grpbuf[64];
1.245 + ptrdiff_t __len = __iend - __buf;
1.246 +
1.247 + // const numpunct<char>& __np = use_facet<numpunct<char> >(__f.getloc());
1.248 + // const string& __grouping = __np.grouping();
1.249 +
1.250 + const numpunct<char>& __np = *__STATIC_CAST(const numpunct<char>*, __f._M_numpunct_facet());
1.251 + const string& __grouping = __f._M_grouping();
1.252 +
1.253 + if (!__grouping.empty()) {
1.254 + int __basechars;
1.255 + if (__flags & ios_base::showbase)
1.256 + switch (__flags & ios_base::basefield) {
1.257 + case ios_base::hex: __basechars = 2; break;
1.258 + case ios_base::oct: __basechars = 1; break;
1.259 + default: __basechars = 0;
1.260 + }
1.261 + else
1.262 + __basechars = 0;
1.263 +
1.264 + // make sure there is room at the end of the buffer
1.265 + // we pass to __insert_grouping
1.266 + copy(__buf, __iend, (char *) __grpbuf);
1.267 + __buf = __grpbuf;
1.268 + __iend = __grpbuf + __len;
1.269 + __len = __insert_grouping(__buf, __iend, __grouping, __np.thousands_sep(),
1.270 + '+', '-', __basechars);
1.271 + }
1.272 +
1.273 + return __copy_integer_and_fill(__buf, __len, __s, __flags, __f.width(0), __fill, '+', '-');
1.274 +}
1.275 +
1.276 +#if defined (_STLP_LONG_LONG)
1.277 +typedef _STLP_LONG_LONG __max_int_t;
1.278 +typedef unsigned _STLP_LONG_LONG __umax_int_t;
1.279 +#else
1.280 +typedef long __max_int_t;
1.281 +typedef unsigned long __umax_int_t;
1.282 +#endif
1.283 +
1.284 +_STLP_DECLSPEC const char* _STLP_CALL __hex_char_table_lo();
1.285 +_STLP_DECLSPEC const char* _STLP_CALL __hex_char_table_hi();
1.286 +
1.287 +template <class _Integer>
1.288 +inline char* _STLP_CALL
1.289 +__write_decimal_backward(char* __ptr, _Integer __x, ios_base::fmtflags __flags, const __true_type& /* is_signed */) {
1.290 + const bool __negative = __x < 0 ;
1.291 + __max_int_t __temp = __x;
1.292 + __umax_int_t __utemp = __negative?-__temp:__temp;
1.293 +
1.294 + for (; __utemp != 0; __utemp /= 10)
1.295 + *--__ptr = (char)((int)(__utemp % 10) + '0');
1.296 + // put sign if needed or requested
1.297 + if (__negative)
1.298 + *--__ptr = '-';
1.299 + else if (__flags & ios_base::showpos)
1.300 + *--__ptr = '+';
1.301 + return __ptr;
1.302 +}
1.303 +
1.304 +template <class _Integer>
1.305 +inline char* _STLP_CALL
1.306 +__write_decimal_backward(char* __ptr, _Integer __x, ios_base::fmtflags __flags, const __false_type& /* is_signed */) {
1.307 + for (; __x != 0; __x /= 10)
1.308 + *--__ptr = (char)((int)(__x % 10) + '0');
1.309 + // put sign if requested
1.310 + if (__flags & ios_base::showpos)
1.311 + *--__ptr = '+';
1.312 + return __ptr;
1.313 +}
1.314 +
1.315 +template <class _Integer>
1.316 +char* _STLP_CALL
1.317 +__write_integer_backward(char* __buf, ios_base::fmtflags __flags, _Integer __x) {
1.318 + char* __ptr = __buf;
1.319 +
1.320 + if (__x == 0) {
1.321 + *--__ptr = '0';
1.322 + if ((__flags & ios_base::showpos) && ((__flags & (ios_base::oct | ios_base::hex)) == 0))
1.323 + *--__ptr = '+';
1.324 + // oct or hex base shall not be added to the 0 value (see '#' flag in C formating strings)
1.325 + }
1.326 + else {
1.327 + switch (__flags & ios_base::basefield) {
1.328 + case ios_base::oct:
1.329 + {
1.330 + __umax_int_t __temp = __x;
1.331 + // if the size of integer is less than 8, clear upper part
1.332 + if ( sizeof(__x) < 8 && sizeof(__umax_int_t) >= 8 )
1.333 + __temp &= 0xFFFFFFFF;
1.334 +
1.335 + for (; __temp != 0; __temp >>=3)
1.336 + *--__ptr = (char)((((unsigned)__temp)& 0x7) + '0');
1.337 +
1.338 + // put leading '0' if showbase is set
1.339 + if (__flags & ios_base::showbase)
1.340 + *--__ptr = '0';
1.341 + }
1.342 + break;
1.343 + case ios_base::hex:
1.344 + {
1.345 + const char* __table_ptr = (__flags & ios_base::uppercase) ?
1.346 + __hex_char_table_hi() : __hex_char_table_lo();
1.347 + __umax_int_t __temp = __x;
1.348 + // if the size of integer is less than 8, clear upper part
1.349 + if ( sizeof(__x) < 8 && sizeof(__umax_int_t) >= 8 )
1.350 + __temp &= 0xFFFFFFFF;
1.351 +
1.352 + for (; __temp != 0; __temp >>=4)
1.353 + *--__ptr = __table_ptr[((unsigned)__temp & 0xF)];
1.354 +
1.355 + if (__flags & ios_base::showbase) {
1.356 + *--__ptr = __table_ptr[16];
1.357 + *--__ptr = '0';
1.358 + }
1.359 + }
1.360 + break;
1.361 + //case ios_base::dec:
1.362 + default:
1.363 + {
1.364 +#if defined(__HP_aCC) && (__HP_aCC == 1)
1.365 + bool _IsSigned = !((_Integer)-1 > 0);
1.366 + if (_IsSigned)
1.367 + __ptr = __write_decimal_backward(__ptr, __x, __flags, __true_type() );
1.368 + else
1.369 + __ptr = __write_decimal_backward(__ptr, __x, __flags, __false_type() );
1.370 +#else
1.371 + typedef typename __bool2type<numeric_limits<_Integer>::is_signed>::_Ret _IsSigned;
1.372 + __ptr = __write_decimal_backward(__ptr, __x, __flags, _IsSigned());
1.373 +#endif
1.374 + }
1.375 + break;
1.376 + }
1.377 + }
1.378 +
1.379 + // return pointer to beginning of the string
1.380 + return __ptr;
1.381 +}
1.382 +
1.383 +template <class _CharT, class _OutputIter, class _Integer>
1.384 +_OutputIter _STLP_CALL
1.385 +__do_put_integer(_OutputIter __s, ios_base& __f, _CharT __fill, _Integer __x) {
1.386 + // buffer size = number of bytes * number of digit necessary in the smallest Standard base (base 8, 3 digits/byte)
1.387 + // plus the longest base representation '0x'
1.388 + // Do not use __buf_size to define __buf static buffer, some compilers (HP aCC) do not accept const variable as
1.389 + // the specification of a static buffer size.
1.390 + char __buf[sizeof(_Integer) * 3 + 2];
1.391 + const ptrdiff_t __buf_size = sizeof(__buf) / sizeof(char);
1.392 + ios_base::fmtflags __flags = __f.flags();
1.393 + char* __ibeg = __write_integer_backward((char*)__buf+__buf_size, __flags, __x);
1.394 + return __put_integer(__ibeg, (char*)__buf+__buf_size, __s, __f, __flags, __fill);
1.395 +}
1.396 +
1.397 +_STLP_MOVE_TO_STD_NAMESPACE
1.398 +
1.399 +//
1.400 +// num_put<>
1.401 +//
1.402 +
1.403 +#if (_STLP_STATIC_TEMPLATE_DATA > 0)
1.404 +
1.405 +# if !defined (__BORLANDC__)
1.406 +template <class _CharT, class _OutputIterator>
1.407 +locale::id num_put<_CharT, _OutputIterator>::id;
1.408 +# endif
1.409 +
1.410 +# if (defined (__CYGWIN__) || defined (__MINGW32__)) && \
1.411 + defined (_STLP_USE_DYNAMIC_LIB) && !defined (__BUILDING_STLPORT)
1.412 +/*
1.413 + * Under cygwin, when STLport is used as a shared library, the id needs
1.414 + * to be specified as imported otherwise they will be duplicated in the
1.415 + * calling executable.
1.416 + */
1.417 +template <>
1.418 +_STLP_DECLSPEC locale::id num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id;
1.419 +/*
1.420 +template <>
1.421 +_STLP_DECLSPEC locale::id num_put<char, char*>::id;
1.422 +*/
1.423 +
1.424 +# if !defined (_STLP_NO_WCHAR_T)
1.425 +template <>
1.426 +_STLP_DECLSPEC locale::id num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
1.427 +/*
1.428 +template <>
1.429 +_STLP_DECLSPEC locale::id num_put<wchar_t, wchar_t*>::id;
1.430 +*/
1.431 +# endif
1.432 +
1.433 +# endif /* __CYGWIN__ && _STLP_USE_DYNAMIC_LIB */
1.434 +
1.435 +#else /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */
1.436 +
1.437 +//typedef num_put<char, char*> num_put_char;
1.438 +typedef num_put<char, ostreambuf_iterator<char, char_traits<char> > > num_put_char_2;
1.439 +
1.440 +//__DECLARE_INSTANCE(locale::id, num_put_char::id, );
1.441 +__DECLARE_INSTANCE(locale::id, num_put_char_2::id, );
1.442 +
1.443 +# if !defined (_STLP_NO_WCHAR_T)
1.444 +
1.445 +//typedef num_put<wchar_t, wchar_t*> num_put_wchar_t;
1.446 +typedef num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > num_put_wchar_t_2;
1.447 +
1.448 +//__DECLARE_INSTANCE(locale::id, num_put_wchar_t::id, );
1.449 +__DECLARE_INSTANCE(locale::id, num_put_wchar_t_2::id, );
1.450 +
1.451 +# endif
1.452 +
1.453 +#endif /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */
1.454 +
1.455 +// issue 118
1.456 +
1.457 +#if !defined (_STLP_NO_BOOL)
1.458 +template <class _CharT, class _OutputIter>
1.459 +_OutputIter
1.460 +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f,
1.461 + char_type __fill, bool __val) const {
1.462 + if (!(__f.flags() & ios_base::boolalpha))
1.463 + return this->do_put(__s, __f, __fill, __STATIC_CAST(long,__val));
1.464 +
1.465 + locale __loc = __f.getloc();
1.466 + // typedef numpunct<_CharT> _Punct;
1.467 + // const _Punct& __np = use_facet<_Punct>(__loc);
1.468 +
1.469 + const numpunct<_CharT>& __np = *__STATIC_CAST(const numpunct<_CharT>*, __f._M_numpunct_facet());
1.470 +
1.471 + basic_string<_CharT> __str = __val ? __np.truename() : __np.falsename();
1.472 +
1.473 + // Reuse __copy_integer_and_fill. Since internal padding makes no
1.474 + // sense for bool, though, make sure we use something else instead.
1.475 + // The last two argument to __copy_integer_and_fill are dummies.
1.476 + ios_base::fmtflags __flags = __f.flags();
1.477 + if ((__flags & ios_base::adjustfield) == ios_base::internal)
1.478 + __flags = (__flags & ~ios_base::adjustfield) | ios_base::right;
1.479 +
1.480 + return _STLP_PRIV __copy_integer_and_fill(__str.c_str(), __str.size(), __s,
1.481 + __flags, __f.width(0), __fill,
1.482 + (_CharT) 0, (_CharT) 0);
1.483 +}
1.484 +
1.485 +#endif
1.486 +
1.487 +template <class _CharT, class _OutputIter>
1.488 +_OutputIter
1.489 +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
1.490 + long __val) const
1.491 +{ return _STLP_PRIV __do_put_integer(__s, __f, __fill, __val); }
1.492 +
1.493 +template <class _CharT, class _OutputIter>
1.494 +_OutputIter
1.495 +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
1.496 + unsigned long __val) const
1.497 +{ return _STLP_PRIV __do_put_integer(__s, __f, __fill, __val); }
1.498 +
1.499 +template <class _CharT, class _OutputIter>
1.500 +_OutputIter
1.501 +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
1.502 + double __val) const
1.503 +{ return _STLP_PRIV __do_put_float(__s, __f, __fill, __val); }
1.504 +
1.505 +#if !defined (_STLP_NO_LONG_DOUBLE)
1.506 +template <class _CharT, class _OutputIter>
1.507 +_OutputIter
1.508 +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
1.509 + long double __val) const
1.510 +{ return _STLP_PRIV __do_put_float(__s, __f, __fill, __val); }
1.511 +#endif
1.512 +
1.513 +#if defined (_STLP_LONG_LONG)
1.514 +template <class _CharT, class _OutputIter>
1.515 +_OutputIter
1.516 +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
1.517 + _STLP_LONG_LONG __val) const
1.518 +{ return _STLP_PRIV __do_put_integer(__s, __f, __fill, __val); }
1.519 +
1.520 +template <class _CharT, class _OutputIter>
1.521 +_OutputIter
1.522 +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
1.523 + unsigned _STLP_LONG_LONG __val) const
1.524 +{ return _STLP_PRIV __do_put_integer(__s, __f, __fill, __val); }
1.525 +#endif /* _STLP_LONG_LONG */
1.526 +
1.527 +
1.528 +// lib.facet.num.put.virtuals "12 For conversion from void* the specifier is %p."
1.529 +template <class _CharT, class _OutputIter>
1.530 +_OutputIter
1.531 +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT /*__fill*/,
1.532 + const void* __val) const {
1.533 + const ctype<_CharT>& __c_type = *__STATIC_CAST(const ctype<_CharT>*, __f._M_ctype_facet());
1.534 + ios_base::fmtflags __save_flags = __f.flags();
1.535 +
1.536 + __f.setf(ios_base::hex, ios_base::basefield);
1.537 + __f.setf(ios_base::showbase);
1.538 + __f.setf(ios_base::internal, ios_base::adjustfield);
1.539 + __f.width((sizeof(void*) * 2) + 2); // digits in pointer type plus '0x' prefix
1.540 +# if defined(_STLP_LONG_LONG) && !defined(__MRC__) //*ty 11/24/2001 - MrCpp can not cast from void* to long long
1.541 + _OutputIter result = this->do_put(__s, __f, __c_type.widen('0'), __REINTERPRET_CAST(unsigned _STLP_LONG_LONG,__val));
1.542 +# else
1.543 + _OutputIter result = this->do_put(__s, __f, __c_type.widen('0'), __REINTERPRET_CAST(unsigned long,__val));
1.544 +# endif
1.545 + __f.flags(__save_flags);
1.546 + return result;
1.547 +}
1.548 +
1.549 +_STLP_END_NAMESPACE
1.550 +
1.551 +#endif /* _STLP_NUM_PUT_C */
1.552 +
1.553 +// Local Variables:
1.554 +// mode:C++
1.555 +// End: