ctype.cc

00001 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004
00002 // Free Software Foundation, Inc.
00003 //
00004 // This file is part of the GNU ISO C++ Library.  This library is free
00005 // software; you can redistribute it and/or modify it under the
00006 // terms of the GNU General Public License as published by the
00007 // Free Software Foundation; either version 2, or (at your option)
00008 // any later version.
00009 
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 
00015 // You should have received a copy of the GNU General Public License along
00016 // with this library; see the file COPYING.  If not, write to the Free
00017 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00018 // USA.
00019 
00020 // As a special exception, you may use this file as part of a free software
00021 // library without restriction.  Specifically, if other files instantiate
00022 // templates or use macros or inline functions from this file, or you compile
00023 // this file and link it with other files to produce an executable, this
00024 // file does not by itself cause the resulting executable to be covered by
00025 // the GNU General Public License.  This exception does not however
00026 // invalidate any other reasons why the executable file might be covered by
00027 // the GNU General Public License.
00028 
00029 #include <locale>
00030 
00031 namespace std 
00032 {
00033   // Definitions for static const data members of ctype_base.
00034   const ctype_base::mask ctype_base::space;
00035   const ctype_base::mask ctype_base::print;
00036   const ctype_base::mask ctype_base::cntrl;
00037   const ctype_base::mask ctype_base::upper;
00038   const ctype_base::mask ctype_base::lower;
00039   const ctype_base::mask ctype_base::alpha;
00040   const ctype_base::mask ctype_base::digit;
00041   const ctype_base::mask ctype_base::punct;
00042   const ctype_base::mask ctype_base::xdigit;
00043   const ctype_base::mask ctype_base::alnum;
00044   const ctype_base::mask ctype_base::graph;
00045 
00046   // Definitions for locale::id of standard facets that are specialized.
00047   locale::id ctype<char>::id;
00048 
00049 #ifdef _GLIBCXX_USE_WCHAR_T  
00050   locale::id ctype<wchar_t>::id;
00051 #endif
00052 
00053   template<>
00054     const ctype<char>&
00055     use_facet<ctype<char> >(const locale& __loc)
00056     {
00057       size_t __i = ctype<char>::id._M_id();
00058       const locale::_Impl* __tmp = __loc._M_impl;
00059       return static_cast<const ctype<char>&>(*(__tmp->_M_facets[__i]));
00060     }
00061 
00062 #ifdef _GLIBCXX_USE_WCHAR_T
00063   template<>
00064     const ctype<wchar_t>&
00065     use_facet<ctype<wchar_t> >(const locale& __loc)
00066     {
00067       size_t __i = ctype<wchar_t>::id._M_id();
00068       const locale::_Impl* __tmp = __loc._M_impl;
00069       return static_cast<const ctype<wchar_t>&>(*(__tmp->_M_facets[__i]));
00070     }
00071 #endif
00072 
00073   // XXX At some point, just rename this file to ctype_configure_char.cc
00074   // and compile it as a separate file instead of including it here.
00075   // Platform-specific initialization code for ctype tables.
00076   #include <bits/ctype_noninline.h>
00077 
00078   const size_t ctype<char>::table_size;
00079 
00080   ctype<char>::~ctype()
00081   { 
00082     _S_destroy_c_locale(_M_c_locale_ctype);
00083     if (_M_del) 
00084       delete[] this->table(); 
00085   }
00086 
00087 #ifdef _GLIBCXX_USE_WCHAR_T
00088   ctype<wchar_t>::ctype(size_t __refs) 
00089   : __ctype_abstract_base<wchar_t>(__refs), 
00090   _M_c_locale_ctype(_S_get_c_locale()), _M_narrow_ok(false)
00091   { _M_initialize_ctype(); }
00092 
00093   ctype<wchar_t>::ctype(__c_locale __cloc, size_t __refs) 
00094   : __ctype_abstract_base<wchar_t>(__refs),
00095   _M_c_locale_ctype(_S_clone_c_locale(__cloc)), _M_narrow_ok(false)
00096   { _M_initialize_ctype(); }
00097 
00098   ctype<wchar_t>::~ctype() 
00099   { _S_destroy_c_locale(_M_c_locale_ctype); }
00100 
00101   template<>
00102     ctype_byname<wchar_t>::ctype_byname(const char* __s, size_t __refs)
00103     : ctype<wchar_t>(__refs) 
00104     {       
00105       if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
00106     {
00107       this->_S_destroy_c_locale(this->_M_c_locale_ctype);
00108       this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
00109       this->_M_initialize_ctype();
00110     }
00111     }
00112 #endif
00113 } // namespace std
00114 

Generated on Fri May 6 01:08:53 2005 for libstdc++-v3 Source by  doxygen 1.4.2