1169691Skan// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005 2103447Skan// Free Software Foundation, Inc. 3103447Skan// 4103447Skan// This file is part of the GNU ISO C++ Library. This library is free 5103447Skan// software; you can redistribute it and/or modify it under the 6103447Skan// terms of the GNU General Public License as published by the 7103447Skan// Free Software Foundation; either version 2, or (at your option) 8103447Skan// any later version. 9103447Skan 10103447Skan// This library is distributed in the hope that it will be useful, 11103447Skan// but WITHOUT ANY WARRANTY; without even the implied warranty of 12103447Skan// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13103447Skan// GNU General Public License for more details. 14103447Skan 15103447Skan// You should have received a copy of the GNU General Public License along 16103447Skan// with this library; see the file COPYING. If not, write to the Free 17169691Skan// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18103447Skan// USA. 19103447Skan 20103447Skan// As a special exception, you may use this file as part of a free software 21103447Skan// library without restriction. Specifically, if other files instantiate 22103447Skan// templates or use macros or inline functions from this file, or you compile 23103447Skan// this file and link it with other files to produce an executable, this 24103447Skan// file does not by itself cause the resulting executable to be covered by 25103447Skan// the GNU General Public License. This exception does not however 26103447Skan// invalidate any other reasons why the executable file might be covered by 27103447Skan// the GNU General Public License. 28103447Skan 29103447Skan#include <locale> 30103447Skan 31169691Skan_GLIBCXX_BEGIN_NAMESPACE(std) 32169691Skan 33132720Skan // Definitions for static const data members of ctype_base. 34132720Skan const ctype_base::mask ctype_base::space; 35132720Skan const ctype_base::mask ctype_base::print; 36132720Skan const ctype_base::mask ctype_base::cntrl; 37132720Skan const ctype_base::mask ctype_base::upper; 38132720Skan const ctype_base::mask ctype_base::lower; 39132720Skan const ctype_base::mask ctype_base::alpha; 40132720Skan const ctype_base::mask ctype_base::digit; 41132720Skan const ctype_base::mask ctype_base::punct; 42132720Skan const ctype_base::mask ctype_base::xdigit; 43132720Skan const ctype_base::mask ctype_base::alnum; 44132720Skan const ctype_base::mask ctype_base::graph; 45103447Skan 46103447Skan // Definitions for locale::id of standard facets that are specialized. 47103447Skan locale::id ctype<char>::id; 48103447Skan 49132720Skan#ifdef _GLIBCXX_USE_WCHAR_T 50103447Skan locale::id ctype<wchar_t>::id; 51103447Skan#endif 52103447Skan 53103447Skan template<> 54103447Skan const ctype<char>& 55103447Skan use_facet<ctype<char> >(const locale& __loc) 56103447Skan { 57103447Skan size_t __i = ctype<char>::id._M_id(); 58103447Skan const locale::_Impl* __tmp = __loc._M_impl; 59103447Skan return static_cast<const ctype<char>&>(*(__tmp->_M_facets[__i])); 60103447Skan } 61103447Skan 62132720Skan#ifdef _GLIBCXX_USE_WCHAR_T 63103447Skan template<> 64103447Skan const ctype<wchar_t>& 65103447Skan use_facet<ctype<wchar_t> >(const locale& __loc) 66103447Skan { 67103447Skan size_t __i = ctype<wchar_t>::id._M_id(); 68103447Skan const locale::_Impl* __tmp = __loc._M_impl; 69103447Skan return static_cast<const ctype<wchar_t>&>(*(__tmp->_M_facets[__i])); 70103447Skan } 71103447Skan#endif 72103447Skan 73132720Skan // XXX At some point, just rename this file to ctype_configure_char.cc 74132720Skan // and compile it as a separate file instead of including it here. 75132720Skan // Platform-specific initialization code for ctype tables. 76132720Skan #include <bits/ctype_noninline.h> 77103447Skan 78103447Skan const size_t ctype<char>::table_size; 79103447Skan 80103447Skan ctype<char>::~ctype() 81103447Skan { 82107606Sobrien _S_destroy_c_locale(_M_c_locale_ctype); 83103447Skan if (_M_del) 84103447Skan delete[] this->table(); 85103447Skan } 86103447Skan 87132720Skan#ifdef _GLIBCXX_USE_WCHAR_T 88103447Skan ctype<wchar_t>::ctype(size_t __refs) 89132720Skan : __ctype_abstract_base<wchar_t>(__refs), 90132720Skan _M_c_locale_ctype(_S_get_c_locale()), _M_narrow_ok(false) 91132720Skan { _M_initialize_ctype(); } 92103447Skan 93103447Skan ctype<wchar_t>::ctype(__c_locale __cloc, size_t __refs) 94132720Skan : __ctype_abstract_base<wchar_t>(__refs), 95132720Skan _M_c_locale_ctype(_S_clone_c_locale(__cloc)), _M_narrow_ok(false) 96132720Skan { _M_initialize_ctype(); } 97103447Skan 98103447Skan ctype<wchar_t>::~ctype() 99107606Sobrien { _S_destroy_c_locale(_M_c_locale_ctype); } 100103447Skan 101103447Skan template<> 102103447Skan ctype_byname<wchar_t>::ctype_byname(const char* __s, size_t __refs) 103103447Skan : ctype<wchar_t>(__refs) 104132720Skan { 105132720Skan if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0) 106132720Skan { 107132720Skan this->_S_destroy_c_locale(this->_M_c_locale_ctype); 108132720Skan this->_S_create_c_locale(this->_M_c_locale_ctype, __s); 109132720Skan this->_M_initialize_ctype(); 110132720Skan } 111103447Skan } 112103447Skan#endif 113103447Skan 114169691Skan_GLIBCXX_END_NAMESPACE 115