]>
Commit | Line | Data |
---|---|---|
72e2386f | 1 | // std::moneypunct implementation details, generic version -*- C++ -*- |
ea0c0b6e | 2 | |
fe932e50 | 3 | // Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. |
ea0c0b6e BK |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
8 | // Free Software Foundation; either version 2, or (at your option) | |
9 | // any later version. | |
10 | ||
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | ||
16 | // You should have received a copy of the GNU General Public License along | |
17 | // with this library; see the file COPYING. If not, write to the Free | |
83f51799 | 18 | // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
ea0c0b6e BK |
19 | // USA. |
20 | ||
21 | // As a special exception, you may use this file as part of a free software | |
22 | // library without restriction. Specifically, if other files instantiate | |
23 | // templates or use macros or inline functions from this file, or you compile | |
24 | // this file and link it with other files to produce an executable, this | |
25 | // file does not by itself cause the resulting executable to be covered by | |
26 | // the GNU General Public License. This exception does not however | |
27 | // invalidate any other reasons why the executable file might be covered by | |
28 | // the GNU General Public License. | |
29 | ||
30 | // | |
72e2386f | 31 | // ISO C++ 14882: 22.2.6.3.2 moneypunct virtual functions |
ea0c0b6e BK |
32 | // |
33 | ||
34 | // Written by Benjamin Kosnik <bkoz@redhat.com> | |
35 | ||
36 | #include <locale> | |
37 | ||
38 | namespace std | |
39 | { | |
69971cd8 BK |
40 | // Construct and return valid pattern consisting of some combination of: |
41 | // space none symbol sign value | |
42 | money_base::pattern | |
a623ef6e | 43 | money_base::_S_construct_pattern(char, char, char) |
69971cd8 BK |
44 | { return _S_default_pattern; } |
45 | ||
46 | template<> | |
47 | void | |
fdf7e809 | 48 | moneypunct<char, true>::_M_initialize_moneypunct(__c_locale, const char*) |
69971cd8 | 49 | { |
fea4065d BK |
50 | // "C" locale. |
51 | if (!_M_data) | |
fe932e50 | 52 | _M_data = new __moneypunct_cache<char, true>; |
fea4065d BK |
53 | |
54 | _M_data->_M_decimal_point = '.'; | |
55 | _M_data->_M_thousands_sep = ','; | |
56 | _M_data->_M_grouping = ""; | |
fe932e50 | 57 | _M_data->_M_grouping_size = 0; |
fea4065d | 58 | _M_data->_M_curr_symbol = ""; |
fe932e50 | 59 | _M_data->_M_curr_symbol_size = 0; |
fea4065d | 60 | _M_data->_M_positive_sign = ""; |
fe932e50 | 61 | _M_data->_M_positive_sign_size = 0; |
fea4065d | 62 | _M_data->_M_negative_sign = ""; |
fe932e50 | 63 | _M_data->_M_negative_sign_size = 0; |
fea4065d BK |
64 | _M_data->_M_frac_digits = 0; |
65 | _M_data->_M_pos_format = money_base::_S_default_pattern; | |
66 | _M_data->_M_neg_format = money_base::_S_default_pattern; | |
fe932e50 PC |
67 | |
68 | for (size_t __i = 0; __i < money_base::_S_end; ++__i) | |
69 | _M_data->_M_atoms[__i] = money_base::_S_atoms[__i]; | |
69971cd8 BK |
70 | } |
71 | ||
72e2386f BK |
72 | template<> |
73 | void | |
fdf7e809 | 74 | moneypunct<char, false>::_M_initialize_moneypunct(__c_locale, const char*) |
72e2386f | 75 | { |
fea4065d BK |
76 | // "C" locale. |
77 | if (!_M_data) | |
fe932e50 | 78 | _M_data = new __moneypunct_cache<char, false>; |
fea4065d BK |
79 | |
80 | _M_data->_M_decimal_point = '.'; | |
81 | _M_data->_M_thousands_sep = ','; | |
82 | _M_data->_M_grouping = ""; | |
fe932e50 | 83 | _M_data->_M_grouping_size = 0; |
fea4065d | 84 | _M_data->_M_curr_symbol = ""; |
fe932e50 | 85 | _M_data->_M_curr_symbol_size = 0; |
fea4065d | 86 | _M_data->_M_positive_sign = ""; |
fe932e50 | 87 | _M_data->_M_positive_sign_size = 0; |
fea4065d | 88 | _M_data->_M_negative_sign = ""; |
fe932e50 | 89 | _M_data->_M_negative_sign_size = 0; |
fea4065d BK |
90 | _M_data->_M_frac_digits = 0; |
91 | _M_data->_M_pos_format = money_base::_S_default_pattern; | |
92 | _M_data->_M_neg_format = money_base::_S_default_pattern; | |
fe932e50 PC |
93 | |
94 | for (size_t __i = 0; __i < money_base::_S_end; ++__i) | |
95 | _M_data->_M_atoms[__i] = money_base::_S_atoms[__i]; | |
72e2386f | 96 | } |
ea0c0b6e | 97 | |
d3a193e3 BK |
98 | template<> |
99 | moneypunct<char, true>::~moneypunct() | |
fea4065d | 100 | { delete _M_data; } |
d3a193e3 BK |
101 | |
102 | template<> | |
103 | moneypunct<char, false>::~moneypunct() | |
fea4065d | 104 | { delete _M_data; } |
d3a193e3 | 105 | |
3d7c150e | 106 | #ifdef _GLIBCXX_USE_WCHAR_T |
72e2386f BK |
107 | template<> |
108 | void | |
fdf7e809 BK |
109 | moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale, |
110 | const char*) | |
69971cd8 BK |
111 | { |
112 | // "C" locale | |
fea4065d | 113 | if (!_M_data) |
fe932e50 | 114 | _M_data = new __moneypunct_cache<wchar_t, true>; |
fea4065d BK |
115 | |
116 | _M_data->_M_decimal_point = L'.'; | |
117 | _M_data->_M_thousands_sep = L','; | |
118 | _M_data->_M_grouping = ""; | |
fe932e50 | 119 | _M_data->_M_grouping_size = 0; |
fea4065d | 120 | _M_data->_M_curr_symbol = L""; |
fe932e50 | 121 | _M_data->_M_curr_symbol_size = 0; |
fea4065d | 122 | _M_data->_M_positive_sign = L""; |
fe932e50 | 123 | _M_data->_M_positive_sign_size = 0; |
fea4065d | 124 | _M_data->_M_negative_sign = L""; |
fe932e50 | 125 | _M_data->_M_negative_sign_size = 0; |
fea4065d BK |
126 | _M_data->_M_frac_digits = 0; |
127 | _M_data->_M_pos_format = money_base::_S_default_pattern; | |
128 | _M_data->_M_neg_format = money_base::_S_default_pattern; | |
fe932e50 | 129 | |
fe932e50 | 130 | for (size_t __i = 0; __i < money_base::_S_end; ++__i) |
af55af57 PC |
131 | _M_data->_M_atoms[__i] = |
132 | static_cast<wchar_t>(money_base::_S_atoms[__i]); | |
69971cd8 BK |
133 | } |
134 | ||
135 | template<> | |
136 | void | |
fdf7e809 BK |
137 | moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale, |
138 | const char*) | |
72e2386f BK |
139 | { |
140 | // "C" locale | |
fea4065d | 141 | if (!_M_data) |
fe932e50 | 142 | _M_data = new __moneypunct_cache<wchar_t, false>; |
fea4065d BK |
143 | |
144 | _M_data->_M_decimal_point = L'.'; | |
145 | _M_data->_M_thousands_sep = L','; | |
146 | _M_data->_M_grouping = ""; | |
fe932e50 | 147 | _M_data->_M_grouping_size = 0; |
fea4065d | 148 | _M_data->_M_curr_symbol = L""; |
fe932e50 | 149 | _M_data->_M_curr_symbol_size = 0; |
fea4065d | 150 | _M_data->_M_positive_sign = L""; |
fe932e50 | 151 | _M_data->_M_positive_sign_size = 0; |
fea4065d | 152 | _M_data->_M_negative_sign = L""; |
fe932e50 | 153 | _M_data->_M_negative_sign_size = 0; |
fea4065d BK |
154 | _M_data->_M_frac_digits = 0; |
155 | _M_data->_M_pos_format = money_base::_S_default_pattern; | |
156 | _M_data->_M_neg_format = money_base::_S_default_pattern; | |
fe932e50 | 157 | |
fe932e50 | 158 | for (size_t __i = 0; __i < money_base::_S_end; ++__i) |
af55af57 PC |
159 | _M_data->_M_atoms[__i] = |
160 | static_cast<wchar_t>(money_base::_S_atoms[__i]); | |
72e2386f | 161 | } |
d3a193e3 BK |
162 | |
163 | template<> | |
164 | moneypunct<wchar_t, true>::~moneypunct() | |
fea4065d | 165 | { delete _M_data; } |
d3a193e3 BK |
166 | |
167 | template<> | |
168 | moneypunct<wchar_t, false>::~moneypunct() | |
fea4065d | 169 | { delete _M_data; } |
ea0c0b6e BK |
170 | #endif |
171 | } |