1254721Semaste// std::numpunct implementation details, generic version -*- C++ -*- 2254721Semaste 3254721Semaste// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. 4254721Semaste// 5254721Semaste// This file is part of the GNU ISO C++ Library. This library is free 6254721Semaste// software; you can redistribute it and/or modify it under the 7254721Semaste// terms of the GNU General Public License as published by the 8254721Semaste// Free Software Foundation; either version 2, or (at your option) 9254721Semaste// any later version. 10254721Semaste 11254721Semaste// This library is distributed in the hope that it will be useful, 12254721Semaste// but WITHOUT ANY WARRANTY; without even the implied warranty of 13254721Semaste// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14254721Semaste// GNU General Public License for more details. 15254721Semaste 16254721Semaste// You should have received a copy of the GNU General Public License along 17254721Semaste// with this library; see the file COPYING. If not, write to the Free 18254721Semaste// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 19254721Semaste// USA. 20254721Semaste 21254721Semaste// As a special exception, you may use this file as part of a free software 22254721Semaste// library without restriction. Specifically, if other files instantiate 23254721Semaste// templates or use macros or inline functions from this file, or you compile 24254721Semaste// this file and link it with other files to produce an executable, this 25254721Semaste// file does not by itself cause the resulting executable to be covered by 26254721Semaste// the GNU General Public License. This exception does not however 27254721Semaste// invalidate any other reasons why the executable file might be covered by 28254721Semaste// the GNU General Public License. 29254721Semaste 30254721Semaste// 31254721Semaste// ISO C++ 14882: 22.2.3.1.2 numpunct virtual functions 32254721Semaste// 33254721Semaste 34254721Semaste// Written by Benjamin Kosnik <bkoz@redhat.com> 35254721Semaste 36254721Semaste#include <locale> 37254721Semaste 38254721Semaste_GLIBCXX_BEGIN_NAMESPACE(std) 39254721Semaste 40254721Semaste template<> 41254721Semaste void 42254721Semaste numpunct<char>::_M_initialize_numpunct(__c_locale) 43254721Semaste { 44254721Semaste // "C" locale 45254721Semaste if (!_M_data) 46254721Semaste _M_data = new __numpunct_cache<char>; 47254721Semaste 48254721Semaste _M_data->_M_grouping = ""; 49254721Semaste _M_data->_M_grouping_size = 0; 50254721Semaste _M_data->_M_use_grouping = false; 51254721Semaste 52254721Semaste _M_data->_M_decimal_point = '.'; 53254721Semaste _M_data->_M_thousands_sep = ','; 54254721Semaste 55254721Semaste for (size_t __i = 0; __i < __num_base::_S_oend; ++__i) 56254721Semaste _M_data->_M_atoms_out[__i] = __num_base::_S_atoms_out[__i]; 57254721Semaste 58254721Semaste for (size_t __i = 0; __i < __num_base::_S_iend; ++__i) 59254721Semaste _M_data->_M_atoms_in[__i] = __num_base::_S_atoms_in[__i]; 60254721Semaste 61254721Semaste _M_data->_M_truename = "true"; 62254721Semaste _M_data->_M_truename_size = 4; 63254721Semaste _M_data->_M_falsename = "false"; 64254721Semaste _M_data->_M_falsename_size = 5; 65254721Semaste } 66254721Semaste 67254721Semaste template<> 68254721Semaste numpunct<char>::~numpunct() 69254721Semaste { delete _M_data; } 70254721Semaste 71254721Semaste#ifdef _GLIBCXX_USE_WCHAR_T 72254721Semaste template<> 73254721Semaste void 74254721Semaste numpunct<wchar_t>::_M_initialize_numpunct(__c_locale) 75254721Semaste { 76254721Semaste // "C" locale 77254721Semaste if (!_M_data) 78254721Semaste _M_data = new __numpunct_cache<wchar_t>; 79254721Semaste 80254721Semaste _M_data->_M_grouping = ""; 81254721Semaste _M_data->_M_grouping_size = 0; 82254721Semaste _M_data->_M_use_grouping = false; 83254721Semaste 84254721Semaste _M_data->_M_decimal_point = L'.'; 85254721Semaste _M_data->_M_thousands_sep = L','; 86254721Semaste 87254721Semaste // Use ctype::widen code without the facet... 88254721Semaste for (size_t __i = 0; __i < __num_base::_S_oend; ++__i) 89254721Semaste _M_data->_M_atoms_out[__i] = 90254721Semaste static_cast<wchar_t>(__num_base::_S_atoms_out[__i]); 91254721Semaste 92254721Semaste for (size_t __i = 0; __i < __num_base::_S_iend; ++__i) 93254721Semaste _M_data->_M_atoms_in[__i] = 94254721Semaste static_cast<wchar_t>(__num_base::_S_atoms_in[__i]); 95254721Semaste 96254721Semaste _M_data->_M_truename = L"true"; 97254721Semaste _M_data->_M_truename_size = 4; 98254721Semaste _M_data->_M_falsename = L"false"; 99254721Semaste _M_data->_M_falsename_size = 5; 100254721Semaste } 101254721Semaste 102254721Semaste template<> 103254721Semaste numpunct<wchar_t>::~numpunct() 104254721Semaste { delete _M_data; } 105254721Semaste#endif 106254721Semaste 107254721Semaste_GLIBCXX_END_NAMESPACE 108254721Semaste 109254721Semaste