epoc32/include/stdapis/stlport/stl/_monetary.c
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
     1.1 --- a/epoc32/include/stdapis/stlport/stl/_monetary.c	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/stdapis/stlport/stl/_monetary.c	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,827 @@
     1.4 -_monetary.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_MONETARY_C
    1.25 +#define _STLP_MONETARY_C
    1.26 +
    1.27 +# ifndef _STLP_INTERNAL_MONETARY_H
    1.28 +#  include <stl/_monetary.h>
    1.29 +# endif
    1.30 +
    1.31 +# if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
    1.32 +
    1.33 +#ifndef _STLP_INTERNAL_IOS_H
    1.34 +# include <stl/_ios.h>
    1.35 +#endif
    1.36 +
    1.37 +#ifndef _STLP_INTERNAL_NUM_PUT_H
    1.38 +# include <stl/_num_put.h>
    1.39 +#endif
    1.40 +
    1.41 +#ifndef _STLP_INTERNAL_NUM_GET_H
    1.42 +# include <stl/_num_get.h>
    1.43 +#endif
    1.44 +
    1.45 +_STLP_BEGIN_NAMESPACE
    1.46 +
    1.47 +# if ( _STLP_STATIC_TEMPLATE_DATA > 0 )
    1.48 +# if !defined(__LIBSTD_CPP_SYMBIAN32_WSD__) && !defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
    1.49 +template <class _CharT, class _InputIterator>
    1.50 +locale::id money_get<_CharT, _InputIterator>::id;
    1.51 +
    1.52 +template <class _CharT, class _OutputIterator>
    1.53 +locale::id money_put<_CharT, _OutputIterator>::id;
    1.54 +#endif
    1.55 +# else /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */
    1.56 +
    1.57 +typedef money_get<char, const char*> money_get_char;
    1.58 +typedef money_put<char, char*> money_put_char;
    1.59 +typedef money_get<char, istreambuf_iterator<char, char_traits<char> > > money_get_char_2;
    1.60 +typedef money_put<char, ostreambuf_iterator<char, char_traits<char> > > money_put_char_2;
    1.61 +
    1.62 +#ifndef __SYMBIAN32__
    1.63 +__DECLARE_INSTANCE(locale::id, money_get_char::id, );
    1.64 +__DECLARE_INSTANCE(locale::id, money_put_char::id, );
    1.65 +__DECLARE_INSTANCE(locale::id, money_get_char_2::id, );
    1.66 +__DECLARE_INSTANCE(locale::id, money_put_char_2::id, );
    1.67 +#endif
    1.68 +
    1.69 +# ifndef _STLP_NO_WCHAR_T
    1.70 +
    1.71 +typedef money_get<wchar_t, const wchar_t*> money_get_wchar_t;
    1.72 +typedef money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > money_get_wchar_t_2;
    1.73 +typedef money_put<wchar_t, wchar_t*> money_put_wchar_t;
    1.74 +typedef money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > money_put_wchar_t_2;
    1.75 +
    1.76 +#ifndef __SYMBIAN32__
    1.77 +__DECLARE_INSTANCE(locale::id, money_get_wchar_t::id, );
    1.78 +__DECLARE_INSTANCE(locale::id, money_put_wchar_t::id, );
    1.79 +__DECLARE_INSTANCE(locale::id, money_get_wchar_t_2::id, );
    1.80 +__DECLARE_INSTANCE(locale::id, money_put_wchar_t_2::id, );
    1.81 +#endif
    1.82 +
    1.83 +# endif
    1.84 +# endif /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */
    1.85 +
    1.86 +// money_get facets
    1.87 +
    1.88 +
    1.89 +// helper functions for do_get
    1.90 +template <class _InIt1, class _InIt2>
    1.91 +pair<_InIt1, bool> __get_string(_InIt1 __first,     _InIt1 __last,
    1.92 +                               _InIt2 __str_first, _InIt2 __str_last) {
    1.93 +  pair<_InIt1, _InIt2> __pr = mismatch(__first, __last, __str_first);
    1.94 +  return make_pair(__pr.first, __pr.second == __str_last);
    1.95 +}
    1.96 +
    1.97 +template <class _InIt, class _OuIt, class _CharT>
    1.98 +bool
    1.99 +__get_monetary_value(_InIt& __first, _InIt __last, _OuIt __stl_out,
   1.100 +                     const ctype<_CharT>& _c_type,
   1.101 +                     _CharT   __point,
   1.102 +                     int      __frac_digits,
   1.103 +                     _CharT __sep,
   1.104 +                     const string& __grouping,
   1.105 +                     bool&         __syntax_ok)
   1.106 +{
   1.107 +
   1.108 +	size_t __digits = 0;
   1.109 +
   1.110 +  if (__first == __last || !_c_type.is(ctype_base::digit, *__first))
   1.111 +    return false;
   1.112 +
   1.113 +  char __group_sizes[128];
   1.114 +  char* __group_sizes_end = __grouping.size() == 0 ? 0 : __group_sizes;
   1.115 +  char   __current_group_size = 0;
   1.116 +
   1.117 +  while (__first != __last) {
   1.118 +    if (_c_type.is(ctype_base::digit, *__first)) {
   1.119 +      ++__current_group_size;
   1.120 +      *__stl_out++ = *__first++;
   1.121 +	  __digits++;
   1.122 +    }
   1.123 +#ifdef __SYMBIAN32__
   1.124 +else if ( (__current_group_size)&&(__group_sizes_end) ){
   1.125 +#else
   1.126 +    else if (__group_sizes_end) {
   1.127 +#endif		
   1.128 +      if (*__first == __sep) {
   1.129 +	*__group_sizes_end++ = __current_group_size; 
   1.130 +	__current_group_size = 0;
   1.131 +	++__first;
   1.132 +      }
   1.133 +      else break;
   1.134 +    }
   1.135 +    else
   1.136 +      break;
   1.137 +  }
   1.138 +
   1.139 +  if (__grouping.size() == 0)
   1.140 +    __syntax_ok = true;
   1.141 +  else {
   1.142 +    if (__group_sizes_end != __group_sizes)
   1.143 +     *__group_sizes_end++ = __current_group_size; 
   1.144 +    
   1.145 +    __syntax_ok = __valid_grouping(__group_sizes, __group_sizes_end,
   1.146 +                                   __grouping.data(), __grouping.data()+ __grouping.size());  
   1.147 +    
   1.148 +    if (__first == __last || *__first != __point) {
   1.149 +      for (int __digits = 0; __digits != __frac_digits; ++__digits)
   1.150 +        *__stl_out++ = _CharT('0');
   1.151 +      return true; // OK not to have decimal point
   1.152 +    }
   1.153 +  }
   1.154 +//bug fix testcase_22427 - commented
   1.155 +//  ++__first; 
   1.156 +
   1.157 +
   1.158 +  //bug fix testcase_22427 - added if
   1.159 +
   1.160 +  if (__first != __last && *__first == __point && __frac_digits)
   1.161 +  {  	
   1.162 +	//bug fix testcase_22427 - commented
   1.163 +	++__first; 
   1.164 +	  while (__first != __last && _c_type.is(ctype_base::digit, *__first)) {
   1.165 +	      *__stl_out++ = *__first++;
   1.166 +	     ++__digits;
   1.167 +	  }
   1.168 +  }
   1.169 +
   1.170 +  //bug fix testcase_22427 - condition changed
   1.171 +//  __syntax_ok = __syntax_ok && (__digits == __frac_digits);
   1.172 +  
   1.173 + if(__digits == 0)
   1.174 +  	__syntax_ok = false;
   1.175 +
   1.176 +  return true;
   1.177 +}
   1.178 +
   1.179 +# ifndef _STLP_NO_LONG_DOUBLE
   1.180 +
   1.181 +//===== methods ======
   1.182 +template <class _CharT, class _InputIter>
   1.183 +_InputIter 
   1.184 +money_get<_CharT, _InputIter>::do_get(_InputIter __s, _InputIter  __end, bool  __intl,
   1.185 +				      ios_base&  __str, ios_base::iostate& __err,
   1.186 +				      long double& __units) const {
   1.187 +  string_type __buf;
   1.188 +  __s = do_get(__s, __end, __intl, __str, __err, __buf);
   1.189 +
   1.190 +  if (__err == ios_base::goodbit || __err == ios_base::eofbit) {
   1.191 +    __buf.push_back(0);
   1.192 +    typename string_type::iterator __b = __buf.begin(), __e = __buf.end();
   1.193 +    // Can't use atold, since it might be wchar_t. Don't get confused by name below :
   1.194 +    // it's perfectly capable of reading long double.
   1.195 +    __get_decimal_integer(__b, __e, __units);
   1.196 +  }
   1.197 +  if (__s == __end)
   1.198 +    __err |= ios_base::eofbit;
   1.199 +  return __s;
   1.200 +}
   1.201 +# endif
   1.202 +
   1.203 +template <class _CharT, class _InputIter>
   1.204 +_InputIter 
   1.205 +money_get<_CharT, _InputIter>::do_get(iter_type __s, 
   1.206 +				      iter_type  __end, bool  __intl,
   1.207 +				      ios_base&  __str, ios_base::iostate&  __err,
   1.208 +				      string_type& __digits) const {
   1.209 +	__err = 0;
   1.210 +  if (__s == __end) {
   1.211 +    __err |= ios_base::eofbit;
   1.212 +    return __s;
   1.213 +  }
   1.214 +
   1.215 +  typedef moneypunct<_CharT, false> _Punct;
   1.216 +  typedef moneypunct<_CharT, true>  _Punct_intl;
   1.217 +  typedef ctype<_CharT>             _Ctype;
   1.218 +#ifdef __SYMBIAN32__			
   1.219 +	bool		__isSignSympresent = false;
   1.220 +#endif			
   1.221 +
   1.222 + bool	__testvalid = true;
   1.223 +  locale __loc = __str.getloc();
   1.224 +  const _Punct&      __punct      = use_facet<_Punct>(__loc) ;
   1.225 +  const _Punct_intl& __punct_intl = use_facet<_Punct_intl>(__loc) ;
   1.226 +  const _Ctype&      __c_type      = use_facet<_Ctype>(__loc) ;
   1.227 +                   
   1.228 +  money_base::pattern __format = __intl ? __punct_intl.neg_format()
   1.229 +                                        : __punct.neg_format();
   1.230 +  string_type __ns = __intl ? __punct_intl.negative_sign()
   1.231 +                            : __punct.negative_sign();
   1.232 +  string_type __ps = __intl ? __punct_intl.positive_sign()
   1.233 +                            : __punct.positive_sign();
   1.234 +  string_type __sign  = __ps;
   1.235 +  int __i;
   1.236 +  bool __is_positive = true;
   1.237 +  bool __symbol_required = (__str.flags() & ios_base::showbase) !=0;
   1.238 +  string_type __buf;
   1.239 +  back_insert_iterator<string_type> __stl_out(__buf);
   1.240 +//  pair<iter_type, bool> __result;
   1.241 +
   1.242 +  for (__i = 0; __i < 4; ++__i) {
   1.243 +    switch (__format.field[__i]) {
   1.244 +    case (char) money_base::none:
   1.245 +#ifndef	__SYMBIAN32__
   1.246 +	  case (char) money_base::space:
   1.247 +#endif	  	
   1.248 +
   1.249 +      if (__i == 3) {
   1.250 +        //if (__c_type.is(ctype_base::space, *__s)) { //gnu buf fix, 22/12/06
   1.251 +        if((__s != __end) && (!__c_type.is(ctype_base::space, *__s)) && (__ps.size()<=1) && (__ns.size()<=1) ){
   1.252 +          __err = ios_base::failbit;
   1.253 +          return __s;
   1.254 +        }
   1.255 +       // break; //gnu bug fix 2/1/07
   1.256 +      }
   1.257 +      while (__s != __end && __c_type.is(ctype_base::space, *__s))
   1.258 +        ++__s;
   1.259 +      break;
   1.260 +#ifdef	__SYMBIAN32__	  
   1.261 +    case (char) money_base::space:
   1.262 +      if (!__c_type.is(ctype_base::space, *__s)) {
   1.263 +#ifdef __SYMBIAN32__      
   1.264 +      	if(!__isSignSympresent) //if no sign symbol present, space is not mandatory.
   1.265 +      		break;
   1.266 +#endif      	
   1.267 +        __err = ios_base::failbit;
   1.268 +        return __s;
   1.269 +      }
   1.270 +      ++__s;
   1.271 +      while (__s != __end && __c_type.is(ctype_base::space, *__s))
   1.272 +        ++__s;
   1.273 +      break;
   1.274 +#endif	  
   1.275 +    case money_base::symbol: {
   1.276 +      string_type __curs = __intl ? __punct_intl.curr_symbol()
   1.277 +                                : __punct.curr_symbol();
   1.278 +      pair<iter_type, bool>
   1.279 +      __result  = __get_string(__s, __end, __curs.begin(), __curs.end());
   1.280 +      if (!__result.second && __symbol_required)
   1.281 +        __err = ios_base::failbit;
   1.282 +      __s = __result.first;
   1.283 +      break;
   1.284 +    }
   1.285 +    case money_base::sign: {
   1.286 +      if (__s == __end) {
   1.287 +        if (__ps.size() == 0)
   1.288 +          break;
   1.289 +        if (__ns.size() == 0) {
   1.290 +          __is_positive = false;
   1.291 +	__sign  = __ns;
   1.292 +          break;
   1.293 +        }
   1.294 +        __err = ios_base::failbit;
   1.295 +        return __s;
   1.296 +      }
   1.297 +      else {
   1.298 +        if (__ps.size() == 0) {
   1.299 +          if (__ns.size() == 0)
   1.300 +            break;
   1.301 +          if (*__s == __ns[0]) {
   1.302 +            ++__s;
   1.303 +            __is_positive = false;
   1.304 +			__sign  = __ns;
   1.305 +#ifdef __SYMBIAN32__			
   1.306 +			__isSignSympresent = true;
   1.307 +#endif			
   1.308 +
   1.309 +            break;
   1.310 +          }
   1.311 +        //  __err = ios_base::failbit; //if ps !=0 and ns!=0, and no negative sign mean it is positive, not fail.
   1.312 +	  //          return __s;
   1.313 +	  break;
   1.314 +        } 
   1.315 +        else {
   1.316 +          if (*__s == __ps[0]) {
   1.317 +            ++__s;
   1.318 +#ifdef __SYMBIAN32__			
   1.319 +			__isSignSympresent = true;
   1.320 +#endif			
   1.321 +
   1.322 +            break;
   1.323 +          }
   1.324 +#ifdef	__SYMBIAN32__
   1.325 +	    if (__ns.size() == 0) //here positive have symbol,negative have no symbol
   1.326 +	    {
   1.327 +	    	__is_positive = false; // in this case if symbol not present means it is negative
   1.328 +	    	__sign = __ns;
   1.329 +	    	break;
   1.330 +	    }
   1.331 +            
   1.332 +#else          
   1.333 +          if (__ns.size() == 0)
   1.334 +            break;
   1.335 +#endif          
   1.336 +          if (*__s == __ns[0]) {
   1.337 +            ++__s;
   1.338 +            __is_positive = false;
   1.339 +			__sign  = __ns;
   1.340 +#ifdef __SYMBIAN32__			
   1.341 +			__isSignSympresent = true;
   1.342 +#endif			
   1.343 +            break;
   1.344 +          }
   1.345 +          __err = ios_base::failbit;
   1.346 +	  //          return __s;
   1.347 +        }
   1.348 +      }
   1.349 +      return __s;
   1.350 +      //      break;
   1.351 +    }
   1.352 +    case money_base::value: {
   1.353 +      _CharT __point = __intl ? __punct_intl.decimal_point()
   1.354 +                              : __punct.decimal_point();
   1.355 +      int __frac_digits = __intl ? __punct_intl.frac_digits()
   1.356 +                                 : __punct.frac_digits();
   1.357 +      string __grouping = __intl ? __punct_intl.grouping()
   1.358 +                                 : __punct.grouping();
   1.359 +      bool __syntax_ok = true;
   1.360 +
   1.361 +      bool __result;
   1.362 +
   1.363 +      _CharT __sep = __grouping.size() == 0 ? _CharT() : 
   1.364 +	__intl ? __punct_intl.thousands_sep() : __punct.thousands_sep();
   1.365 +
   1.366 +      __result = __get_monetary_value(__s, __end, __stl_out, __c_type,
   1.367 +                                      __point, __frac_digits,
   1.368 +                                      __sep,
   1.369 +                                      __grouping, __syntax_ok);      
   1.370 +
   1.371 +      if (!__syntax_ok)
   1.372 +        __err |= ios_base::failbit;
   1.373 +      if (!__result) {
   1.374 +        __err = ios_base::failbit;
   1.375 +        return __s;
   1.376 +      }
   1.377 +      break;
   1.378 +      
   1.379 +    }                           // Close money_base::value case
   1.380 +
   1.381 +
   1.382 +    }                           // Close switch statement
   1.383 +  }                             // Close for loop
   1.384 +
   1.385 +#ifndef __SYMBIAN32__ //find the given number pos or neg, required for cases where sign is present at string starting and ending
   1.386 +	do{
   1.387 +	bool type = true;
   1.388 +
   1.389 +	int si = __ps.size();
   1.390 +	for (int i = 1;i<__ps.size();i++)
   1.391 +		{
   1.392 +			if(__s[i-1]!=__ps[i])
   1.393 +			{
   1.394 +				type = false;
   1.395 +				break;
   1.396 +			}
   1.397 +		}
   1.398 +	
   1.399 +	if ((si!=0) && (type ==true))
   1.400 +	{
   1.401 +		__sign = __ps;
   1.402 +            break;
   1.403 +	}  
   1.404 +          if (__ns.size() == 0)
   1.405 +            break;
   1.406 +	type = true;
   1.407 +	for (int i =1;i<__ns.size();i++)
   1.408 +		{
   1.409 +			if(__s[i-1]!=__ns[i])
   1.410 +			{
   1.411 +				type = false;
   1.412 +				break;
   1.413 +			}
   1.414 +		}
   1.415 +          if (type ==true) {
   1.416 +            __is_positive = false;
   1.417 +		__sign = __ns;
   1.418 +            break;
   1.419 +          }
   1.420 +	}while(0);
   1.421 +
   1.422 +#endif
   1.423 +
   1.424 +
   1.425 +#ifdef __SYMBIAN32__
   1.426 +// Need to get the rest of the sign characters, if they exist.
   1.427 +      if (__sign.size() > 1)
   1.428 +        {
   1.429 +          int __len = __sign.size();
   1.430 +          int __i = 1;
   1.431 +	  char_type __c = *__s;
   1.432 +	  char_type __eol = '\0';
   1.433 +          for (; __c != __eol && __i < __len; __i++)
   1.434 +          	{
   1.435 +            	if (__s != __end)
   1.436 +              	__c = *(++__s);
   1.437 +            	
   1.438 +          }
   1.439 +		  //checking sign completely extracted successfully
   1.440 +		 
   1.441 +          if (__i != __len)
   1.442 +            __testvalid = false;
   1.443 +        }
   1.444 +
   1.445 +#endif
   1.446 +
   1.447 +  if (__is_positive) {
   1.448 +    if (__ps.size() > 1) {
   1.449 +#ifndef __SYMBIAN32__		
   1.450 +      pair<_InputIter, bool>
   1.451 +        __result = __get_string(__s, __end, __ps.begin() + 1, __ps.end());
   1.452 +      __s = __result.first;
   1.453 +      if (!__result.second)
   1.454 +	__err |= ios::failbit;
   1.455 +#endif
   1.456 +	if(!__testvalid)
   1.457 +		__err |= ios::failbit;
   1.458 +    }
   1.459 +    if (!(__err & ios_base::failbit))
   1.460 +      __digits = __buf;
   1.461 +  }
   1.462 +  else {
   1.463 +    if (__ns.size() > 1) {
   1.464 +#ifndef __SYMBIAN32__		
   1.465 +      pair<_InputIter, bool>
   1.466 +        __result = __get_string(__s, __end, __ns.begin() + 1, __ns.end());
   1.467 +      __s = __result.first;
   1.468 +      if (!__result.second)
   1.469 +	__err |= ios::failbit;
   1.470 +#endif
   1.471 +	if(!__testvalid)
   1.472 +		__err |= ios::failbit;
   1.473 +    }
   1.474 +    if (!(__err & ios::failbit) && (__ns == __sign)) {
   1.475 +      __buf.insert(__buf.begin(),__c_type.widen('-'));      
   1.476 +    }
   1.477 +#ifdef __SYMBIAN32__	
   1.478 +  if (!(__err & ios_base::failbit))
   1.479 +      __digits = __buf;	
   1.480 +#else  
   1.481 +   __digits = __buf;	
   1.482 +#endif
   1.483 +  }
   1.484 +  if (__s == __end)
   1.485 +    __err |= ios::eofbit;
   1.486 +
   1.487 +  return __s;
   1.488 +}
   1.489 +
   1.490 +// money_put facets
   1.491 +
   1.492 +template <class _CharT, class _OutputIter>
   1.493 +_OutputIter
   1.494 +money_put<_CharT, _OutputIter>
   1.495 + ::do_put(_OutputIter __s, bool __intl, ios_base& __str,
   1.496 +          char_type __fill,
   1.497 +          const string_type& __digits) const { 
   1.498 +  typedef ctype<_CharT>             _Ctype;
   1.499 +  typedef moneypunct<_CharT, false> _Punct;
   1.500 +  typedef moneypunct<_CharT, true>  _Punct_intl;
   1.501 +
   1.502 +  locale __loc = __str.getloc();
   1.503 +  const _Ctype&      __c_type      = use_facet<_Ctype>(__loc) ;
   1.504 +  const _Punct&      __punct      = use_facet<_Punct>(__loc) ;
   1.505 +  const _Punct_intl& __punct_intl = use_facet<_Punct_intl>(__loc) ;
   1.506 +
   1.507 +  // some special characters
   1.508 +
   1.509 +  char_type __minus = __c_type.widen('-');
   1.510 +  char_type __plus  = __c_type.widen('+');
   1.511 +  char_type __space = __c_type.widen(' ');
   1.512 +  char_type __zero  = __c_type.widen('0');
   1.513 +  char_type __point = __intl ? __c_type.widen(__punct_intl.decimal_point())
   1.514 +			     : __c_type.widen(__punct.decimal_point());
   1.515 +
   1.516 +  char_type __sep = __intl ? __punct_intl.thousands_sep()
   1.517 +			   : __punct     .thousands_sep();
   1.518 +
   1.519 +  string __grouping = __intl ? __punct_intl.grouping()
   1.520 +		             : __punct     .grouping();
   1.521 +				
   1.522 +  int __frac_digits      = __intl ? __punct_intl.frac_digits() 
   1.523 +                                  : __punct.frac_digits();
   1.524 +
   1.525 +  string_type __curr_sym = __intl ? __punct_intl.curr_symbol() 
   1.526 +                                  : __punct.curr_symbol();
   1.527 +
   1.528 +    // if there are no digits we are going to return __s.  If there
   1.529 +    // are digits, but not enough to fill the frac_digits, we are
   1.530 +    // going to add zeros.  I don't know whether this is right or
   1.531 +    // not.
   1.532 +
   1.533 +  if (__digits.size() == 0) 
   1.534 +    return __s;
   1.535 +
   1.536 +  typename string_type::const_iterator __digits_first = __digits.begin();
   1.537 +  typename string_type::const_iterator __digits_last  = __digits.end();
   1.538 +
   1.539 +  bool __is_negative = *__digits_first == __minus;
   1.540 +  if (__is_negative)
   1.541 +    ++__digits_first;
   1.542 +
   1.543 +  string_type __sign = __intl ?
   1.544 +			 __is_negative ? __punct_intl.negative_sign()
   1.545 +				       : __punct_intl.positive_sign()
   1.546 +			      :
   1.547 +			 __is_negative ? __punct.negative_sign()
   1.548 +				       : __punct.positive_sign();
   1.549 +  typename string_type::const_iterator __cp = __digits_first;
   1.550 +  while (__cp != __digits_last && __c_type.is(ctype_base::digit, *__cp))
   1.551 +    ++__cp;
   1.552 +  if (__cp == __digits_first)
   1.553 +    return __s;
   1.554 +  __digits_last = __cp;
   1.555 +
   1.556 +  // If grouping is required, we make a copy of __digits and
   1.557 +  // insert the grouping.
   1.558 +
   1.559 +  // To handle the fractional digits, we augment the first group
   1.560 +  // by frac_digits.  If there is only one group, we need first
   1.561 +  // to duplicate it.
   1.562 +
   1.563 +  string_type __new_digits(__digits_first, __digits_last);
   1.564 +#ifdef	__SYMBIAN32__
   1.565 +	int __numberofseperators = 0;
   1.566 +	if (__grouping.size()>0)
   1.567 +	__numberofseperators = (__new_digits.size()/__grouping[0])+1;
   1.568 +	else
   1.569 +		__numberofseperators = 0;
   1.570 +  __new_digits.resize(__new_digits.size()+__numberofseperators);
   1.571 +#endif  
   1.572 +  if (__grouping.size() != 0) {
   1.573 +    if (__grouping.size() == 1)
   1.574 +      __grouping.push_back(__grouping[0]);
   1.575 +    __grouping[0] += __frac_digits;
   1.576 +    _CharT* __data_ptr = __CONST_CAST(_CharT*,__new_digits.data());
   1.577 +    _CharT* __data_end = __data_ptr + __new_digits.size();
   1.578 +    
   1.579 +    
   1.580 +    ptrdiff_t __value_length = __insert_grouping(__data_ptr,
   1.581 +#ifdef	__SYMBIAN32__	    
   1.582 +	  				         __data_end-__numberofseperators,
   1.583 +#else
   1.584 +							__data_end,
   1.585 +#endif	  				         
   1.586 +					         __grouping,
   1.587 +					         __sep,
   1.588 +					         __plus, __minus, 0);
   1.589 +    __digits_first = __new_digits.begin();
   1.590 +    __digits_last  = __digits_first + __value_length;
   1.591 +  }
   1.592 +
   1.593 +  // Determine the amount of padding required, if any.  
   1.594 +#ifdef	__SYMBIAN32__
   1.595 +	  int __width        = __str.width(); //width returns signed value.
   1.596 +#else    
   1.597 +  size_t __width        = __str.width();
   1.598 +#endif
   1.599 +
   1.600 +#if defined(_STLP_DEBUG) && (defined(__HP_aCC) || (__HP_aCC <= 1))
   1.601 +  size_t __value_length = operator -(__digits_last, __digits_first);
   1.602 +#else
   1.603 +  size_t __value_length = __digits_last - __digits_first;
   1.604 +#endif
   1.605 +
   1.606 +  size_t __length       = __value_length;
   1.607 +      
   1.608 +  __length += __sign.size();
   1.609 +  if (__frac_digits != 0)
   1.610 +    ++__length;
   1.611 +
   1.612 +  bool __generate_curr = (__str.flags() & ios_base::showbase) !=0;
   1.613 +  if (__generate_curr)
   1.614 +    __length += __curr_sym.size();
   1.615 +  money_base::pattern __format =
   1.616 +    __intl ? (__is_negative ? __punct_intl.neg_format() 
   1.617 +                            : __punct_intl.pos_format())
   1.618 +           : (__is_negative ? __punct.neg_format() 
   1.619 +                            : __punct.pos_format());
   1.620 +  {
   1.621 +    for (int __i = 0; __i < 4; ++__i)
   1.622 +      if (__format.field[__i] == (char) money_base::space)
   1.623 +        ++__length;
   1.624 +  }
   1.625 +
   1.626 +  size_t __fill_amt = (int)__length < __width ? __width - __length : 0;
   1.627 +
   1.628 +  ios_base::fmtflags __fill_pos = __str.flags() & ios_base::adjustfield;
   1.629 +
   1.630 +  if (__fill_amt != 0 &&
   1.631 +      !(__fill_pos & (ios_base::left | ios_base::internal)))
   1.632 +    __s = fill_n(__s, __fill_amt, __fill);
   1.633 +    
   1.634 +  for (int __i = 0; __i < 4; ++__i) {
   1.635 +    char __ffield = __format.field[__i];
   1.636 +    if (__ffield == money_base::none) {
   1.637 +      if (__fill_amt != 0 && __fill_pos == ios_base::internal)
   1.638 +        __s = fill_n(__s, __fill_amt, __fill);
   1.639 +    }
   1.640 +    else if (__ffield == money_base::space) {
   1.641 +#ifdef __SYMBIAN32__
   1.642 +	if(__fill != __space)
   1.643 +		*__s++ = __fill;
   1.644 +	else
   1.645 +#endif		
   1.646 +      *__s++ = __space;
   1.647 +      if (__fill_amt != 0 && __fill_pos == ios_base::internal)
   1.648 +        __s = fill_n(__s, __fill_amt, __fill);
   1.649 +    }
   1.650 +    else if (__ffield == money_base::symbol) {
   1.651 +      if (__generate_curr)
   1.652 +        __s = copy(__curr_sym.begin(), __curr_sym.end(), __s);
   1.653 +    }
   1.654 +    else if (__ffield == money_base::sign) {
   1.655 +      if (__sign.size() != 0)
   1.656 +        *__s++ = __sign[0];
   1.657 +    }
   1.658 +    else if (__ffield == money_base::value) {
   1.659 +      if (__frac_digits == 0)
   1.660 +        __s = copy(__digits_first, __digits_last, __s);
   1.661 +      else {
   1.662 +        if ((int)__value_length <= __frac_digits) {
   1.663 +          *__s++ = __point;
   1.664 +          __s = copy(__digits_first, __digits_last, __s);
   1.665 +          __s =  fill_n(__s, __frac_digits - __value_length, __zero);
   1.666 +        }
   1.667 +        else {
   1.668 +#ifdef	__SYMBIAN32__
   1.669 +	  if (__frac_digits>0)
   1.670 +	  	{
   1.671 +#endif	  	
   1.672 +          __s = copy(__digits_first, __digits_last - __frac_digits, __s);
   1.673 +          if (__frac_digits != 0) {
   1.674 +            *__s++ = __point;
   1.675 +            __s = copy(__digits_last - __frac_digits, __digits_last, __s);
   1.676 +#ifdef	__SYMBIAN32__
   1.677 +	          }
   1.678 +#endif			  
   1.679 +          }
   1.680 +        }
   1.681 +      }
   1.682 +    }
   1.683 +  } // Close for loop
   1.684 +
   1.685 +  // Ouput rest of sign if necessary.
   1.686 +
   1.687 +  if (__sign.size() > 1)
   1.688 +    __s = copy(__sign.begin() + 1, __sign.end(), __s);
   1.689 +  if (!(__fill_pos & (ios_base::right | ios_base::internal)))
   1.690 +    __s = fill_n(__s, __fill_amt, __fill);
   1.691 +  
   1.692 +#ifdef __SYMBIAN32__
   1.693 +	__str.width(0);
   1.694 +#endif
   1.695 +  return __s;
   1.696 +}
   1.697 +
   1.698 +#ifdef	__SYMBIAN32__
   1.699 +/*
   1.700 +template<class _CharT, bool _International>//__DFL_NON_TYPE_PARAM(bool, _International, false)>
   1.701 +moneypunct<_CharT, _International>::moneypunct(size_t __refs = 0):_BaseFacet(__refs)
   1.702 +{ 
   1.703 +	
   1.704 +	
   1.705 +}*/
   1.706 +
   1.707 +template<class _CharT, bool _International>//__DFL_NON_TYPE_PARAM(bool, _International, false)>
   1.708 +_CharT        moneypunct<_CharT,_International>::do_decimal_point() const
   1.709 +{
   1.710 +	return _CharT('.');
   1.711 +}
   1.712 +
   1.713 +template<class _CharT, bool _International>//__DFL_NON_TYPE_PARAM(bool, _International, false)>
   1.714 +_CharT        moneypunct<_CharT,_International>::do_thousands_sep() const
   1.715 +{
   1.716 +	return _CharT(',');
   1.717 +}
   1.718 +template<class _CharT, bool _International>//__DFL_NON_TYPE_PARAM(bool, _International, false)>
   1.719 +basic_string<_CharT>      moneypunct<_CharT,_International>::do_curr_symbol()   const
   1.720 +{
   1.721 +	return _M_currSym;
   1.722 +}
   1.723 +
   1.724 +template<class _CharT, bool _International>//__DFL_NON_TYPE_PARAM(bool, _International, false)>
   1.725 +basic_string<_CharT>      moneypunct<_CharT,_International>::do_positive_sign()   const
   1.726 +{
   1.727 +	return _M_psign;
   1.728 +}
   1.729 +
   1.730 +template<class _CharT, bool _International>//__DFL_NON_TYPE_PARAM(bool, _International, false)>
   1.731 +basic_string<_CharT>      moneypunct<_CharT,_International>::do_negative_sign()   const
   1.732 +{
   1.733 +	return _M_nsign;
   1.734 +}
   1.735 +
   1.736 +template<class _CharT, bool _International>//__DFL_NON_TYPE_PARAM(bool, _International, false)>
   1.737 +string      moneypunct<_CharT,_International>::do_grouping()   const
   1.738 +{
   1.739 +	return _M_group;
   1.740 +}
   1.741 +
   1.742 +template<class _CharT, bool _International>//__DFL_NON_TYPE_PARAM(bool, _International, false)>
   1.743 +money_base::pattern        moneypunct<_CharT,_International>::do_pos_format()   const
   1.744 +{
   1.745 +	return _M_pos_format;
   1.746 +}
   1.747 +
   1.748 +template<class _CharT, bool _International>//__DFL_NON_TYPE_PARAM(bool, _International, false)>
   1.749 +money_base::pattern        moneypunct<_CharT,_International>::do_neg_format()   const
   1.750 +{
   1.751 +	return _M_neg_format;
   1.752 +}
   1.753 +
   1.754 +template<class _CharT, bool _International>
   1.755 +int       moneypunct<_CharT,_International>::do_frac_digits()   const
   1.756 +{
   1.757 +	return 0;
   1.758 +}
   1.759 +
   1.760 +
   1.761 +//monetary_byname<any>
   1.762 +
   1.763 +template<class _CharT, bool _International>
   1.764 +_CharT moneypunct_byname<_CharT, _International>::do_decimal_point() const 
   1.765 +  {return _Locale_mon_decimal_pointE(_M_monetary);}
   1.766 +
   1.767 +template<class _CharT, bool _International>
   1.768 +_CharT moneypunct_byname<_CharT, _International>::do_thousands_sep() const
   1.769 +  {return _Locale_mon_thousands_sepE(_M_monetary);}
   1.770 +
   1.771 +template<class _CharT, bool _International>
   1.772 +string  moneypunct_byname<_CharT, _International>::do_grouping() const
   1.773 +  {return moneypunct<_CharT,_International>::_M_group;}
   1.774 +
   1.775 +template<class _CharT, bool _International>
   1.776 +basic_string<_CharT> moneypunct_byname<_CharT, _International>::do_curr_symbol() const
   1.777 +  {return moneypunct<_CharT,_International>::_M_currSym;}
   1.778 +
   1.779 +template<class _CharT, bool _International>
   1.780 +basic_string<_CharT> moneypunct_byname<_CharT, _International>::do_positive_sign() const
   1.781 +  {return moneypunct<_CharT,_International>::_M_psign;}
   1.782 +
   1.783 +template<class _CharT, bool _International>
   1.784 +basic_string<_CharT> moneypunct_byname<_CharT, _International>::do_negative_sign() const
   1.785 +  {return moneypunct<_CharT,_International>::_M_nsign;}
   1.786 +
   1.787 +template<class _CharT, bool _International>
   1.788 +int moneypunct_byname<_CharT, _International>::do_frac_digits() const 
   1.789 +  {return _Locale_int_frac_digitsE(_M_monetary);}
   1.790 +
   1.791 +template<class _CharT, bool _International>
   1.792 +void moneypunct_byname<_CharT, _International>::Convert_string2_string_chart(basic_string<_CharT> &dst, string src)
   1.793 +	{
   1.794 +		int length = src.length();
   1.795 +		const char* str = src.c_str();
   1.796 +		for(int i = 0; i<length;i++)
   1.797 +		{
   1.798 +			dst.append(1, (_CharT)*str++);
   1.799 +			
   1.800 +		}
   1.801 +			
   1.802 +	}
   1.803 +
   1.804 +template<class _CharT, bool _International>
   1.805 +moneypunct_byname<_CharT, _International>::moneypunct_byname(const char * name,
   1.806 +						  size_t refs):
   1.807 +  moneypunct<_CharT, _International>(refs),
   1.808 +  _M_monetary(__acquire_monetaryE(name))
   1.809 +{
   1.810 +  if (!_M_monetary)
   1.811 +    locale::_M_throw_runtime_error();
   1.812 +  
   1.813 +  		moneypunct<_CharT,_International>::_M_group = _Locale_mon_groupingE(_M_monetary);
   1.814 +		Convert_string2_string_chart(moneypunct<_CharT,_International>::_M_psign, _Locale_positive_signE(_M_monetary));
   1.815 +		Convert_string2_string_chart(moneypunct<_CharT,_International>::_M_nsign, _Locale_negative_signE(_M_monetary));
   1.816 +		Convert_string2_string_chart(moneypunct<_CharT,_International>::_M_currSym, _Locale_int_curr_symbolE(_M_monetary));
   1.817 +}
   1.818 +
   1.819 +template<class _CharT, bool _International>
   1.820 +moneypunct_byname<_CharT, _International>::~moneypunct_byname()
   1.821 +{
   1.822 +  __release_monetaryE(_M_monetary);
   1.823 +}
   1.824 +
   1.825 +
   1.826 +#endif
   1.827 +_STLP_END_NAMESPACE
   1.828 +
   1.829 +# endif /* EXPOSE */
   1.830 +
   1.831 +#endif /* _STLP_MONETARY_C */