Whole document tree
    

Whole document tree

locale_facets.h Source File
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

locale_facets.h

Go to the documentation of this file.
00001 // Locale support -*- C++ -*-
00002 
00003 // Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // You should have received a copy of the GNU General Public License along
00017 // with this library; see the file COPYING.  If not, write to the Free
00018 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00019 // USA.
00020 
00021 // As a special exception, you may use this file as part of a free software
00022 // library without restriction.  Specifically, if other files instantiate
00023 // templates or use macros or inline functions from this file, or you compile
00024 // this file and link it with other files to produce an executable, this
00025 // file does not by itself cause the resulting executable to be covered by
00026 // the GNU General Public License.  This exception does not however
00027 // invalidate any other reasons why the executable file might be covered by
00028 // the GNU General Public License.
00029 
00030 //
00031 // ISO C++ 14882: 22.1  Locales
00032 //
00033 
00034 // Warning: this file is not meant for user inclusion.  Use <locale>.
00035 
00036 #ifndef _CPP_BITS_LOCFACETS_H
00037 #define _CPP_BITS_LOCFACETS_H   1
00038 
00039 #pragma GCC system_header
00040 
00041 #include <bits/std_ctime.h> // For struct tm
00042 #include <bits/std_ios.h>   // For ios_base
00043 #ifdef _GLIBCPP_USE_WCHAR_T
00044 # include <langinfo.h>      // For codecvt
00045 # include <bits/std_cwctype.h>  // For wctype_t
00046 # include <iconv.h>     // For codecvt using iconv, iconv_t
00047 #endif 
00048 
00049 namespace std
00050 {
00051   // 22.2.1.1  Template class ctype
00052   // Include host-specific ctype enums for ctype_base.
00053   #include <bits/ctype_base.h>
00054 
00055   // __ctype_abstract_base is the common base for ctype<_CharT>.  
00056   template<typename _CharT>
00057     class __ctype_abstract_base : public locale::facet, public ctype_base
00058     {
00059     public:
00060       // Types:
00061       typedef _CharT char_type;
00062 
00063       bool 
00064       is(mask __m, char_type __c) const
00065       { return this->do_is(__m, __c); }
00066 
00067       const char_type*
00068       is(const char_type *__lo, const char_type *__hi, mask *__vec) const   
00069       { return this->do_is(__lo, __hi, __vec); }
00070 
00071       const char_type*
00072       scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
00073       { return this->do_scan_is(__m, __lo, __hi); }
00074 
00075       const char_type*
00076       scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
00077       { return this->do_scan_not(__m, __lo, __hi); }
00078 
00079       char_type 
00080       toupper(char_type __c) const
00081       { return this->do_toupper(__c); }
00082 
00083       const char_type*
00084       toupper(char_type *__lo, const char_type* __hi) const
00085       { return this->do_toupper(__lo, __hi); }
00086 
00087       char_type 
00088       tolower(char_type __c) const
00089       { return this->do_tolower(__c); }
00090 
00091       const char_type*
00092       tolower(char_type* __lo, const char_type* __hi) const
00093       { return this->do_tolower(__lo, __hi); }
00094 
00095       char_type 
00096       widen(char __c) const
00097       { return this->do_widen(__c); }
00098 
00099       const char*
00100       widen(const char* __lo, const char* __hi, char_type* __to) const
00101       { return this->do_widen(__lo, __hi, __to); }
00102 
00103       char 
00104       narrow(char_type __c, char __dfault) const
00105       { return this->do_narrow(__c, __dfault); }
00106 
00107       const char_type*
00108       narrow(const char_type* __lo, const char_type* __hi,
00109           char __dfault, char *__to) const
00110       { return this->do_narrow(__lo, __hi, __dfault, __to); }
00111 
00112     protected:
00113       explicit 
00114       __ctype_abstract_base(size_t __refs = 0): locale::facet(__refs) { }
00115 
00116       virtual 
00117       ~__ctype_abstract_base() { }
00118       
00119       virtual bool 
00120       do_is(mask __m, char_type __c) const = 0;
00121 
00122       virtual const char_type*
00123       do_is(const char_type* __lo, const char_type* __hi, 
00124         mask* __vec) const = 0;
00125 
00126       virtual const char_type*
00127       do_scan_is(mask __m, const char_type* __lo,
00128          const char_type* __hi) const = 0;
00129 
00130       virtual const char_type*
00131       do_scan_not(mask __m, const char_type* __lo, 
00132           const char_type* __hi) const = 0;
00133 
00134       virtual char_type 
00135       do_toupper(char_type) const = 0;
00136 
00137       virtual const char_type*
00138       do_toupper(char_type* __lo, const char_type* __hi) const = 0;
00139 
00140       virtual char_type 
00141       do_tolower(char_type) const = 0;
00142 
00143       virtual const char_type*
00144       do_tolower(char_type* __lo, const char_type* __hi) const = 0;
00145       
00146       virtual char_type 
00147       do_widen(char) const = 0;
00148 
00149       virtual const char*
00150       do_widen(const char* __lo, const char* __hi, 
00151            char_type* __dest) const = 0;
00152 
00153       virtual char 
00154       do_narrow(char_type, char __dfault) const = 0;
00155 
00156       virtual const char_type*
00157       do_narrow(const char_type* __lo, const char_type* __hi,
00158          char __dfault, char* __dest) const = 0;
00159     };
00160 
00161   // NB: Generic, mostly useless implementation.
00162   template<typename _CharT>
00163     class ctype : public __ctype_abstract_base<_CharT>
00164     {
00165     public:
00166       // Types:
00167       typedef _CharT            char_type;
00168       typedef typename ctype::mask  mask;
00169 
00170       explicit 
00171       ctype(size_t __refs = 0) : __ctype_abstract_base<_CharT>(__refs) { }
00172 
00173       static locale::id id;
00174 
00175    protected:
00176       virtual 
00177       ~ctype() { }
00178 
00179       virtual bool 
00180       do_is(mask __m, char_type __c) const
00181       { return false; }
00182 
00183       virtual const char_type*
00184       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const
00185       { return __hi; }
00186 
00187       virtual const char_type*
00188       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
00189       { return __hi; }
00190 
00191       virtual const char_type*
00192       do_scan_not(mask __m, const char_type* __lo,
00193           const char_type* __hi) const
00194       { return __hi; }
00195 
00196       virtual char_type 
00197       do_toupper(char_type __c) const
00198       { return __c; }
00199 
00200       virtual const char_type*
00201       do_toupper(char_type* __lo, const char_type* __hi) const
00202       { return __hi; }
00203 
00204       virtual char_type 
00205       do_tolower(char_type __c) const
00206       { return __c; }
00207 
00208       virtual const char_type*
00209       do_tolower(char_type* __lo, const char_type* __hi) const
00210       { return __hi; }
00211       
00212       virtual char_type 
00213       do_widen(char __c) const
00214       { return char_type(); }
00215 
00216       virtual const char*
00217       do_widen(const char* __lo, const char* __hi, char_type* __dest) const
00218       { return __hi; }
00219 
00220       virtual char 
00221       do_narrow(char_type, char __dfault) const
00222       { return __dfault; }
00223 
00224       virtual const char_type*
00225       do_narrow(const char_type* __lo, const char_type* __hi,
00226         char __dfault, char* __dest) const
00227       { return __hi; }
00228     };
00229 
00230   template<typename _CharT>
00231     locale::id ctype<_CharT>::id;
00232 
00233   // 22.2.1.3  ctype specializations
00234   template<>
00235     class ctype<char> : public __ctype_abstract_base<char>
00236     {
00237     public:
00238       // Types:
00239       typedef char         char_type;
00240 
00241     private:
00242       // Data Members:
00243       bool             _M_del;
00244       __to_type const&         _M_toupper;
00245       __to_type const&         _M_tolower;
00246       const mask* const&       _M_ctable;
00247       const mask*              _M_table;
00248       
00249     public:
00250       static locale::id        id;
00251       static const size_t      table_size = 1 + static_cast<unsigned char>(-1);
00252 
00253       explicit 
00254       ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0);
00255 
00256       inline bool 
00257       is(mask __m, char __c) const;
00258  
00259       inline const char*
00260       is(const char* __lo, const char* __hi, mask* __vec) const;
00261  
00262       inline const char*
00263       scan_is(mask __m, const char* __lo, const char* __hi) const;
00264 
00265       inline const char*
00266       scan_not(mask __m, const char* __lo, const char* __hi) const;
00267      
00268     protected:
00269       virtual 
00270       ~ctype();
00271 
00272       const mask* 
00273       table() const throw()
00274       { return _M_table; }
00275 
00276       const mask* 
00277       classic_table() throw()
00278       { return _M_ctable; }
00279 
00280       virtual bool 
00281       do_is(mask __m, char_type __c) const;
00282 
00283       virtual const char_type*
00284       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
00285 
00286       virtual const char_type*
00287       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
00288 
00289       virtual const char_type*
00290       do_scan_not(mask __m, const char_type* __lo, 
00291           const char_type* __hi) const;
00292 
00293       virtual char_type 
00294       do_toupper(char_type) const;
00295 
00296       virtual const char_type*
00297       do_toupper(char_type* __lo, const char_type* __hi) const;
00298 
00299       virtual char_type 
00300       do_tolower(char_type) const;
00301 
00302       virtual const char_type*
00303       do_tolower(char_type* __lo, const char_type* __hi) const;
00304       
00305       virtual char_type 
00306       do_widen(char) const;
00307 
00308       virtual const char*
00309       do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
00310 
00311       virtual char 
00312       do_narrow(char_type, char __dfault) const;
00313 
00314       virtual const char_type*
00315       do_narrow(const char_type* __lo, const char_type* __hi,
00316          char __dfault, char* __dest) const;
00317     };
00318  
00319   template<>
00320     const ctype<char>&
00321     use_facet<ctype<char> >(const locale& __loc);
00322 
00323 #ifdef _GLIBCPP_USE_WCHAR_T
00324   // ctype<wchar_t> specialization
00325   template<>
00326     class ctype<wchar_t> : public __ctype_abstract_base<wchar_t>
00327     {
00328     public:
00329       // Types:
00330       typedef wchar_t          char_type;
00331       typedef wctype_t         __wmask_type;
00332 
00333       // Data Members:
00334       static locale::id        id;
00335 
00336       explicit 
00337       ctype(size_t __refs = 0);
00338 
00339     protected:
00340       __wmask_type
00341       _M_convert_to_wmask(const mask __m) const;
00342 
00343       virtual 
00344       ~ctype();
00345 
00346       virtual bool 
00347       do_is(mask __m, char_type __c) const;
00348 
00349       virtual const char_type*
00350       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
00351 
00352       virtual const char_type*
00353       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
00354 
00355       virtual const char_type*
00356       do_scan_not(mask __m, const char_type* __lo, 
00357           const char_type* __hi) const;
00358 
00359       virtual char_type 
00360       do_toupper(char_type) const;
00361 
00362       virtual const char_type*
00363       do_toupper(char_type* __lo, const char_type* __hi) const;
00364 
00365       virtual char_type 
00366       do_tolower(char_type) const;
00367 
00368       virtual const char_type*
00369       do_tolower(char_type* __lo, const char_type* __hi) const;
00370       
00371       virtual char_type 
00372       do_widen(char) const;
00373 
00374       virtual const char*
00375       do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
00376 
00377       virtual char 
00378       do_narrow(char_type, char __dfault) const;
00379 
00380       virtual const char_type*
00381       do_narrow(const char_type* __lo, const char_type* __hi,
00382          char __dfault, char* __dest) const;
00383 
00384     };
00385 
00386   template<>
00387     const ctype<wchar_t>&
00388     use_facet<ctype<wchar_t> >(const locale& __loc);
00389 #endif //_GLIBCPP_USE_WCHAR_T
00390 
00391   // Include host-specific ctype inlines.
00392   #include <bits/ctype_inline.h>
00393 
00394   // 22.2.1.2  Template class ctype_byname
00395   template<typename _CharT>
00396     class ctype_byname : public ctype<_CharT>
00397     {
00398     public:
00399       typedef _CharT        char_type;
00400 
00401       explicit 
00402       ctype_byname(const char*, size_t __refs = 0);
00403 
00404     protected:
00405       virtual 
00406       ~ctype_byname() { }
00407     };
00408 
00409   // 22.2.1.4  Class ctype_byname specialization
00410   template<>
00411     ctype_byname<char>::ctype_byname(const char*, size_t refs);
00412 
00413 
00414   // 22.2.1.5  Template class codecvt
00415   #include <bits/codecvt.h>
00416 
00417   template<typename _CharT, typename _InIter>
00418     class _Numeric_get;  // forward
00419 
00420   // _Format_cache holds the information extracted from the numpunct<>
00421   // and moneypunct<> facets in a form optimized for parsing and
00422   // formatting.  It is stored via a void* pointer in the pword()
00423   // array of an iosbase object passed to the _get and _put facets.
00424   // NB: contains no user-serviceable parts.
00425   template<typename _CharT>
00426     class _Format_cache
00427     {
00428     public: 
00429       // Types:
00430       typedef _CharT                char_type;
00431       typedef char_traits<_CharT>       traits_type;
00432       typedef basic_string<_CharT>      string_type;
00433       typedef typename string_type::size_type   size_type;
00434 
00435       // Forward decls and Friends:
00436       friend class locale;
00437       template<typename _Char, typename _InIter>
00438         friend class _Numeric_get;
00439       friend class num_get<_CharT>;
00440       friend class num_put<_CharT>;
00441       friend class time_get<_CharT>;
00442       friend class money_get<_CharT>;
00443       friend class time_put<_CharT>;
00444       friend class money_put<_CharT>;
00445 
00446       // Data Members:
00447 
00448       // ios_base::pword() reserved cell
00449       static int        _S_pword_ix; 
00450 
00451       // True iff data members are consistent with the current locale,
00452       // ie imbue sets this to false.
00453       bool          _M_valid;
00454 
00455       // A list of valid numeric literals: for the standard "C" locale,
00456       // this would usually be: "-+xX0123456789abcdef0123456789ABCDEF"
00457       static const char     _S_literals[];
00458 
00459       // NB: Code depends on the order of definitions of the names
00460       // these are indices into _S_literals, above.
00461       // This string is formatted for putting, not getting. (output, not input)
00462       enum 
00463       {  
00464     _S_minus, 
00465     _S_plus, 
00466     _S_x, 
00467     _S_X, 
00468     _S_digits,
00469     _S_digits_end = _S_digits + 16,
00470     _S_udigits = _S_digits_end,  
00471     _S_udigits_end = _S_udigits + 16,
00472     _S_ee = _S_digits + 14, // For scientific notation, 'E'
00473     _S_Ee = _S_udigits + 14 // For scientific notation, 'e'
00474       };
00475 
00476       // The sign used to separate decimal values: for standard US
00477       // locales, this would usually be: "."
00478       // Abstracted from numpunct::decimal_point().
00479       char_type         _M_decimal_point;
00480 
00481       // The sign used to separate groups of digits into smaller
00482       // strings that the eye can parse with less difficulty: for
00483       // standard US locales, this would usually be: ","
00484       // Abstracted from numpunct::thousands_sep().
00485       char_type         _M_thousands_sep;
00486 
00487       // However the US's "false" and "true" are translated.
00488       // From numpunct::truename() and numpunct::falsename(), respectively.
00489       string_type       _M_truename;
00490       string_type       _M_falsename;
00491 
00492       // If we are checking groupings. This should be equivalent to 
00493       // numpunct::groupings().size() != 0
00494       bool          _M_use_grouping;
00495 
00496       // If we are using numpunct's groupings, this is the current
00497       // grouping string in effect (from numpunct::grouping()).
00498       string            _M_grouping;
00499 
00500       _Format_cache();
00501 
00502       ~_Format_cache() throw() { }
00503 
00504       // Given a member of the ios heirarchy as an argument, extract
00505       // out all the current formatting information into a
00506       // _Format_cache object and return a pointer to it.
00507       static _Format_cache<_CharT>* 
00508       _S_get(ios_base& __ios);
00509 
00510       void 
00511       _M_populate(ios_base&);
00512 
00513       static void 
00514       _S_callback(ios_base::event __event, ios_base& __ios, int __ix) throw();
00515     };
00516 
00517   template<typename _CharT>
00518     int _Format_cache<_CharT>::_S_pword_ix;
00519 
00520   template<typename _CharT>
00521     const char _Format_cache<_CharT>::
00522     _S_literals[] = "-+xX0123456789abcdef0123456789ABCDEF";
00523 
00524    template<> _Format_cache<char>::_Format_cache();
00525 #ifdef _GLIBCPP_USE_WCHAR_T
00526    template<> _Format_cache<wchar_t>::_Format_cache();
00527 #endif
00528 
00529   // _Numeric_get is used by num_get, money_get, and time_get to help
00530   // in parsing out numbers.
00531   template<typename _CharT, typename _InIter>
00532     class _Numeric_get
00533     {
00534     public:
00535       // Types:
00536       typedef _CharT     char_type;
00537       typedef _InIter    iter_type;
00538 
00539       // Forward decls and Friends:
00540       template<typename _Char, typename _InIterT>
00541       friend class num_get;
00542       template<typename _Char, typename _InIterT>
00543       friend class time_get;
00544       template<typename _Char, typename _InIterT>
00545       friend class money_get;
00546       template<typename _Char, typename _InIterT>
00547       friend class num_put;
00548       template<typename _Char, typename _InIterT>
00549       friend class time_put;
00550       template<typename _Char, typename _InIterT>
00551       friend class money_put;
00552 
00553     private:
00554       explicit 
00555       _Numeric_get() { }
00556 
00557       virtual 
00558       ~_Numeric_get() { }
00559 
00560       iter_type 
00561       _M_get_digits(iter_type __in, iter_type __end) const;
00562     };
00563 
00564   // This is the size of the buffer passed to _M_extract
00565   const int _M_extract_buffer_length = 32;
00566 
00567   template<typename _CharT, typename _InIter>
00568     class num_get : public locale::facet
00569     {
00570     public:
00571       // Types:
00572       typedef _CharT            char_type;
00573       typedef _InIter           iter_type;
00574       typedef char_traits<_CharT>   __traits_type;
00575 
00576       static locale::id id;
00577 
00578       explicit 
00579       num_get(size_t __refs = 0) : locale::facet(__refs) { }
00580 
00581       iter_type 
00582       get(iter_type __in, iter_type __end, ios_base& __io,
00583       ios_base::iostate& __err, bool& __v) const
00584       { return do_get(__in, __end, __io, __err, __v); }
00585 
00586 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
00587       iter_type 
00588       get(iter_type __in, iter_type __end, ios_base& __io,
00589       ios_base::iostate& __err, short& __v) const
00590       { return do_get(__in, __end, __io, __err, __v); }
00591 
00592       iter_type 
00593       get(iter_type __in, iter_type __end, ios_base& __io,
00594       ios_base::iostate& __err, int& __v)   const
00595       { return do_get(__in, __end, __io, __err, __v); }
00596 #endif
00597 
00598       iter_type
00599       get(iter_type __in, iter_type __end, ios_base& __io, 
00600       ios_base::iostate& __err, long& __v) const
00601       { return do_get(__in, __end, __io, __err, __v); }
00602 
00603 #ifdef _GLIBCPP_USE_LONG_LONG
00604       iter_type 
00605       get(iter_type __in, iter_type __end, ios_base& __io,
00606       ios_base::iostate& __err, long long& __v) const
00607       { return do_get(__in, __end, __io, __err, __v); }
00608 #endif
00609 
00610       iter_type 
00611       get(iter_type __in, iter_type __end, ios_base& __io,
00612       ios_base::iostate& __err, unsigned short& __v) const
00613       { return do_get(__in, __end, __io, __err, __v); }
00614 
00615       iter_type 
00616       get(iter_type __in, iter_type __end, ios_base& __io,
00617       ios_base::iostate& __err, unsigned int& __v)   const
00618       { return do_get(__in, __end, __io, __err, __v); }
00619 
00620       iter_type 
00621       get(iter_type __in, iter_type __end, ios_base& __io,
00622       ios_base::iostate& __err, unsigned long& __v)  const
00623       { return do_get(__in, __end, __io, __err, __v); }
00624 
00625 #ifdef _GLIBCPP_USE_LONG_LONG
00626       iter_type 
00627       get(iter_type __in, iter_type __end, ios_base& __io,
00628       ios_base::iostate& __err, unsigned long long& __v)  const
00629       { return do_get(__in, __end, __io, __err, __v); }
00630 #endif
00631 
00632       iter_type 
00633       get(iter_type __in, iter_type __end, ios_base& __io,
00634       ios_base::iostate& __err, float& __v) const
00635       { return do_get(__in, __end, __io, __err, __v); }
00636 
00637       iter_type 
00638       get(iter_type __in, iter_type __end, ios_base& __io,
00639       ios_base::iostate& __err, double& __v) const
00640       { return do_get(__in, __end, __io, __err, __v); }
00641 
00642       iter_type 
00643       get(iter_type __in, iter_type __end, ios_base& __io,
00644       ios_base::iostate& __err, long double& __v) const
00645       { return do_get(__in, __end, __io, __err, __v); }
00646 
00647       iter_type 
00648       get(iter_type __in, iter_type __end, ios_base& __io,
00649       ios_base::iostate& __err, void*& __v) const
00650       { return do_get(__in, __end, __io, __err, __v); }      
00651 
00652     protected:
00653       virtual ~num_get() { }
00654 
00655       // This consolidates the extraction, storage and
00656       // error-processing parts of the do_get(...) overloaded member
00657       // functions. 
00658       // NB: This is specialized for char.
00659       void 
00660       _M_extract(iter_type __beg, iter_type __end, ios_base& __io, 
00661          ios_base::iostate& __err, char* __xtrc, 
00662          int& __base, bool __fp = true) const;
00663 
00664       virtual iter_type 
00665       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
00666 
00667 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
00668       virtual iter_type 
00669       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, short&) const;
00670       virtual iter_type 
00671       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, int&) const;
00672 #endif
00673       virtual iter_type 
00674       do_get (iter_type, iter_type, ios_base&, ios_base::iostate&, long&) const;
00675 #ifdef _GLIBCPP_USE_LONG_LONG 
00676       virtual iter_type 
00677       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, 
00678          long long&) const;
00679 #endif
00680       virtual iter_type 
00681       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, 
00682           unsigned short&) const;
00683       virtual iter_type 
00684       do_get(iter_type, iter_type, ios_base&,
00685           ios_base::iostate& __err, unsigned int&) const;
00686       virtual iter_type 
00687       do_get(iter_type, iter_type, ios_base&,
00688           ios_base::iostate& __err, unsigned long&) const;
00689 #ifdef _GLIBCPP_USE_LONG_LONG 
00690       virtual iter_type 
00691       do_get(iter_type, iter_type, ios_base&,
00692          ios_base::iostate& __err, unsigned long long&) const;
00693 #endif
00694       virtual iter_type 
00695       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, 
00696          float&) const;
00697 
00698       virtual iter_type 
00699       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, 
00700          double&) const;
00701 
00702       virtual iter_type 
00703       do_get(iter_type, iter_type, ios_base&, 
00704          ios_base::iostate& __err, long double&) const;
00705 
00706       virtual iter_type 
00707       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, 
00708          void*&) const;
00709     };
00710 
00711   template<typename _CharT, typename _InIter>
00712     locale::id num_get<_CharT, _InIter>::id;
00713 
00714   // Declare specialized extraction member function.
00715   template<>
00716     void
00717     num_get<char, istreambuf_iterator<char> >::    
00718     _M_extract(istreambuf_iterator<char> __beg, 
00719            istreambuf_iterator<char> __end, ios_base& __io, 
00720            ios_base::iostate& __err, char* __xtrc, 
00721            int& __base, bool __fp) const;
00722 
00723   // _Numeric_put is used by num_put, money_put, and time_put
00724   //   to help in formatting out numbers.
00725   template<typename _CharT, typename _OutIter>
00726     class _Numeric_put
00727     {
00728     public:
00729       typedef _CharT      char_type;
00730       typedef _OutIter    iter_type;
00731     protected:
00732       explicit 
00733       _Numeric_put() { }
00734 
00735       virtual 
00736       ~_Numeric_put() { }
00737     };
00738 
00739   template<typename _CharT, typename _OutIter>
00740     class num_put : public locale::facet
00741     {
00742     public:
00743       // Types:
00744       typedef _CharT       char_type;
00745       typedef _OutIter     iter_type;
00746 
00747       static locale::id id;
00748 
00749       explicit 
00750       num_put(size_t __refs = 0) : locale::facet(__refs) { }
00751 
00752       iter_type 
00753       put(iter_type __s, ios_base& __f, char_type __fill, bool __v) const
00754       { return do_put(__s, __f, __fill, __v); }
00755 
00756       iter_type 
00757       put(iter_type __s, ios_base& __f, char_type __fill, long __v) const
00758       { return do_put(__s, __f, __fill, __v); }
00759 
00760       iter_type 
00761       put(iter_type __s, ios_base& __f, char_type __fill, 
00762       unsigned long __v) const
00763       { return do_put(__s, __f, __fill, __v); }
00764 
00765 #ifdef _GLIBCPP_USE_LONG_LONG 
00766       iter_type 
00767       put(iter_type __s, ios_base& __f, char_type __fill, long long __v) const
00768       { return do_put(__s, __f, __fill, __v); }
00769 
00770       iter_type 
00771       put(iter_type __s, ios_base& __f, char_type __fill, 
00772       unsigned long long __v) const
00773       { return do_put(__s, __f, __fill, __v); }
00774 #endif
00775 
00776       iter_type 
00777       put(iter_type __s, ios_base& __f, char_type __fill, double __v) const
00778       { return do_put(__s, __f, __fill, __v); }
00779 
00780       iter_type 
00781       put(iter_type __s, ios_base& __f, char_type __fill, 
00782       long double __v) const
00783       { return do_put(__s, __f, __fill, __v); }
00784 
00785       iter_type 
00786       put(iter_type __s, ios_base& __f, char_type __fill, 
00787       const void* __v) const
00788       { return do_put(__s, __f, __fill, __v); }
00789 
00790     protected:
00791       virtual 
00792       ~num_put() { };
00793 
00794       virtual iter_type 
00795       do_put(iter_type, ios_base&, char_type __fill, bool __v) const;
00796 
00797       virtual iter_type 
00798       do_put(iter_type, ios_base&, char_type __fill, long __v) const;
00799 
00800 #ifdef _GLIBCPP_USE_LONG_LONG 
00801       virtual iter_type 
00802       do_put(iter_type, ios_base&, char_type __fill, long long __v) const;
00803 #endif
00804 
00805       virtual iter_type 
00806       do_put(iter_type, ios_base&, char_type __fill, unsigned long) const;
00807 
00808 #ifdef _GLIBCPP_USE_LONG_LONG
00809       virtual iter_type
00810       do_put(iter_type, ios_base&, char_type __fill, unsigned long long) const;
00811 #endif
00812 
00813       virtual iter_type 
00814       do_put(iter_type, ios_base&, char_type __fill, double __v) const;
00815 
00816       virtual iter_type 
00817       do_put(iter_type, ios_base&, char_type __fill, long double __v) const;
00818 
00819       virtual iter_type 
00820       do_put(iter_type, ios_base&, char_type __fill, const void* __v) const;
00821     };
00822 
00823   template <typename _CharT, typename _OutIter>
00824     locale::id num_put<_CharT, _OutIter>::id;
00825 
00826   template<typename _CharT>
00827     class numpunct : public locale::facet
00828     {
00829     public:
00830       // Types:
00831       typedef _CharT                char_type;
00832       typedef basic_string<_CharT>  string_type;
00833 
00834       static locale::id id;
00835 
00836     private:
00837       char_type     _M_decimal_point;
00838       char_type     _M_thousands_sep;
00839       string        _M_grouping;
00840       string_type   _M_truename;
00841       string_type   _M_falsename;
00842 
00843     public:
00844       explicit 
00845       numpunct(size_t __refs = 0) : locale::facet(__refs) 
00846       { _M_initialize_numpunct(); }
00847 
00848       explicit 
00849       numpunct(__c_locale __cloc, size_t __refs = 0) : locale::facet(__refs) 
00850       { _M_initialize_numpunct(__cloc); }
00851 
00852       char_type    
00853       decimal_point() const
00854       { return do_decimal_point(); }
00855 
00856       char_type    
00857       thousands_sep() const
00858       { return do_thousands_sep(); }
00859 
00860       string       
00861       grouping() const
00862       { return do_grouping(); }
00863 
00864       string_type  
00865       truename() const
00866       { return do_truename(); }
00867 
00868       string_type  
00869       falsename() const
00870       { return do_falsename(); }
00871 
00872     protected:
00873       virtual 
00874       ~numpunct() { }
00875 
00876       virtual char_type    
00877       do_decimal_point() const
00878       { return _M_decimal_point; }
00879 
00880       virtual char_type    
00881       do_thousands_sep() const
00882       { return _M_thousands_sep; }
00883 
00884       virtual string
00885       do_grouping() const
00886       { return _M_grouping; }
00887 
00888       virtual string_type  
00889       do_truename() const
00890       { return _M_truename; }
00891 
00892       virtual string_type  
00893       do_falsename() const
00894       { return _M_falsename; }
00895 
00896       // For use at construction time only.
00897       void 
00898       _M_initialize_numpunct(__c_locale __cloc = NULL);
00899     };
00900 
00901   template<typename _CharT>
00902     locale::id numpunct<_CharT>::id;
00903 
00904   template<typename _CharT>
00905     void
00906     numpunct<_CharT>::_M_initialize_numpunct(__c_locale /*__cloc*/)
00907     { 
00908       // NB: Cannot be made generic. 
00909     }
00910 
00911   template<> 
00912     void
00913     numpunct<char>::_M_initialize_numpunct(__c_locale __cloc);
00914 #ifdef _GLIBCPP_USE_WCHAR_T
00915   template<> 
00916     void
00917     numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc);
00918 #endif
00919 
00920 
00921   template<typename _CharT>
00922     class numpunct_byname : public numpunct<_CharT>
00923     {
00924       __c_locale            _M_c_locale_numpunct;
00925     public:
00926       typedef _CharT                char_type;
00927       typedef basic_string<_CharT>  string_type;
00928 
00929       explicit 
00930       numpunct_byname(const char* __s, size_t __refs = 0)
00931       : numpunct<_CharT>(__refs)
00932       {
00933     _S_create_c_locale(_M_c_locale_numpunct, __s);
00934     _M_initialize_numpunct(_M_c_locale_numpunct);   
00935       }
00936 
00937     protected:
00938       virtual 
00939       ~numpunct_byname() 
00940       { _S_destroy_c_locale(_M_c_locale_numpunct); }
00941     };
00942 
00943 
00944   template<typename _CharT>
00945     class collate : public locale::facet
00946     {
00947     public:
00948       // Types:
00949       typedef _CharT               char_type;
00950       typedef basic_string<_CharT> string_type;
00951 
00952       static locale::id id;
00953 
00954       explicit 
00955       collate(size_t __refs = 0) : locale::facet(__refs) { }
00956 
00957       int 
00958       compare(const _CharT* __lo1, const _CharT* __hi1,
00959           const _CharT* __lo2, const _CharT* __hi2) const
00960       { return this->do_compare(__lo1, __hi1, __lo2, __hi2); }
00961 
00962       string_type 
00963       transform(const _CharT* __lo, const _CharT* __hi) const
00964       { return this->do_transform(__lo, __hi); }
00965 
00966       long 
00967       hash(const _CharT* __lo, const _CharT* __hi) const
00968       { return this->do_hash(__lo, __hi); }
00969       
00970   protected:
00971       ~collate() { } // virtual
00972 
00973       virtual int  
00974       do_compare(const _CharT* __lo1, const _CharT* __hi1,
00975          const _CharT* __lo2, const _CharT* __hi2) const;
00976 
00977       virtual string_type 
00978       do_transform(const _CharT* __lo, const _CharT* __hi) const;
00979 
00980       virtual long   
00981       do_hash(const _CharT* __lo, const _CharT* __hi) const;
00982     };
00983 
00984   template<typename _CharT>
00985     locale::id collate<_CharT>::id;
00986 
00987   // Required specializations.
00988   template<>
00989     int 
00990     collate<char>::do_compare(const char* __lo1, const char* __hi1, 
00991                   const char* __lo2, const char* __hi2) const;
00992 
00993   template<>
00994     string
00995     collate<char>::do_transform(const char* __lo, const char* __hi) const;
00996 
00997   template<>
00998     long
00999     collate<char>::do_hash(const char* __lo, const char* __hi) const;
01000 #ifdef _GLIBCPP_USE_WCHAR_T
01001   template<>
01002     int 
01003     collate<wchar_t>::do_compare(const wchar_t* __lo1, const wchar_t* __hi1, 
01004                  const wchar_t* __lo2, 
01005                  const wchar_t* __hi2) const;
01006 
01007   template<>
01008     wstring
01009     collate<wchar_t>::do_transform(const wchar_t* __lo, 
01010                    const wchar_t* __hi) const;
01011 
01012   template<>
01013     long
01014     collate<wchar_t>::do_hash(const wchar_t* __lo, const wchar_t* __hi) const;
01015 #endif
01016 
01017   template<typename _CharT>
01018     class collate_byname : public collate<_CharT>
01019     {
01020     public:
01021       // Types:
01022       typedef _CharT               char_type;
01023       typedef basic_string<_CharT> string_type;
01024 
01025       explicit 
01026       collate_byname(const char*, size_t __refs = 0);
01027 
01028     protected:
01029       virtual 
01030       ~collate_byname() { }
01031     };
01032 
01033   template<>
01034     collate_byname<char>::collate_byname(const char*, size_t __refs);
01035 #ifdef _GLIBCPP_USE_WCHAR_T
01036   template<>
01037     collate_byname<wchar_t>::collate_byname(const char*, size_t __refs);
01038 #endif
01039 
01040   class time_base
01041   {
01042   public:
01043     enum dateorder { no_order, dmy, mdy, ymd, ydm };
01044   };
01045 
01046   template<typename _CharT, typename _InIter>
01047     class time_get : public locale::facet, public time_base
01048     {
01049     public:
01050       // Types:
01051       typedef _CharT     char_type;
01052       typedef _InIter    iter_type;
01053 
01054       static locale::id id;
01055 
01056       explicit 
01057       time_get(size_t __refs = 0) 
01058       : locale::facet (__refs), _M_daynames(0), _M_monthnames(0) { }
01059 
01060       dateorder 
01061       date_order()  const
01062       { return do_date_order(); }
01063 
01064       iter_type 
01065       get_time(iter_type __s, iter_type __end, ios_base& __f, 
01066            ios_base::iostate& __err, tm* __t)  const
01067       { return do_get_time(__s, __end, __f, __err, __t); }
01068 
01069       iter_type 
01070       get_date(iter_type __s, iter_type __end, ios_base& __f,
01071            ios_base::iostate& __err, tm* __t)  const
01072       { return do_get_date(__s, __end, __f, __err, __t); }
01073 
01074       iter_type 
01075       get_weekday(iter_type __s, iter_type __end, ios_base& __f,
01076           ios_base::iostate& __err, tm* __t) const
01077       { return do_get_weekday(__s,__end,__f,__err,__t); }
01078 
01079       iter_type 
01080       get_monthname(iter_type __s, iter_type __end, ios_base& __f, 
01081             ios_base::iostate& __err, tm* __t) const
01082       { return do_get_monthname(__s,__end,__f,__err,__t); }
01083 
01084       iter_type 
01085       get_year(iter_type __s, iter_type __end, ios_base& __f,
01086            ios_base::iostate& __err, tm* __t) const
01087       { return do_get_year(__s,__end,__f,__err,__t); }
01088 
01089     protected:
01090       virtual 
01091       ~time_get() 
01092       {      
01093     delete [] _M_monthnames; 
01094     delete [] _M_daynames; 
01095       }
01096 
01097       virtual dateorder 
01098       do_date_order()  const
01099       { return time_base::ymd; }
01100 
01101       virtual iter_type 
01102       do_get_time(iter_type __s, iter_type /*__end*/, ios_base&,
01103           ios_base::iostate& /*__err*/, tm* /*__t*/) const
01104       { return __s; }
01105 
01106       virtual iter_type 
01107       do_get_date(iter_type __s, iter_type /*__end*/, ios_base&,
01108           ios_base::iostate& /*__err*/, tm* /*__t*/) const
01109       { return __s; }
01110 
01111       virtual iter_type 
01112       do_get_weekday(iter_type __s, iter_type __end, ios_base&,
01113              ios_base::iostate& __err, tm* __t) const;
01114 
01115       virtual iter_type 
01116       do_get_monthname(iter_type __s, iter_type __end, ios_base&, 
01117                ios_base::iostate& __err, tm* __t) const;
01118 
01119       virtual iter_type 
01120       do_get_year(iter_type __s, iter_type /*__end*/, ios_base&,
01121            ios_base::iostate& /*__err*/, tm* /*__t*/) const
01122       { return __s; }
01123 
01124       mutable basic_string<_CharT>* _M_daynames;
01125       mutable basic_string<_CharT>* _M_monthnames;
01126     };
01127 
01128   template<typename _CharT, typename _InIter>
01129     locale::id time_get<_CharT, _InIter>::id;
01130 
01131   template<typename _CharT, typename _InIter>
01132     class time_get_byname : public time_get<_CharT, _InIter>
01133     {
01134     public:
01135       typedef _CharT     char_type;
01136       typedef _InIter    iter_type;
01137 
01138       explicit 
01139       time_get_byname(const char*, size_t __refs = 0) 
01140       : time_get<_CharT, _InIter>(__refs) { }
01141     protected:
01142       virtual 
01143       ~time_get_byname() { }
01144     };
01145 
01146   template<typename _CharT, typename _OutIter>
01147     class time_put : public locale::facet, public time_base
01148     {
01149     public:
01150       typedef _CharT     char_type;
01151       typedef _OutIter   iter_type;
01152 
01153       static locale::id id;
01154 
01155       explicit 
01156       time_put(size_t __refs = 0) : locale::facet (__refs) { }
01157 
01158       // NB: this is a nonvirtual, calls do_put in a loop.
01159       iter_type 
01160       put(iter_type __s, ios_base& /*__f*/, char_type /*__fill*/,
01161           const tm* /*__tmb*/, const _CharT* /*__pattern*/,
01162           const _CharT* /*__pat_end*/) const
01163       { return __s; }
01164 
01165       iter_type 
01166       put(iter_type __s, ios_base& __f, char_type __fill,
01167       const tm* __tmb, char __format, char __modifier = 0) const
01168       { return do_put(__s, __f, __fill, __tmb, __format, __modifier); }
01169 
01170     protected:
01171       virtual 
01172       ~time_put() { }
01173 
01174       virtual iter_type 
01175       do_put(iter_type __s, ios_base&, char_type, const tm* /*__t*/, 
01176          char /*__format*/, char /*__mod*/) const
01177       { return __s; }
01178     };
01179 
01180   template<typename _CharT, typename _OutIter>
01181     locale::id time_put<_CharT, _OutIter>::id;
01182 
01183   template<typename _CharT, typename _OutIter>
01184     class time_put_byname : public time_put<_CharT, _OutIter>
01185     {
01186     public:
01187       typedef _CharT     char_type;
01188       typedef _OutIter   iter_type;
01189 
01190       explicit 
01191       time_put_byname(const char*, size_t __refs = 0) 
01192       : time_put<_CharT, _OutIter> (__refs) { }
01193 
01194     protected:
01195       virtual 
01196       ~time_put_byname() { }
01197     };
01198 
01199 
01200   template<typename _CharT, typename _InIter>
01201     class money_get : public locale::facet
01202     {
01203     public:
01204       typedef _CharT        char_type;
01205       typedef _InIter       iter_type;
01206       typedef basic_string<_CharT> string_type;
01207 
01208       static locale::id id;
01209 
01210       explicit 
01211       money_get(size_t __refs = 0) : locale::facet(__refs) { }
01212 
01213       iter_type 
01214       get(iter_type __s, iter_type __end, bool __intl,
01215       ios_base& __f, ios_base::iostate& __err, long double& __units) const
01216       { return do_get(__s, __end, __intl, __f, __err, __units); }
01217 
01218       iter_type 
01219       get(iter_type __s, iter_type __end, bool __intl, ios_base& __f, 
01220        ios_base::iostate& __err, string_type& __digits) const
01221       { return do_get(__s, __end, __intl, __f, __err, __digits); }
01222 
01223     protected:
01224       virtual 
01225       ~money_get() { }
01226 
01227       virtual iter_type 
01228       do_get(iter_type __s, iter_type /*__end*/, bool /*__intl*/,
01229              ios_base& /*__io*/, ios_base::iostate& /*__err*/,
01230              long double& /*__units*/) const
01231       { return __s; }
01232 
01233       virtual iter_type 
01234       do_get(iter_type __s, iter_type /*__end*/, bool /*__intl*/,
01235              ios_base& /*__io*/, ios_base::iostate& /*__err*/,
01236              string_type& /*__digits*/) const
01237       { return __s; }
01238     };
01239 
01240   template<typename _CharT, typename _InIter>
01241     locale::id money_get<_CharT, _InIter>::id;
01242 
01243   template<typename _CharT, typename _OutIter>
01244     class money_put : public locale::facet
01245     {
01246     public:
01247       typedef _CharT              char_type;
01248       typedef _OutIter            iter_type;
01249       typedef basic_string<_CharT> string_type;
01250 
01251       static locale::id id;
01252 
01253       explicit 
01254       money_put(size_t __refs = 0) : locale::facet(__refs) { }
01255 
01256       iter_type 
01257       put(iter_type __s, bool __intl, ios_base& __f,
01258       char_type __fill, long double __units) const
01259       { return do_put(__s, __intl, __f, __fill, __units); }
01260 
01261       iter_type 
01262       put(iter_type __s, bool __intl, ios_base& __f,
01263       char_type __fill, const string_type& __digits) const
01264       { return do_put(__s, __intl, __f, __fill, __digits); }
01265 
01266     protected:
01267       virtual 
01268       ~money_put() { }
01269 
01270       virtual iter_type
01271       do_put(iter_type __s, bool, ios_base& /*__io*/, char_type /*__fill*/,
01272          long double /*__units*/) const
01273       { return __s; }
01274 
01275       virtual iter_type
01276       do_put(iter_type __s, bool, ios_base& /*__io*/, char_type /*__fill*/,
01277          const string_type& /*__digits*/) const
01278       { return __s; }
01279     };
01280 
01281   template<typename _CharT, typename _OutIter>
01282     locale::id money_put<_CharT, _OutIter>::id;
01283 
01284   struct money_base
01285   {
01286     enum part { none, space, symbol, sign, value };
01287     struct pattern { char field[4]; };
01288 
01289     static const pattern _S_default_pattern;
01290 
01291     // Construct and return valid pattern consisting of some combination of:
01292     // space none symbol sign value
01293     static pattern 
01294     _S_construct_pattern(char __preceeds, char __space, char __posn);
01295   };
01296 
01297   template<typename _CharT, bool _Intl>
01298     class moneypunct : public locale::facet, public money_base
01299     {
01300     public:
01301       // Types:
01302       typedef _CharT            char_type;
01303       typedef basic_string<_CharT>  string_type;
01304 
01305       static const bool intl = _Intl;
01306       static locale::id id;
01307 
01308     private:
01309       char_type     _M_decimal_point;
01310       char_type     _M_thousands_sep;
01311       string        _M_grouping;
01312       string_type   _M_curr_symbol;
01313       string_type   _M_positive_sign;
01314       string_type   _M_negative_sign;
01315       int       _M_frac_digits;
01316       pattern       _M_pos_format;
01317       pattern       _M_neg_format;
01318 
01319     public:
01320       explicit 
01321       moneypunct(size_t __refs = 0) : locale::facet(__refs)
01322       { _M_initialize_moneypunct(); }
01323 
01324       explicit 
01325       moneypunct(__c_locale __cloc, size_t __refs = 0) : locale::facet(__refs)
01326       { _M_initialize_moneypunct(__cloc); }
01327 
01328       char_type
01329       decimal_point() const
01330       { return this->do_decimal_point(); }
01331       
01332       char_type
01333       thousands_sep() const
01334       { return this->do_thousands_sep(); }
01335       
01336       string 
01337       grouping() const
01338       { return this->do_grouping(); }
01339 
01340       string_type  
01341       curr_symbol() const
01342       { return this->do_curr_symbol(); }
01343 
01344       string_type  
01345       positive_sign() const
01346       { return this->do_positive_sign(); }
01347 
01348       string_type  
01349       negative_sign() const
01350       { return this->do_negative_sign(); }
01351 
01352       int          
01353       frac_digits() const
01354       { return this->do_frac_digits(); }
01355 
01356       pattern      
01357       pos_format() const
01358       { return this->do_pos_format(); }
01359 
01360       pattern      
01361       neg_format() const
01362       { return this->do_neg_format(); }
01363 
01364     protected:
01365       virtual 
01366       ~moneypunct() { }
01367 
01368       virtual char_type
01369       do_decimal_point() const
01370       { return _M_decimal_point; }
01371       
01372       virtual char_type
01373       do_thousands_sep() const
01374       { return _M_thousands_sep; }
01375       
01376       virtual string 
01377       do_grouping() const
01378       { return _M_grouping; }
01379 
01380       virtual string_type  
01381       do_curr_symbol()   const
01382       { return _M_curr_symbol; }
01383 
01384       virtual string_type  
01385       do_positive_sign() const
01386       { return _M_positive_sign; }
01387 
01388       virtual string_type  
01389       do_negative_sign() const
01390       { return _M_negative_sign; }
01391 
01392       virtual int          
01393       do_frac_digits() const
01394       { return _M_frac_digits; }
01395 
01396       virtual pattern      
01397       do_pos_format() const
01398       { return _M_pos_format; }
01399 
01400       virtual pattern      
01401       do_neg_format() const
01402       { return _M_neg_format; }
01403 
01404       // For use at construction time only.
01405       void 
01406       _M_initialize_moneypunct(__c_locale __cloc = NULL);
01407     };
01408 
01409   template<typename _CharT, bool _Intl>
01410     locale::id moneypunct<_CharT, _Intl>::id;
01411 
01412   template<typename _CharT, bool _Intl>
01413     const bool moneypunct<_CharT, _Intl>::intl;
01414 
01415   template<typename _CharT, bool _Intl>
01416     void
01417     moneypunct<_CharT, _Intl>::_M_initialize_moneypunct(__c_locale /*__cloc*/)
01418     { 
01419       // NB: Cannot be made generic. 
01420     }
01421 
01422   template<> 
01423     void
01424     moneypunct<char>::_M_initialize_moneypunct(__c_locale __cloc);
01425 #ifdef _GLIBCPP_USE_WCHAR_T
01426   template<> 
01427     void
01428     moneypunct<wchar_t>::_M_initialize_moneypunct(__c_locale __cloc);
01429 #endif
01430 
01431   template<typename _CharT, bool _Intl>
01432     class moneypunct_byname : public moneypunct<_CharT, _Intl>
01433     {
01434       __c_locale            _M_c_locale_moneypunct;
01435     public:
01436       typedef _CharT            char_type;
01437       typedef basic_string<_CharT>  string_type;
01438 
01439       static const bool intl = _Intl;
01440 
01441       explicit 
01442       moneypunct_byname(const char* __s, size_t __refs = 0)
01443       : moneypunct<_CharT, _Intl>(__refs)
01444       {
01445     _S_create_c_locale(_M_c_locale_moneypunct, __s);
01446     _M_initialize_moneypunct(_M_c_locale_moneypunct);   
01447       }
01448 
01449     protected:
01450       virtual 
01451       ~moneypunct_byname() 
01452       { _S_destroy_c_locale(_M_c_locale_moneypunct); }
01453     };
01454 
01455   template<typename _CharT, bool _Intl>
01456     const bool moneypunct_byname<_CharT, _Intl>::intl;
01457 
01458 
01459   struct messages_base
01460   {
01461     typedef int catalog;
01462   };
01463 
01464   template<typename _CharT>
01465     class messages : public locale::facet, public messages_base
01466     {
01467     public:
01468       typedef _CharT            char_type;
01469       typedef basic_string<_CharT>  string_type;
01470 
01471       static locale::id id;
01472 
01473       explicit 
01474       messages(size_t __refs = 0) : locale::facet(__refs) { }
01475 
01476       catalog 
01477       open(const basic_string<char>& __s, const locale& __loc) const
01478       { return do_open(__s, __loc); }
01479 
01480       string_type  
01481       get(catalog __c, int __set, int __msgid, const string_type& __s) const
01482       { return do_get(__c,__set,__msgid,__s); }
01483 
01484       void 
01485       close(catalog __c) const
01486       { return do_close(__c); }
01487 
01488     protected:
01489       virtual 
01490       ~messages() { }
01491 
01492       // NB: Probably these should be pure, and implemented only in
01493       //  specializations of messages<>.  But for now...
01494       virtual catalog 
01495       do_open(const basic_string<char>&, const locale&) const
01496       { return 0; }
01497 
01498       virtual string_type  
01499       do_get(catalog, int, int /*__msgid*/, const string_type& __dfault) const
01500       { return __dfault; }
01501 
01502       virtual void    
01503       do_close(catalog) const { }
01504     };
01505 
01506   template<typename _CharT>
01507     locale::id messages<_CharT>::id;
01508 
01509   template<typename _CharT>
01510     class messages_byname : public messages<_CharT>
01511     {
01512     public:
01513       typedef _CharT char_type;
01514       typedef basic_string<_CharT> string_type;
01515 
01516       explicit 
01517       messages_byname(const char*, size_t __refs = 0);
01518 
01519     protected:
01520       virtual 
01521       ~messages_byname() { }
01522     };
01523 
01524   template<>
01525     messages_byname<char>::messages_byname(const char*, size_t __refs);
01526 #ifdef _GLIBCPP_USE_WCHAR_T
01527   template<>
01528     messages_byname<wchar_t>::messages_byname(const char*, size_t __refs);
01529 #endif
01530 
01531   // Subclause convenience interfaces, inlines 
01532   // NB: these are inline
01533   // because, when used in a loop, some compilers can hoist the body
01534   // out of the loop; then it's just as fast as the C is*() function.
01535   template<typename _CharT>
01536     inline bool 
01537     isspace(_CharT __c, const locale& __loc)
01538     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c); }
01539 
01540   template<typename _CharT>
01541     inline bool 
01542     isprint(_CharT __c, const locale& __loc)
01543     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c); }
01544 
01545   template<typename _CharT>
01546     inline bool 
01547     iscntrl(_CharT __c, const locale& __loc)
01548     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c); }
01549 
01550   template<typename _CharT>
01551     inline bool 
01552     isupper(_CharT __c, const locale& __loc)
01553     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c); }
01554 
01555   template<typename _CharT>
01556     inline bool islower(_CharT __c, const locale& __loc)
01557     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c); }
01558 
01559   template<typename _CharT>
01560     inline bool 
01561     isalpha(_CharT __c, const locale& __loc)
01562     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c); }
01563 
01564   template<typename _CharT>
01565     inline bool 
01566     isdigit(_CharT __c, const locale& __loc)
01567     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c); }
01568 
01569   template<typename _CharT>
01570     inline bool 
01571     ispunct(_CharT __c, const locale& __loc)
01572     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c); }
01573 
01574   template<typename _CharT>
01575     inline bool 
01576     isxdigit(_CharT __c, const locale& __loc)
01577     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c); }
01578 
01579   template<typename _CharT>
01580     inline bool 
01581     isalnum(_CharT __c, const locale& __loc)
01582     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c); }
01583 
01584   template<typename _CharT>
01585     inline bool 
01586     isgraph(_CharT __c, const locale& __loc)
01587     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c); }
01588 
01589   template<typename _CharT>
01590     inline _CharT 
01591     toupper(_CharT __c, const locale& __loc)
01592     { return use_facet<ctype<_CharT> >(__loc).toupper(__c); }
01593 
01594   template<typename _CharT>
01595     inline _CharT 
01596     tolower(_CharT __c, const locale& __loc)
01597     { return use_facet<ctype<_CharT> >(__loc).tolower(__c); }
01598 } // namespace std
01599 
01600 #endif  /* _CPP_BITS_LOCFACETS_H */
01601 
01602 // Local Variables:
01603 // mode:c++
01604 // End:

Generated on Mon Apr 8 03:11:29 2002 for libstdc++-v3 Source by doxygen1.2.15