]>
Commit | Line | Data |
---|---|---|
41a49e36 | 1 | // std::numpunct implementation details, generic version -*- C++ -*- |
e3e68d56 | 2 | |
f1717362 | 3 | // Copyright (C) 2001-2016 Free Software Foundation, Inc. |
e3e68d56 | 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 | |
6bc9506f | 8 | // Free Software Foundation; either version 3, or (at your option) |
e3e68d56 | 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 | ||
6bc9506f | 16 | // Under Section 7 of GPL version 3, you are granted additional |
17 | // permissions described in the GCC Runtime Library Exception, version | |
18 | // 3.1, as published by the Free Software Foundation. | |
e3e68d56 | 19 | |
6bc9506f | 20 | // You should have received a copy of the GNU General Public License and |
21 | // a copy of the GCC Runtime Library Exception along with this program; | |
22 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
23 | // <http://www.gnu.org/licenses/>. | |
e3e68d56 | 24 | |
25 | // | |
41a49e36 | 26 | // ISO C++ 14882: 22.2.3.1.2 numpunct virtual functions |
e3e68d56 | 27 | // |
28 | ||
29 | // Written by Benjamin Kosnik <bkoz@redhat.com> | |
30 | ||
31 | #include <locale> | |
32 | ||
2948dd21 | 33 | namespace std _GLIBCXX_VISIBILITY(default) |
34 | { | |
35 | _GLIBCXX_BEGIN_NAMESPACE_VERSION | |
1069247d | 36 | |
41a49e36 | 37 | template<> |
38 | void | |
39 | numpunct<char>::_M_initialize_numpunct(__c_locale) | |
40 | { | |
41 | // "C" locale | |
36bcb738 | 42 | if (!_M_data) |
43 | _M_data = new __numpunct_cache<char>; | |
44 | ||
45 | _M_data->_M_grouping = ""; | |
e176a2c6 | 46 | _M_data->_M_grouping_size = 0; |
36bcb738 | 47 | _M_data->_M_use_grouping = false; |
48 | ||
49 | _M_data->_M_decimal_point = '.'; | |
50 | _M_data->_M_thousands_sep = ','; | |
51 | ||
1724ec2f | 52 | for (size_t __i = 0; __i < __num_base::_S_oend; ++__i) |
53 | _M_data->_M_atoms_out[__i] = __num_base::_S_atoms_out[__i]; | |
36bcb738 | 54 | |
1724ec2f | 55 | for (size_t __i = 0; __i < __num_base::_S_iend; ++__i) |
56 | _M_data->_M_atoms_in[__i] = __num_base::_S_atoms_in[__i]; | |
36bcb738 | 57 | |
58 | _M_data->_M_truename = "true"; | |
67a3c585 | 59 | _M_data->_M_truename_size = 4; |
5c76831e | 60 | _M_data->_M_falsename = "false"; |
67a3c585 | 61 | _M_data->_M_falsename_size = 5; |
41a49e36 | 62 | } |
5f8a31fe | 63 | |
64 | template<> | |
65 | numpunct<char>::~numpunct() | |
36bcb738 | 66 | { delete _M_data; } |
41a49e36 | 67 | |
5a64d8cf | 68 | #ifdef _GLIBCXX_USE_WCHAR_T |
41a49e36 | 69 | template<> |
70 | void | |
71 | numpunct<wchar_t>::_M_initialize_numpunct(__c_locale) | |
72 | { | |
73 | // "C" locale | |
36bcb738 | 74 | if (!_M_data) |
75 | _M_data = new __numpunct_cache<wchar_t>; | |
76 | ||
77 | _M_data->_M_grouping = ""; | |
e176a2c6 | 78 | _M_data->_M_grouping_size = 0; |
36bcb738 | 79 | _M_data->_M_use_grouping = false; |
80 | ||
81 | _M_data->_M_decimal_point = L'.'; | |
82 | _M_data->_M_thousands_sep = L','; | |
83 | ||
84 | // Use ctype::widen code without the facet... | |
1724ec2f | 85 | for (size_t __i = 0; __i < __num_base::_S_oend; ++__i) |
67a3c585 | 86 | _M_data->_M_atoms_out[__i] = |
87 | static_cast<wchar_t>(__num_base::_S_atoms_out[__i]); | |
36bcb738 | 88 | |
1724ec2f | 89 | for (size_t __i = 0; __i < __num_base::_S_iend; ++__i) |
67a3c585 | 90 | _M_data->_M_atoms_in[__i] = |
91 | static_cast<wchar_t>(__num_base::_S_atoms_in[__i]); | |
bd5c892b | 92 | |
36bcb738 | 93 | _M_data->_M_truename = L"true"; |
67a3c585 | 94 | _M_data->_M_truename_size = 4; |
36bcb738 | 95 | _M_data->_M_falsename = L"false"; |
67a3c585 | 96 | _M_data->_M_falsename_size = 5; |
41a49e36 | 97 | } |
5f8a31fe | 98 | |
99 | template<> | |
100 | numpunct<wchar_t>::~numpunct() | |
36bcb738 | 101 | { delete _M_data; } |
e3e68d56 | 102 | #endif |
1069247d | 103 | |
2948dd21 | 104 | _GLIBCXX_END_NAMESPACE_VERSION |
105 | } // namespace | |
1069247d | 106 |