epoc32/include/stdapis/stlport/stl/_monetary.c
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     1 /*
     2  * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
     3  *
     4  * Copyright (c) 1999
     5  * Silicon Graphics Computer Systems, Inc.
     6  *
     7  * Copyright (c) 1999 
     8  * Boris Fomitchev
     9  *
    10  * This material is provided "as is", with absolutely no warranty expressed
    11  * or implied. Any use is at your own risk.
    12  *
    13  * Permission to use or copy this software for any purpose is hereby granted 
    14  * without fee, provided the above notices are retained on all copies.
    15  * Permission to modify the code and to distribute modified code is granted,
    16  * provided the above notices are retained, and a notice that the code was
    17  * modified is included with the above copyright notice.
    18  *
    19  */ 
    20 #ifndef _STLP_MONETARY_C
    21 #define _STLP_MONETARY_C
    22 
    23 # ifndef _STLP_INTERNAL_MONETARY_H
    24 #  include <stl/_monetary.h>
    25 # endif
    26 
    27 # if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
    28 
    29 #ifndef _STLP_INTERNAL_IOS_H
    30 # include <stl/_ios.h>
    31 #endif
    32 
    33 #ifndef _STLP_INTERNAL_NUM_PUT_H
    34 # include <stl/_num_put.h>
    35 #endif
    36 
    37 #ifndef _STLP_INTERNAL_NUM_GET_H
    38 # include <stl/_num_get.h>
    39 #endif
    40 
    41 _STLP_BEGIN_NAMESPACE
    42 
    43 # if ( _STLP_STATIC_TEMPLATE_DATA > 0 )
    44 # if !defined(__LIBSTD_CPP_SYMBIAN32_WSD__) && !defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
    45 template <class _CharT, class _InputIterator>
    46 locale::id money_get<_CharT, _InputIterator>::id;
    47 
    48 template <class _CharT, class _OutputIterator>
    49 locale::id money_put<_CharT, _OutputIterator>::id;
    50 #endif
    51 # else /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */
    52 
    53 typedef money_get<char, const char*> money_get_char;
    54 typedef money_put<char, char*> money_put_char;
    55 typedef money_get<char, istreambuf_iterator<char, char_traits<char> > > money_get_char_2;
    56 typedef money_put<char, ostreambuf_iterator<char, char_traits<char> > > money_put_char_2;
    57 
    58 #ifndef __SYMBIAN32__
    59 __DECLARE_INSTANCE(locale::id, money_get_char::id, );
    60 __DECLARE_INSTANCE(locale::id, money_put_char::id, );
    61 __DECLARE_INSTANCE(locale::id, money_get_char_2::id, );
    62 __DECLARE_INSTANCE(locale::id, money_put_char_2::id, );
    63 #endif
    64 
    65 # ifndef _STLP_NO_WCHAR_T
    66 
    67 typedef money_get<wchar_t, const wchar_t*> money_get_wchar_t;
    68 typedef money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > money_get_wchar_t_2;
    69 typedef money_put<wchar_t, wchar_t*> money_put_wchar_t;
    70 typedef money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > money_put_wchar_t_2;
    71 
    72 #ifndef __SYMBIAN32__
    73 __DECLARE_INSTANCE(locale::id, money_get_wchar_t::id, );
    74 __DECLARE_INSTANCE(locale::id, money_put_wchar_t::id, );
    75 __DECLARE_INSTANCE(locale::id, money_get_wchar_t_2::id, );
    76 __DECLARE_INSTANCE(locale::id, money_put_wchar_t_2::id, );
    77 #endif
    78 
    79 # endif
    80 # endif /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */
    81 
    82 // money_get facets
    83 
    84 
    85 // helper functions for do_get
    86 template <class _InIt1, class _InIt2>
    87 pair<_InIt1, bool> __get_string(_InIt1 __first,     _InIt1 __last,
    88                                _InIt2 __str_first, _InIt2 __str_last) {
    89   pair<_InIt1, _InIt2> __pr = mismatch(__first, __last, __str_first);
    90   return make_pair(__pr.first, __pr.second == __str_last);
    91 }
    92 
    93 template <class _InIt, class _OuIt, class _CharT>
    94 bool
    95 __get_monetary_value(_InIt& __first, _InIt __last, _OuIt __stl_out,
    96                      const ctype<_CharT>& _c_type,
    97                      _CharT   __point,
    98                      int      __frac_digits,
    99                      _CharT __sep,
   100                      const string& __grouping,
   101                      bool&         __syntax_ok)
   102 {
   103 
   104 	size_t __digits = 0;
   105 
   106   if (__first == __last || !_c_type.is(ctype_base::digit, *__first))
   107     return false;
   108 
   109   char __group_sizes[128];
   110   char* __group_sizes_end = __grouping.size() == 0 ? 0 : __group_sizes;
   111   char   __current_group_size = 0;
   112 
   113   while (__first != __last) {
   114     if (_c_type.is(ctype_base::digit, *__first)) {
   115       ++__current_group_size;
   116       *__stl_out++ = *__first++;
   117 	  __digits++;
   118     }
   119 #ifdef __SYMBIAN32__
   120 else if ( (__current_group_size)&&(__group_sizes_end) ){
   121 #else
   122     else if (__group_sizes_end) {
   123 #endif		
   124       if (*__first == __sep) {
   125 	*__group_sizes_end++ = __current_group_size; 
   126 	__current_group_size = 0;
   127 	++__first;
   128       }
   129       else break;
   130     }
   131     else
   132       break;
   133   }
   134 
   135   if (__grouping.size() == 0)
   136     __syntax_ok = true;
   137   else {
   138     if (__group_sizes_end != __group_sizes)
   139      *__group_sizes_end++ = __current_group_size; 
   140     
   141     __syntax_ok = __valid_grouping(__group_sizes, __group_sizes_end,
   142                                    __grouping.data(), __grouping.data()+ __grouping.size());  
   143     
   144     if (__first == __last || *__first != __point) {
   145       for (int __digits = 0; __digits != __frac_digits; ++__digits)
   146         *__stl_out++ = _CharT('0');
   147       return true; // OK not to have decimal point
   148     }
   149   }
   150 //bug fix testcase_22427 - commented
   151 //  ++__first; 
   152 
   153 
   154   //bug fix testcase_22427 - added if
   155 
   156   if (__first != __last && *__first == __point && __frac_digits)
   157   {  	
   158 	//bug fix testcase_22427 - commented
   159 	++__first; 
   160 	  while (__first != __last && _c_type.is(ctype_base::digit, *__first)) {
   161 	      *__stl_out++ = *__first++;
   162 	     ++__digits;
   163 	  }
   164   }
   165 
   166   //bug fix testcase_22427 - condition changed
   167 //  __syntax_ok = __syntax_ok && (__digits == __frac_digits);
   168   
   169  if(__digits == 0)
   170   	__syntax_ok = false;
   171 
   172   return true;
   173 }
   174 
   175 # ifndef _STLP_NO_LONG_DOUBLE
   176 
   177 //===== methods ======
   178 template <class _CharT, class _InputIter>
   179 _InputIter 
   180 money_get<_CharT, _InputIter>::do_get(_InputIter __s, _InputIter  __end, bool  __intl,
   181 				      ios_base&  __str, ios_base::iostate& __err,
   182 				      long double& __units) const {
   183   string_type __buf;
   184   __s = do_get(__s, __end, __intl, __str, __err, __buf);
   185 
   186   if (__err == ios_base::goodbit || __err == ios_base::eofbit) {
   187     __buf.push_back(0);
   188     typename string_type::iterator __b = __buf.begin(), __e = __buf.end();
   189     // Can't use atold, since it might be wchar_t. Don't get confused by name below :
   190     // it's perfectly capable of reading long double.
   191     __get_decimal_integer(__b, __e, __units);
   192   }
   193   if (__s == __end)
   194     __err |= ios_base::eofbit;
   195   return __s;
   196 }
   197 # endif
   198 
   199 template <class _CharT, class _InputIter>
   200 _InputIter 
   201 money_get<_CharT, _InputIter>::do_get(iter_type __s, 
   202 				      iter_type  __end, bool  __intl,
   203 				      ios_base&  __str, ios_base::iostate&  __err,
   204 				      string_type& __digits) const {
   205 	__err = 0;
   206   if (__s == __end) {
   207     __err |= ios_base::eofbit;
   208     return __s;
   209   }
   210 
   211   typedef moneypunct<_CharT, false> _Punct;
   212   typedef moneypunct<_CharT, true>  _Punct_intl;
   213   typedef ctype<_CharT>             _Ctype;
   214 #ifdef __SYMBIAN32__			
   215 	bool		__isSignSympresent = false;
   216 #endif			
   217 
   218  bool	__testvalid = true;
   219   locale __loc = __str.getloc();
   220   const _Punct&      __punct      = use_facet<_Punct>(__loc) ;
   221   const _Punct_intl& __punct_intl = use_facet<_Punct_intl>(__loc) ;
   222   const _Ctype&      __c_type      = use_facet<_Ctype>(__loc) ;
   223                    
   224   money_base::pattern __format = __intl ? __punct_intl.neg_format()
   225                                         : __punct.neg_format();
   226   string_type __ns = __intl ? __punct_intl.negative_sign()
   227                             : __punct.negative_sign();
   228   string_type __ps = __intl ? __punct_intl.positive_sign()
   229                             : __punct.positive_sign();
   230   string_type __sign  = __ps;
   231   int __i;
   232   bool __is_positive = true;
   233   bool __symbol_required = (__str.flags() & ios_base::showbase) !=0;
   234   string_type __buf;
   235   back_insert_iterator<string_type> __stl_out(__buf);
   236 //  pair<iter_type, bool> __result;
   237 
   238   for (__i = 0; __i < 4; ++__i) {
   239     switch (__format.field[__i]) {
   240     case (char) money_base::none:
   241 #ifndef	__SYMBIAN32__
   242 	  case (char) money_base::space:
   243 #endif	  	
   244 
   245       if (__i == 3) {
   246         //if (__c_type.is(ctype_base::space, *__s)) { //gnu buf fix, 22/12/06
   247         if((__s != __end) && (!__c_type.is(ctype_base::space, *__s)) && (__ps.size()<=1) && (__ns.size()<=1) ){
   248           __err = ios_base::failbit;
   249           return __s;
   250         }
   251        // break; //gnu bug fix 2/1/07
   252       }
   253       while (__s != __end && __c_type.is(ctype_base::space, *__s))
   254         ++__s;
   255       break;
   256 #ifdef	__SYMBIAN32__	  
   257     case (char) money_base::space:
   258       if (!__c_type.is(ctype_base::space, *__s)) {
   259 #ifdef __SYMBIAN32__      
   260       	if(!__isSignSympresent) //if no sign symbol present, space is not mandatory.
   261       		break;
   262 #endif      	
   263         __err = ios_base::failbit;
   264         return __s;
   265       }
   266       ++__s;
   267       while (__s != __end && __c_type.is(ctype_base::space, *__s))
   268         ++__s;
   269       break;
   270 #endif	  
   271     case money_base::symbol: {
   272       string_type __curs = __intl ? __punct_intl.curr_symbol()
   273                                 : __punct.curr_symbol();
   274       pair<iter_type, bool>
   275       __result  = __get_string(__s, __end, __curs.begin(), __curs.end());
   276       if (!__result.second && __symbol_required)
   277         __err = ios_base::failbit;
   278       __s = __result.first;
   279       break;
   280     }
   281     case money_base::sign: {
   282       if (__s == __end) {
   283         if (__ps.size() == 0)
   284           break;
   285         if (__ns.size() == 0) {
   286           __is_positive = false;
   287 	__sign  = __ns;
   288           break;
   289         }
   290         __err = ios_base::failbit;
   291         return __s;
   292       }
   293       else {
   294         if (__ps.size() == 0) {
   295           if (__ns.size() == 0)
   296             break;
   297           if (*__s == __ns[0]) {
   298             ++__s;
   299             __is_positive = false;
   300 			__sign  = __ns;
   301 #ifdef __SYMBIAN32__			
   302 			__isSignSympresent = true;
   303 #endif			
   304 
   305             break;
   306           }
   307         //  __err = ios_base::failbit; //if ps !=0 and ns!=0, and no negative sign mean it is positive, not fail.
   308 	  //          return __s;
   309 	  break;
   310         } 
   311         else {
   312           if (*__s == __ps[0]) {
   313             ++__s;
   314 #ifdef __SYMBIAN32__			
   315 			__isSignSympresent = true;
   316 #endif			
   317 
   318             break;
   319           }
   320 #ifdef	__SYMBIAN32__
   321 	    if (__ns.size() == 0) //here positive have symbol,negative have no symbol
   322 	    {
   323 	    	__is_positive = false; // in this case if symbol not present means it is negative
   324 	    	__sign = __ns;
   325 	    	break;
   326 	    }
   327             
   328 #else          
   329           if (__ns.size() == 0)
   330             break;
   331 #endif          
   332           if (*__s == __ns[0]) {
   333             ++__s;
   334             __is_positive = false;
   335 			__sign  = __ns;
   336 #ifdef __SYMBIAN32__			
   337 			__isSignSympresent = true;
   338 #endif			
   339             break;
   340           }
   341           __err = ios_base::failbit;
   342 	  //          return __s;
   343         }
   344       }
   345       return __s;
   346       //      break;
   347     }
   348     case money_base::value: {
   349       _CharT __point = __intl ? __punct_intl.decimal_point()
   350                               : __punct.decimal_point();
   351       int __frac_digits = __intl ? __punct_intl.frac_digits()
   352                                  : __punct.frac_digits();
   353       string __grouping = __intl ? __punct_intl.grouping()
   354                                  : __punct.grouping();
   355       bool __syntax_ok = true;
   356 
   357       bool __result;
   358 
   359       _CharT __sep = __grouping.size() == 0 ? _CharT() : 
   360 	__intl ? __punct_intl.thousands_sep() : __punct.thousands_sep();
   361 
   362       __result = __get_monetary_value(__s, __end, __stl_out, __c_type,
   363                                       __point, __frac_digits,
   364                                       __sep,
   365                                       __grouping, __syntax_ok);      
   366 
   367       if (!__syntax_ok)
   368         __err |= ios_base::failbit;
   369       if (!__result) {
   370         __err = ios_base::failbit;
   371         return __s;
   372       }
   373       break;
   374       
   375     }                           // Close money_base::value case
   376 
   377 
   378     }                           // Close switch statement
   379   }                             // Close for loop
   380 
   381 #ifndef __SYMBIAN32__ //find the given number pos or neg, required for cases where sign is present at string starting and ending
   382 	do{
   383 	bool type = true;
   384 
   385 	int si = __ps.size();
   386 	for (int i = 1;i<__ps.size();i++)
   387 		{
   388 			if(__s[i-1]!=__ps[i])
   389 			{
   390 				type = false;
   391 				break;
   392 			}
   393 		}
   394 	
   395 	if ((si!=0) && (type ==true))
   396 	{
   397 		__sign = __ps;
   398             break;
   399 	}  
   400           if (__ns.size() == 0)
   401             break;
   402 	type = true;
   403 	for (int i =1;i<__ns.size();i++)
   404 		{
   405 			if(__s[i-1]!=__ns[i])
   406 			{
   407 				type = false;
   408 				break;
   409 			}
   410 		}
   411           if (type ==true) {
   412             __is_positive = false;
   413 		__sign = __ns;
   414             break;
   415           }
   416 	}while(0);
   417 
   418 #endif
   419 
   420 
   421 #ifdef __SYMBIAN32__
   422 // Need to get the rest of the sign characters, if they exist.
   423       if (__sign.size() > 1)
   424         {
   425           int __len = __sign.size();
   426           int __i = 1;
   427 	  char_type __c = *__s;
   428 	  char_type __eol = '\0';
   429           for (; __c != __eol && __i < __len; __i++)
   430           	{
   431             	if (__s != __end)
   432               	__c = *(++__s);
   433             	
   434           }
   435 		  //checking sign completely extracted successfully
   436 		 
   437           if (__i != __len)
   438             __testvalid = false;
   439         }
   440 
   441 #endif
   442 
   443   if (__is_positive) {
   444     if (__ps.size() > 1) {
   445 #ifndef __SYMBIAN32__		
   446       pair<_InputIter, bool>
   447         __result = __get_string(__s, __end, __ps.begin() + 1, __ps.end());
   448       __s = __result.first;
   449       if (!__result.second)
   450 	__err |= ios::failbit;
   451 #endif
   452 	if(!__testvalid)
   453 		__err |= ios::failbit;
   454     }
   455     if (!(__err & ios_base::failbit))
   456       __digits = __buf;
   457   }
   458   else {
   459     if (__ns.size() > 1) {
   460 #ifndef __SYMBIAN32__		
   461       pair<_InputIter, bool>
   462         __result = __get_string(__s, __end, __ns.begin() + 1, __ns.end());
   463       __s = __result.first;
   464       if (!__result.second)
   465 	__err |= ios::failbit;
   466 #endif
   467 	if(!__testvalid)
   468 		__err |= ios::failbit;
   469     }
   470     if (!(__err & ios::failbit) && (__ns == __sign)) {
   471       __buf.insert(__buf.begin(),__c_type.widen('-'));      
   472     }
   473 #ifdef __SYMBIAN32__	
   474   if (!(__err & ios_base::failbit))
   475       __digits = __buf;	
   476 #else  
   477    __digits = __buf;	
   478 #endif
   479   }
   480   if (__s == __end)
   481     __err |= ios::eofbit;
   482 
   483   return __s;
   484 }
   485 
   486 // money_put facets
   487 
   488 template <class _CharT, class _OutputIter>
   489 _OutputIter
   490 money_put<_CharT, _OutputIter>
   491  ::do_put(_OutputIter __s, bool __intl, ios_base& __str,
   492           char_type __fill,
   493           const string_type& __digits) const { 
   494   typedef ctype<_CharT>             _Ctype;
   495   typedef moneypunct<_CharT, false> _Punct;
   496   typedef moneypunct<_CharT, true>  _Punct_intl;
   497 
   498   locale __loc = __str.getloc();
   499   const _Ctype&      __c_type      = use_facet<_Ctype>(__loc) ;
   500   const _Punct&      __punct      = use_facet<_Punct>(__loc) ;
   501   const _Punct_intl& __punct_intl = use_facet<_Punct_intl>(__loc) ;
   502 
   503   // some special characters
   504 
   505   char_type __minus = __c_type.widen('-');
   506   char_type __plus  = __c_type.widen('+');
   507   char_type __space = __c_type.widen(' ');
   508   char_type __zero  = __c_type.widen('0');
   509   char_type __point = __intl ? __c_type.widen(__punct_intl.decimal_point())
   510 			     : __c_type.widen(__punct.decimal_point());
   511 
   512   char_type __sep = __intl ? __punct_intl.thousands_sep()
   513 			   : __punct     .thousands_sep();
   514 
   515   string __grouping = __intl ? __punct_intl.grouping()
   516 		             : __punct     .grouping();
   517 				
   518   int __frac_digits      = __intl ? __punct_intl.frac_digits() 
   519                                   : __punct.frac_digits();
   520 
   521   string_type __curr_sym = __intl ? __punct_intl.curr_symbol() 
   522                                   : __punct.curr_symbol();
   523 
   524     // if there are no digits we are going to return __s.  If there
   525     // are digits, but not enough to fill the frac_digits, we are
   526     // going to add zeros.  I don't know whether this is right or
   527     // not.
   528 
   529   if (__digits.size() == 0) 
   530     return __s;
   531 
   532   typename string_type::const_iterator __digits_first = __digits.begin();
   533   typename string_type::const_iterator __digits_last  = __digits.end();
   534 
   535   bool __is_negative = *__digits_first == __minus;
   536   if (__is_negative)
   537     ++__digits_first;
   538 
   539   string_type __sign = __intl ?
   540 			 __is_negative ? __punct_intl.negative_sign()
   541 				       : __punct_intl.positive_sign()
   542 			      :
   543 			 __is_negative ? __punct.negative_sign()
   544 				       : __punct.positive_sign();
   545   typename string_type::const_iterator __cp = __digits_first;
   546   while (__cp != __digits_last && __c_type.is(ctype_base::digit, *__cp))
   547     ++__cp;
   548   if (__cp == __digits_first)
   549     return __s;
   550   __digits_last = __cp;
   551 
   552   // If grouping is required, we make a copy of __digits and
   553   // insert the grouping.
   554 
   555   // To handle the fractional digits, we augment the first group
   556   // by frac_digits.  If there is only one group, we need first
   557   // to duplicate it.
   558 
   559   string_type __new_digits(__digits_first, __digits_last);
   560 #ifdef	__SYMBIAN32__
   561 	int __numberofseperators = 0;
   562 	if (__grouping.size()>0)
   563 	__numberofseperators = (__new_digits.size()/__grouping[0])+1;
   564 	else
   565 		__numberofseperators = 0;
   566   __new_digits.resize(__new_digits.size()+__numberofseperators);
   567 #endif  
   568   if (__grouping.size() != 0) {
   569     if (__grouping.size() == 1)
   570       __grouping.push_back(__grouping[0]);
   571     __grouping[0] += __frac_digits;
   572     _CharT* __data_ptr = __CONST_CAST(_CharT*,__new_digits.data());
   573     _CharT* __data_end = __data_ptr + __new_digits.size();
   574     
   575     
   576     ptrdiff_t __value_length = __insert_grouping(__data_ptr,
   577 #ifdef	__SYMBIAN32__	    
   578 	  				         __data_end-__numberofseperators,
   579 #else
   580 							__data_end,
   581 #endif	  				         
   582 					         __grouping,
   583 					         __sep,
   584 					         __plus, __minus, 0);
   585     __digits_first = __new_digits.begin();
   586     __digits_last  = __digits_first + __value_length;
   587   }
   588 
   589   // Determine the amount of padding required, if any.  
   590 #ifdef	__SYMBIAN32__
   591 	  int __width        = __str.width(); //width returns signed value.
   592 #else    
   593   size_t __width        = __str.width();
   594 #endif
   595 
   596 #if defined(_STLP_DEBUG) && (defined(__HP_aCC) || (__HP_aCC <= 1))
   597   size_t __value_length = operator -(__digits_last, __digits_first);
   598 #else
   599   size_t __value_length = __digits_last - __digits_first;
   600 #endif
   601 
   602   size_t __length       = __value_length;
   603       
   604   __length += __sign.size();
   605   if (__frac_digits != 0)
   606     ++__length;
   607 
   608   bool __generate_curr = (__str.flags() & ios_base::showbase) !=0;
   609   if (__generate_curr)
   610     __length += __curr_sym.size();
   611   money_base::pattern __format =
   612     __intl ? (__is_negative ? __punct_intl.neg_format() 
   613                             : __punct_intl.pos_format())
   614            : (__is_negative ? __punct.neg_format() 
   615                             : __punct.pos_format());
   616   {
   617     for (int __i = 0; __i < 4; ++__i)
   618       if (__format.field[__i] == (char) money_base::space)
   619         ++__length;
   620   }
   621 
   622   size_t __fill_amt = (int)__length < __width ? __width - __length : 0;
   623 
   624   ios_base::fmtflags __fill_pos = __str.flags() & ios_base::adjustfield;
   625 
   626   if (__fill_amt != 0 &&
   627       !(__fill_pos & (ios_base::left | ios_base::internal)))
   628     __s = fill_n(__s, __fill_amt, __fill);
   629     
   630   for (int __i = 0; __i < 4; ++__i) {
   631     char __ffield = __format.field[__i];
   632     if (__ffield == money_base::none) {
   633       if (__fill_amt != 0 && __fill_pos == ios_base::internal)
   634         __s = fill_n(__s, __fill_amt, __fill);
   635     }
   636     else if (__ffield == money_base::space) {
   637 #ifdef __SYMBIAN32__
   638 	if(__fill != __space)
   639 		*__s++ = __fill;
   640 	else
   641 #endif		
   642       *__s++ = __space;
   643       if (__fill_amt != 0 && __fill_pos == ios_base::internal)
   644         __s = fill_n(__s, __fill_amt, __fill);
   645     }
   646     else if (__ffield == money_base::symbol) {
   647       if (__generate_curr)
   648         __s = copy(__curr_sym.begin(), __curr_sym.end(), __s);
   649     }
   650     else if (__ffield == money_base::sign) {
   651       if (__sign.size() != 0)
   652         *__s++ = __sign[0];
   653     }
   654     else if (__ffield == money_base::value) {
   655       if (__frac_digits == 0)
   656         __s = copy(__digits_first, __digits_last, __s);
   657       else {
   658         if ((int)__value_length <= __frac_digits) {
   659           *__s++ = __point;
   660           __s = copy(__digits_first, __digits_last, __s);
   661           __s =  fill_n(__s, __frac_digits - __value_length, __zero);
   662         }
   663         else {
   664 #ifdef	__SYMBIAN32__
   665 	  if (__frac_digits>0)
   666 	  	{
   667 #endif	  	
   668           __s = copy(__digits_first, __digits_last - __frac_digits, __s);
   669           if (__frac_digits != 0) {
   670             *__s++ = __point;
   671             __s = copy(__digits_last - __frac_digits, __digits_last, __s);
   672 #ifdef	__SYMBIAN32__
   673 	          }
   674 #endif			  
   675           }
   676         }
   677       }
   678     }
   679   } // Close for loop
   680 
   681   // Ouput rest of sign if necessary.
   682 
   683   if (__sign.size() > 1)
   684     __s = copy(__sign.begin() + 1, __sign.end(), __s);
   685   if (!(__fill_pos & (ios_base::right | ios_base::internal)))
   686     __s = fill_n(__s, __fill_amt, __fill);
   687   
   688 #ifdef __SYMBIAN32__
   689 	__str.width(0);
   690 #endif
   691   return __s;
   692 }
   693 
   694 #ifdef	__SYMBIAN32__
   695 /*
   696 template<class _CharT, bool _International>//__DFL_NON_TYPE_PARAM(bool, _International, false)>
   697 moneypunct<_CharT, _International>::moneypunct(size_t __refs = 0):_BaseFacet(__refs)
   698 { 
   699 	
   700 	
   701 }*/
   702 
   703 template<class _CharT, bool _International>//__DFL_NON_TYPE_PARAM(bool, _International, false)>
   704 _CharT        moneypunct<_CharT,_International>::do_decimal_point() const
   705 {
   706 	return _CharT('.');
   707 }
   708 
   709 template<class _CharT, bool _International>//__DFL_NON_TYPE_PARAM(bool, _International, false)>
   710 _CharT        moneypunct<_CharT,_International>::do_thousands_sep() const
   711 {
   712 	return _CharT(',');
   713 }
   714 template<class _CharT, bool _International>//__DFL_NON_TYPE_PARAM(bool, _International, false)>
   715 basic_string<_CharT>      moneypunct<_CharT,_International>::do_curr_symbol()   const
   716 {
   717 	return _M_currSym;
   718 }
   719 
   720 template<class _CharT, bool _International>//__DFL_NON_TYPE_PARAM(bool, _International, false)>
   721 basic_string<_CharT>      moneypunct<_CharT,_International>::do_positive_sign()   const
   722 {
   723 	return _M_psign;
   724 }
   725 
   726 template<class _CharT, bool _International>//__DFL_NON_TYPE_PARAM(bool, _International, false)>
   727 basic_string<_CharT>      moneypunct<_CharT,_International>::do_negative_sign()   const
   728 {
   729 	return _M_nsign;
   730 }
   731 
   732 template<class _CharT, bool _International>//__DFL_NON_TYPE_PARAM(bool, _International, false)>
   733 string      moneypunct<_CharT,_International>::do_grouping()   const
   734 {
   735 	return _M_group;
   736 }
   737 
   738 template<class _CharT, bool _International>//__DFL_NON_TYPE_PARAM(bool, _International, false)>
   739 money_base::pattern        moneypunct<_CharT,_International>::do_pos_format()   const
   740 {
   741 	return _M_pos_format;
   742 }
   743 
   744 template<class _CharT, bool _International>//__DFL_NON_TYPE_PARAM(bool, _International, false)>
   745 money_base::pattern        moneypunct<_CharT,_International>::do_neg_format()   const
   746 {
   747 	return _M_neg_format;
   748 }
   749 
   750 template<class _CharT, bool _International>
   751 int       moneypunct<_CharT,_International>::do_frac_digits()   const
   752 {
   753 	return 0;
   754 }
   755 
   756 
   757 //monetary_byname<any>
   758 
   759 template<class _CharT, bool _International>
   760 _CharT moneypunct_byname<_CharT, _International>::do_decimal_point() const 
   761   {return _Locale_mon_decimal_pointE(_M_monetary);}
   762 
   763 template<class _CharT, bool _International>
   764 _CharT moneypunct_byname<_CharT, _International>::do_thousands_sep() const
   765   {return _Locale_mon_thousands_sepE(_M_monetary);}
   766 
   767 template<class _CharT, bool _International>
   768 string  moneypunct_byname<_CharT, _International>::do_grouping() const
   769   {return moneypunct<_CharT,_International>::_M_group;}
   770 
   771 template<class _CharT, bool _International>
   772 basic_string<_CharT> moneypunct_byname<_CharT, _International>::do_curr_symbol() const
   773   {return moneypunct<_CharT,_International>::_M_currSym;}
   774 
   775 template<class _CharT, bool _International>
   776 basic_string<_CharT> moneypunct_byname<_CharT, _International>::do_positive_sign() const
   777   {return moneypunct<_CharT,_International>::_M_psign;}
   778 
   779 template<class _CharT, bool _International>
   780 basic_string<_CharT> moneypunct_byname<_CharT, _International>::do_negative_sign() const
   781   {return moneypunct<_CharT,_International>::_M_nsign;}
   782 
   783 template<class _CharT, bool _International>
   784 int moneypunct_byname<_CharT, _International>::do_frac_digits() const 
   785   {return _Locale_int_frac_digitsE(_M_monetary);}
   786 
   787 template<class _CharT, bool _International>
   788 void moneypunct_byname<_CharT, _International>::Convert_string2_string_chart(basic_string<_CharT> &dst, string src)
   789 	{
   790 		int length = src.length();
   791 		const char* str = src.c_str();
   792 		for(int i = 0; i<length;i++)
   793 		{
   794 			dst.append(1, (_CharT)*str++);
   795 			
   796 		}
   797 			
   798 	}
   799 
   800 template<class _CharT, bool _International>
   801 moneypunct_byname<_CharT, _International>::moneypunct_byname(const char * name,
   802 						  size_t refs):
   803   moneypunct<_CharT, _International>(refs),
   804   _M_monetary(__acquire_monetaryE(name))
   805 {
   806   if (!_M_monetary)
   807     locale::_M_throw_runtime_error();
   808   
   809   		moneypunct<_CharT,_International>::_M_group = _Locale_mon_groupingE(_M_monetary);
   810 		Convert_string2_string_chart(moneypunct<_CharT,_International>::_M_psign, _Locale_positive_signE(_M_monetary));
   811 		Convert_string2_string_chart(moneypunct<_CharT,_International>::_M_nsign, _Locale_negative_signE(_M_monetary));
   812 		Convert_string2_string_chart(moneypunct<_CharT,_International>::_M_currSym, _Locale_int_curr_symbolE(_M_monetary));
   813 }
   814 
   815 template<class _CharT, bool _International>
   816 moneypunct_byname<_CharT, _International>::~moneypunct_byname()
   817 {
   818   __release_monetaryE(_M_monetary);
   819 }
   820 
   821 
   822 #endif
   823 _STLP_END_NAMESPACE
   824 
   825 # endif /* EXPOSE */
   826 
   827 #endif /* _STLP_MONETARY_C */