stdcpp/src/monetary.cpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     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 # include "stlport_prefix.h"
       
    21 
       
    22 #include <stl/_monetary.h>
       
    23 #include <stl/_istream.h>
       
    24 
       
    25 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
    26 #include "libstdcppwsd.h"
       
    27 # endif
       
    28 
       
    29 _STLP_BEGIN_NAMESPACE
       
    30 
       
    31 static void _Init_monetary_formats(money_base::pattern& pos_format,
       
    32 				   money_base::pattern& neg_format) {
       
    33   pos_format.field[0] = (char) money_base::symbol;
       
    34   pos_format.field[1] = (char) money_base::sign;
       
    35   pos_format.field[2] = (char) money_base::none;
       
    36   pos_format.field[3] = (char) money_base::value;
       
    37 
       
    38   neg_format.field[0] = (char) money_base::symbol;
       
    39   neg_format.field[1] = (char) money_base::sign;
       
    40   neg_format.field[2] = (char) money_base::none;
       
    41   neg_format.field[3] = (char) money_base::value;
       
    42 }
       
    43 
       
    44 // This is being used throughout the library
       
    45 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
    46 void monetary_empty_string_init()
       
    47 {
       
    48 	get_monetary_S_empty_string().copy("", 1);
       
    49 # ifndef _STLP_NO_WCHAR_T
       
    50 	get_monetary_S_empty_wstring().copy(L"", 1);	
       
    51 # endif //_STLP_NO_WCHAR_T
       
    52 }
       
    53 # else
       
    54 string _S_empty_string("");
       
    55 # ifndef _STLP_NO_WCHAR_T
       
    56 wstring _S_empty_wstring(L"");
       
    57 # endif //_STLP_NO_WCHAR_T
       
    58 # endif //__LIBSTD_CPP_SYMBIAN32_WSD__
       
    59 
       
    60 //
       
    61 // moneypunct<>
       
    62 //
       
    63 
       
    64 _STLP_EXP_DECLSPEC moneypunct<char, true>::moneypunct(size_t __refs) : _BaseFacet(__refs) { 
       
    65     _Init_monetary_formats(_M_pos_format, _M_neg_format); 
       
    66 }
       
    67  _STLP_EXP_DECLSPEC moneypunct<char, true>::~moneypunct() {}
       
    68 
       
    69 _STLP_EXP_DECLSPEC char moneypunct<char, true>::do_decimal_point() const {return '.';}
       
    70 _STLP_EXP_DECLSPEC char moneypunct<char, true>::do_thousands_sep() const {return ',';}
       
    71 
       
    72 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
    73 _STLP_EXP_DECLSPEC string moneypunct<char, true>::do_grouping() const { return get_monetary_S_empty_string(); }
       
    74 _STLP_EXP_DECLSPEC string moneypunct<char, true>::do_curr_symbol() const { return get_monetary_S_empty_string(); }
       
    75 _STLP_EXP_DECLSPEC string moneypunct<char, true>::do_positive_sign() const { return get_monetary_S_empty_string(); }
       
    76 _STLP_EXP_DECLSPEC string moneypunct<char, true>::do_negative_sign() const { return get_monetary_S_empty_string(); }
       
    77 # else
       
    78 _STLP_EXP_DECLSPEC string moneypunct<char, true>::do_grouping() const { return _S_empty_string; }
       
    79 _STLP_EXP_DECLSPEC string moneypunct<char, true>::do_curr_symbol() const { return _S_empty_string; }
       
    80 _STLP_EXP_DECLSPEC string moneypunct<char, true>::do_positive_sign() const { return _S_empty_string; }
       
    81 _STLP_EXP_DECLSPEC string moneypunct<char, true>::do_negative_sign() const { return _S_empty_string; }
       
    82 # endif //__LIBSTD_CPP_SYMBIAN32_WSD__
       
    83 
       
    84 _STLP_EXP_DECLSPEC money_base::pattern moneypunct<char, true>::do_pos_format() const  {return _M_pos_format;}
       
    85 _STLP_EXP_DECLSPEC money_base::pattern moneypunct<char, true>::do_neg_format() const {return _M_neg_format;}
       
    86 _STLP_EXP_DECLSPEC int moneypunct<char, true>::do_frac_digits() const {return 0;}
       
    87 
       
    88 _STLP_EXP_DECLSPEC moneypunct<char, false>::moneypunct(size_t __refs) : _BaseFacet(__refs) { 
       
    89     _Init_monetary_formats(_M_pos_format, _M_neg_format); 
       
    90 }
       
    91 _STLP_EXP_DECLSPEC moneypunct<char, false>::~moneypunct() {}
       
    92 
       
    93 _STLP_EXP_DECLSPEC char moneypunct<char, false>::do_decimal_point() const {return '.';}
       
    94 _STLP_EXP_DECLSPEC char moneypunct<char, false>::do_thousands_sep() const {return ',';}
       
    95 
       
    96 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
    97 _STLP_EXP_DECLSPEC string moneypunct<char, false>::do_grouping() const { return get_monetary_S_empty_string(); }
       
    98 _STLP_EXP_DECLSPEC string moneypunct<char, false>::do_curr_symbol() const { return get_monetary_S_empty_string(); }
       
    99 _STLP_EXP_DECLSPEC string moneypunct<char, false>::do_positive_sign() const { return get_monetary_S_empty_string(); }
       
   100 _STLP_EXP_DECLSPEC string moneypunct<char, false>::do_negative_sign() const { return get_monetary_S_empty_string(); }
       
   101 # else
       
   102 _STLP_EXP_DECLSPEC string moneypunct<char, false>::do_grouping() const { return _S_empty_string; }
       
   103 _STLP_EXP_DECLSPEC string moneypunct<char, false>::do_curr_symbol() const { return _S_empty_string; }
       
   104 _STLP_EXP_DECLSPEC string moneypunct<char, false>::do_positive_sign() const { return _S_empty_string; }
       
   105 _STLP_EXP_DECLSPEC string moneypunct<char, false>::do_negative_sign() const { return _S_empty_string; }
       
   106 # endif //__LIBSTD_CPP_SYMBIAN32_WSD__
       
   107 
       
   108 _STLP_EXP_DECLSPEC money_base::pattern moneypunct<char, false>::do_pos_format() const {return _M_pos_format;}
       
   109 _STLP_EXP_DECLSPEC money_base::pattern moneypunct<char, false>::do_neg_format() const {return _M_neg_format;}
       
   110 _STLP_EXP_DECLSPEC int moneypunct<char, false>::do_frac_digits() const {return 0;}
       
   111 
       
   112 
       
   113 # ifndef _STLP_NO_WCHAR_T
       
   114 
       
   115 _STLP_EXP_DECLSPEC moneypunct<wchar_t, true>::moneypunct(size_t __refs) : _BaseFacet(__refs) { 
       
   116     _Init_monetary_formats(_M_pos_format, _M_neg_format); 
       
   117 }
       
   118 _STLP_EXP_DECLSPEC moneypunct<wchar_t, true>::~moneypunct() {}
       
   119 
       
   120 _STLP_EXP_DECLSPEC wchar_t moneypunct<wchar_t, true>::do_decimal_point() const {return L'.';}
       
   121 _STLP_EXP_DECLSPEC wchar_t moneypunct<wchar_t, true>::do_thousands_sep() const {return L',';}
       
   122 
       
   123 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   124 _STLP_EXP_DECLSPEC string moneypunct<wchar_t, true>::do_grouping() const {return get_monetary_S_empty_string();}
       
   125 
       
   126 _STLP_EXP_DECLSPEC wstring moneypunct<wchar_t, true>::do_curr_symbol() const
       
   127   {return get_monetary_S_empty_wstring();}
       
   128 _STLP_EXP_DECLSPEC wstring moneypunct<wchar_t, true>::do_positive_sign() const
       
   129   {return get_monetary_S_empty_wstring();}
       
   130 _STLP_EXP_DECLSPEC wstring moneypunct<wchar_t, true>::do_negative_sign() const
       
   131   {return get_monetary_S_empty_wstring();}
       
   132 # else
       
   133 _STLP_EXP_DECLSPEC string moneypunct<wchar_t, true>::do_grouping() const {return _S_empty_string;}
       
   134 
       
   135 _STLP_EXP_DECLSPEC wstring moneypunct<wchar_t, true>::do_curr_symbol() const
       
   136   {return _S_empty_wstring;}
       
   137 _STLP_EXP_DECLSPEC wstring moneypunct<wchar_t, true>::do_positive_sign() const
       
   138   {return _S_empty_wstring;}
       
   139 _STLP_EXP_DECLSPEC wstring moneypunct<wchar_t, true>::do_negative_sign() const
       
   140   {return _S_empty_wstring;}
       
   141 # endif  //__LIBSTD_CPP_SYMBIAN32_WSD__
       
   142 
       
   143 _STLP_EXP_DECLSPEC int moneypunct<wchar_t, true>::do_frac_digits() const {return 0;}
       
   144 _STLP_EXP_DECLSPEC money_base::pattern moneypunct<wchar_t, true>::do_pos_format() const
       
   145   {return _M_pos_format;}
       
   146 _STLP_EXP_DECLSPEC money_base::pattern moneypunct<wchar_t, true>::do_neg_format() const
       
   147   {return _M_neg_format;}
       
   148 
       
   149 _STLP_EXP_DECLSPEC moneypunct<wchar_t, false>::moneypunct(size_t __refs) : _BaseFacet(__refs) { 
       
   150     _Init_monetary_formats(_M_pos_format, _M_neg_format); 
       
   151 }
       
   152 _STLP_EXP_DECLSPEC moneypunct<wchar_t, false>::~moneypunct() {}
       
   153 
       
   154 _STLP_EXP_DECLSPEC wchar_t moneypunct<wchar_t, false>::do_decimal_point() const {return L'.';}
       
   155 _STLP_EXP_DECLSPEC wchar_t moneypunct<wchar_t, false>::do_thousands_sep() const {return L',';}
       
   156 
       
   157 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   158 _STLP_EXP_DECLSPEC string moneypunct<wchar_t, false>::do_grouping() const { return get_monetary_S_empty_string();}
       
   159 _STLP_EXP_DECLSPEC wstring moneypunct<wchar_t, false>::do_curr_symbol() const
       
   160   {return get_monetary_S_empty_wstring();}
       
   161 _STLP_EXP_DECLSPEC wstring moneypunct<wchar_t, false>::do_positive_sign() const
       
   162   {return get_monetary_S_empty_wstring();}
       
   163 _STLP_EXP_DECLSPEC wstring moneypunct<wchar_t, false>::do_negative_sign() const
       
   164   {return get_monetary_S_empty_wstring();}
       
   165 # else
       
   166 _STLP_EXP_DECLSPEC string moneypunct<wchar_t, false>::do_grouping() const { return _S_empty_string;}
       
   167 _STLP_EXP_DECLSPEC wstring moneypunct<wchar_t, false>::do_curr_symbol() const
       
   168   {return _S_empty_wstring;}
       
   169 _STLP_EXP_DECLSPEC wstring moneypunct<wchar_t, false>::do_positive_sign() const
       
   170   {return _S_empty_wstring;}
       
   171 _STLP_EXP_DECLSPEC wstring moneypunct<wchar_t, false>::do_negative_sign() const
       
   172   {return _S_empty_wstring;}
       
   173 # endif //__LIBSTD_CPP_SYMBIAN32_WSD__
       
   174 
       
   175 _STLP_EXP_DECLSPEC int moneypunct<wchar_t, false>::do_frac_digits() const {return 0;}
       
   176 
       
   177 _STLP_EXP_DECLSPEC money_base::pattern moneypunct<wchar_t, false>::do_pos_format() const
       
   178   {return _M_pos_format;}
       
   179 _STLP_EXP_DECLSPEC money_base::pattern moneypunct<wchar_t, false>::do_neg_format() const
       
   180   {return _M_neg_format;}
       
   181 
       
   182 # endif /* WCHAR_T */
       
   183 
       
   184 //
       
   185 // Instantiations
       
   186 //
       
   187 
       
   188 # if !defined(_STLP_NO_FORCE_INSTANTIATE)
       
   189 
       
   190 template class money_get<char, istreambuf_iterator<char, char_traits<char> > >;
       
   191 template class money_put<char, ostreambuf_iterator<char, char_traits<char> > >;
       
   192 // template class money_put<char, char*>;
       
   193 
       
   194 #ifndef _STLP_NO_WCHAR_T
       
   195 template class money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
       
   196 template class money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
       
   197 // template class money_put<wchar_t, wchar_t*>;
       
   198 // template class money_get<wchar_t, const wchar_t*>;
       
   199 #endif
       
   200 
       
   201 # endif
       
   202 
       
   203 #ifdef __SYMBIAN32__
       
   204 _STLP_EXP_DECLSPEC void _Init_monetary_formatsE(money_base::pattern& pos_format,
       
   205 				   money_base::pattern& neg_format)
       
   206 {
       
   207 	_Init_monetary_formats(pos_format, neg_format);
       
   208 }
       
   209 
       
   210 _Locale_monetary* __acquire_monetary(const char* name); 
       
   211 void __release_monetary(_Locale_monetary* cat);
       
   212 
       
   213 _STLP_EXP_DECLSPEC _Locale_monetary* __acquire_monetaryE(const char*  name)
       
   214 {
       
   215 	return __acquire_monetary(name);
       
   216 }
       
   217 _STLP_EXP_DECLSPEC void __release_monetaryE (_Locale_monetary* _M_monetary)
       
   218 {
       
   219 	__release_monetary(_M_monetary);
       
   220 }
       
   221 
       
   222 _STLP_EXP_DECLSPEC char _Locale_mon_decimal_pointE(_Locale_monetary* _M_monetary)
       
   223 {
       
   224 	return _Locale_mon_decimal_point(_M_monetary);
       
   225 }
       
   226 
       
   227 _STLP_EXP_DECLSPEC char _Locale_mon_thousands_sepE(_Locale_monetary* _M_monetary)
       
   228 {
       
   229 	return _Locale_mon_thousands_sep(_M_monetary);
       
   230 }
       
   231 
       
   232 _STLP_EXP_DECLSPEC string _Locale_mon_groupingE(_Locale_monetary* _M_monetary)
       
   233 {
       
   234 	return _Locale_mon_grouping(_M_monetary);
       
   235 }
       
   236 
       
   237 
       
   238 _STLP_EXP_DECLSPEC string _Locale_int_curr_symbolE(_Locale_monetary* _M_monetary)
       
   239 {
       
   240 	return _Locale_int_curr_symbol(_M_monetary);
       
   241 }
       
   242 
       
   243 _STLP_EXP_DECLSPEC string _Locale_positive_signE(_Locale_monetary* _M_monetary)
       
   244 {
       
   245 	return _Locale_positive_sign(_M_monetary);
       
   246 }
       
   247 
       
   248 _STLP_EXP_DECLSPEC string _Locale_negative_signE(_Locale_monetary* _M_monetary)
       
   249 {
       
   250 	return _Locale_negative_sign(_M_monetary);
       
   251 }
       
   252 
       
   253 
       
   254 _STLP_EXP_DECLSPEC int _Locale_int_frac_digitsE(_Locale_monetary* _M_monetary)
       
   255 {
       
   256 	return _Locale_int_frac_digits(_M_monetary);
       
   257 }
       
   258 
       
   259 
       
   260 #endif
       
   261 _STLP_END_NAMESPACE  
       
   262 
       
   263 // Local Variables:
       
   264 // mode:C++
       
   265 // End: