locale_facets.h

Go to the documentation of this file.
00001 // Locale support -*- C++ -*-
00002 
00003 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
00004 // Free Software Foundation, Inc.
00005 //
00006 // This file is part of the GNU ISO C++ Library.  This library is free
00007 // software; you can redistribute it and/or modify it under the
00008 // terms of the GNU General Public License as published by the
00009 // Free Software Foundation; either version 2, or (at your option)
00010 // any later version.
00011 
00012 // This library is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 
00017 // You should have received a copy of the GNU General Public License along
00018 // with this library; see the file COPYING.  If not, write to the Free
00019 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00020 // USA.
00021 
00022 // As a special exception, you may use this file as part of a free software
00023 // library without restriction.  Specifically, if other files instantiate
00024 // templates or use macros or inline functions from this file, or you compile
00025 // this file and link it with other files to produce an executable, this
00026 // file does not by itself cause the resulting executable to be covered by
00027 // the GNU General Public License.  This exception does not however
00028 // invalidate any other reasons why the executable file might be covered by
00029 // the GNU General Public License.
00030 
00031 //
00032 // ISO C++ 14882: 22.1  Locales
00033 //
00034 
00040 #ifndef _LOCALE_FACETS_H
00041 #define _LOCALE_FACETS_H 1
00042 
00043 #pragma GCC system_header
00044 
00045 #include <ctime>    // For struct tm
00046 #include <cwctype>  // For wctype_t
00047 #include <iosfwd>
00048 #include <bits/ios_base.h>  // For ios_base, ios_base::iostate
00049 #include <streambuf>
00050 
00051 namespace std
00052 {
00053   // NB: Don't instantiate required wchar_t facets if no wchar_t support.
00054 #ifdef _GLIBCXX_USE_WCHAR_T
00055 # define  _GLIBCXX_NUM_FACETS 28
00056 #else
00057 # define  _GLIBCXX_NUM_FACETS 14
00058 #endif
00059 
00060   // Convert string to numeric value of type _Tv and store results.
00061   // NB: This is specialized for all required types, there is no
00062   // generic definition.
00063   template<typename _Tv>
00064     void
00065     __convert_to_v(const char* __in, _Tv& __out, ios_base::iostate& __err,
00066            const __c_locale& __cloc);
00067 
00068   // Explicit specializations for required types.
00069   template<>
00070     void
00071     __convert_to_v(const char*, float&, ios_base::iostate&,
00072            const __c_locale&);
00073 
00074   template<>
00075     void
00076     __convert_to_v(const char*, double&, ios_base::iostate&,
00077            const __c_locale&);
00078 
00079   template<>
00080     void
00081     __convert_to_v(const char*, long double&, ios_base::iostate&,
00082            const __c_locale&);
00083 
00084   // NB: __pad is a struct, rather than a function, so it can be
00085   // partially-specialized.
00086   template<typename _CharT, typename _Traits>
00087     struct __pad
00088     {
00089       static void
00090       _S_pad(ios_base& __io, _CharT __fill, _CharT* __news,
00091          const _CharT* __olds, const streamsize __newlen,
00092          const streamsize __oldlen, const bool __num);
00093     };
00094 
00095   // Used by both numeric and monetary facets.
00096   // Inserts "group separator" characters into an array of characters.
00097   // It's recursive, one iteration per group.  It moves the characters
00098   // in the buffer this way: "xxxx12345" -> "12,345xxx".  Call this
00099   // only with __glen != 0.
00100   template<typename _CharT>
00101     _CharT*
00102     __add_grouping(_CharT* __s, _CharT __sep,
00103            const char* __gbeg, size_t __gsize,
00104            const _CharT* __first, const _CharT* __last);
00105 
00106   // This template permits specializing facet output code for
00107   // ostreambuf_iterator.  For ostreambuf_iterator, sputn is
00108   // significantly more efficient than incrementing iterators.
00109   template<typename _CharT>
00110     inline
00111     ostreambuf_iterator<_CharT>
00112     __write(ostreambuf_iterator<_CharT> __s, const _CharT* __ws, int __len)
00113     {
00114       __s._M_put(__ws, __len);
00115       return __s;
00116     }
00117 
00118   // This is the unspecialized form of the template.
00119   template<typename _CharT, typename _OutIter>
00120     inline
00121     _OutIter
00122     __write(_OutIter __s, const _CharT* __ws, int __len)
00123     {
00124       for (int __j = 0; __j < __len; __j++, ++__s)
00125     *__s = __ws[__j];
00126       return __s;
00127     }
00128 
00129 
00130   // 22.2.1.1  Template class ctype
00131   // Include host and configuration specific ctype enums for ctype_base.
00132   #include <bits/ctype_base.h>
00133 
00134   // Common base for ctype<_CharT>.
00144   template<typename _CharT>
00145     class __ctype_abstract_base : public locale::facet, public ctype_base
00146     {
00147     public:
00148       // Types:
00150       typedef _CharT char_type;
00151 
00162       bool
00163       is(mask __m, char_type __c) const
00164       { return this->do_is(__m, __c); }
00165 
00179       const char_type*
00180       is(const char_type *__lo, const char_type *__hi, mask *__vec) const
00181       { return this->do_is(__lo, __hi, __vec); }
00182 
00195       const char_type*
00196       scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
00197       { return this->do_scan_is(__m, __lo, __hi); }
00198 
00211       const char_type*
00212       scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
00213       { return this->do_scan_not(__m, __lo, __hi); }
00214 
00225       char_type
00226       toupper(char_type __c) const
00227       { return this->do_toupper(__c); }
00228 
00240       const char_type*
00241       toupper(char_type *__lo, const char_type* __hi) const
00242       { return this->do_toupper(__lo, __hi); }
00243 
00254       char_type
00255       tolower(char_type __c) const
00256       { return this->do_tolower(__c); }
00257 
00269       const char_type*
00270       tolower(char_type* __lo, const char_type* __hi) const
00271       { return this->do_tolower(__lo, __hi); }
00272 
00286       char_type
00287       widen(char __c) const
00288       { return this->do_widen(__c); }
00289 
00305       const char*
00306       widen(const char* __lo, const char* __hi, char_type* __to) const
00307       { return this->do_widen(__lo, __hi, __to); }
00308 
00324       char
00325       narrow(char_type __c, char __dfault) const
00326       { return this->do_narrow(__c, __dfault); }
00327 
00346       const char_type*
00347       narrow(const char_type* __lo, const char_type* __hi,
00348           char __dfault, char *__to) const
00349       { return this->do_narrow(__lo, __hi, __dfault, __to); }
00350 
00351     protected:
00352       explicit
00353       __ctype_abstract_base(size_t __refs = 0): facet(__refs) { }
00354 
00355       virtual
00356       ~__ctype_abstract_base() { }
00357 
00371       virtual bool
00372       do_is(mask __m, char_type __c) const = 0;
00373 
00390       virtual const char_type*
00391       do_is(const char_type* __lo, const char_type* __hi,
00392         mask* __vec) const = 0;
00393 
00409       virtual const char_type*
00410       do_scan_is(mask __m, const char_type* __lo,
00411          const char_type* __hi) const = 0;
00412 
00428       virtual const char_type*
00429       do_scan_not(mask __m, const char_type* __lo,
00430           const char_type* __hi) const = 0;
00431 
00446       virtual char_type
00447       do_toupper(char_type) const = 0;
00448 
00463       virtual const char_type*
00464       do_toupper(char_type* __lo, const char_type* __hi) const = 0;
00465 
00479       virtual char_type
00480       do_tolower(char_type) const = 0;
00481 
00496       virtual const char_type*
00497       do_tolower(char_type* __lo, const char_type* __hi) const = 0;
00498 
00515       virtual char_type
00516       do_widen(char) const = 0;
00517 
00536       virtual const char*
00537       do_widen(const char* __lo, const char* __hi,
00538            char_type* __dest) const = 0;
00539 
00558       virtual char
00559       do_narrow(char_type, char __dfault) const = 0;
00560 
00582       virtual const char_type*
00583       do_narrow(const char_type* __lo, const char_type* __hi,
00584         char __dfault, char* __dest) const = 0;
00585     };
00586 
00587   // NB: Generic, mostly useless implementation.
00605   template<typename _CharT>
00606     class ctype : public __ctype_abstract_base<_CharT>
00607     {
00608     public:
00609       // Types:
00610       typedef _CharT            char_type;
00611       typedef typename __ctype_abstract_base<_CharT>::mask mask;
00612 
00614       static locale::id         id;
00615 
00616       explicit
00617       ctype(size_t __refs = 0) : __ctype_abstract_base<_CharT>(__refs) { }
00618 
00619    protected:
00620       virtual
00621       ~ctype();
00622 
00623       virtual bool
00624       do_is(mask __m, char_type __c) const;
00625 
00626       virtual const char_type*
00627       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
00628 
00629       virtual const char_type*
00630       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
00631 
00632       virtual const char_type*
00633       do_scan_not(mask __m, const char_type* __lo,
00634           const char_type* __hi) const;
00635 
00636       virtual char_type
00637       do_toupper(char_type __c) const;
00638 
00639       virtual const char_type*
00640       do_toupper(char_type* __lo, const char_type* __hi) const;
00641 
00642       virtual char_type
00643       do_tolower(char_type __c) const;
00644 
00645       virtual const char_type*
00646       do_tolower(char_type* __lo, const char_type* __hi) const;
00647 
00648       virtual char_type
00649       do_widen(char __c) const;
00650 
00651       virtual const char*
00652       do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
00653 
00654       virtual char
00655       do_narrow(char_type, char __dfault) const;
00656 
00657       virtual const char_type*
00658       do_narrow(const char_type* __lo, const char_type* __hi,
00659         char __dfault, char* __dest) const;
00660     };
00661 
00662   template<typename _CharT>
00663     locale::id ctype<_CharT>::id;
00664 
00665   // 22.2.1.3  ctype<char> specialization.
00674   template<>
00675     class ctype<char> : public locale::facet, public ctype_base
00676     {
00677     public:
00678       // Types:
00680       typedef char      char_type;
00681 
00682     protected:
00683       // Data Members:
00684       __c_locale        _M_c_locale_ctype;
00685       bool          _M_del;
00686       __to_type         _M_toupper;
00687       __to_type         _M_tolower;
00688       const mask*       _M_table;
00689       mutable char      _M_widen_ok;
00690       mutable char      _M_widen[1 + static_cast<unsigned char>(-1)];
00691       mutable char      _M_narrow[1 + static_cast<unsigned char>(-1)];
00692       mutable char      _M_narrow_ok;   // 0 uninitialized, 1 init,
00693                         // 2 memcpy can't be used
00694 
00695     public:
00697       static locale::id        id;
00699       static const size_t      table_size = 1 + static_cast<unsigned char>(-1);
00700 
00711       explicit
00712       ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0);
00713 
00724       explicit
00725       ctype(__c_locale __cloc, const mask* __table = 0, bool __del = false,
00726         size_t __refs = 0);
00727 
00737       inline bool
00738       is(mask __m, char __c) const;
00739 
00752       inline const char*
00753       is(const char* __lo, const char* __hi, mask* __vec) const;
00754 
00766       inline const char*
00767       scan_is(mask __m, const char* __lo, const char* __hi) const;
00768 
00780       inline const char*
00781       scan_not(mask __m, const char* __lo, const char* __hi) const;
00782 
00795       char_type
00796       toupper(char_type __c) const
00797       { return this->do_toupper(__c); }
00798 
00812       const char_type*
00813       toupper(char_type *__lo, const char_type* __hi) const
00814       { return this->do_toupper(__lo, __hi); }
00815 
00828       char_type
00829       tolower(char_type __c) const
00830       { return this->do_tolower(__c); }
00831 
00845       const char_type*
00846       tolower(char_type* __lo, const char_type* __hi) const
00847       { return this->do_tolower(__lo, __hi); }
00848 
00865       char_type
00866       widen(char __c) const
00867       {
00868     if (_M_widen_ok)
00869       return _M_widen[static_cast<unsigned char>(__c)];
00870     this->_M_widen_init();
00871     return this->do_widen(__c);
00872       }
00873 
00892       const char*
00893       widen(const char* __lo, const char* __hi, char_type* __to) const
00894       {
00895     if (_M_widen_ok == 1)
00896       {
00897         memcpy(__to, __lo, __hi - __lo);
00898         return __hi;
00899       }
00900     if (!_M_widen_ok)
00901       _M_widen_init();
00902     return this->do_widen(__lo, __hi, __to);
00903       }
00904 
00923       char
00924       narrow(char_type __c, char __dfault) const
00925       {
00926     if (_M_narrow[static_cast<unsigned char>(__c)])
00927       return _M_narrow[static_cast<unsigned char>(__c)];
00928     const char __t = do_narrow(__c, __dfault);
00929     if (__t != __dfault)
00930       _M_narrow[static_cast<unsigned char>(__c)] = __t;
00931     return __t;
00932       }
00933 
00956       const char_type*
00957       narrow(const char_type* __lo, const char_type* __hi,
00958          char __dfault, char *__to) const
00959       {
00960     if (__builtin_expect(_M_narrow_ok == 1, true))
00961       {
00962         memcpy(__to, __lo, __hi - __lo);
00963         return __hi;
00964       }
00965     if (!_M_narrow_ok)
00966       _M_narrow_init();
00967     return this->do_narrow(__lo, __hi, __dfault, __to);
00968       }
00969 
00970     protected:
00973       const mask*
00974       table() const throw()
00975       { return _M_table; }
00976 
00978       static const mask*
00979       classic_table() throw();
00980 
00987       virtual
00988       ~ctype();
00989 
01003       virtual char_type
01004       do_toupper(char_type) const;
01005 
01020       virtual const char_type*
01021       do_toupper(char_type* __lo, const char_type* __hi) const;
01022 
01036       virtual char_type
01037       do_tolower(char_type) const;
01038 
01053       virtual const char_type*
01054       do_tolower(char_type* __lo, const char_type* __hi) const;
01055 
01073       virtual char_type
01074       do_widen(char __c) const
01075       { return __c; }
01076 
01096       virtual const char*
01097       do_widen(const char* __lo, const char* __hi, char_type* __dest) const
01098       {
01099     memcpy(__dest, __lo, __hi - __lo);
01100     return __hi;
01101       }
01102 
01122       virtual char
01123       do_narrow(char_type __c, char) const
01124       { return __c; }
01125 
01148       virtual const char_type*
01149       do_narrow(const char_type* __lo, const char_type* __hi,
01150         char, char* __dest) const
01151       {
01152     memcpy(__dest, __lo, __hi - __lo);
01153     return __hi;
01154       }
01155 
01156     private:
01157 
01158       void _M_widen_init() const
01159       {
01160     char __tmp[sizeof(_M_widen)];
01161     for (size_t __i = 0; __i < sizeof(_M_widen); ++__i)
01162       __tmp[__i] = __i;
01163     do_widen(__tmp, __tmp + sizeof(__tmp), _M_widen);
01164 
01165     _M_widen_ok = 1;
01166     // Set _M_widen_ok to 2 if memcpy can't be used.
01167     if (memcmp(__tmp, _M_widen, sizeof(_M_widen)))
01168       _M_widen_ok = 2;
01169       }
01170 
01171       // Fill in the narrowing cache and flag whether all values are
01172       // valid or not.  _M_narrow_ok is set to 2 if memcpy can't
01173       // be used.
01174       void _M_narrow_init() const
01175       {
01176     char __tmp[sizeof(_M_narrow)];
01177     for (size_t __i = 0; __i < sizeof(_M_narrow); ++__i)
01178       __tmp[__i] = __i;
01179     do_narrow(__tmp, __tmp + sizeof(__tmp), 0, _M_narrow);
01180 
01181     _M_narrow_ok = 1;
01182     if (memcmp(__tmp, _M_narrow, sizeof(_M_narrow)))
01183       _M_narrow_ok = 2;
01184     else
01185       {
01186         // Deal with the special case of zero: renarrow with a
01187         // different default and compare.
01188         char __c;
01189         do_narrow(__tmp, __tmp + 1, 1, &__c);
01190         if (__c == 1)
01191           _M_narrow_ok = 2;
01192       }
01193       }
01194     };
01195 
01196   template<>
01197     const ctype<char>&
01198     use_facet<ctype<char> >(const locale& __loc);
01199 
01200 #ifdef _GLIBCXX_USE_WCHAR_T
01201   // 22.2.1.3  ctype<wchar_t> specialization
01212   template<>
01213     class ctype<wchar_t> : public __ctype_abstract_base<wchar_t>
01214     {
01215     public:
01216       // Types:
01218       typedef wchar_t       char_type;
01219       typedef wctype_t      __wmask_type;
01220 
01221     protected:
01222       __c_locale        _M_c_locale_ctype;
01223 
01224       // Pre-computed narrowed and widened chars.
01225       bool                      _M_narrow_ok;
01226       char                      _M_narrow[128];
01227       wint_t                    _M_widen[1 + static_cast<unsigned char>(-1)];
01228 
01229       // Pre-computed elements for do_is.
01230       mask                      _M_bit[16];
01231       __wmask_type              _M_wmask[16];
01232 
01233     public:
01234       // Data Members:
01236       static locale::id     id;
01237 
01245       explicit
01246       ctype(size_t __refs = 0);
01247 
01256       explicit
01257       ctype(__c_locale __cloc, size_t __refs = 0);
01258 
01259     protected:
01260       __wmask_type
01261       _M_convert_to_wmask(const mask __m) const;
01262 
01264       virtual
01265       ~ctype();
01266 
01280       virtual bool
01281       do_is(mask __m, char_type __c) const;
01282 
01299       virtual const char_type*
01300       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
01301 
01317       virtual const char_type*
01318       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
01319 
01335       virtual const char_type*
01336       do_scan_not(mask __m, const char_type* __lo,
01337           const char_type* __hi) const;
01338 
01352       virtual char_type
01353       do_toupper(char_type) const;
01354 
01369       virtual const char_type*
01370       do_toupper(char_type* __lo, const char_type* __hi) const;
01371 
01385       virtual char_type
01386       do_tolower(char_type) const;
01387 
01402       virtual const char_type*
01403       do_tolower(char_type* __lo, const char_type* __hi) const;
01404 
01422       virtual char_type
01423       do_widen(char) const;
01424 
01444       virtual const char*
01445       do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
01446 
01467       virtual char
01468       do_narrow(char_type, char __dfault) const;
01469 
01493       virtual const char_type*
01494       do_narrow(const char_type* __lo, const char_type* __hi,
01495         char __dfault, char* __dest) const;
01496 
01497       // For use at construction time only.
01498       void
01499       _M_initialize_ctype();
01500     };
01501 
01502   template<>
01503     const ctype<wchar_t>&
01504     use_facet<ctype<wchar_t> >(const locale& __loc);
01505 #endif //_GLIBCXX_USE_WCHAR_T
01506 
01507   // Include host and configuration specific ctype inlines.
01508   #include <bits/ctype_inline.h>
01509 
01510   // 22.2.1.2  Template class ctype_byname
01511   template<typename _CharT>
01512     class ctype_byname : public ctype<_CharT>
01513     {
01514     public:
01515       typedef _CharT        char_type;
01516 
01517       explicit
01518       ctype_byname(const char* __s, size_t __refs = 0);
01519 
01520     protected:
01521       virtual
01522       ~ctype_byname() { };
01523     };
01524 
01525   // 22.2.1.4  Class ctype_byname specializations.
01526   template<>
01527     ctype_byname<char>::ctype_byname(const char*, size_t refs);
01528 
01529   template<>
01530     ctype_byname<wchar_t>::ctype_byname(const char*, size_t refs);
01531 
01532   // 22.2.1.5  Template class codecvt
01533   #include <bits/codecvt.h>
01534 
01535   // 22.2.2  The numeric category.
01536   class __num_base
01537   {
01538   public:
01539     // NB: Code depends on the order of _S_atoms_out elements.
01540     // Below are the indices into _S_atoms_out.
01541     enum
01542       {
01543         _S_ominus,
01544         _S_oplus,
01545         _S_ox,
01546         _S_oX,
01547         _S_odigits,
01548         _S_odigits_end = _S_odigits + 16,
01549         _S_oudigits = _S_odigits_end,
01550         _S_oudigits_end = _S_oudigits + 16,
01551         _S_oe = _S_odigits + 14,  // For scientific notation, 'e'
01552         _S_oE = _S_oudigits + 14, // For scientific notation, 'E'
01553     _S_oend = _S_oudigits_end
01554       };
01555 
01556     // A list of valid numeric literals for output.  This array
01557     // contains chars that will be passed through the current locale's
01558     // ctype<_CharT>.widen() and then used to render numbers.
01559     // For the standard "C" locale, this is
01560     // "-+xX0123456789abcdef0123456789ABCDEF".
01561     static const char* _S_atoms_out;
01562 
01563     // String literal of acceptable (narrow) input, for num_get.
01564     // "-+xX0123456789abcdefABCDEF"
01565     static const char* _S_atoms_in;
01566 
01567     enum
01568     {
01569       _S_iminus,
01570       _S_iplus,
01571       _S_ix,
01572       _S_iX,
01573       _S_izero,
01574       _S_ie = _S_izero + 14,
01575       _S_iE = _S_izero + 20,
01576       _S_iend = 26
01577     };
01578 
01579     // num_put
01580     // Construct and return valid scanf format for floating point types.
01581     static void
01582     _S_format_float(const ios_base& __io, char* __fptr, char __mod);
01583   };
01584 
01585   template<typename _CharT>
01586     struct __numpunct_cache : public locale::facet
01587     {
01588       const char*           _M_grouping;
01589       size_t                            _M_grouping_size;
01590       bool              _M_use_grouping;
01591       const _CharT*         _M_truename;
01592       size_t                            _M_truename_size;
01593       const _CharT*         _M_falsename;
01594       size_t                            _M_falsename_size;
01595       _CharT                _M_decimal_point;
01596       _CharT                _M_thousands_sep;
01597 
01598       // A list of valid numeric literals for output: in the standard
01599       // "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF".
01600       // This array contains the chars after having been passed
01601       // through the current locale's ctype<_CharT>.widen().
01602       _CharT                _M_atoms_out[__num_base::_S_oend];
01603 
01604       // A list of valid numeric literals for input: in the standard
01605       // "C" locale, this is "-+xX0123456789abcdefABCDEF"
01606       // This array contains the chars after having been passed
01607       // through the current locale's ctype<_CharT>.widen().
01608       _CharT                _M_atoms_in[__num_base::_S_iend];
01609 
01610       bool              _M_allocated;
01611 
01612       __numpunct_cache(size_t __refs = 0) : facet(__refs),
01613       _M_grouping(NULL), _M_grouping_size(0), _M_use_grouping(false),
01614       _M_truename(NULL), _M_truename_size(0), _M_falsename(NULL),
01615       _M_falsename_size(0), _M_decimal_point(_CharT()),
01616       _M_thousands_sep(_CharT()), _M_allocated(false)
01617       { }
01618 
01619       ~__numpunct_cache();
01620 
01621       void
01622       _M_cache(const locale& __loc);
01623 
01624     private:
01625       __numpunct_cache&
01626       operator=(const __numpunct_cache&);
01627       
01628       explicit
01629       __numpunct_cache(const __numpunct_cache&);
01630     };
01631 
01632   template<typename _CharT>
01633     __numpunct_cache<_CharT>::~__numpunct_cache()
01634     {
01635       if (_M_allocated)
01636     {
01637       delete [] _M_grouping;
01638       delete [] _M_truename;
01639       delete [] _M_falsename;
01640     }
01641     }
01642 
01656   template<typename _CharT>
01657     class numpunct : public locale::facet
01658     {
01659     public:
01660       // Types:
01662 
01663       typedef _CharT            char_type;
01664       typedef basic_string<_CharT>  string_type;
01666       typedef __numpunct_cache<_CharT>  __cache_type;
01667 
01668     protected:
01669       __cache_type*         _M_data;
01670 
01671     public:
01673       static locale::id         id;
01674 
01680       explicit
01681       numpunct(size_t __refs = 0) : facet(__refs), _M_data(NULL)
01682       { _M_initialize_numpunct(); }
01683 
01693       explicit
01694       numpunct(__cache_type* __cache, size_t __refs = 0)
01695       : facet(__refs), _M_data(__cache)
01696       { _M_initialize_numpunct(); }
01697 
01707       explicit
01708       numpunct(__c_locale __cloc, size_t __refs = 0)
01709       : facet(__refs), _M_data(NULL)
01710       { _M_initialize_numpunct(__cloc); }
01711 
01721       char_type
01722       decimal_point() const
01723       { return this->do_decimal_point(); }
01724 
01734       char_type
01735       thousands_sep() const
01736       { return this->do_thousands_sep(); }
01737 
01765       string
01766       grouping() const
01767       { return this->do_grouping(); }
01768 
01778       string_type
01779       truename() const
01780       { return this->do_truename(); }
01781 
01791       string_type
01792       falsename() const
01793       { return this->do_falsename(); }
01794 
01795     protected:
01797       virtual
01798       ~numpunct();
01799 
01808       virtual char_type
01809       do_decimal_point() const
01810       { return _M_data->_M_decimal_point; }
01811 
01820       virtual char_type
01821       do_thousands_sep() const
01822       { return _M_data->_M_thousands_sep; }
01823 
01833       virtual string
01834       do_grouping() const
01835       { return _M_data->_M_grouping; }
01836 
01846       virtual string_type
01847       do_truename() const
01848       { return _M_data->_M_truename; }
01849 
01859       virtual string_type
01860       do_falsename() const
01861       { return _M_data->_M_falsename; }
01862 
01863       // For use at construction time only.
01864       void
01865       _M_initialize_numpunct(__c_locale __cloc = NULL);
01866     };
01867 
01868   template<typename _CharT>
01869     locale::id numpunct<_CharT>::id;
01870 
01871   template<>
01872     numpunct<char>::~numpunct();
01873 
01874   template<>
01875     void
01876     numpunct<char>::_M_initialize_numpunct(__c_locale __cloc);
01877 
01878 #ifdef _GLIBCXX_USE_WCHAR_T
01879   template<>
01880     numpunct<wchar_t>::~numpunct();
01881 
01882   template<>
01883     void
01884     numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc);
01885 #endif
01886 
01887   template<typename _CharT>
01888     class numpunct_byname : public numpunct<_CharT>
01889     {
01890     public:
01891       typedef _CharT            char_type;
01892       typedef basic_string<_CharT>  string_type;
01893 
01894       explicit
01895       numpunct_byname(const char* __s, size_t __refs = 0)
01896       : numpunct<_CharT>(__refs)
01897       {
01898     if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
01899       {
01900         __c_locale __tmp;
01901         this->_S_create_c_locale(__tmp, __s);
01902         this->_M_initialize_numpunct(__tmp);
01903         this->_S_destroy_c_locale(__tmp);
01904       }
01905       }
01906 
01907     protected:
01908       virtual
01909       ~numpunct_byname() { }
01910     };
01911 
01924   template<typename _CharT, typename _InIter>
01925     class num_get : public locale::facet
01926     {
01927     public:
01928       // Types:
01930 
01931       typedef _CharT            char_type;
01932       typedef _InIter           iter_type;
01934 
01936       static locale::id         id;
01937 
01945       explicit
01946       num_get(size_t __refs = 0) : facet(__refs) { }
01947 
01971       iter_type
01972       get(iter_type __in, iter_type __end, ios_base& __io,
01973       ios_base::iostate& __err, bool& __v) const
01974       { return this->do_get(__in, __end, __io, __err, __v); }
01975 
01977 
02007       iter_type
02008       get(iter_type __in, iter_type __end, ios_base& __io,
02009       ios_base::iostate& __err, long& __v) const
02010       { return this->do_get(__in, __end, __io, __err, __v); }
02011 
02012       iter_type
02013       get(iter_type __in, iter_type __end, ios_base& __io,
02014       ios_base::iostate& __err, unsigned short& __v) const
02015       { return this->do_get(__in, __end, __io, __err, __v); }
02016 
02017       iter_type
02018       get(iter_type __in, iter_type __end, ios_base& __io,
02019       ios_base::iostate& __err, unsigned int& __v)   const
02020       { return this->do_get(__in, __end, __io, __err, __v); }
02021 
02022       iter_type
02023       get(iter_type __in, iter_type __end, ios_base& __io,
02024       ios_base::iostate& __err, unsigned long& __v)  const
02025       { return this->do_get(__in, __end, __io, __err, __v); }
02026 
02027 #ifdef _GLIBCXX_USE_LONG_LONG
02028       iter_type
02029       get(iter_type __in, iter_type __end, ios_base& __io,
02030       ios_base::iostate& __err, long long& __v) const
02031       { return this->do_get(__in, __end, __io, __err, __v); }
02032 
02033       iter_type
02034       get(iter_type __in, iter_type __end, ios_base& __io,
02035       ios_base::iostate& __err, unsigned long long& __v)  const
02036       { return this->do_get(__in, __end, __io, __err, __v); }
02037 #endif
02038 
02039 
02041 
02066       iter_type
02067       get(iter_type __in, iter_type __end, ios_base& __io,
02068       ios_base::iostate& __err, float& __v) const
02069       { return this->do_get(__in, __end, __io, __err, __v); }
02070 
02071       iter_type
02072       get(iter_type __in, iter_type __end, ios_base& __io,
02073       ios_base::iostate& __err, double& __v) const
02074       { return this->do_get(__in, __end, __io, __err, __v); }
02075 
02076       iter_type
02077       get(iter_type __in, iter_type __end, ios_base& __io,
02078       ios_base::iostate& __err, long double& __v) const
02079       { return this->do_get(__in, __end, __io, __err, __v); }
02081 
02108       iter_type
02109       get(iter_type __in, iter_type __end, ios_base& __io,
02110       ios_base::iostate& __err, void*& __v) const
02111       { return this->do_get(__in, __end, __io, __err, __v); }
02112 
02113     protected:
02115       virtual ~num_get() { }
02116 
02117       iter_type
02118       _M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&,
02119                string& __xtrc) const;
02120 
02121       template<typename _ValueT>
02122         iter_type
02123         _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&,
02124                _ValueT& __v) const;
02125 
02127 
02141       virtual iter_type
02142       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
02143 
02144 
02145       virtual iter_type
02146       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, long&) const;
02147 
02148       virtual iter_type
02149       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02150           unsigned short&) const;
02151 
02152       virtual iter_type
02153       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02154          unsigned int&) const;
02155 
02156       virtual iter_type
02157       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02158          unsigned long&) const;
02159 
02160 #ifdef _GLIBCXX_USE_LONG_LONG
02161       virtual iter_type
02162       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02163          long long&) const;
02164 
02165       virtual iter_type
02166       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02167          unsigned long long&) const;
02168 #endif
02169 
02170       virtual iter_type
02171       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02172          float&) const;
02173 
02174       virtual iter_type
02175       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02176          double&) const;
02177 
02178       virtual iter_type
02179       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02180          long double&) const;
02181 
02182       virtual iter_type
02183       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02184          void*&) const;
02186     };
02187 
02188   template<typename _CharT, typename _InIter>
02189     locale::id num_get<_CharT, _InIter>::id;
02190 
02191 
02203   template<typename _CharT, typename _OutIter>
02204     class num_put : public locale::facet
02205     {
02206     public:
02207       // Types:
02209 
02210       typedef _CharT        char_type;
02211       typedef _OutIter      iter_type;
02213 
02215       static locale::id     id;
02216 
02224       explicit
02225       num_put(size_t __refs = 0) : facet(__refs) { }
02226 
02242       iter_type
02243       put(iter_type __s, ios_base& __f, char_type __fill, bool __v) const
02244       { return this->do_put(__s, __f, __fill, __v); }
02245 
02247 
02284       iter_type
02285       put(iter_type __s, ios_base& __f, char_type __fill, long __v) const
02286       { return this->do_put(__s, __f, __fill, __v); }
02287 
02288       iter_type
02289       put(iter_type __s, ios_base& __f, char_type __fill,
02290       unsigned long __v) const
02291       { return this->do_put(__s, __f, __fill, __v); }
02292 
02293 #ifdef _GLIBCXX_USE_LONG_LONG
02294       iter_type
02295       put(iter_type __s, ios_base& __f, char_type __fill, long long __v) const
02296       { return this->do_put(__s, __f, __fill, __v); }
02297 
02298       iter_type
02299       put(iter_type __s, ios_base& __f, char_type __fill,
02300       unsigned long long __v) const
02301       { return this->do_put(__s, __f, __fill, __v); }
02302 #endif
02303 
02304 
02306 
02347       iter_type
02348       put(iter_type __s, ios_base& __f, char_type __fill, double __v) const
02349       { return this->do_put(__s, __f, __fill, __v); }
02350 
02351       iter_type
02352       put(iter_type __s, ios_base& __f, char_type __fill,
02353       long double __v) const
02354       { return this->do_put(__s, __f, __fill, __v); }
02356 
02372       iter_type
02373       put(iter_type __s, ios_base& __f, char_type __fill,
02374       const void* __v) const
02375       { return this->do_put(__s, __f, __fill, __v); }
02376 
02377     protected:
02378       template<typename _ValueT>
02379         iter_type
02380         _M_insert_float(iter_type, ios_base& __io, char_type __fill,
02381             char __mod, _ValueT __v) const;
02382 
02383       void
02384       _M_group_float(const char* __grouping, size_t __grouping_size,
02385              char_type __sep, const char_type* __p, char_type* __new,
02386              char_type* __cs, int& __len) const;
02387 
02388       template<typename _ValueT>
02389         iter_type
02390         _M_insert_int(iter_type, ios_base& __io, char_type __fill,
02391               _ValueT __v) const;
02392 
02393       void
02394       _M_group_int(const char* __grouping, size_t __grouping_size,
02395            char_type __sep, ios_base& __io, char_type* __new,
02396            char_type* __cs, int& __len) const;
02397 
02398       void
02399       _M_pad(char_type __fill, streamsize __w, ios_base& __io,
02400          char_type* __new, const char_type* __cs, int& __len) const;
02401 
02403       virtual
02404       ~num_put() { };
02405 
02407 
02420       virtual iter_type
02421       do_put(iter_type, ios_base&, char_type __fill, bool __v) const;
02422 
02423       virtual iter_type
02424       do_put(iter_type, ios_base&, char_type __fill, long __v) const;
02425 
02426       virtual iter_type
02427       do_put(iter_type, ios_base&, char_type __fill, unsigned long) const;
02428 
02429 #ifdef _GLIBCXX_USE_LONG_LONG
02430       virtual iter_type
02431       do_put(iter_type, ios_base&, char_type __fill, long long __v) const;
02432 
02433       virtual iter_type
02434       do_put(iter_type, ios_base&, char_type __fill, unsigned long long) const;
02435 #endif
02436 
02437       virtual iter_type
02438       do_put(iter_type, ios_base&, char_type __fill, double __v) const;
02439 
02440       virtual iter_type
02441       do_put(iter_type, ios_base&, char_type __fill, long double __v) const;
02442 
02443       virtual iter_type
02444       do_put(iter_type, ios_base&, char_type __fill, const void* __v) const;
02446     };
02447 
02448   template <typename _CharT, typename _OutIter>
02449     locale::id num_put<_CharT, _OutIter>::id;
02450 
02451 
02464   template<typename _CharT>
02465     class collate : public locale::facet
02466     {
02467     public:
02468       // Types:
02470 
02471       typedef _CharT            char_type;
02472       typedef basic_string<_CharT>  string_type;
02474 
02475     protected:
02476       // Underlying "C" library locale information saved from
02477       // initialization, needed by collate_byname as well.
02478       __c_locale            _M_c_locale_collate;
02479 
02480     public:
02482       static locale::id         id;
02483 
02491       explicit
02492       collate(size_t __refs = 0)
02493       : facet(__refs), _M_c_locale_collate(_S_get_c_locale())
02494       { }
02495 
02505       explicit
02506       collate(__c_locale __cloc, size_t __refs = 0)
02507       : facet(__refs), _M_c_locale_collate(_S_clone_c_locale(__cloc))
02508       { }
02509 
02522       int
02523       compare(const _CharT* __lo1, const _CharT* __hi1,
02524           const _CharT* __lo2, const _CharT* __hi2) const
02525       { return this->do_compare(__lo1, __hi1, __lo2, __hi2); }
02526 
02541       string_type
02542       transform(const _CharT* __lo, const _CharT* __hi) const
02543       { return this->do_transform(__lo, __hi); }
02544 
02555       long
02556       hash(const _CharT* __lo, const _CharT* __hi) const
02557       { return this->do_hash(__lo, __hi); }
02558 
02559       // Used to abstract out _CharT bits in virtual member functions, below.
02560       int
02561       _M_compare(const _CharT*, const _CharT*) const;
02562 
02563       size_t
02564       _M_transform(_CharT*, const _CharT*, size_t) const;
02565 
02566   protected:
02568       virtual
02569       ~collate()
02570       { _S_destroy_c_locale(_M_c_locale_collate); }
02571 
02584       virtual int
02585       do_compare(const _CharT* __lo1, const _CharT* __hi1,
02586          const _CharT* __lo2, const _CharT* __hi2) const;
02587 
02600       virtual string_type
02601       do_transform(const _CharT* __lo, const _CharT* __hi) const;
02602 
02613       virtual long
02614       do_hash(const _CharT* __lo, const _CharT* __hi) const;
02615     };
02616 
02617   template<typename _CharT>
02618     locale::id collate<_CharT>::id;
02619 
02620   // Specializations.
02621   template<>
02622     int
02623     collate<char>::_M_compare(const char*, const char*) const;
02624 
02625   template<>
02626     size_t
02627     collate<char>::_M_transform(char*, const char*, size_t) const;
02628 
02629 #ifdef _GLIBCXX_USE_WCHAR_T
02630   template<>
02631     int
02632     collate<wchar_t>::_M_compare(const wchar_t*, const wchar_t*) const;
02633 
02634   template<>
02635     size_t
02636     collate<wchar_t>::_M_transform(wchar_t*, const wchar_t*, size_t) const;
02637 #endif
02638 
02639   template<typename _CharT>
02640     class collate_byname : public collate<_CharT>
02641     {
02642     public:
02644 
02645       typedef _CharT               char_type;
02646       typedef basic_string<_CharT> string_type;
02648 
02649       explicit
02650       collate_byname(const char* __s, size_t __refs = 0)
02651       : collate<_CharT>(__refs)
02652       {
02653     if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
02654       {
02655         this->_S_destroy_c_locale(this->_M_c_locale_collate);
02656         this->_S_create_c_locale(this->_M_c_locale_collate, __s);
02657       }
02658       }
02659 
02660     protected:
02661       virtual
02662       ~collate_byname() { }
02663     };
02664 
02665 
02672   class time_base
02673   {
02674   public:
02675     enum dateorder { no_order, dmy, mdy, ymd, ydm };
02676   };
02677 
02678   template<typename _CharT>
02679     struct __timepunct_cache : public locale::facet
02680     {
02681       // List of all known timezones, with GMT first.
02682       static const _CharT*      _S_timezones[14];
02683 
02684       const _CharT*         _M_date_format;
02685       const _CharT*         _M_date_era_format;
02686       const _CharT*         _M_time_format;
02687       const _CharT*         _M_time_era_format;
02688       const _CharT*         _M_date_time_format;
02689       const _CharT*         _M_date_time_era_format;
02690       const _CharT*         _M_am;
02691       const _CharT*         _M_pm;
02692       const _CharT*         _M_am_pm_format;
02693 
02694       // Day names, starting with "C"'s Sunday.
02695       const _CharT*         _M_day1;
02696       const _CharT*         _M_day2;
02697       const _CharT*         _M_day3;
02698       const _CharT*         _M_day4;
02699       const _CharT*         _M_day5;
02700       const _CharT*         _M_day6;
02701       const _CharT*         _M_day7;
02702 
02703       // Abbreviated day names, starting with "C"'s Sun.
02704       const _CharT*         _M_aday1;
02705       const _CharT*         _M_aday2;
02706       const _CharT*         _M_aday3;
02707       const _CharT*         _M_aday4;
02708       const _CharT*         _M_aday5;
02709       const _CharT*         _M_aday6;
02710       const _CharT*         _M_aday7;
02711 
02712       // Month names, starting with "C"'s January.
02713       const _CharT*         _M_month01;
02714       const _CharT*         _M_month02;
02715       const _CharT*         _M_month03;
02716       const _CharT*         _M_month04;
02717       const _CharT*         _M_month05;
02718       const _CharT*         _M_month06;
02719       const _CharT*         _M_month07;
02720       const _CharT*         _M_month08;
02721       const _CharT*         _M_month09;
02722       const _CharT*         _M_month10;
02723       const _CharT*         _M_month11;
02724       const _CharT*         _M_month12;
02725 
02726       // Abbreviated month names, starting with "C"'s Jan.
02727       const _CharT*         _M_amonth01;
02728       const _CharT*         _M_amonth02;
02729       const _CharT*         _M_amonth03;
02730       const _CharT*         _M_amonth04;
02731       const _CharT*         _M_amonth05;
02732       const _CharT*         _M_amonth06;
02733       const _CharT*         _M_amonth07;
02734       const _CharT*         _M_amonth08;
02735       const _CharT*         _M_amonth09;
02736       const _CharT*         _M_amonth10;
02737       const _CharT*         _M_amonth11;
02738       const _CharT*         _M_amonth12;
02739 
02740       bool              _M_allocated;
02741 
02742       __timepunct_cache(size_t __refs = 0) : facet(__refs),
02743       _M_date_format(NULL), _M_date_era_format(NULL), _M_time_format(NULL),
02744       _M_time_era_format(NULL), _M_date_time_format(NULL),
02745       _M_date_time_era_format(NULL), _M_am(NULL), _M_pm(NULL),
02746       _M_am_pm_format(NULL), _M_day1(NULL), _M_day2(NULL), _M_day3(NULL),
02747       _M_day4(NULL), _M_day5(NULL), _M_day6(NULL), _M_day7(NULL),
02748       _M_aday1(NULL), _M_aday2(NULL), _M_aday3(NULL), _M_aday4(NULL),
02749       _M_aday5(NULL), _M_aday6(NULL), _M_aday7(NULL), _M_month01(NULL),
02750       _M_month02(NULL), _M_month03(NULL), _M_month04(NULL), _M_month05(NULL),
02751       _M_month06(NULL), _M_month07(NULL), _M_month08(NULL), _M_month09(NULL),
02752       _M_month10(NULL), _M_month11(NULL), _M_month12(NULL), _M_amonth01(NULL),
02753       _M_amonth02(NULL), _M_amonth03(NULL), _M_amonth04(NULL),
02754       _M_amonth05(NULL), _M_amonth06(NULL), _M_amonth07(NULL),
02755       _M_amonth08(NULL), _M_amonth09(NULL), _M_amonth10(NULL),
02756       _M_amonth11(NULL), _M_amonth12(NULL), _M_allocated(false)
02757       { }
02758 
02759       ~__timepunct_cache();
02760 
02761       void
02762       _M_cache(const locale& __loc);
02763 
02764     private:
02765       __timepunct_cache&
02766       operator=(const __timepunct_cache&);
02767       
02768       explicit
02769       __timepunct_cache(const __timepunct_cache&);
02770     };
02771 
02772   template<typename _CharT>
02773     __timepunct_cache<_CharT>::~__timepunct_cache()
02774     {
02775       if (_M_allocated)
02776     {
02777       // Unused.
02778     }
02779     }
02780 
02781   // Specializations.
02782   template<>
02783     const char*
02784     __timepunct_cache<char>::_S_timezones[14];
02785 
02786 #ifdef _GLIBCXX_USE_WCHAR_T
02787   template<>
02788     const wchar_t*
02789     __timepunct_cache<wchar_t>::_S_timezones[14];
02790 #endif
02791 
02792   // Generic.
02793   template<typename _CharT>
02794     const _CharT* __timepunct_cache<_CharT>::_S_timezones[14];
02795 
02796   template<typename _CharT>
02797     class __timepunct : public locale::facet
02798     {
02799     public:
02800       // Types:
02801       typedef _CharT            __char_type;
02802       typedef basic_string<_CharT>  __string_type;
02803       typedef __timepunct_cache<_CharT> __cache_type;
02804 
02805     protected:
02806       __cache_type*         _M_data;
02807       __c_locale            _M_c_locale_timepunct;
02808       const char*           _M_name_timepunct;
02809 
02810     public:
02812       static locale::id         id;
02813 
02814       explicit
02815       __timepunct(size_t __refs = 0);
02816 
02817       explicit
02818       __timepunct(__cache_type* __cache, size_t __refs = 0);
02819 
02830       explicit
02831       __timepunct(__c_locale __cloc, const char* __s, size_t __refs = 0);
02832 
02833       void
02834       _M_put(_CharT* __s, size_t __maxlen, const _CharT* __format,
02835          const tm* __tm) const;
02836 
02837       void
02838       _M_date_formats(const _CharT** __date) const
02839       {
02840     // Always have default first.
02841     __date[0] = _M_data->_M_date_format;
02842     __date[1] = _M_data->_M_date_era_format;
02843       }
02844 
02845       void
02846       _M_time_formats(const _CharT** __time) const
02847       {
02848     // Always have default first.
02849     __time[0] = _M_data->_M_time_format;
02850     __time[1] = _M_data->_M_time_era_format;
02851       }
02852 
02853       void
02854       _M_date_time_formats(const _CharT** __dt) const
02855       {
02856     // Always have default first.
02857     __dt[0] = _M_data->_M_date_time_format;
02858     __dt[1] = _M_data->_M_date_time_era_format;
02859       }
02860 
02861       void
02862       _M_am_pm_format(const _CharT* __ampm) const
02863       { __ampm = _M_data->_M_am_pm_format; }
02864 
02865       void
02866       _M_am_pm(const _CharT** __ampm) const
02867       {
02868     __ampm[0] = _M_data->_M_am;
02869     __ampm[1] = _M_data->_M_pm;
02870       }
02871 
02872       void
02873       _M_days(const _CharT** __days) const
02874       {
02875     __days[0] = _M_data->_M_day1;
02876     __days[1] = _M_data->_M_day2;
02877     __days[2] = _M_data->_M_day3;
02878     __days[3] = _M_data->_M_day4;
02879     __days[4] = _M_data->_M_day5;
02880     __days[5] = _M_data->_M_day6;
02881     __days[6] = _M_data->_M_day7;
02882       }
02883 
02884       void
02885       _M_days_abbreviated(const _CharT** __days) const
02886       {
02887     __days[0] = _M_data->_M_aday1;
02888     __days[1] = _M_data->_M_aday2;
02889     __days[2] = _M_data->_M_aday3;
02890     __days[3] = _M_data->_M_aday4;
02891     __days[4] = _M_data->_M_aday5;
02892     __days[5] = _M_data->_M_aday6;
02893     __days[6] = _M_data->_M_aday7;
02894       }
02895 
02896       void
02897       _M_months(const _CharT** __months) const
02898       {
02899     __months[0] = _M_data->_M_month01;
02900     __months[1] = _M_data->_M_month02;
02901     __months[2] = _M_data->_M_month03;
02902     __months[3] = _M_data->_M_month04;
02903     __months[4] = _M_data->_M_month05;
02904     __months[5] = _M_data->_M_month06;
02905     __months[6] = _M_data->_M_month07;
02906     __months[7] = _M_data->_M_month08;
02907     __months[8] = _M_data->_M_month09;
02908     __months[9] = _M_data->_M_month10;
02909     __months[10] = _M_data->_M_month11;
02910     __months[11] = _M_data->_M_month12;
02911       }
02912 
02913       void
02914       _M_months_abbreviated(const _CharT** __months) const
02915       {
02916     __months[0] = _M_data->_M_amonth01;
02917     __months[1] = _M_data->_M_amonth02;
02918     __months[2] = _M_data->_M_amonth03;
02919     __months[3] = _M_data->_M_amonth04;
02920     __months[4] = _M_data->_M_amonth05;
02921     __months[5] = _M_data->_M_amonth06;
02922     __months[6] = _M_data->_M_amonth07;
02923     __months[7] = _M_data->_M_amonth08;
02924     __months[8] = _M_data->_M_amonth09;
02925     __months[9] = _M_data->_M_amonth10;
02926     __months[10] = _M_data->_M_amonth11;
02927     __months[11] = _M_data->_M_amonth12;
02928       }
02929 
02930     protected:
02931       virtual
02932       ~__timepunct();
02933 
02934       // For use at construction time only.
02935       void
02936       _M_initialize_timepunct(__c_locale __cloc = NULL);
02937     };
02938 
02939   template<typename _CharT>
02940     locale::id __timepunct<_CharT>::id;
02941 
02942   // Specializations.
02943   template<>
02944     void
02945     __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc);
02946 
02947   template<>
02948     void
02949     __timepunct<char>::_M_put(char*, size_t, const char*, const tm*) const;
02950 
02951 #ifdef _GLIBCXX_USE_WCHAR_T
02952   template<>
02953     void
02954     __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc);
02955 
02956   template<>
02957     void
02958     __timepunct<wchar_t>::_M_put(wchar_t*, size_t, const wchar_t*,
02959                  const tm*) const;
02960 #endif
02961 
02962   // Include host and configuration specific timepunct functions.
02963   #include <bits/time_members.h>
02964 
02977   template<typename _CharT, typename _InIter>
02978     class time_get : public locale::facet, public time_base
02979     {
02980     public:
02981       // Types:
02983 
02984       typedef _CharT            char_type;
02985       typedef _InIter           iter_type;
02987       typedef basic_string<_CharT>  __string_type;
02988 
02990       static locale::id         id;
02991 
02999       explicit
03000       time_get(size_t __refs = 0)
03001       : facet (__refs) { }
03002 
03016       dateorder
03017       date_order()  const
03018       { return this->do_date_order(); }
03019 
03040       iter_type
03041       get_time(iter_type __beg, iter_type __end, ios_base& __io,
03042            ios_base::iostate& __err, tm* __tm)  const
03043       { return this->do_get_time(__beg, __end, __io, __err, __tm); }
03044 
03065       iter_type
03066       get_date(iter_type __beg, iter_type __end, ios_base& __io,
03067            ios_base::iostate& __err, tm* __tm)  const
03068       { return this->do_get_date(__beg, __end, __io, __err, __tm); }
03069 
03093       iter_type
03094       get_weekday(iter_type __beg, iter_type __end, ios_base& __io,
03095           ios_base::iostate& __err, tm* __tm) const
03096       { return this->do_get_weekday(__beg, __end, __io, __err, __tm); }
03097 
03122       iter_type
03123       get_monthname(iter_type __beg, iter_type __end, ios_base& __io,
03124             ios_base::iostate& __err, tm* __tm) const
03125       { return this->do_get_monthname(__beg, __end, __io, __err, __tm); }
03126 
03148       iter_type
03149       get_year(iter_type __beg, iter_type __end, ios_base& __io,
03150            ios_base::iostate& __err, tm* __tm) const
03151       { return this->do_get_year(__beg, __end, __io, __err, __tm); }
03152 
03153     protected:
03155       virtual
03156       ~time_get() { }
03157 
03168       virtual dateorder
03169       do_date_order() const;
03170 
03186       virtual iter_type
03187       do_get_time(iter_type __beg, iter_type __end, ios_base& __io,
03188           ios_base::iostate& __err, tm* __tm) const;
03189 
03205       virtual iter_type
03206       do_get_date(iter_type __beg, iter_type __end, ios_base& __io,
03207           ios_base::iostate& __err, tm* __tm) const;
03208 
03224       virtual iter_type
03225       do_get_weekday(iter_type __beg, iter_type __end, ios_base&,
03226              ios_base::iostate& __err, tm* __tm) const;
03227 
03243       virtual iter_type
03244       do_get_monthname(iter_type __beg, iter_type __end, ios_base&,
03245                ios_base::iostate& __err, tm* __tm) const;
03246 
03262       virtual iter_type
03263       do_get_year(iter_type __beg, iter_type __end, ios_base& __io,
03264           ios_base::iostate& __err, tm* __tm) const;
03265 
03266       // Extract numeric component of length __len.
03267       iter_type
03268       _M_extract_num(iter_type __beg, iter_type __end, int& __member,
03269              int __min, int __max, size_t __len,
03270              ios_base& __io, ios_base::iostate& __err) const;
03271 
03272       // Extract day or month name, or any unique array of string
03273       // literals in a const _CharT* array.
03274       iter_type
03275       _M_extract_name(iter_type __beg, iter_type __end, int& __member,
03276               const _CharT** __names, size_t __indexlen,
03277               ios_base& __io, ios_base::iostate& __err) const;
03278 
03279       // Extract on a component-by-component basis, via __format argument.
03280       iter_type
03281       _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io,
03282                 ios_base::iostate& __err, tm* __tm,
03283                 const _CharT* __format) const;
03284     };
03285 
03286   template<typename _CharT, typename _InIter>
03287     locale::id time_get<_CharT, _InIter>::id;
03288 
03289   template<typename _CharT, typename _InIter>
03290     class time_get_byname : public time_get<_CharT, _InIter>
03291     {
03292     public:
03293       // Types:
03294       typedef _CharT            char_type;
03295       typedef _InIter           iter_type;
03296 
03297       explicit
03298       time_get_byname(const char*, size_t __refs = 0)
03299       : time_get<_CharT, _InIter>(__refs) { }
03300 
03301     protected:
03302       virtual
03303       ~time_get_byname() { }
03304     };
03305 
03317   template<typename _CharT, typename _OutIter>
03318     class time_put : public locale::facet
03319     {
03320     public:
03321       // Types:
03323 
03324       typedef _CharT            char_type;
03325       typedef _OutIter          iter_type;
03327 
03329       static locale::id         id;
03330 
03338       explicit
03339       time_put(size_t __refs = 0)
03340       : facet(__refs) { }
03341 
03357       iter_type
03358       put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
03359       const _CharT* __beg, const _CharT* __end) const;
03360 
03377       iter_type
03378       put(iter_type __s, ios_base& __io, char_type __fill,
03379       const tm* __tm, char __format, char __mod = 0) const
03380       { return this->do_put(__s, __io, __fill, __tm, __format, __mod); }
03381 
03382     protected:
03384       virtual
03385       ~time_put()
03386       { }
03387 
03404       virtual iter_type
03405       do_put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
03406          char __format, char __mod) const;
03407     };
03408 
03409   template<typename _CharT, typename _OutIter>
03410     locale::id time_put<_CharT, _OutIter>::id;
03411 
03412   template<typename _CharT, typename _OutIter>
03413     class time_put_byname : public time_put<_CharT, _OutIter>
03414     {
03415     public:
03416       // Types:
03417       typedef _CharT            char_type;
03418       typedef _OutIter          iter_type;
03419 
03420       explicit
03421       time_put_byname(const char*, size_t __refs = 0)
03422       : time_put<_CharT, _OutIter>(__refs)
03423       { };
03424 
03425     protected:
03426       virtual
03427       ~time_put_byname() { }
03428     };
03429 
03430 
03441   class money_base
03442   {
03443   public:
03444     enum part { none, space, symbol, sign, value };
03445     struct pattern { char field[4]; };
03446 
03447     static const pattern _S_default_pattern;
03448 
03449     enum
03450     {
03451       _S_minus,
03452       _S_zero,
03453       _S_end = 11
03454     };
03455 
03456     // String literal of acceptable (narrow) input/output, for
03457     // money_get/money_put. "-0123456789"
03458     static const char* _S_atoms;
03459 
03460     // Construct and return valid pattern consisting of some combination of:
03461     // space none symbol sign value
03462     static pattern
03463     _S_construct_pattern(char __precedes, char __space, char __posn);
03464   };
03465 
03466   template<typename _CharT, bool _Intl>
03467     struct __moneypunct_cache : public locale::facet
03468     {
03469       const char*           _M_grouping;
03470       size_t                            _M_grouping_size;
03471       bool              _M_use_grouping;
03472       _CharT                _M_decimal_point;
03473       _CharT                _M_thousands_sep;
03474       const _CharT*         _M_curr_symbol;
03475       size_t                            _M_curr_symbol_size;
03476       const _CharT*         _M_positive_sign;
03477       size_t                            _M_positive_sign_size;
03478       const _CharT*         _M_negative_sign;
03479       size_t                            _M_negative_sign_size;
03480       int               _M_frac_digits;
03481       money_base::pattern       _M_pos_format;
03482       money_base::pattern           _M_neg_format;
03483 
03484       // A list of valid numeric literals for input and output: in the standard
03485       // "C" locale, this is "-0123456789". This array contains the chars after
03486       // having been passed through the current locale's ctype<_CharT>.widen().
03487       _CharT                _M_atoms[money_base::_S_end];
03488 
03489       bool              _M_allocated;
03490 
03491       __moneypunct_cache(size_t __refs = 0) : facet(__refs),
03492       _M_grouping(NULL), _M_grouping_size(0), _M_use_grouping(false),
03493       _M_decimal_point(_CharT()), _M_thousands_sep(_CharT()),
03494       _M_curr_symbol(NULL), _M_curr_symbol_size(0),
03495       _M_positive_sign(NULL), _M_positive_sign_size(0),
03496       _M_negative_sign(NULL), _M_negative_sign_size(0),
03497       _M_frac_digits(0),
03498       _M_pos_format(money_base::pattern()),
03499       _M_neg_format(money_base::pattern()), _M_allocated(false)
03500       { }
03501 
03502       ~__moneypunct_cache();
03503 
03504       void
03505       _M_cache(const locale& __loc);
03506 
03507     private:
03508       __moneypunct_cache&
03509       operator=(const __moneypunct_cache&);
03510       
03511       explicit
03512       __moneypunct_cache(const __moneypunct_cache&);
03513     };
03514 
03515   template<typename _CharT, bool _Intl>
03516     __moneypunct_cache<_CharT, _Intl>::~__moneypunct_cache()
03517     {
03518       if (_M_allocated)
03519     {
03520       delete [] _M_grouping;
03521       delete [] _M_curr_symbol;
03522       delete [] _M_positive_sign;
03523       delete [] _M_negative_sign;
03524     }
03525     }
03526 
03533   template<typename _CharT, bool _Intl>
03534     class moneypunct : public locale::facet, public money_base
03535     {
03536     public:
03537       // Types:
03539 
03540       typedef _CharT            char_type;
03541       typedef basic_string<_CharT>  string_type;
03543       typedef __moneypunct_cache<_CharT, _Intl>     __cache_type;
03544 
03545     private:
03546       __cache_type*         _M_data;
03547 
03548     public:
03551       static const bool         intl = _Intl;
03553       static locale::id         id;
03554 
03562       explicit
03563       moneypunct(size_t __refs = 0) : facet(__refs), _M_data(NULL)
03564       { _M_initialize_moneypunct(); }
03565 
03574       explicit
03575       moneypunct(__cache_type* __cache, size_t __refs = 0)
03576       : facet(__refs), _M_data(__cache)
03577       { _M_initialize_moneypunct(); }
03578 
03589       explicit
03590       moneypunct(__c_locale __cloc, const char* __s, size_t __refs = 0)
03591       : facet(__refs), _M_data(NULL)
03592       { _M_initialize_moneypunct(__cloc, __s); }
03593 
03603       char_type
03604       decimal_point() const
03605       { return this->do_decimal_point(); }
03606 
03616       char_type
03617       thousands_sep() const
03618       { return this->do_thousands_sep(); }
03619 
03645       string
03646       grouping() const
03647       { return this->do_grouping(); }
03648 
03658       string_type
03659       curr_symbol() const
03660       { return this->do_curr_symbol(); }
03661 
03675       string_type
03676       positive_sign() const
03677       { return this->do_positive_sign(); }
03678 
03692       string_type
03693       negative_sign() const
03694       { return this->do_negative_sign(); }
03695 
03708       int
03709       frac_digits() const
03710       { return this->do_frac_digits(); }
03711 
03713 
03743       pattern
03744       pos_format() const
03745       { return this->do_pos_format(); }
03746 
03747       pattern
03748       neg_format() const
03749       { return this->do_neg_format(); }
03751 
03752     protected:
03754       virtual
03755       ~moneypunct();
03756 
03765       virtual char_type
03766       do_decimal_point() const
03767       { return _M_data->_M_decimal_point; }
03768 
03777       virtual char_type
03778       do_thousands_sep() const
03779       { return _M_data->_M_thousands_sep; }
03780 
03790       virtual string
03791       do_grouping() const
03792       { return _M_data->_M_grouping; }
03793 
03803       virtual string_type
03804       do_curr_symbol()   const
03805       { return _M_data->_M_curr_symbol; }
03806 
03816       virtual string_type
03817       do_positive_sign() const
03818       { return _M_data->_M_positive_sign; }
03819 
03829       virtual string_type
03830       do_negative_sign() const
03831       { return _M_data->_M_negative_sign; }
03832 
03843       virtual int
03844       do_frac_digits() const
03845       { return _M_data->_M_frac_digits; }
03846 
03857       virtual pattern
03858       do_pos_format() const
03859       { return _M_data->_M_pos_format; }
03860 
03871       virtual pattern
03872       do_neg_format() const
03873       { return _M_data->_M_neg_format; }
03874 
03875       // For use at construction time only.
03876        void
03877        _M_initialize_moneypunct(__c_locale __cloc = NULL,
03878                 const char* __name = NULL);
03879     };
03880 
03881   template<typename _CharT, bool _Intl>
03882     locale::id moneypunct<_CharT, _Intl>::id;
03883 
03884   template<typename _CharT, bool _Intl>
03885     const bool moneypunct<_CharT, _Intl>::intl;
03886 
03887   template<>
03888     moneypunct<char, true>::~moneypunct();
03889 
03890   template<>
03891     moneypunct<char, false>::~moneypunct();
03892 
03893   template<>
03894     void
03895     moneypunct<char, true>::_M_initialize_moneypunct(__c_locale, const char*);
03896 
03897   template<>
03898     void
03899     moneypunct<char, false>::_M_initialize_moneypunct(__c_locale, const char*);
03900 
03901 #ifdef _GLIBCXX_USE_WCHAR_T
03902   template<>
03903     moneypunct<wchar_t, true>::~moneypunct();
03904 
03905   template<>
03906     moneypunct<wchar_t, false>::~moneypunct();
03907 
03908   template<>
03909     void
03910     moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale,
03911                             const char*);
03912 
03913   template<>
03914     void
03915     moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale,
03916                              const char*);
03917 #endif
03918 
03919   template<typename _CharT, bool _Intl>
03920     class moneypunct_byname : public moneypunct<_CharT, _Intl>
03921     {
03922     public:
03923       typedef _CharT            char_type;
03924       typedef basic_string<_CharT>  string_type;
03925 
03926       static const bool intl = _Intl;
03927 
03928       explicit
03929       moneypunct_byname(const char* __s, size_t __refs = 0)
03930       : moneypunct<_CharT, _Intl>(__refs)
03931       {
03932     if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
03933       {
03934         __c_locale __tmp;
03935         this->_S_create_c_locale(__tmp, __s);
03936         this->_M_initialize_moneypunct(__tmp);
03937         this->_S_destroy_c_locale(__tmp);
03938       }
03939       }
03940 
03941     protected:
03942       virtual
03943       ~moneypunct_byname() { }
03944     };
03945 
03946   template<typename _CharT, bool _Intl>
03947     const bool moneypunct_byname<_CharT, _Intl>::intl;
03948 
03961   template<typename _CharT, typename _InIter>
03962     class money_get : public locale::facet
03963     {
03964     public:
03965       // Types:
03967 
03968       typedef _CharT            char_type;
03969       typedef _InIter           iter_type;
03970       typedef basic_string<_CharT>  string_type;
03972 
03974       static locale::id         id;
03975 
03983       explicit
03984       money_get(size_t __refs = 0) : facet(__refs) { }
03985 
04013       iter_type
04014       get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
04015       ios_base::iostate& __err, long double& __units) const
04016       { return this->do_get(__s, __end, __intl, __io, __err, __units); }
04017 
04043       iter_type
04044       get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
04045       ios_base::iostate& __err, string_type& __digits) const
04046       { return this->do_get(__s, __end, __intl, __io, __err, __digits); }
04047 
04048     protected:
04050       virtual
04051       ~money_get() { }
04052 
04060       virtual iter_type
04061       do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
04062          ios_base::iostate& __err, long double& __units) const;
04063 
04071       virtual iter_type
04072       do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
04073          ios_base::iostate& __err, string_type& __digits) const;
04074 
04075       template<bool _Intl>
04076         iter_type
04077         _M_extract(iter_type __s, iter_type __end, ios_base& __io,
04078            ios_base::iostate& __err, string& __digits) const;     
04079     };
04080 
04081   template<typename _CharT, typename _InIter>
04082     locale::id money_get<_CharT, _InIter>::id;
04083 
04096   template<typename _CharT, typename _OutIter>
04097     class money_put : public locale::facet
04098     {
04099     public:
04101 
04102       typedef _CharT            char_type;
04103       typedef _OutIter          iter_type;
04104       typedef basic_string<_CharT>  string_type;
04106 
04108       static locale::id         id;
04109 
04117       explicit
04118       money_put(size_t __refs = 0) : facet(__refs) { }
04119 
04137       iter_type
04138       put(iter_type __s, bool __intl, ios_base& __io,
04139       char_type __fill, long double __units) const
04140       { return this->do_put(__s, __intl, __io, __fill, __units); }
04141 
04159       iter_type
04160       put(iter_type __s, bool __intl, ios_base& __io,
04161       char_type __fill, const string_type& __digits) const
04162       { return this->do_put(__s, __intl, __io, __fill, __digits); }
04163 
04164     protected:
04166       virtual
04167       ~money_put() { }
04168 
04187       virtual iter_type
04188       do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
04189          long double __units) const;
04190 
04209       virtual iter_type
04210       do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
04211          const string_type& __digits) const;
04212 
04213       template<bool _Intl>
04214         iter_type
04215         _M_insert(iter_type __s, ios_base& __io, char_type __fill,
04216           const string_type& __digits) const;
04217     };
04218 
04219   template<typename _CharT, typename _OutIter>
04220     locale::id money_put<_CharT, _OutIter>::id;
04221 
04225   struct messages_base
04226   {
04227     typedef int catalog;
04228   };
04229 
04250   template<typename _CharT>
04251     class messages : public locale::facet, public messages_base
04252     {
04253     public:
04254       // Types:
04256 
04257       typedef _CharT            char_type;
04258       typedef basic_string<_CharT>  string_type;
04260 
04261     protected:
04262       // Underlying "C" library locale information saved from
04263       // initialization, needed by messages_byname as well.
04264       __c_locale            _M_c_locale_messages;
04265       const char*           _M_name_messages;
04266 
04267     public:
04269       static locale::id         id;
04270 
04278       explicit
04279       messages(size_t __refs = 0);
04280 
04281       // Non-standard.
04292       explicit
04293       messages(__c_locale __cloc, const char* __s, size_t __refs = 0);
04294 
04295       /*
04296        *  @brief  Open a message catalog.
04297        *
04298        *  This function opens and returns a handle to a message catalog by
04299        *  returning do_open(s, loc).
04300        *
04301        *  @param  s  The catalog to open.
04302        *  @param  loc  Locale to use for character set conversions.
04303        *  @return  Handle to the catalog or value < 0 if open fails.
04304       */
04305       catalog
04306       open(const basic_string<char>& __s, const locale& __loc) const
04307       { return this->do_open(__s, __loc); }
04308 
04309       // Non-standard and unorthodox, yet effective.
04310       /*
04311        *  @brief  Open a message catalog.
04312        *
04313        *  This non-standard function opens and returns a handle to a message
04314        *  catalog by returning do_open(s, loc).  The third argument provides a
04315        *  message catalog root directory for gnu gettext and is ignored
04316        *  otherwise.
04317        *
04318        *  @param  s  The catalog to open.
04319        *  @param  loc  Locale to use for character set conversions.
04320        *  @param  dir  Message catalog root directory.
04321        *  @return  Handle to the catalog or value < 0 if open fails.
04322       */
04323       catalog
04324       open(const basic_string<char>&, const locale&, const char*) const;
04325 
04326       /*
04327        *  @brief  Look up a string in a message catalog.
04328        *
04329        *  This function retrieves and returns a message from a catalog by
04330        *  returning do_get(c, set, msgid, s).
04331        *
04332        *  For gnu, @a set and @a msgid are ignored.  Returns gettext(s).
04333        *  For default, returns s. For ieee, returns catgets(c,set,msgid,s).
04334        *
04335        *  @param  c  The catalog to access.
04336        *  @param  set  Implementation-defined.
04337        *  @param  msgid  Implementation-defined.
04338        *  @param  s  Default return value if retrieval fails.
04339        *  @return  Retrieved message or @a s if get fails.
04340       */
04341       string_type
04342       get(catalog __c, int __set, int __msgid, const string_type& __s) const
04343       { return this->do_get(__c, __set, __msgid, __s); }
04344 
04345       /*
04346        *  @brief  Close a message catalog.
04347        *
04348        *  Closes catalog @a c by calling do_close(c).
04349        *
04350        *  @param  c  The catalog to close.
04351       */
04352       void
04353       close(catalog __c) const
04354       { return this->do_close(__c); }
04355 
04356     protected:
04358       virtual
04359       ~messages();
04360 
04361       /*
04362        *  @brief  Open a message catalog.
04363        *
04364        *  This function opens and returns a handle to a message catalog in an
04365        *  implementation-defined manner.  This function is a hook for derived
04366        *  classes to change the value returned.
04367        *
04368        *  @param  s  The catalog to open.
04369        *  @param  loc  Locale to use for character set conversions.
04370        *  @return  Handle to the opened catalog, value < 0 if open failed.
04371       */
04372       virtual catalog
04373       do_open(const basic_string<char>&, const locale&) const;
04374 
04375       /*
04376        *  @brief  Look up a string in a message catalog.
04377        *
04378        *  This function retrieves and returns a message from a catalog in an
04379        *  implementation-defined manner.  This function is a hook for derived
04380        *  classes to change the value returned.
04381        *
04382        *  For gnu, @a set and @a msgid are ignored.  Returns gettext(s).
04383        *  For default, returns s. For ieee, returns catgets(c,set,msgid,s).
04384        *
04385        *  @param  c  The catalog to access.
04386        *  @param  set  Implementation-defined.
04387        *  @param  msgid  Implementation-defined.
04388        *  @param  s  Default return value if retrieval fails.
04389        *  @return  Retrieved message or @a s if get fails.
04390       */
04391       virtual string_type
04392       do_get(catalog, int, int, const string_type& __dfault) const;
04393 
04394       /*
04395        *  @brief  Close a message catalog.
04396        *
04397        *  @param  c  The catalog to close.
04398       */
04399       virtual void
04400       do_close(catalog) const;
04401 
04402       // Returns a locale and codeset-converted string, given a char* message.
04403       char*
04404       _M_convert_to_char(const string_type& __msg) const
04405       {
04406     // XXX
04407     return reinterpret_cast<char*>(const_cast<_CharT*>(__msg.c_str()));
04408       }
04409 
04410       // Returns a locale and codeset-converted string, given a char* message.
04411       string_type
04412       _M_convert_from_char(char*) const
04413       {
04414 #if 0
04415     // Length of message string without terminating null.
04416     size_t __len = char_traits<char>::length(__msg) - 1;
04417 
04418     // "everybody can easily convert the string using
04419     // mbsrtowcs/wcsrtombs or with iconv()"
04420 
04421     // Convert char* to _CharT in locale used to open catalog.
04422     // XXX need additional template parameter on messages class for this..
04423     // typedef typename codecvt<char, _CharT, _StateT> __codecvt_type;
04424     typedef typename codecvt<char, _CharT, mbstate_t> __codecvt_type;
04425 
04426     __codecvt_type::state_type __state;
04427     // XXX may need to initialize state.
04428     //initialize_state(__state._M_init());
04429 
04430     char* __from_next;
04431     // XXX what size for this string?
04432     _CharT* __to = static_cast<_CharT*>(__builtin_alloca(__len + 1));
04433     const __codecvt_type& __cvt = use_facet<__codecvt_type>(_M_locale_conv);
04434     __cvt.out(__state, __msg, __msg + __len, __from_next,
04435           __to, __to + __len + 1, __to_next);
04436     return string_type(__to);
04437 #endif
04438 #if 0
04439     typedef ctype<_CharT> __ctype_type;
04440     // const __ctype_type& __cvt = use_facet<__ctype_type>(_M_locale_msg);
04441     const __ctype_type& __cvt = use_facet<__ctype_type>(locale());
04442     // XXX Again, proper length of converted string an issue here.
04443     // For now, assume the converted length is not larger.
04444     _CharT* __dest = static_cast<_CharT*>(__builtin_alloca(__len + 1));
04445     __cvt.widen(__msg, __msg + __len, __dest);
04446     return basic_string<_CharT>(__dest);
04447 #endif
04448     return string_type();
04449       }
04450      };
04451 
04452   template<typename _CharT>
04453     locale::id messages<_CharT>::id;
04454 
04455   // Specializations for required instantiations.
04456   template<>
04457     string
04458     messages<char>::do_get(catalog, int, int, const string&) const;
04459 
04460 #ifdef _GLIBCXX_USE_WCHAR_T
04461   template<>
04462     wstring
04463     messages<wchar_t>::do_get(catalog, int, int, const wstring&) const;
04464 #endif
04465 
04466   template<typename _CharT>
04467     class messages_byname : public messages<_CharT>
04468     {
04469     public:
04470       typedef _CharT            char_type;
04471       typedef basic_string<_CharT>  string_type;
04472 
04473       explicit
04474       messages_byname(const char* __s, size_t __refs = 0);
04475 
04476     protected:
04477       virtual
04478       ~messages_byname()
04479       { }
04480     };
04481 
04482   // Include host and configuration specific messages functions.
04483   #include <bits/messages_members.h>
04484 
04485 
04486   // Subclause convenience interfaces, inlines.
04487   // NB: These are inline because, when used in a loop, some compilers
04488   // can hoist the body out of the loop; then it's just as fast as the
04489   // C is*() function.
04491 
04492   template<typename _CharT>
04493     inline bool
04494     isspace(_CharT __c, const locale& __loc)
04495     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c); }
04496 
04497   template<typename _CharT>
04498     inline bool
04499     isprint(_CharT __c, const locale& __loc)
04500     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c); }
04501 
04502   template<typename _CharT>
04503     inline bool
04504     iscntrl(_CharT __c, const locale& __loc)
04505     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c); }
04506 
04507   template<typename _CharT>
04508     inline bool
04509     isupper(_CharT __c, const locale& __loc)
04510     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c); }
04511 
04512   template<typename _CharT>
04513     inline bool islower(_CharT __c, const locale& __loc)
04514     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c); }
04515 
04516   template<typename _CharT>
04517     inline bool
04518     isalpha(_CharT __c, const locale& __loc)
04519     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c); }
04520 
04521   template<typename _CharT>
04522     inline bool
04523     isdigit(_CharT __c, const locale& __loc)
04524     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c); }
04525 
04526   template<typename _CharT>
04527     inline bool
04528     ispunct(_CharT __c, const locale& __loc)
04529     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c); }
04530 
04531   template<typename _CharT>
04532     inline bool
04533     isxdigit(_CharT __c, const locale& __loc)
04534     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c); }
04535 
04536   template<typename _CharT>
04537     inline bool
04538     isalnum(_CharT __c, const locale& __loc)
04539     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c); }
04540 
04541   template<typename _CharT>
04542     inline bool
04543     isgraph(_CharT __c, const locale& __loc)
04544     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c); }
04545 
04546   template<typename _CharT>
04547     inline _CharT
04548     toupper(_CharT __c, const locale& __loc)
04549     { return use_facet<ctype<_CharT> >(__loc).toupper(__c); }
04550 
04551   template<typename _CharT>
04552     inline _CharT
04553     tolower(_CharT __c, const locale& __loc)
04554     { return use_facet<ctype<_CharT> >(__loc).tolower(__c); }
04556 } // namespace std
04557 
04558 #endif

Generated on Tue Jan 30 17:31:51 2007 for GNU C++ STL by doxygen 1.3.6