1// std::moneypunct implementation details, generic version -*- C++ -*- 2 3// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009, 2010 4// Free Software Foundation, Inc. 5// 6// This file is part of the GNU ISO C++ Library. This library is free 7// software; you can redistribute it and/or modify it under the 8// terms of the GNU General Public License as published by the 9// Free Software Foundation; either version 3, or (at your option) 10// any later version. 11 12// This library is distributed in the hope that it will be useful, 13// but WITHOUT ANY WARRANTY; without even the implied warranty of 14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15// GNU General Public License for more details. 16 17// Under Section 7 of GPL version 3, you are granted additional 18// permissions described in the GCC Runtime Library Exception, version 19// 3.1, as published by the Free Software Foundation. 20 21// You should have received a copy of the GNU General Public License and 22// a copy of the GCC Runtime Library Exception along with this program; 23// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 24// <http://www.gnu.org/licenses/>. 25 26// 27// ISO C++ 14882: 22.2.6.3.2 moneypunct virtual functions 28// 29 30// Written by Benjamin Kosnik <bkoz@redhat.com> 31 32#include <locale> 33 34_GLIBCXX_BEGIN_NAMESPACE(std) 35 36 // Construct and return valid pattern consisting of some combination of: 37 // space none symbol sign value 38 money_base::pattern 39 money_base::_S_construct_pattern(char, char, char) throw() 40 { return _S_default_pattern; } 41 42 template<> 43 void 44 moneypunct<char, true>::_M_initialize_moneypunct(__c_locale, const char*) 45 { 46 // "C" locale. 47 if (!_M_data) 48 _M_data = new __moneypunct_cache<char, true>; 49 50 _M_data->_M_decimal_point = '.'; 51 _M_data->_M_thousands_sep = ','; 52 _M_data->_M_grouping = ""; 53 _M_data->_M_grouping_size = 0; 54 _M_data->_M_curr_symbol = ""; 55 _M_data->_M_curr_symbol_size = 0; 56 _M_data->_M_positive_sign = ""; 57 _M_data->_M_positive_sign_size = 0; 58 _M_data->_M_negative_sign = ""; 59 _M_data->_M_negative_sign_size = 0; 60 _M_data->_M_frac_digits = 0; 61 _M_data->_M_pos_format = money_base::_S_default_pattern; 62 _M_data->_M_neg_format = money_base::_S_default_pattern; 63 64 for (size_t __i = 0; __i < money_base::_S_end; ++__i) 65 _M_data->_M_atoms[__i] = money_base::_S_atoms[__i]; 66 } 67 68 template<> 69 void 70 moneypunct<char, false>::_M_initialize_moneypunct(__c_locale, const char*) 71 { 72 // "C" locale. 73 if (!_M_data) 74 _M_data = new __moneypunct_cache<char, false>; 75 76 _M_data->_M_decimal_point = '.'; 77 _M_data->_M_thousands_sep = ','; 78 _M_data->_M_grouping = ""; 79 _M_data->_M_grouping_size = 0; 80 _M_data->_M_curr_symbol = ""; 81 _M_data->_M_curr_symbol_size = 0; 82 _M_data->_M_positive_sign = ""; 83 _M_data->_M_positive_sign_size = 0; 84 _M_data->_M_negative_sign = ""; 85 _M_data->_M_negative_sign_size = 0; 86 _M_data->_M_frac_digits = 0; 87 _M_data->_M_pos_format = money_base::_S_default_pattern; 88 _M_data->_M_neg_format = money_base::_S_default_pattern; 89 90 for (size_t __i = 0; __i < money_base::_S_end; ++__i) 91 _M_data->_M_atoms[__i] = money_base::_S_atoms[__i]; 92 } 93 94 template<> 95 moneypunct<char, true>::~moneypunct() 96 { delete _M_data; } 97 98 template<> 99 moneypunct<char, false>::~moneypunct() 100 { delete _M_data; } 101 102#ifdef _GLIBCXX_USE_WCHAR_T 103 template<> 104 void 105 moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale, 106 const char*) 107 { 108 // "C" locale 109 if (!_M_data) 110 _M_data = new __moneypunct_cache<wchar_t, true>; 111 112 _M_data->_M_decimal_point = L'.'; 113 _M_data->_M_thousands_sep = L','; 114 _M_data->_M_grouping = ""; 115 _M_data->_M_grouping_size = 0; 116 _M_data->_M_curr_symbol = L""; 117 _M_data->_M_curr_symbol_size = 0; 118 _M_data->_M_positive_sign = L""; 119 _M_data->_M_positive_sign_size = 0; 120 _M_data->_M_negative_sign = L""; 121 _M_data->_M_negative_sign_size = 0; 122 _M_data->_M_frac_digits = 0; 123 _M_data->_M_pos_format = money_base::_S_default_pattern; 124 _M_data->_M_neg_format = money_base::_S_default_pattern; 125 126 for (size_t __i = 0; __i < money_base::_S_end; ++__i) 127 _M_data->_M_atoms[__i] = 128 static_cast<wchar_t>(money_base::_S_atoms[__i]); 129 } 130 131 template<> 132 void 133 moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale, 134 const char*) 135 { 136 // "C" locale 137 if (!_M_data) 138 _M_data = new __moneypunct_cache<wchar_t, false>; 139 140 _M_data->_M_decimal_point = L'.'; 141 _M_data->_M_thousands_sep = L','; 142 _M_data->_M_grouping = ""; 143 _M_data->_M_grouping_size = 0; 144 _M_data->_M_curr_symbol = L""; 145 _M_data->_M_curr_symbol_size = 0; 146 _M_data->_M_positive_sign = L""; 147 _M_data->_M_positive_sign_size = 0; 148 _M_data->_M_negative_sign = L""; 149 _M_data->_M_negative_sign_size = 0; 150 _M_data->_M_frac_digits = 0; 151 _M_data->_M_pos_format = money_base::_S_default_pattern; 152 _M_data->_M_neg_format = money_base::_S_default_pattern; 153 154 for (size_t __i = 0; __i < money_base::_S_end; ++__i) 155 _M_data->_M_atoms[__i] = 156 static_cast<wchar_t>(money_base::_S_atoms[__i]); 157 } 158 159 template<> 160 moneypunct<wchar_t, true>::~moneypunct() 161 { delete _M_data; } 162 163 template<> 164 moneypunct<wchar_t, false>::~moneypunct() 165 { delete _M_data; } 166#endif 167 168_GLIBCXX_END_NAMESPACE 169