1.1 --- a/epoc32/include/stdapis/stlport/stl/_num_put.c Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/stlport/stl/_num_put.c Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,673 @@
1.4 -_num_put.c
1.5 +/*
1.6 + * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
1.7 + *
1.8 + * Copyright (c) 1999
1.9 + * Silicon Graphics Computer Systems, Inc.
1.10 + *
1.11 + * Copyright (c) 1999
1.12 + * Boris Fomitchev
1.13 + *
1.14 + * This material is provided "as is", with absolutely no warranty expressed
1.15 + * or implied. Any use is at your own risk.
1.16 + *
1.17 + * Permission to use or copy this software for any purpose is hereby granted
1.18 + * without fee, provided the above notices are retained on all copies.
1.19 + * Permission to modify the code and to distribute modified code is granted,
1.20 + * provided the above notices are retained, and a notice that the code was
1.21 + * modified is included with the above copyright notice.
1.22 + *
1.23 + */
1.24 +#ifndef _STLP_NUM_PUT_C
1.25 +#define _STLP_NUM_PUT_C
1.26 +
1.27 +#ifndef _STLP_INTERNAL_NUM_PUT_H
1.28 +# include <stl/_num_put.h>
1.29 +#endif
1.30 +
1.31 +# if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
1.32 +
1.33 +#ifndef _STLP_LIMITS_H
1.34 +# include <stl/_limits.h>
1.35 +#endif
1.36 +
1.37 +_STLP_BEGIN_NAMESPACE
1.38 +
1.39 +// _M_do_put_float and its helper functions. Strategy: write the output
1.40 +// to a buffer of char, transform the buffer to _CharT, and then copy
1.41 +// it to the output.
1.42 +
1.43 +template <class _CharT, class _OutputIter,class _Float>
1.44 +_OutputIter _STLP_CALL
1.45 +_M_do_put_float(_OutputIter __s, ios_base& __f, _CharT __fill,_Float __x);
1.46 +
1.47 +
1.48 +//----------------------------------------------------------------------
1.49 +// num_put facet
1.50 +
1.51 +template <class _CharT, class _OutputIter>
1.52 +_OutputIter _STLP_CALL
1.53 +__copy_float_and_fill(const _CharT* __first, const _CharT* __last,
1.54 + _OutputIter __stl_out,
1.55 + ios_base::fmtflags __flags,
1.56 + streamsize __width, _CharT __fill,
1.57 + _CharT __xplus, _CharT __xminus) {
1.58 + if (__width <= __last - __first)
1.59 + return copy(__first, __last, __stl_out);
1.60 + else {
1.61 + streamsize __pad = __width - (__last - __first);
1.62 + ios_base::fmtflags __dir = __flags & ios_base::adjustfield;
1.63 +
1.64 + if (__dir == ios_base::left) {
1.65 + __stl_out = copy(__first, __last, __stl_out);
1.66 + return fill_n(__stl_out, __pad, __fill);
1.67 + }
1.68 + else if (__dir == ios_base::internal && __first != __last &&
1.69 + (*__first == __xplus || *__first == __xminus)) {
1.70 + *__stl_out++ = *__first++;
1.71 + __stl_out = fill_n(__stl_out, __pad, __fill);
1.72 + return copy(__first, __last, __stl_out);
1.73 + }
1.74 + else {
1.75 + __stl_out = fill_n(__stl_out, __pad, __fill);
1.76 + return copy(__first, __last, __stl_out);
1.77 + }
1.78 + }
1.79 +}
1.80 +
1.81 +#ifndef _STLP_NO_WCHAR_T
1.82 +// Helper routine for wchar_t
1.83 +template <class _OutputIter>
1.84 +_OutputIter _STLP_CALL
1.85 +__put_float(char* __ibuf, char* __iend, _OutputIter __stl_out,
1.86 + ios_base& __f, wchar_t __fill,
1.87 + wchar_t __decimal_point,
1.88 + wchar_t __sep, const string& __grouping)
1.89 +{
1.90 + //const ctype<wchar_t>& __ct = *(ctype<wchar_t>*)__f._M_ctype_facet() ;
1.91 + const ctype<wchar_t>& __ct = use_facet< ctype<wchar_t> >(__f.getloc());
1.92 +
1.93 + // wchar_t __wbuf[128]; //stdcxx fix
1.94 + wchar_t __wbuf[256+10];
1.95 + wchar_t* __eend = __convert_float_buffer(__ibuf, __iend, __wbuf,
1.96 + __ct, __decimal_point);
1.97 + if (!__grouping.empty()) {
1.98 + // In order to do separator-insertion only to the left of the
1.99 + // decimal point, we adjust the size of the first (right-most)
1.100 + // group. We need to be careful if there is only one entry in
1.101 + // grouping: in this case we need to duplicate the first entry.
1.102 +
1.103 + string __new_grouping = __grouping;
1.104 + wchar_t* __decimal_pos = find(__wbuf, __eend, __decimal_point);
1.105 + if (__grouping.size() == 1)
1.106 + __new_grouping.push_back(__grouping[0]);
1.107 +
1.108 + // dwa 1/24/00 - try as I might, there doesn't seem to be a way
1.109 + // to suppress the warning
1.110 + __new_grouping[0] += __STATIC_CAST(char, __eend - __decimal_pos);
1.111 + ptrdiff_t __len = __insert_grouping(__wbuf, __eend, __new_grouping,
1.112 + __sep,
1.113 + __ct.widen('+'), __ct.widen('-'),
1.114 + 0);
1.115 + __eend = __wbuf + __len;
1.116 + }
1.117 +
1.118 + return __copy_float_and_fill(__wbuf, __eend, __stl_out,
1.119 + __f.flags(), __f.width(0), __fill,
1.120 + __ct.widen('+'), __ct.widen('-'));
1.121 +}
1.122 +# endif /* WCHAR_T */
1.123 +
1.124 +#ifdef __SYMBIAN32__
1.125 +template<class _CharT>
1.126 +ptrdiff_t _STLP_CALL
1.127 +__insert_grouping(_CharT * first, _CharT * last, const string& grouping,
1.128 + _CharT separator, _CharT Plus, _CharT Minus, int basechars)
1.129 +{
1.130 + int length = last-first;
1.131 + ptrdiff_t res;
1.132 + char* str = new char(length+64); //morespace for seperators
1.133 + memset(str,'\0',length+64);
1.134 + memcpy(str,first, length);
1.135 + char _separator = (char)separator;
1.136 + char _Plus = (char)Plus;
1.137 + char _Minus = (char)Minus;
1.138 +
1.139 + res = __insert_grouping(str, str+length, grouping,
1.140 + _separator, _Plus, _Minus, basechars);
1.141 + memcpy(first,str,res);
1.142 + delete str;
1.143 + return res;
1.144 +
1.145 +}
1.146 +
1.147 +#endif
1.148 +// Helper routine for char
1.149 +template <class _OutputIter>
1.150 +_OutputIter _STLP_CALL
1.151 +__put_float(char* __ibuf, char* __iend, _OutputIter __stl_out,
1.152 + ios_base& __f, char __fill,
1.153 + char __decimal_point,
1.154 + char __sep, const string& __grouping)
1.155 +{
1.156 + __adjust_float_buffer(__ibuf, __iend, __decimal_point);
1.157 + if (!__grouping.empty()) {
1.158 + string __new_grouping = __grouping;
1.159 + const char * __decimal_pos = find(__ibuf, __iend, __decimal_point);
1.160 + if (__grouping.size() == 1)
1.161 + __new_grouping.push_back(__grouping[0]);
1.162 + __new_grouping[0] += __STATIC_CAST(char, (__iend - __decimal_pos));
1.163 + ptrdiff_t __len = __insert_grouping(__ibuf, __iend, __new_grouping,
1.164 + __sep, '+', '-', 0);
1.165 + __iend = __ibuf + __len;
1.166 + }
1.167 +
1.168 + return __copy_float_and_fill(__ibuf, __iend, __stl_out,
1.169 + __f.flags(), __f.width(0), __fill, '+', '-');
1.170 +}
1.171 +
1.172 +#ifdef __SYMBIAN32__
1.173 +
1.174 +template <class _CharT, class _OutputIter>
1.175 +_OutputIter _STLP_CALL
1.176 +__put_float(char* __ibuf, char* __iend, _OutputIter __stl_out,
1.177 + ios_base& __f, _CharT __fill,
1.178 + _CharT __decimal_point,
1.179 + _CharT __sep, const string& __grouping)
1.180 +{
1.181 + __adjust_float_buffer(__ibuf, __iend, __decimal_point);
1.182 + if (!__grouping.empty()) {
1.183 + string __new_grouping = __grouping;
1.184 + const char * __decimal_pos = find(__ibuf, __iend, __decimal_point);
1.185 + if (__grouping.size() == 1)
1.186 + __new_grouping.push_back(__grouping[0]);
1.187 + __new_grouping[0] += __STATIC_CAST(char, (__iend - __decimal_pos));
1.188 + ptrdiff_t __len = __insert_grouping(__ibuf, __iend, __new_grouping,
1.189 + __sep, '+', '-', 0);
1.190 + __iend = __ibuf + __len;
1.191 + }
1.192 +
1.193 + _CharT __wbuf[64];
1.194 + locale __loc = __f.getloc();
1.195 + const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
1.196 + __ct.widen(__ibuf, __iend, __wbuf);
1.197 +
1.198 + ptrdiff_t __len = __iend - __ibuf;
1.199 + return __copy_float_and_fill(__wbuf, __wbuf+__len, __stl_out,
1.200 + __f.flags(), __f.width(0), __fill, (_CharT)'+', (_CharT)'-');
1.201 +}
1.202 +
1.203 +
1.204 +#endif
1.205 +template <class _CharT, class _OutputIter, class _Float>
1.206 +_OutputIter _STLP_CALL
1.207 +_M_do_put_float(_OutputIter __s, ios_base& __f,
1.208 + _CharT __fill, _Float __x)
1.209 +{
1.210 + string __buf;
1.211 + __buf.reserve(256+10); //+2 - 10/1/07
1.212 + __write_float(__buf, __f.flags(), (int)__f.precision(), __x);
1.213 +
1.214 + //const numpunct<_CharT>& __np = *(const numpunct<_CharT>*)__f._M_numpunct_facet();
1.215 + const numpunct<_CharT>& __np = use_facet< numpunct<_CharT> >(__f.getloc());
1.216 +
1.217 + return __put_float(__CONST_CAST(char*, __buf.c_str()),
1.218 + __CONST_CAST(char*, __buf.c_str()) + __buf.size(),
1.219 + __s, __f, __fill,
1.220 + __np.decimal_point(),
1.221 + // __np.thousands_sep(), __f._M_grouping()); //stdcxx fix - 17/1/07
1.222 + __np.thousands_sep(), __np.grouping());
1.223 +}
1.224 +
1.225 +// _M_do_put_integer and its helper functions.
1.226 +
1.227 +template <class _CharT, class _OutputIter>
1.228 +_OutputIter _STLP_CALL
1.229 +__copy_integer_and_fill(const _CharT* __buf, ptrdiff_t __len,
1.230 + _OutputIter __stl_out,
1.231 + ios_base::fmtflags __flg, streamsize __wid, _CharT __fill,
1.232 + _CharT __xplus, _CharT __xminus)
1.233 +{
1.234 + if (__len >= __wid)
1.235 + return copy(__buf, __buf + __len, __stl_out);
1.236 + else {
1.237 + ptrdiff_t __pad = __wid - __len;
1.238 + ios_base::fmtflags __dir = __flg & ios_base::adjustfield;
1.239 +
1.240 + if (__dir == ios_base::left) {
1.241 + __stl_out = copy(__buf, __buf + __len, __stl_out);
1.242 + return fill_n(__stl_out, __pad, __fill);
1.243 + }
1.244 + else if (__dir == ios_base::internal && __len != 0 &&
1.245 + (__buf[0] == __xplus || __buf[0] == __xminus)) {
1.246 + *__stl_out++ = __buf[0];
1.247 + __stl_out = fill_n(__stl_out, __pad, __fill);
1.248 + return copy(__buf + 1, __buf + __len, __stl_out);
1.249 + }
1.250 + else if (__dir == ios_base::internal && __len >= 2 &&
1.251 + (__flg & ios_base::showbase) &&
1.252 + (__flg & ios_base::basefield) == ios_base::hex) {
1.253 + *__stl_out++ = __buf[0];
1.254 + *__stl_out++ = __buf[1];
1.255 + __stl_out = fill_n(__stl_out, __pad, __fill);
1.256 + return copy(__buf + 2, __buf + __len, __stl_out);
1.257 + }
1.258 + else {
1.259 + __stl_out = fill_n(__stl_out, __pad, __fill);
1.260 + return copy(__buf, __buf + __len, __stl_out);
1.261 + }
1.262 + }
1.263 +}
1.264 +
1.265 +#ifndef _STLP_NO_WCHAR_T
1.266 +// Helper function for wchar_t
1.267 +template <class _OutputIter>
1.268 +_OutputIter _STLP_CALL
1.269 +__put_integer(char* __buf, char* __iend, _OutputIter __s,
1.270 + ios_base& __f,
1.271 + ios_base::fmtflags __flags, wchar_t __fill)
1.272 +{
1.273 + locale __loc = __f.getloc();
1.274 + const ctype<wchar_t>& __ct = use_facet<ctype<wchar_t> >(__loc);
1.275 + //const ctype<wchar_t>& __ct = *(const ctype<wchar_t>*)__f._M_ctype_facet();
1.276 +
1.277 + wchar_t __xplus = __ct.widen('+');
1.278 + wchar_t __xminus = __ct.widen('-');
1.279 +
1.280 + wchar_t __wbuf[64];
1.281 + __ct.widen(__buf, __iend, __wbuf);
1.282 + ptrdiff_t __len = __iend - __buf;
1.283 + wchar_t* __eend = __wbuf + __len;
1.284 +
1.285 + const numpunct<wchar_t>& __np = use_facet<numpunct<wchar_t> >(__loc);
1.286 + const string& __grouping = __np.grouping();
1.287 +
1.288 + //const numpunct<wchar_t>& __np = *(const numpunct<wchar_t>*)__f._M_numpunct_facet();
1.289 + // const string& __grouping = __f._M_grouping();
1.290 +
1.291 + if (!__grouping.empty()) {
1.292 + int __basechars;
1.293 + if (__flags & ios_base::showbase)
1.294 + switch (__flags & ios_base::basefield) {
1.295 + case ios_base::hex: __basechars = 2; break;
1.296 + case ios_base::oct: __basechars = 1; break;
1.297 + default: __basechars = 0;
1.298 + }
1.299 + else
1.300 + __basechars = 0;
1.301 +
1.302 + __len = __insert_grouping(__wbuf, __eend, __grouping, __np.thousands_sep(),
1.303 + __xplus, __xminus, __basechars);
1.304 + }
1.305 +
1.306 + return __copy_integer_and_fill((wchar_t*)__wbuf, __len, __s,
1.307 + __flags, __f.width(0), __fill, __xplus, __xminus);
1.308 +}
1.309 +#endif
1.310 +
1.311 +#ifdef __SYMBIAN32__
1.312 +template <class _CharT, class _OutputIter>
1.313 +_OutputIter _STLP_CALL
1.314 +__put_integer(char* __buf, char* __iend, _OutputIter __s,
1.315 + ios_base& __f,
1.316 + ios_base::fmtflags __flags, _CharT __fill)
1.317 +{
1.318 + locale __loc = __f.getloc();
1.319 + const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
1.320 + //const ctype<wchar_t>& __ct = *(const ctype<wchar_t>*)__f._M_ctype_facet();
1.321 +
1.322 + _CharT __xplus = '+';
1.323 + _CharT __xminus = '-';
1.324 +
1.325 + _CharT __wbuf[64];
1.326 +
1.327 + ptrdiff_t __len = __iend - __buf;
1.328 + _CharT* __eend = __wbuf + __len;
1.329 +
1.330 +
1.331 + const numpunct<char>& __np = use_facet<numpunct<char> >(__loc);
1.332 + const string& __grouping = __np.grouping();
1.333 +
1.334 + //const numpunct<wchar_t>& __np = *(const numpunct<wchar_t>*)__f._M_numpunct_facet();
1.335 + // const string& __grouping = __f._M_grouping();
1.336 +
1.337 + if (!__grouping.empty()) {
1.338 + int __basechars;
1.339 + if (__flags & ios_base::showbase)
1.340 + switch (__flags & ios_base::basefield) {
1.341 + case ios_base::hex: __basechars = 2; break;
1.342 + case ios_base::oct: __basechars = 1; break;
1.343 + default: __basechars = 0;
1.344 + }
1.345 + else
1.346 + __basechars = 0;
1.347 +
1.348 + __len = __insert_grouping(__buf, __iend, __grouping, __np.thousands_sep(),
1.349 + __ct.narrow( __xplus, '+'), __ct.narrow(__xminus, '-'), __basechars);
1.350 + __ct.widen(__buf, __iend, __wbuf);
1.351 +
1.352 + }
1.353 +
1.354 + return __copy_integer_and_fill(__wbuf, __len, __s,
1.355 + __flags, __f.width(0), __fill, __xplus, __xminus);
1.356 +}
1.357 +
1.358 +
1.359 +#endif
1.360 +// Helper function for char
1.361 +template <class _OutputIter>
1.362 +_OutputIter _STLP_CALL
1.363 +__put_integer(char* __buf, char* __iend, _OutputIter __s,
1.364 + ios_base& __f, ios_base::fmtflags __flags, char __fill)
1.365 +{
1.366 + ptrdiff_t __len = __iend - __buf;
1.367 + char __grpbuf[64];
1.368 +
1.369 + // const numpunct<char>& __np = use_facet<numpunct<char> >(__f.getloc());
1.370 + // const string& __grouping = __np.grouping();
1.371 +
1.372 + const numpunct<char>& __np = *(const numpunct<char>*)__f._M_numpunct_facet();
1.373 +// const string& __grouping = __f._M_grouping(); //stdcxx fix, 17/1/07
1.374 + const string& __grouping = __np.grouping();
1.375 +
1.376 + if (!__grouping.empty()) {
1.377 + int __basechars;
1.378 + if (__flags & ios_base::showbase)
1.379 + switch (__flags & ios_base::basefield) {
1.380 + case ios_base::hex: __basechars = 2; break;
1.381 + case ios_base::oct: __basechars = 1; break;
1.382 + default: __basechars = 0;
1.383 + }
1.384 + else
1.385 + __basechars = 0;
1.386 +
1.387 + // make sure there is room at the end of the buffer
1.388 + // we pass to __insert_grouping
1.389 +
1.390 + copy(__buf, __iend, (char *) __grpbuf);
1.391 + __buf = __grpbuf;
1.392 + __iend = __grpbuf + __len;
1.393 + __len = __insert_grouping(__buf, __iend, __grouping, __np.thousands_sep(),
1.394 + '+', '-', __basechars);
1.395 + }
1.396 +
1.397 + return __copy_integer_and_fill(__buf, __len, __s, __flags, __f.width(0), __fill, '+', '-');
1.398 +}
1.399 +
1.400 +#ifdef _STLP_LONG_LONG
1.401 +typedef _STLP_LONG_LONG __max_int_t;
1.402 +typedef unsigned _STLP_LONG_LONG __umax_int_t;
1.403 +#else
1.404 +typedef long __max_int_t;
1.405 +typedef unsigned long __umax_int_t;
1.406 +#endif
1.407 +
1.408 +extern _STLP_DECLSPEC const char* get_hex_char_table_lo();
1.409 +extern _STLP_DECLSPEC const char* get_hex_char_table_hi();
1.410 +
1.411 +template <class _Integer>
1.412 +inline char* _STLP_CALL
1.413 +__write_decimal_backward(char* __ptr, _Integer __x, ios_base::fmtflags __flags, const __true_type& /* is_signed */)
1.414 +{
1.415 + const bool __negative = __x < 0 ;
1.416 + __max_int_t __temp = __x;
1.417 + __umax_int_t __utemp = __negative?-__temp:__temp;
1.418 +
1.419 + for (; __utemp != 0; __utemp /= 10)
1.420 + *--__ptr = (int)(__utemp % 10) + '0';
1.421 + // put sign if needed or requested
1.422 + if (__negative)
1.423 + *--__ptr = '-';
1.424 + else if (__flags & ios_base::showpos)
1.425 + *--__ptr = '+';
1.426 + return __ptr;
1.427 +}
1.428 +
1.429 +template <class _Integer>
1.430 +inline char* _STLP_CALL
1.431 +__write_decimal_backward(char* __ptr, _Integer __x, ios_base::fmtflags __flags, const __false_type& /* is_signed */)
1.432 +{
1.433 + for (; __x != 0; __x /= 10)
1.434 + *--__ptr = (int)(__x % 10) + '0';
1.435 + // put sign if requested
1.436 + if (__flags & ios_base::showpos)
1.437 + *--__ptr = '+';
1.438 + return __ptr;
1.439 +}
1.440 +
1.441 +template <class _Integer>
1.442 +char* _STLP_CALL
1.443 +__write_integer_backward(char* __buf, ios_base::fmtflags __flags, _Integer __x)
1.444 +{
1.445 + char* __ptr = __buf;
1.446 + __umax_int_t __temp;
1.447 +
1.448 + if (__x == 0) {
1.449 + *--__ptr = '0';
1.450 + if ((__flags & ios_base::showpos) && ( (__flags & (ios_base::hex | ios_base::oct)) == 0 ))
1.451 + *--__ptr = '+';
1.452 + }
1.453 + else {
1.454 +
1.455 + switch (__flags & ios_base::basefield) {
1.456 + case ios_base::oct:
1.457 + __temp = __x;
1.458 + // if the size of integer is less than 8, clear upper part
1.459 + if ( sizeof(__x) < 8 && sizeof(__umax_int_t) >= 8 )
1.460 + __temp &= 0xFFFFFFFF;
1.461 +
1.462 + for (; __temp != 0; __temp >>=3)
1.463 + *--__ptr = (((unsigned)__temp)& 0x7) + '0';
1.464 +
1.465 + // put leading '0' is showbase is set
1.466 + if (__flags & ios_base::showbase)
1.467 + *--__ptr = '0';
1.468 + break;
1.469 + case ios_base::hex:
1.470 + {
1.471 + const char* __table_ptr = (__flags & ios_base::uppercase) ?
1.472 + get_hex_char_table_hi() : get_hex_char_table_lo();
1.473 + __temp = __x;
1.474 + // if the size of integer is less than 8, clear upper part
1.475 + if ( sizeof(__x) < 8 && sizeof(__umax_int_t) >= 8 )
1.476 + __temp &= 0xFFFFFFFF;
1.477 +
1.478 + for (; __temp != 0; __temp >>=4)
1.479 + *--__ptr = __table_ptr[((unsigned)__temp & 0xF)];
1.480 +
1.481 + if (__flags & ios_base::showbase) {
1.482 + *--__ptr = __table_ptr[16];
1.483 + *--__ptr = '0';
1.484 + }
1.485 + }
1.486 + break;
1.487 + default:
1.488 + {
1.489 +#if defined(__HP_aCC) && (__HP_aCC == 1)
1.490 + bool _IsSigned = !((_Integer)-1 > 0);
1.491 + if (_IsSigned)
1.492 + __ptr = __write_decimal_backward(__ptr, __x, __flags, __true_type() );
1.493 + else
1.494 + __ptr = __write_decimal_backward(__ptr, __x, __flags, __false_type() );
1.495 +#else
1.496 + typedef typename __bool2type<numeric_limits<_Integer>::is_signed>::_Ret _IsSigned;
1.497 + __ptr = __write_decimal_backward(__ptr, __x, __flags, _IsSigned());
1.498 +# endif
1.499 + }
1.500 + break;
1.501 + }
1.502 + }
1.503 + // return pointer to beginning of the string
1.504 + return __ptr;
1.505 +}
1.506 +
1.507 +//
1.508 +// num_put<>
1.509 +//
1.510 +
1.511 +# if ( _STLP_STATIC_TEMPLATE_DATA > 0 )
1.512 +# if !defined(__LIBSTD_CPP_SYMBIAN32_WSD__) && !defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
1.513 +template <class _CharT, class _OutputIterator>
1.514 +locale::id num_put<_CharT, _OutputIterator>::id;
1.515 +#endif
1.516 +# else /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */
1.517 +
1.518 +typedef num_put<char, const char*> num_put_char;
1.519 +typedef num_put<char, char*> num_put_char_2;
1.520 +typedef num_put<char, ostreambuf_iterator<char, char_traits<char> > > num_put_char_3;
1.521 +typedef num_put<char, back_insert_iterator<string> > num_put_char_4;
1.522 +
1.523 +#ifndef __SYMBIAN32__
1.524 +__DECLARE_INSTANCE(locale::id, num_put_char::id, );
1.525 +__DECLARE_INSTANCE(locale::id, num_put_char_2::id, );
1.526 +__DECLARE_INSTANCE(locale::id, num_put_char_3::id, );
1.527 +#endif
1.528 +
1.529 +# ifndef _STLP_NO_WCHAR_T
1.530 +
1.531 +typedef num_put<wchar_t, const wchar_t*> num_put_wchar_t;
1.532 +typedef num_put<wchar_t, wchar_t*> num_put_wchar_t_2;
1.533 +typedef num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > num_put_wchar_t_3;
1.534 +
1.535 +#ifndef __SYMBIAN32__
1.536 +__DECLARE_INSTANCE(locale::id, num_put_wchar_t::id, );
1.537 +__DECLARE_INSTANCE(locale::id, num_put_wchar_t_2::id, );
1.538 +__DECLARE_INSTANCE(locale::id, num_put_wchar_t_3::id, );
1.539 +#endif
1.540 +
1.541 +# endif
1.542 +
1.543 +# endif /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */
1.544 +
1.545 +// issue 118
1.546 +
1.547 +# ifndef _STLP_NO_BOOL
1.548 +
1.549 +template <class _CharT, class _OutputIter>
1.550 +_OutputIter
1.551 +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f,
1.552 + char_type __fill, bool __val) const {
1.553 + if (!(__f.flags() & ios_base::boolalpha))
1.554 + return this->do_put(__s, __f, __fill, __STATIC_CAST(long,__val));
1.555 +
1.556 + locale __loc = __f.getloc();
1.557 + typedef numpunct<_CharT> _Punct;
1.558 + const _Punct& __np = use_facet<_Punct>(__loc);
1.559 +
1.560 + //const numpunct<_CharT>& __np = *(const numpunct<_CharT>*)__f._M_numpunct_facet();
1.561 +
1.562 + basic_string<_CharT> __str = __val ? __np.truename() : __np.falsename();
1.563 +
1.564 + // Reuse __copy_integer_and_fill. Since internal padding makes no
1.565 + // sense for bool, though, make sure we use something else instead.
1.566 + // The last two argument to __copy_integer_and_fill are dummies.
1.567 + ios_base::fmtflags __flags = __f.flags();
1.568 + if ((__flags & ios_base::adjustfield) == ios_base::internal)
1.569 + __flags = (__flags & ~ios_base::adjustfield) | ios_base::right;
1.570 +
1.571 + return __copy_integer_and_fill(__str.c_str(), __str.size(), __s,
1.572 + __flags, __f.width(0), __fill,
1.573 + (_CharT) 0, (_CharT) 0);
1.574 +}
1.575 +
1.576 +# endif
1.577 +
1.578 +template <class _CharT, class _OutputIter>
1.579 +_OutputIter
1.580 +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
1.581 + long __val) const {
1.582 +
1.583 + char __buf[64]; // Large enough for a base 8 64-bit integer,
1.584 + // plus any necessary grouping.
1.585 + ios_base::fmtflags __flags = __f.flags();
1.586 + char* __ibeg = __write_integer_backward((char*)__buf+64, __flags, __val);
1.587 + return __put_integer(__ibeg, (char*)__buf+64, __s, __f, __flags, __fill);
1.588 +}
1.589 +
1.590 +
1.591 +template <class _CharT, class _OutputIter>
1.592 +_OutputIter
1.593 +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
1.594 + unsigned long __val) const {
1.595 + char __buf[64]; // Large enough for a base 8 64-bit integer,
1.596 + // plus any necessary grouping.
1.597 +
1.598 + ios_base::fmtflags __flags = __f.flags();
1.599 + char* __ibeg = __write_integer_backward((char*)__buf+64, __flags, __val);
1.600 + return __put_integer(__ibeg, (char*)__buf+64, __s, __f, __flags, __fill);
1.601 +}
1.602 +
1.603 +template <class _CharT, class _OutputIter>
1.604 +_OutputIter
1.605 +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
1.606 + double __val) const {
1.607 + return _M_do_put_float(__s, __f, __fill, __val);
1.608 +}
1.609 +
1.610 +#ifndef _STLP_NO_LONG_DOUBLE
1.611 +template <class _CharT, class _OutputIter>
1.612 +_OutputIter
1.613 +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
1.614 + long double __val) const {
1.615 + return _M_do_put_float(__s, __f, __fill, __val);
1.616 +}
1.617 +#endif
1.618 +
1.619 +#ifdef _STLP_LONG_LONG
1.620 +template <class _CharT, class _OutputIter>
1.621 +_OutputIter
1.622 +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
1.623 + _STLP_LONG_LONG __val) const {
1.624 + char __buf[64]; // Large enough for a base 8 64-bit integer,
1.625 + // plus any necessary grouping.
1.626 +
1.627 + ios_base::fmtflags __flags = __f.flags();
1.628 + char* __ibeg = __write_integer_backward((char*)__buf+64, __flags, __val);
1.629 + return __put_integer(__ibeg, (char*)__buf+64, __s, __f, __flags, __fill);
1.630 +}
1.631 +
1.632 +template <class _CharT, class _OutputIter>
1.633 +_OutputIter
1.634 +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
1.635 + unsigned _STLP_LONG_LONG __val) const {
1.636 + char __buf[64]; // Large enough for a base 8 64-bit integer,
1.637 + // plus any necessary grouping.
1.638 +
1.639 + ios_base::fmtflags __flags = __f.flags();
1.640 + char* __ibeg = __write_integer_backward((char*)__buf+64, __flags, __val);
1.641 + return __put_integer(__ibeg, (char*)__buf+64, __s, __f, __flags, __fill);
1.642 +}
1.643 +
1.644 +#endif /* _STLP_LONG_LONG */
1.645 +
1.646 +
1.647 +// lib.facet.num.put.virtuals "12 For conversion from void* the specifier is %p."
1.648 +template <class _CharT, class _OutputIter>
1.649 +_OutputIter
1.650 +num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT /*__fill*/,
1.651 + const void* __val) const {
1.652 + //const ctype<_CharT>& __c_type = *(const ctype<_CharT>*)__f._M_ctype_facet();
1.653 + const ctype<_CharT>& __c_type = use_facet< ctype<_CharT> >(__f.getloc());
1.654 + ios_base::fmtflags __save_flags = __f.flags();
1.655 +
1.656 + __f.setf(ios_base::hex, ios_base::basefield);
1.657 + __f.setf(ios_base::showbase);
1.658 + __f.setf(ios_base::internal, ios_base::adjustfield);
1.659 + //__f.width((sizeof(void*) * 2) + 2); // digits in pointer type plus '0x' prefix //making output equal to linux.
1.660 +# if defined(_STLP_LONG_LONG) && !defined(__MRC__) //*ty 11/24/2001 - MrCpp can not cast from void* to long long
1.661 + _OutputIter result = this->do_put(__s, __f, __c_type.widen('0'), __REINTERPRET_CAST(unsigned _STLP_LONG_LONG,__val));
1.662 +# else
1.663 + _OutputIter result = this->do_put(__s, __f, __c_type.widen('0'), __REINTERPRET_CAST(unsigned long,__val));
1.664 +# endif
1.665 + __f.flags(__save_flags);
1.666 + return result;
1.667 +}
1.668 +
1.669 +_STLP_END_NAMESPACE
1.670 +
1.671 +# endif /* _STLP_EXPOSE_STREAM_IMPLEMENTATION */
1.672 +
1.673 +#endif /* _STLP_NUM_PUT_C */
1.674 +
1.675 +// Local Variables:
1.676 +// mode:C++
1.677 +// End: