1 /*
2 * Copyright (c) 1999
3 * Silicon Graphics Computer Systems, Inc.
4 *
5 * Copyright (c) 1999
6 * Boris Fomitchev
7 *
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
10 *
11 * Permission to use or copy this software for any purpose is hereby granted
12 * without fee, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
16 *
17 */
18 #include "stlport_prefix.h"
19
20 #include <locale>
21 #include <istream>
22
23 _STLP_BEGIN_NAMESPACE
24
_Init_monetary_formats(money_base::pattern & pos_format,money_base::pattern & neg_format)25 static void _Init_monetary_formats(money_base::pattern& pos_format,
26 money_base::pattern& neg_format) {
27 pos_format.field[0] = (char) money_base::symbol;
28 pos_format.field[1] = (char) money_base::sign;
29 pos_format.field[2] = (char) money_base::none;
30 pos_format.field[3] = (char) money_base::value;
31
32 neg_format.field[0] = (char) money_base::symbol;
33 neg_format.field[1] = (char) money_base::sign;
34 neg_format.field[2] = (char) money_base::none;
35 neg_format.field[3] = (char) money_base::value;
36 }
37
38 // This is being used throughout the library
39 static const char _S_empty_string[] = "";
40 #ifndef _STLP_NO_WCHAR_T
41 static const wchar_t _S_empty_wstring[] = L"";
42 #endif
43
44 //
45 // moneypunct<>
46 //
47
moneypunct(size_t __refs)48 moneypunct<char, true>::moneypunct(size_t __refs) : locale::facet(__refs)
49 { _Init_monetary_formats(_M_pos_format, _M_neg_format); }
~moneypunct()50 moneypunct<char, true>::~moneypunct() {}
51
do_decimal_point() const52 char moneypunct<char, true>::do_decimal_point() const {return ' ';}
do_thousands_sep() const53 char moneypunct<char, true>::do_thousands_sep() const {return ' ';}
do_grouping() const54 string moneypunct<char, true>::do_grouping() const { return _S_empty_string; }
do_curr_symbol() const55 string moneypunct<char, true>::do_curr_symbol() const { return _S_empty_string; }
do_positive_sign() const56 string moneypunct<char, true>::do_positive_sign() const { return _S_empty_string; }
do_negative_sign() const57 string moneypunct<char, true>::do_negative_sign() const { return _S_empty_string; }
do_pos_format() const58 money_base::pattern moneypunct<char, true>::do_pos_format() const {return _M_pos_format;}
do_neg_format() const59 money_base::pattern moneypunct<char, true>::do_neg_format() const {return _M_neg_format;}
do_frac_digits() const60 int moneypunct<char, true>::do_frac_digits() const {return 0;}
61
moneypunct(size_t __refs)62 moneypunct<char, false>::moneypunct(size_t __refs) : locale::facet(__refs)
63 { _Init_monetary_formats(_M_pos_format, _M_neg_format); }
~moneypunct()64 moneypunct<char, false>::~moneypunct() {}
65
do_decimal_point() const66 char moneypunct<char, false>::do_decimal_point() const {return ' ';}
do_thousands_sep() const67 char moneypunct<char, false>::do_thousands_sep() const {return ' ';}
68
do_grouping() const69 string moneypunct<char, false>::do_grouping() const { return _S_empty_string; }
do_curr_symbol() const70 string moneypunct<char, false>::do_curr_symbol() const { return _S_empty_string; }
do_positive_sign() const71 string moneypunct<char, false>::do_positive_sign() const { return _S_empty_string; }
do_negative_sign() const72 string moneypunct<char, false>::do_negative_sign() const { return _S_empty_string; }
do_pos_format() const73 money_base::pattern moneypunct<char, false>::do_pos_format() const {return _M_pos_format;}
do_neg_format() const74 money_base::pattern moneypunct<char, false>::do_neg_format() const {return _M_neg_format;}
do_frac_digits() const75 int moneypunct<char, false>::do_frac_digits() const {return 0;}
76
77 #ifndef _STLP_NO_WCHAR_T
moneypunct(size_t __refs)78 moneypunct<wchar_t, true>::moneypunct(size_t __refs) : locale::facet(__refs)
79 { _Init_monetary_formats(_M_pos_format, _M_neg_format); }
~moneypunct()80 moneypunct<wchar_t, true>::~moneypunct() {}
81
do_decimal_point() const82 wchar_t moneypunct<wchar_t, true>::do_decimal_point() const {return L' ';}
do_thousands_sep() const83 wchar_t moneypunct<wchar_t, true>::do_thousands_sep() const {return L' ';}
do_grouping() const84 string moneypunct<wchar_t, true>::do_grouping() const {return _S_empty_string;}
85
do_curr_symbol() const86 wstring moneypunct<wchar_t, true>::do_curr_symbol() const
87 {return _S_empty_wstring;}
do_positive_sign() const88 wstring moneypunct<wchar_t, true>::do_positive_sign() const
89 {return _S_empty_wstring;}
do_negative_sign() const90 wstring moneypunct<wchar_t, true>::do_negative_sign() const
91 {return _S_empty_wstring;}
do_frac_digits() const92 int moneypunct<wchar_t, true>::do_frac_digits() const {return 0;}
do_pos_format() const93 money_base::pattern moneypunct<wchar_t, true>::do_pos_format() const
94 {return _M_pos_format;}
do_neg_format() const95 money_base::pattern moneypunct<wchar_t, true>::do_neg_format() const
96 {return _M_neg_format;}
97
moneypunct(size_t __refs)98 moneypunct<wchar_t, false>::moneypunct(size_t __refs) : locale::facet(__refs)
99 { _Init_monetary_formats(_M_pos_format, _M_neg_format); }
~moneypunct()100 moneypunct<wchar_t, false>::~moneypunct() {}
101
do_decimal_point() const102 wchar_t moneypunct<wchar_t, false>::do_decimal_point() const {return L' ';}
do_thousands_sep() const103 wchar_t moneypunct<wchar_t, false>::do_thousands_sep() const {return L' ';}
do_grouping() const104 string moneypunct<wchar_t, false>::do_grouping() const { return _S_empty_string;}
do_curr_symbol() const105 wstring moneypunct<wchar_t, false>::do_curr_symbol() const
106 {return _S_empty_wstring;}
do_positive_sign() const107 wstring moneypunct<wchar_t, false>::do_positive_sign() const
108 {return _S_empty_wstring;}
do_negative_sign() const109 wstring moneypunct<wchar_t, false>::do_negative_sign() const
110 {return _S_empty_wstring;}
do_frac_digits() const111 int moneypunct<wchar_t, false>::do_frac_digits() const {return 0;}
112
do_pos_format() const113 money_base::pattern moneypunct<wchar_t, false>::do_pos_format() const
114 {return _M_pos_format;}
do_neg_format() const115 money_base::pattern moneypunct<wchar_t, false>::do_neg_format() const
116 {return _M_neg_format;}
117
118 #endif /* WCHAR_T */
119
120 //
121 // Instantiations
122 //
123
124 #if !defined (_STLP_NO_FORCE_INSTANTIATE)
125
126 template class _STLP_CLASS_DECLSPEC money_get<char, istreambuf_iterator<char, char_traits<char> > >;
127 template class _STLP_CLASS_DECLSPEC money_put<char, ostreambuf_iterator<char, char_traits<char> > >;
128 // template class money_put<char, char*>;
129
130 # ifndef _STLP_NO_WCHAR_T
131 template class _STLP_CLASS_DECLSPEC money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
132 template class _STLP_CLASS_DECLSPEC money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
133 // template class money_put<wchar_t, wchar_t*>;
134 // template class money_get<wchar_t, const wchar_t*>;
135 # endif
136
137 #endif
138
139 #if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION)
140 const bool moneypunct<char, true>::intl;
141 const bool moneypunct<char, false>::intl;
142 # ifndef _STLP_NO_WCHAR_T
143 const bool moneypunct<wchar_t, true>::intl;
144 const bool moneypunct<wchar_t, false>::intl;
145 # endif
146 #endif
147
148 _STLP_END_NAMESPACE
149
150 // Local Variables:
151 // mode:C++
152 // End:
153