# locale_facets.h

Go to the documentation of this file.

    00001 // Locale support -*- C++ -*-
    00002
    00003 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
    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 _CPP_BITS_LOCFACETS_H
    00041 #define _CPP_BITS_LOCFACETS_H   1
    00042
    00043 #pragma GCC system_header
    00044
    00045 #include <ctime>    // For struct tm
    00046 #include <cwctype>  // For wctype_t
    00047 #include <ios>      // For ios_base
    00048
    00049 namespace std
    00050 {
    00051   // NB: Don't instantiate required wchar_t facets if no wchar_t support.
    00052 #ifdef _GLIBCPP_USE_WCHAR_T
    00053 # define  _GLIBCPP_NUM_FACETS 28
    00054 #else
    00055 # define  _GLIBCPP_NUM_FACETS 14
    00056 #endif
    00057
    00058   template<typename _CharT, typename _Traits>
    00059     struct __pad;
    00060
    00061   // 22.2.1.1  Template class ctype
    00062   // Include host and configuration specific ctype enums for ctype_base.
    00063   #include <bits/ctype_base.h>
    00064
    00065   // Common base for ctype<_CharT>.
    00066   template<typename _CharT>
    00067     class __ctype_abstract_base : public locale::facet, public ctype_base
    00068     {
    00069     public:
    00070       // Types:
    00071       typedef _CharT char_type;
    00072
    00073       bool
    00074       is(mask __m, char_type __c) const
    00075       { return this->do_is(__m, __c); }
    00076
    00077       const char_type*
    00078       is(const char_type *__lo, const char_type *__hi, mask *__vec) const
    00079       { return this->do_is(__lo, __hi, __vec); }
    00080
    00081       const char_type*
    00082       scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
    00083       { return this->do_scan_is(__m, __lo, __hi); }
    00084
    00085       const char_type*
    00086       scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
    00087       { return this->do_scan_not(__m, __lo, __hi); }
    00088
    00089       char_type
    00090       toupper(char_type __c) const
    00091       { return this->do_toupper(__c); }
    00092
    00093       const char_type*
    00094       toupper(char_type *__lo, const char_type* __hi) const
    00095       { return this->do_toupper(__lo, __hi); }
    00096
    00097       char_type
    00098       tolower(char_type __c) const
    00099       { return this->do_tolower(__c); }
    00100
    00101       const char_type*
    00102       tolower(char_type* __lo, const char_type* __hi) const
    00103       { return this->do_tolower(__lo, __hi); }
    00104
    00105       char_type
    00106       widen(char __c) const
    00107       { return this->do_widen(__c); }
    00108
    00109       const char*
    00110       widen(const char* __lo, const char* __hi, char_type* __to) const
    00111       { return this->do_widen(__lo, __hi, __to); }
    00112
    00113       char
    00114       narrow(char_type __c, char __dfault) const
    00115       { return this->do_narrow(__c, __dfault); }
    00116
    00117       const char_type*
    00118       narrow(const char_type* __lo, const char_type* __hi,
    00119           char __dfault, char *__to) const
    00120       { return this->do_narrow(__lo, __hi, __dfault, __to); }
    00121
    00122     protected:
    00123       explicit
    00124       __ctype_abstract_base(size_t __refs = 0): locale::facet(__refs) { }
    00125
    00126       virtual
    00127       ~__ctype_abstract_base() { }
    00128
    00129       virtual bool
    00130       do_is(mask __m, char_type __c) const = 0;
    00131
    00132       virtual const char_type*
    00133       do_is(const char_type* __lo, const char_type* __hi,
    00134         mask* __vec) const = 0;
    00135
    00136       virtual const char_type*
    00137       do_scan_is(mask __m, const char_type* __lo,
    00138          const char_type* __hi) const = 0;
    00139
    00140       virtual const char_type*
    00141       do_scan_not(mask __m, const char_type* __lo,
    00142           const char_type* __hi) const = 0;
    00143
    00144       virtual char_type
    00145       do_toupper(char_type) const = 0;
    00146
    00147       virtual const char_type*
    00148       do_toupper(char_type* __lo, const char_type* __hi) const = 0;
    00149
    00150       virtual char_type
    00151       do_tolower(char_type) const = 0;
    00152
    00153       virtual const char_type*
    00154       do_tolower(char_type* __lo, const char_type* __hi) const = 0;
    00155
    00156       virtual char_type
    00157       do_widen(char) const = 0;
    00158
    00159       virtual const char*
    00160       do_widen(const char* __lo, const char* __hi,
    00161            char_type* __dest) const = 0;
    00162
    00163       virtual char
    00164       do_narrow(char_type, char __dfault) const = 0;
    00165
    00166       virtual const char_type*
    00167       do_narrow(const char_type* __lo, const char_type* __hi,
    00168          char __dfault, char* __dest) const = 0;
    00169     };
    00170
    00171   // NB: Generic, mostly useless implementation.
    00172   template<typename _CharT>
    00173     class ctype : public __ctype_abstract_base<_CharT>
    00174     {
    00175     public:
    00176       // Types:
    00177       typedef _CharT            char_type;
    00178       typedef typename ctype::mask  mask;
    00179
    00180       static locale::id             id;
    00181
    00182       explicit
    00183       ctype(size_t __refs = 0) : __ctype_abstract_base<_CharT>(__refs) { }
    00184
    00185    protected:
    00186       virtual
    00187       ~ctype();
    00188
    00189       virtual bool
    00190       do_is(mask __m, char_type __c) const;
    00191
    00192       virtual const char_type*
    00193       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
    00194
    00195       virtual const char_type*
    00196       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
    00197
    00198       virtual const char_type*
    00199       do_scan_not(mask __m, const char_type* __lo,
    00200           const char_type* __hi) const;
    00201
    00202       virtual char_type
    00203       do_toupper(char_type __c) const;
    00204
    00205       virtual const char_type*
    00206       do_toupper(char_type* __lo, const char_type* __hi) const;
    00207
    00208       virtual char_type
    00209       do_tolower(char_type __c) const;
    00210
    00211       virtual const char_type*
    00212       do_tolower(char_type* __lo, const char_type* __hi) const;
    00213
    00214       virtual char_type
    00215       do_widen(char __c) const;
    00216
    00217       virtual const char*
    00218       do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
    00219
    00220       virtual char
    00221       do_narrow(char_type, char __dfault) const;
    00222
    00223       virtual const char_type*
    00224       do_narrow(const char_type* __lo, const char_type* __hi,
    00225         char __dfault, char* __dest) const;
    00226     };
    00227
    00228   template<typename _CharT>
    00229     locale::id ctype<_CharT>::id;
    00230
    00231   // 22.2.1.3  ctype<char> specialization.
    00232   template<>
    00233     class ctype<char> : public __ctype_abstract_base<char>
    00234     {
    00235     public:
    00236       // Types:
    00237       typedef char          char_type;
    00238
    00239     protected:
    00240       // Data Members:
    00241       __c_locale        _M_c_locale_ctype;
    00242       bool              _M_del;
    00243       __to_type             _M_toupper;
    00244       __to_type             _M_tolower;
    00245       const mask*               _M_table;
    00246
    00247     public:
    00248       static locale::id        id;
    00249       static const size_t      table_size = 1 + static_cast<unsigned char>(-1);
    00250
    00251       explicit
    00252       ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0);
    00253
    00254       explicit
    00255       ctype(__c_locale __cloc, const mask* __table = 0, bool __del = false,
    00256         size_t __refs = 0);
    00257
    00258       inline bool
    00259       is(mask __m, char __c) const;
    00260
    00261       inline const char*
    00262       is(const char* __lo, const char* __hi, mask* __vec) const;
    00263
    00264       inline const char*
    00265       scan_is(mask __m, const char* __lo, const char* __hi) const;
    00266
    00267       inline const char*
    00268       scan_not(mask __m, const char* __lo, const char* __hi) const;
    00269
    00270     protected:
    00271       const mask*
    00272       table() const throw()
    00273       { return _M_table; }
    00274
    00275       static const mask*
    00276       classic_table() throw();
    00277
    00278       virtual
    00279       ~ctype();
    00280
    00281       virtual bool
    00282       do_is(mask __m, char_type __c) const;
    00283
    00284       virtual const char_type*
    00285       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
    00286
    00287       virtual const char_type*
    00288       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
    00289
    00290       virtual const char_type*
    00291       do_scan_not(mask __m, const char_type* __lo,
    00292           const char_type* __hi) const;
    00293
    00294       virtual char_type
    00295       do_toupper(char_type) const;
    00296
    00297       virtual const char_type*
    00298       do_toupper(char_type* __lo, const char_type* __hi) const;
    00299
    00300       virtual char_type
    00301       do_tolower(char_type) const;
    00302
    00303       virtual const char_type*
    00304       do_tolower(char_type* __lo, const char_type* __hi) const;
    00305
    00306       virtual char_type
    00307       do_widen(char) const;
    00308
    00309       virtual const char*
    00310       do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
    00311
    00312       virtual char
    00313       do_narrow(char_type, char __dfault) const;
    00314
    00315       virtual const char_type*
    00316       do_narrow(const char_type* __lo, const char_type* __hi,
    00317         char __dfault, char* __dest) const;
    00318     };
    00319
    00320   template<>
    00321     const ctype<char>&
    00322     use_facet<ctype<char> >(const locale& __loc);
    00323
    00324 #ifdef _GLIBCPP_USE_WCHAR_T
    00325   // 22.2.1.3  ctype<wchar_t> specialization
    00326   template<>
    00327     class ctype<wchar_t> : public __ctype_abstract_base<wchar_t>
    00328     {
    00329     public:
    00330       // Types:
    00331       typedef wchar_t           char_type;
    00332       typedef wctype_t          __wmask_type;
    00333
    00334     protected:
    00335       __c_locale        _M_c_locale_ctype;
    00336
    00337     public:
    00338       // Data Members:
    00339       static locale::id         id;
    00340
    00341       explicit
    00342       ctype(size_t __refs = 0);
    00343
    00344       explicit
    00345       ctype(__c_locale __cloc, size_t __refs = 0);
    00346
    00347     protected:
    00348       __wmask_type
    00349       _M_convert_to_wmask(const mask __m) const;
    00350
    00351       virtual
    00352       ~ctype();
    00353
    00354       virtual bool
    00355       do_is(mask __m, char_type __c) const;
    00356
    00357       virtual const char_type*
    00358       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
    00359
    00360       virtual const char_type*
    00361       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
    00362
    00363       virtual const char_type*
    00364       do_scan_not(mask __m, const char_type* __lo,
    00365           const char_type* __hi) const;
    00366
    00367       virtual char_type
    00368       do_toupper(char_type) const;
    00369
    00370       virtual const char_type*
    00371       do_toupper(char_type* __lo, const char_type* __hi) const;
    00372
    00373       virtual char_type
    00374       do_tolower(char_type) const;
    00375
    00376       virtual const char_type*
    00377       do_tolower(char_type* __lo, const char_type* __hi) const;
    00378
    00379       virtual char_type
    00380       do_widen(char) const;
    00381
    00382       virtual const char*
    00383       do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
    00384
    00385       virtual char
    00386       do_narrow(char_type, char __dfault) const;
    00387
    00388       virtual const char_type*
    00389       do_narrow(const char_type* __lo, const char_type* __hi,
    00390         char __dfault, char* __dest) const;
    00391
    00392     };
    00393
    00394   template<>
    00395     const ctype<wchar_t>&
    00396     use_facet<ctype<wchar_t> >(const locale& __loc);
    00397 #endif //_GLIBCPP_USE_WCHAR_T
    00398
    00399   // Include host and configuration specific ctype inlines.
    00400   #include <bits/ctype_inline.h>
    00401
    00402   // 22.2.1.2  Template class ctype_byname
    00403   template<typename _CharT>
    00404     class ctype_byname : public ctype<_CharT>
    00405     {
    00406     public:
    00407       typedef _CharT        char_type;
    00408
    00409       explicit
    00410       ctype_byname(const char* __s, size_t __refs = 0);
    00411
    00412     protected:
    00413       virtual
    00414       ~ctype_byname() { };
    00415     };
    00416
    00417   // 22.2.1.4  Class ctype_byname specializations.
    00418   template<>
    00419     ctype_byname<char>::ctype_byname(const char*, size_t refs);
    00420
    00421   template<>
    00422     ctype_byname<wchar_t>::ctype_byname(const char*, size_t refs);
    00423
    00424   // 22.2.1.5  Template class codecvt
    00425   #include <bits/codecvt.h>
    00426
    00427
    00428   // 22.2.2  The numeric category.
    00429   class __num_base
    00430   {
    00431   protected:
    00432     // String literal of acceptable (narrow) input, for num_get.
    00433     // "0123456789eEabcdfABCDF"
    00434     static const char _S_atoms[];
    00435
    00436     enum
    00437     {
    00438       _M_zero,
    00439       _M_e = _M_zero + 10,
    00440       _M_E = _M_zero + 11,
    00441       _M_size = 21 + 1
    00442     };
    00443
    00444     // num_put
    00445     // Construct and return valid scanf format for floating point types.
    00446     static bool
    00447     _S_format_float(const ios_base& __io, char* __fptr, char __mod,
    00448             streamsize __prec);
    00449
    00450     // Construct and return valid scanf format for integer types.
    00451     static void
    00452     _S_format_int(const ios_base& __io, char* __fptr, char __mod, char __modl);
    00453   };
    00454
    00455
    00456   template<typename _CharT>
    00457     class numpunct : public locale::facet
    00458     {
    00459     public:
    00460       // Types:
    00461       typedef _CharT                char_type;
    00462       typedef basic_string<_CharT>  string_type;
    00463
    00464       static locale::id         id;
    00465
    00466     private:
    00467       char_type             _M_decimal_point;
    00468       char_type             _M_thousands_sep;
    00469       const char*           _M_grouping;
    00470       const char_type*          _M_truename;
    00471       const char_type*          _M_falsename;
    00472
    00473     public:
    00474       explicit
    00475       numpunct(size_t __refs = 0) : locale::facet(__refs)
    00476       { _M_initialize_numpunct(); }
    00477
    00478       explicit
    00479       numpunct(__c_locale __cloc, size_t __refs = 0) : locale::facet(__refs)
    00480       { _M_initialize_numpunct(__cloc); }
    00481
    00482       char_type
    00483       decimal_point() const
    00484       { return this->do_decimal_point(); }
    00485
    00486       char_type
    00487       thousands_sep() const
    00488       { return this->do_thousands_sep(); }
    00489
    00490       string
    00491       grouping() const
    00492       { return this->do_grouping(); }
    00493
    00494       string_type
    00495       truename() const
    00496       { return this->do_truename(); }
    00497
    00498       string_type
    00499       falsename() const
    00500       { return this->do_falsename(); }
    00501
    00502     protected:
    00503       virtual
    00504       ~numpunct();
    00505
    00506       virtual char_type
    00507       do_decimal_point() const
    00508       { return _M_decimal_point; }
    00509
    00510       virtual char_type
    00511       do_thousands_sep() const
    00512       { return _M_thousands_sep; }
    00513
    00514       virtual string
    00515       do_grouping() const
    00516       { return _M_grouping; }
    00517
    00518       virtual string_type
    00519       do_truename() const
    00520       { return _M_truename; }
    00521
    00522       virtual string_type
    00523       do_falsename() const
    00524       { return _M_falsename; }
    00525
    00526       // For use at construction time only.
    00527       void
    00528       _M_initialize_numpunct(__c_locale __cloc = NULL);
    00529     };
    00530
    00531   template<typename _CharT>
    00532     locale::id numpunct<_CharT>::id;
    00533
    00534   template<>
    00535     numpunct<char>::~numpunct();
    00536
    00537   template<>
    00538     void
    00539     numpunct<char>::_M_initialize_numpunct(__c_locale __cloc);
    00540
    00541 #ifdef _GLIBCPP_USE_WCHAR_T
    00542   template<>
    00543     numpunct<wchar_t>::~numpunct();
    00544
    00545   template<>
    00546     void
    00547     numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc);
    00548 #endif
    00549
    00550   template<typename _CharT>
    00551     class numpunct_byname : public numpunct<_CharT>
    00552     {
    00553       // Data Member.
    00554       __c_locale            _M_c_locale_numpunct;
    00555
    00556     public:
    00557       typedef _CharT                char_type;
    00558       typedef basic_string<_CharT>  string_type;
    00559
    00560       explicit
    00561       numpunct_byname(const char* __s, size_t __refs = 0)
    00562       : numpunct<_CharT>(__refs)
    00563       {
    00564     _S_create_c_locale(_M_c_locale_numpunct, __s);
    00565     _M_initialize_numpunct(_M_c_locale_numpunct);
    00566       }
    00567
    00568     protected:
    00569       virtual
    00570       ~numpunct_byname()
    00571       { _S_destroy_c_locale(_M_c_locale_numpunct); }
    00572     };
    00573
    00574   template<typename _CharT, typename _InIter>
    00575     class num_get : public locale::facet, public __num_base
    00576     {
    00577     public:
    00578       // Types:
    00579       typedef _CharT            char_type;
    00580       typedef _InIter           iter_type;
    00581
    00582       static locale::id         id;
    00583
    00584       explicit
    00585       num_get(size_t __refs = 0) : locale::facet(__refs) { }
    00586
    00587       iter_type
    00588       get(iter_type __in, iter_type __end, ios_base& __io,
    00589       ios_base::iostate& __err, bool& __v) const
    00590       { return this->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, long& __v) const
    00595       { return this->do_get(__in, __end, __io, __err, __v); }
    00596
    00597       iter_type
    00598       get(iter_type __in, iter_type __end, ios_base& __io,
    00599       ios_base::iostate& __err, unsigned short& __v) const
    00600       { return this->do_get(__in, __end, __io, __err, __v); }
    00601
    00602       iter_type
    00603       get(iter_type __in, iter_type __end, ios_base& __io,
    00604       ios_base::iostate& __err, unsigned int& __v)   const
    00605       { return this->do_get(__in, __end, __io, __err, __v); }
    00606
    00607       iter_type
    00608       get(iter_type __in, iter_type __end, ios_base& __io,
    00609       ios_base::iostate& __err, unsigned long& __v)  const
    00610       { return this->do_get(__in, __end, __io, __err, __v); }
    00611
    00612 #ifdef _GLIBCPP_USE_LONG_LONG
    00613       iter_type
    00614       get(iter_type __in, iter_type __end, ios_base& __io,
    00615       ios_base::iostate& __err, long long& __v) const
    00616       { return this->do_get(__in, __end, __io, __err, __v); }
    00617
    00618       iter_type
    00619       get(iter_type __in, iter_type __end, ios_base& __io,
    00620       ios_base::iostate& __err, unsigned long long& __v)  const
    00621       { return this->do_get(__in, __end, __io, __err, __v); }
    00622 #endif
    00623
    00624       iter_type
    00625       get(iter_type __in, iter_type __end, ios_base& __io,
    00626       ios_base::iostate& __err, float& __v) const
    00627       { return this->do_get(__in, __end, __io, __err, __v); }
    00628
    00629       iter_type
    00630       get(iter_type __in, iter_type __end, ios_base& __io,
    00631       ios_base::iostate& __err, double& __v) const
    00632       { return this->do_get(__in, __end, __io, __err, __v); }
    00633
    00634       iter_type
    00635       get(iter_type __in, iter_type __end, ios_base& __io,
    00636       ios_base::iostate& __err, long double& __v) const
    00637       { return this->do_get(__in, __end, __io, __err, __v); }
    00638
    00639       iter_type
    00640       get(iter_type __in, iter_type __end, ios_base& __io,
    00641       ios_base::iostate& __err, void*& __v) const
    00642       { return this->do_get(__in, __end, __io, __err, __v); }
    00643
    00644     protected:
    00645       virtual ~num_get() { }
    00646
    00647       iter_type
    00648       _M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&,
    00649                string& __xtrc) const;
    00650
    00651       iter_type
    00652       _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&,
    00653              string& __xtrc, int& __base) const;
    00654
    00655       virtual iter_type
    00656       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
    00657
    00658
    00659       virtual iter_type
    00660       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, long&) const;
    00661
    00662       virtual iter_type
    00663       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    00664           unsigned short&) const;
    00665
    00666       virtual iter_type
    00667       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    00668          unsigned int&) const;
    00669
    00670       virtual iter_type
    00671       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    00672          unsigned long&) const;
    00673
    00674 #ifdef _GLIBCPP_USE_LONG_LONG
    00675       virtual iter_type
    00676       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    00677          long long&) const;
    00678
    00679       virtual iter_type
    00680       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    00681          unsigned long long&) const;
    00682 #endif
    00683
    00684       virtual iter_type
    00685       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    00686          float&) const;
    00687
    00688       virtual iter_type
    00689       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    00690          double&) const;
    00691
    00692       virtual iter_type
    00693       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    00694          long double&) const;
    00695
    00696       virtual iter_type
    00697       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    00698          void*&) const;
    00699     };
    00700
    00701   template<typename _CharT, typename _InIter>
    00702     locale::id num_get<_CharT, _InIter>::id;
    00703
    00704 #if 0
    00705   // Partial specialization for istreambuf_iterator, so can use traits_type.
    00706   template<typename _CharT>
    00707     class num_get<_CharT, istreambuf_iterator<_CharT> >;
    00708
    00709       iter_type
    00710       _M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&,
    00711                string& __xtrc) const;
    00712
    00713       iter_type
    00714       _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&,
    00715              string& __xtrc, int& __base) const;
    00716
    00717       virtual iter_type
    00718       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
    00719 #endif
    00720
    00721   template<typename _CharT, typename _OutIter>
    00722     class num_put : public locale::facet, public __num_base
    00723     {
    00724     public:
    00725       // Types:
    00726       typedef _CharT        char_type;
    00727       typedef _OutIter      iter_type;
    00728
    00729       static locale::id     id;
    00730
    00731       explicit
    00732       num_put(size_t __refs = 0) : locale::facet(__refs) { }
    00733
    00734       iter_type
    00735       put(iter_type __s, ios_base& __f, char_type __fill, bool __v) const
    00736       { return this->do_put(__s, __f, __fill, __v); }
    00737
    00738       iter_type
    00739       put(iter_type __s, ios_base& __f, char_type __fill, long __v) const
    00740       { return this->do_put(__s, __f, __fill, __v); }
    00741
    00742       iter_type
    00743       put(iter_type __s, ios_base& __f, char_type __fill,
    00744       unsigned long __v) const
    00745       { return this->do_put(__s, __f, __fill, __v); }
    00746
    00747 #ifdef _GLIBCPP_USE_LONG_LONG
    00748       iter_type
    00749       put(iter_type __s, ios_base& __f, char_type __fill, long long __v) const
    00750       { return this->do_put(__s, __f, __fill, __v); }
    00751
    00752       iter_type
    00753       put(iter_type __s, ios_base& __f, char_type __fill,
    00754       unsigned long long __v) const
    00755       { return this->do_put(__s, __f, __fill, __v); }
    00756 #endif
    00757
    00758       iter_type
    00759       put(iter_type __s, ios_base& __f, char_type __fill, double __v) const
    00760       { return this->do_put(__s, __f, __fill, __v); }
    00761
    00762       iter_type
    00763       put(iter_type __s, ios_base& __f, char_type __fill,
    00764       long double __v) const
    00765       { return this->do_put(__s, __f, __fill, __v); }
    00766
    00767       iter_type
    00768       put(iter_type __s, ios_base& __f, char_type __fill,
    00769       const void* __v) const
    00770       { return this->do_put(__s, __f, __fill, __v); }
    00771
    00772     protected:
    00773       template<typename _ValueT>
    00774         iter_type
    00775         _M_convert_float(iter_type, ios_base& __io, char_type __fill,
    00776              char __mod, _ValueT __v) const;
    00777
    00778       template<typename _ValueT>
    00779         iter_type
    00780         _M_convert_int(iter_type, ios_base& __io, char_type __fill,
    00781                char __mod, char __modl, _ValueT __v) const;
    00782
    00783       iter_type
    00784       _M_widen_float(iter_type, ios_base& __io, char_type __fill, char* __cs,
    00785              int __len) const;
    00786
    00787       iter_type
    00788       _M_widen_int(iter_type, ios_base& __io, char_type __fill, char* __cs,
    00789            int __len) const;
    00790
    00791       iter_type
    00792       _M_insert(iter_type, ios_base& __io, char_type __fill,
    00793         const char_type* __ws, int __len) const;
    00794
    00795       virtual
    00796       ~num_put() { };
    00797
    00798       virtual iter_type
    00799       do_put(iter_type, ios_base&, char_type __fill, bool __v) const;
    00800
    00801       virtual iter_type
    00802       do_put(iter_type, ios_base&, char_type __fill, long __v) const;
    00803
    00804       virtual iter_type
    00805       do_put(iter_type, ios_base&, char_type __fill, unsigned long) const;
    00806
    00807 #ifdef _GLIBCPP_USE_LONG_LONG
    00808       virtual iter_type
    00809       do_put(iter_type, ios_base&, char_type __fill, long long __v) const;
    00810
    00811       virtual iter_type
    00812       do_put(iter_type, ios_base&, char_type __fill, unsigned long long) const;
    00813 #endif
    00814
    00815       virtual iter_type
    00816       do_put(iter_type, ios_base&, char_type __fill, double __v) const;
    00817
    00818       virtual iter_type
    00819       do_put(iter_type, ios_base&, char_type __fill, long double __v) const;
    00820
    00821       virtual iter_type
    00822       do_put(iter_type, ios_base&, char_type __fill, const void* __v) const;
    00823     };
    00824
    00825   template <typename _CharT, typename _OutIter>
    00826     locale::id num_put<_CharT, _OutIter>::id;
    00827
    00828
    00829   template<typename _CharT>
    00830     class collate : public locale::facet
    00831     {
    00832     public:
    00833       // Types:
    00834       typedef _CharT                char_type;
    00835       typedef basic_string<_CharT>  string_type;
    00836
    00837     protected:
    00838       // Underlying "C" library locale information saved from
    00839       // initialization, needed by collate_byname as well.
    00840       __c_locale            _M_c_locale_collate;
    00841
    00842     public:
    00843       static locale::id         id;
    00844
    00845       explicit
    00846       collate(size_t __refs = 0)
    00847       : locale::facet(__refs)
    00848       { _M_c_locale_collate = _S_c_locale; }
    00849
    00850       explicit
    00851       collate(__c_locale __cloc, size_t __refs = 0)
    00852       : locale::facet(__refs)
    00853       { _M_c_locale_collate = _S_clone_c_locale(__cloc); }
    00854
    00855       int
    00856       compare(const _CharT* __lo1, const _CharT* __hi1,
    00857           const _CharT* __lo2, const _CharT* __hi2) const
    00858       { return this->do_compare(__lo1, __hi1, __lo2, __hi2); }
    00859
    00860       string_type
    00861       transform(const _CharT* __lo, const _CharT* __hi) const
    00862       { return this->do_transform(__lo, __hi); }
    00863
    00864       long
    00865       hash(const _CharT* __lo, const _CharT* __hi) const
    00866       { return this->do_hash(__lo, __hi); }
    00867
    00868       // Used to abstract out _CharT bits in virtual member functions, below.
    00869       int
    00870       _M_compare(const _CharT*, const _CharT*) const;
    00871
    00872       size_t
    00873       _M_transform(_CharT*, const _CharT*, size_t) const;
    00874
    00875   protected:
    00876       virtual
    00877       ~collate()
    00878       { _S_destroy_c_locale(_M_c_locale_collate); }
    00879
    00880       virtual int
    00881       do_compare(const _CharT* __lo1, const _CharT* __hi1,
    00882          const _CharT* __lo2, const _CharT* __hi2) const;
    00883
    00884       virtual string_type
    00885       do_transform(const _CharT* __lo, const _CharT* __hi) const;
    00886
    00887       virtual long
    00888       do_hash(const _CharT* __lo, const _CharT* __hi) const;
    00889     };
    00890
    00891   template<typename _CharT>
    00892     locale::id collate<_CharT>::id;
    00893
    00894   // Specializations.
    00895   template<>
    00896     int
    00897     collate<char>::_M_compare(const char*, const char*) const;
    00898
    00899   template<>
    00900     size_t
    00901     collate<char>::_M_transform(char*, const char*, size_t) const;
    00902
    00903 #ifdef _GLIBCPP_USE_WCHAR_T
    00904   template<>
    00905     int
    00906     collate<wchar_t>::_M_compare(const wchar_t*, const wchar_t*) const;
    00907
    00908   template<>
    00909     size_t
    00910     collate<wchar_t>::_M_transform(wchar_t*, const wchar_t*, size_t) const;
    00911 #endif
    00912
    00913   template<typename _CharT>
    00914     class collate_byname : public collate<_CharT>
    00915     {
    00916     public:
    00917       typedef _CharT               char_type;
    00918       typedef basic_string<_CharT> string_type;
    00919
    00920       explicit
    00921       collate_byname(const char* __s, size_t __refs = 0)
    00922       : collate<_CharT>(__refs)
    00923       {
    00924     _S_destroy_c_locale(_M_c_locale_collate);
    00925     _S_create_c_locale(_M_c_locale_collate, __s);
    00926       }
    00927
    00928     protected:
    00929       virtual
    00930       ~collate_byname() { }
    00931     };
    00932
    00933
    00934   class time_base
    00935   {
    00936   public:
    00937     enum dateorder { no_order, dmy, mdy, ymd, ydm };
    00938   };
    00939
    00940   template<typename _CharT>
    00941     class __timepunct : public locale::facet
    00942     {
    00943     public:
    00944       // Types:
    00945       typedef _CharT                __char_type;
    00946       typedef basic_string<_CharT>  __string_type;
    00947
    00948       static locale::id         id;
    00949
    00950       // List of all known timezones, with GMT first.
    00951       static const _CharT*      _S_timezones[14];
    00952
    00953     protected:
    00954       __c_locale            _M_c_locale_timepunct;
    00955       char*             _M_name_timepunct;
    00956       const _CharT*             _M_date_format;
    00957       const _CharT*             _M_date_era_format;
    00958       const _CharT*             _M_time_format;
    00959       const _CharT*             _M_time_era_format;
    00960       const _CharT*         _M_date_time_format;
    00961       const _CharT*         _M_date_time_era_format;
    00962       const _CharT*             _M_am;
    00963       const _CharT*             _M_pm;
    00964       const _CharT*         _M_am_pm_format;
    00965
    00966       // Day names, starting with "C"'s Sunday.
    00967       const _CharT*             _M_day1;
    00968       const _CharT*             _M_day2;
    00969       const _CharT*             _M_day3;
    00970       const _CharT*             _M_day4;
    00971       const _CharT*             _M_day5;
    00972       const _CharT*             _M_day6;
    00973       const _CharT*             _M_day7;
    00974
    00975       // Abbreviated day names, starting with "C"'s Sun.
    00976       const _CharT*             _M_day_a1;
    00977       const _CharT*             _M_day_a2;
    00978       const _CharT*             _M_day_a3;
    00979       const _CharT*             _M_day_a4;
    00980       const _CharT*             _M_day_a5;
    00981       const _CharT*             _M_day_a6;
    00982       const _CharT*             _M_day_a7;
    00983
    00984       // Month names, starting with "C"'s January.
    00985       const _CharT*             _M_month01;
    00986       const _CharT*             _M_month02;
    00987       const _CharT*             _M_month03;
    00988       const _CharT*             _M_month04;
    00989       const _CharT*             _M_month05;
    00990       const _CharT*             _M_month06;
    00991       const _CharT*             _M_month07;
    00992       const _CharT*             _M_month08;
    00993       const _CharT*             _M_month09;
    00994       const _CharT*             _M_month10;
    00995       const _CharT*             _M_month11;
    00996       const _CharT*             _M_month12;
    00997
    00998       // Abbreviated month names, starting with "C"'s Jan.
    00999       const _CharT*             _M_month_a01;
    01000       const _CharT*             _M_month_a02;
    01001       const _CharT*             _M_month_a03;
    01002       const _CharT*             _M_month_a04;
    01003       const _CharT*             _M_month_a05;
    01004       const _CharT*             _M_month_a06;
    01005       const _CharT*             _M_month_a07;
    01006       const _CharT*             _M_month_a08;
    01007       const _CharT*             _M_month_a09;
    01008       const _CharT*             _M_month_a10;
    01009       const _CharT*             _M_month_a11;
    01010       const _CharT*             _M_month_a12;
    01011
    01012     public:
    01013       explicit
    01014       __timepunct(size_t __refs = 0)
    01015       : locale::facet(__refs)
    01016       {
    01017     _M_name_timepunct = new char[2];
    01018     strcpy(_M_name_timepunct, "C");
    01019     _M_initialize_timepunct();
    01020       }
    01021
    01022       explicit
    01023       __timepunct(__c_locale __cloc, const char* __s, size_t __refs = 0)
    01024       : locale::facet(__refs)
    01025       {
    01026     _M_name_timepunct = new char[strlen(__s) + 1];
    01027     strcpy(_M_name_timepunct, __s);
    01028     _M_initialize_timepunct(__cloc);
    01029       }
    01030
    01031       void
    01032       _M_put(_CharT* __s, size_t __maxlen, const _CharT* __format,
    01033          const tm* __tm) const;
    01034
    01035       void
    01036       _M_date_formats(const _CharT** __date) const
    01037       {
    01038     // Always have default first.
    01039     __date[0] = _M_date_format;
    01040     __date[1] = _M_date_era_format;
    01041       }
    01042
    01043       void
    01044       _M_time_formats(const _CharT** __time) const
    01045       {
    01046     // Always have default first.
    01047     __time[0] = _M_time_format;
    01048     __time[1] = _M_time_era_format;
    01049       }
    01050
    01051       void
    01052       _M_ampm(const _CharT** __ampm) const
    01053       {
    01054     __ampm[0] = _M_am;
    01055     __ampm[1] = _M_pm;
    01056       }
    01057
    01058       void
    01059       _M_date_time_formats(const _CharT** __dt) const
    01060       {
    01061     // Always have default first.
    01062     __dt[0] = _M_date_time_format;
    01063     __dt[1] = _M_date_time_era_format;
    01064       }
    01065
    01066       void
    01067       _M_days(const _CharT** __days) const
    01068       {
    01069     __days[0] = _M_day1;
    01070     __days[1] = _M_day2;
    01071     __days[2] = _M_day3;
    01072     __days[3] = _M_day4;
    01073     __days[4] = _M_day5;
    01074     __days[5] = _M_day6;
    01075     __days[6] = _M_day7;
    01076       }
    01077
    01078       void
    01079       _M_days_abbreviated(const _CharT** __days) const
    01080       {
    01081     __days[0] = _M_day_a1;
    01082     __days[1] = _M_day_a2;
    01083     __days[2] = _M_day_a3;
    01084     __days[3] = _M_day_a4;
    01085     __days[4] = _M_day_a5;
    01086     __days[5] = _M_day_a6;
    01087     __days[6] = _M_day_a7;
    01088       }
    01089
    01090       void
    01091       _M_months(const _CharT** __months) const
    01092       {
    01093     __months[0] = _M_month01;
    01094     __months[1] = _M_month02;
    01095     __months[2] = _M_month03;
    01096     __months[3] = _M_month04;
    01097     __months[4] = _M_month05;
    01098     __months[5] = _M_month06;
    01099     __months[6] = _M_month07;
    01100     __months[7] = _M_month08;
    01101     __months[8] = _M_month09;
    01102     __months[9] = _M_month10;
    01103     __months[10] = _M_month11;
    01104     __months[11] = _M_month12;
    01105       }
    01106
    01107       void
    01108       _M_months_abbreviated(const _CharT** __months) const
    01109       {
    01110     __months[0] = _M_month_a01;
    01111     __months[1] = _M_month_a02;
    01112     __months[2] = _M_month_a03;
    01113     __months[3] = _M_month_a04;
    01114     __months[4] = _M_month_a05;
    01115     __months[5] = _M_month_a06;
    01116     __months[6] = _M_month_a07;
    01117     __months[7] = _M_month_a08;
    01118     __months[8] = _M_month_a09;
    01119     __months[9] = _M_month_a10;
    01120     __months[10] = _M_month_a11;
    01121     __months[11] = _M_month_a12;
    01122       }
    01123
    01124     protected:
    01125       virtual
    01126       ~__timepunct()
    01127       {
    01128     delete [] _M_name_timepunct;
    01129     _S_destroy_c_locale(_M_c_locale_timepunct);
    01130       }
    01131
    01132       // For use at construction time only.
    01133       void
    01134       _M_initialize_timepunct(__c_locale __cloc = NULL);
    01135     };
    01136
    01137   template<typename _CharT>
    01138     locale::id __timepunct<_CharT>::id;
    01139
    01140   // Specializations.
    01141   template<>
    01142     const char*
    01143     __timepunct<char>::_S_timezones[14];
    01144
    01145   template<>
    01146     void
    01147     __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc);
    01148
    01149   template<>
    01150     void
    01151     __timepunct<char>::_M_put(char*, size_t, const char*, const tm*) const;
    01152
    01153 #ifdef _GLIBCPP_USE_WCHAR_T
    01154   template<>
    01155     const wchar_t*
    01156     __timepunct<wchar_t>::_S_timezones[14];
    01157
    01158   template<>
    01159     void
    01160     __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc);
    01161
    01162   template<>
    01163     void
    01164     __timepunct<wchar_t>::_M_put(wchar_t*, size_t, const wchar_t*,
    01165                  const tm*) const;
    01166 #endif
    01167
    01168   // Generic.
    01169   template<typename _CharT>
    01170     const _CharT* __timepunct<_CharT>::_S_timezones[14];
    01171
    01172
    01173   template<typename _CharT, typename _InIter>
    01174     class time_get : public locale::facet, public time_base
    01175     {
    01176     public:
    01177       // Types:
    01178       typedef _CharT            char_type;
    01179       typedef _InIter           iter_type;
    01180       typedef basic_string<_CharT>  __string_type;
    01181
    01182       static locale::id         id;
    01183
    01184       explicit
    01185       time_get(size_t __refs = 0)
    01186       : locale::facet (__refs) { }
    01187
    01188       dateorder
    01189       date_order()  const
    01190       { return this->do_date_order(); }
    01191
    01192       iter_type
    01193       get_time(iter_type __beg, iter_type __end, ios_base& __io,
    01194            ios_base::iostate& __err, tm* __tm)  const
    01195       { return this->do_get_time(__beg, __end, __io, __err, __tm); }
    01196
    01197       iter_type
    01198       get_date(iter_type __beg, iter_type __end, ios_base& __io,
    01199            ios_base::iostate& __err, tm* __tm)  const
    01200       { return this->do_get_date(__beg, __end, __io, __err, __tm); }
    01201
    01202       iter_type
    01203       get_weekday(iter_type __beg, iter_type __end, ios_base& __io,
    01204           ios_base::iostate& __err, tm* __tm) const
    01205       { return this->do_get_weekday(__beg, __end, __io, __err, __tm); }
    01206
    01207       iter_type
    01208       get_monthname(iter_type __beg, iter_type __end, ios_base& __io,
    01209             ios_base::iostate& __err, tm* __tm) const
    01210       { return this->do_get_monthname(__beg, __end, __io, __err, __tm); }
    01211
    01212       iter_type
    01213       get_year(iter_type __beg, iter_type __end, ios_base& __io,
    01214            ios_base::iostate& __err, tm* __tm) const
    01215       { return this->do_get_year(__beg, __end, __io, __err, __tm); }
    01216
    01217     protected:
    01218       virtual
    01219       ~time_get() { }
    01220
    01221       virtual dateorder
    01222       do_date_order() const;
    01223
    01224       virtual iter_type
    01225       do_get_time(iter_type __beg, iter_type __end, ios_base& __io,
    01226           ios_base::iostate& __err, tm* __tm) const;
    01227
    01228       virtual iter_type
    01229       do_get_date(iter_type __beg, iter_type __end, ios_base& __io,
    01230           ios_base::iostate& __err, tm* __tm) const;
    01231
    01232       virtual iter_type
    01233       do_get_weekday(iter_type __beg, iter_type __end, ios_base&,
    01234              ios_base::iostate& __err, tm* __tm) const;
    01235
    01236       virtual iter_type
    01237       do_get_monthname(iter_type __beg, iter_type __end, ios_base&,
    01238                ios_base::iostate& __err, tm* __tm) const;
    01239
    01240       virtual iter_type
    01241       do_get_year(iter_type __beg, iter_type __end, ios_base& __io,
    01242           ios_base::iostate& __err, tm* __tm) const;
    01243
    01244       // Extract numeric component of length __len.
    01245       void
    01246       _M_extract_num(iter_type& __beg, iter_type& __end, int& __member,
    01247              int __min, int __max, size_t __len,
    01248              const ctype<_CharT>& __ctype,
    01249              ios_base::iostate& __err) const;
    01250
    01251       // Extract day or month name, or any unique array of string
    01252       // literals in a const _CharT* array.
    01253       void
    01254       _M_extract_name(iter_type& __beg, iter_type& __end, int& __member,
    01255               const _CharT** __names, size_t __indexlen,
    01256               ios_base::iostate& __err) const;
    01257
    01258       // Extract on a component-by-component basis, via __format argument.
    01259       void
    01260       _M_extract_via_format(iter_type& __beg, iter_type& __end, ios_base& __io,
    01261                 ios_base::iostate& __err, tm* __tm,
    01262                 const _CharT* __format) const;
    01263     };
    01264
    01265   template<typename _CharT, typename _InIter>
    01266     locale::id time_get<_CharT, _InIter>::id;
    01267
    01268   template<typename _CharT, typename _InIter>
    01269     class time_get_byname : public time_get<_CharT, _InIter>
    01270     {
    01271     public:
    01272       // Types:
    01273       typedef _CharT            char_type;
    01274       typedef _InIter           iter_type;
    01275
    01276       explicit
    01277       time_get_byname(const char*, size_t __refs = 0)
    01278       : time_get<_CharT, _InIter>(__refs) { }
    01279
    01280     protected:
    01281       virtual
    01282       ~time_get_byname() { }
    01283     };
    01284
    01285   template<typename _CharT, typename _OutIter>
    01286     class time_put : public locale::facet, public time_base
    01287     {
    01288     public:
    01289       // Types:
    01290       typedef _CharT            char_type;
    01291       typedef _OutIter          iter_type;
    01292
    01293       static locale::id             id;
    01294
    01295       explicit
    01296       time_put(size_t __refs = 0)
    01297       : locale::facet(__refs) { }
    01298
    01299       iter_type
    01300       put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
    01301       const _CharT* __beg, const _CharT* __end) const;
    01302
    01303       iter_type
    01304       put(iter_type __s, ios_base& __io, char_type __fill,
    01305       const tm* __tm, char __format, char __mod = 0) const
    01306       { return this->do_put(__s, __io, __fill, __tm, __format, __mod); }
    01307
    01308     protected:
    01309       virtual
    01310       ~time_put()
    01311       { }
    01312
    01313       virtual iter_type
    01314       do_put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
    01315          char __format, char __mod) const;
    01316     };
    01317
    01318   template<typename _CharT, typename _OutIter>
    01319     locale::id time_put<_CharT, _OutIter>::id;
    01320
    01321   template<typename _CharT, typename _OutIter>
    01322     class time_put_byname : public time_put<_CharT, _OutIter>
    01323     {
    01324     public:
    01325       // Types:
    01326       typedef _CharT            char_type;
    01327       typedef _OutIter          iter_type;
    01328
    01329       explicit
    01330       time_put_byname(const char* /*__s*/, size_t __refs = 0)
    01331       : time_put<_CharT, _OutIter>(__refs)
    01332       { };
    01333
    01334     protected:
    01335       virtual
    01336       ~time_put_byname() { }
    01337     };
    01338
    01339
    01340   class money_base
    01341   {
    01342   public:
    01343     enum part { none, space, symbol, sign, value };
    01344     struct pattern { char field[4]; };
    01345
    01346     static const pattern _S_default_pattern;
    01347
    01348     // Construct and return valid pattern consisting of some combination of:
    01349     // space none symbol sign value
    01350     static pattern
    01351     _S_construct_pattern(char __precedes, char __space, char __posn);
    01352   };
    01353
    01354   template<typename _CharT, bool _Intl>
    01355     class moneypunct : public locale::facet, public money_base
    01356     {
    01357     public:
    01358       // Types:
    01359       typedef _CharT            char_type;
    01360       typedef basic_string<_CharT>  string_type;
    01361
    01362       static const bool         intl = _Intl;
    01363       static locale::id         id;
    01364
    01365     private:
    01366       const char*           _M_grouping;
    01367       char_type             _M_decimal_point;
    01368       char_type             _M_thousands_sep;
    01369       const char_type*          _M_curr_symbol;
    01370       const char_type*          _M_positive_sign;
    01371       const char_type*          _M_negative_sign;
    01372       int               _M_frac_digits;
    01373       pattern               _M_pos_format;
    01374       pattern               _M_neg_format;
    01375
    01376     public:
    01377       explicit
    01378       moneypunct(size_t __refs = 0) : locale::facet(__refs)
    01379       { _M_initialize_moneypunct(); }
    01380
    01381       explicit
    01382       moneypunct(__c_locale __cloc, const char* __s, size_t __refs = 0)
    01383       : locale::facet(__refs)
    01384       { _M_initialize_moneypunct(__cloc, __s); }
    01385
    01386       char_type
    01387       decimal_point() const
    01388       { return this->do_decimal_point(); }
    01389
    01390       char_type
    01391       thousands_sep() const
    01392       { return this->do_thousands_sep(); }
    01393
    01394       string
    01395       grouping() const
    01396       { return this->do_grouping(); }
    01397
    01398       string_type
    01399       curr_symbol() const
    01400       { return this->do_curr_symbol(); }
    01401
    01402       string_type
    01403       positive_sign() const
    01404       { return this->do_positive_sign(); }
    01405
    01406       string_type
    01407       negative_sign() const
    01408       { return this->do_negative_sign(); }
    01409
    01410       int
    01411       frac_digits() const
    01412       { return this->do_frac_digits(); }
    01413
    01414       pattern
    01415       pos_format() const
    01416       { return this->do_pos_format(); }
    01417
    01418       pattern
    01419       neg_format() const
    01420       { return this->do_neg_format(); }
    01421
    01422     protected:
    01423       virtual
    01424       ~moneypunct();
    01425
    01426       virtual char_type
    01427       do_decimal_point() const
    01428       { return _M_decimal_point; }
    01429
    01430       virtual char_type
    01431       do_thousands_sep() const
    01432       { return _M_thousands_sep; }
    01433
    01434       virtual string
    01435       do_grouping() const
    01436       { return _M_grouping; }
    01437
    01438       virtual string_type
    01439       do_curr_symbol()   const
    01440       { return _M_curr_symbol; }
    01441
    01442       virtual string_type
    01443       do_positive_sign() const
    01444       { return _M_positive_sign; }
    01445
    01446       virtual string_type
    01447       do_negative_sign() const
    01448       { return _M_negative_sign; }
    01449
    01450       virtual int
    01451       do_frac_digits() const
    01452       { return _M_frac_digits; }
    01453
    01454       virtual pattern
    01455       do_pos_format() const
    01456       { return _M_pos_format; }
    01457
    01458       virtual pattern
    01459       do_neg_format() const
    01460       { return _M_neg_format; }
    01461
    01462       // For use at construction time only.
    01463        void
    01464        _M_initialize_moneypunct(__c_locale __cloc = NULL,
    01465                 const char* __name = NULL);
    01466     };
    01467
    01468   template<typename _CharT, bool _Intl>
    01469     locale::id moneypunct<_CharT, _Intl>::id;
    01470
    01471   template<typename _CharT, bool _Intl>
    01472     const bool moneypunct<_CharT, _Intl>::intl;
    01473
    01474   template<>
    01475     moneypunct<char, true>::~moneypunct();
    01476
    01477   template<>
    01478     moneypunct<char, false>::~moneypunct();
    01479
    01480   template<>
    01481     void
    01482     moneypunct<char, true>::_M_initialize_moneypunct(__c_locale, const char*);
    01483
    01484   template<>
    01485     void
    01486     moneypunct<char, false>::_M_initialize_moneypunct(__c_locale, const char*);
    01487
    01488 #ifdef _GLIBCPP_USE_WCHAR_T
    01489   template<>
    01490     moneypunct<wchar_t, true>::~moneypunct();
    01491
    01492   template<>
    01493     moneypunct<wchar_t, false>::~moneypunct();
    01494
    01495   template<>
    01496     void
    01497     moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale,
    01498                             const char*);
    01499
    01500   template<>
    01501     void
    01502     moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale,
    01503                              const char*);
    01504 #endif
    01505
    01506   template<typename _CharT, bool _Intl>
    01507     class moneypunct_byname : public moneypunct<_CharT, _Intl>
    01508     {
    01509       __c_locale            _M_c_locale_moneypunct;
    01510
    01511     public:
    01512       typedef _CharT            char_type;
    01513       typedef basic_string<_CharT>  string_type;
    01514
    01515       static const bool intl = _Intl;
    01516
    01517       explicit
    01518       moneypunct_byname(const char* __s, size_t __refs = 0)
    01519       : moneypunct<_CharT, _Intl>(__refs)
    01520       {
    01521     _S_create_c_locale(_M_c_locale_moneypunct, __s);
    01522     _M_initialize_moneypunct(_M_c_locale_moneypunct);
    01523       }
    01524
    01525     protected:
    01526       virtual
    01527       ~moneypunct_byname()
    01528       { _S_destroy_c_locale(_M_c_locale_moneypunct); }
    01529     };
    01530
    01531   template<typename _CharT, bool _Intl>
    01532     const bool moneypunct_byname<_CharT, _Intl>::intl;
    01533
    01534   template<typename _CharT, typename _InIter>
    01535     class money_get : public locale::facet
    01536     {
    01537     public:
    01538       // Types:
    01539       typedef _CharT                char_type;
    01540       typedef _InIter               iter_type;
    01541       typedef basic_string<_CharT>  string_type;
    01542
    01543       static locale::id         id;
    01544
    01545       explicit
    01546       money_get(size_t __refs = 0) : locale::facet(__refs) { }
    01547
    01548       iter_type
    01549       get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
    01550       ios_base::iostate& __err, long double& __units) const
    01551       { return this->do_get(__s, __end, __intl, __io, __err, __units); }
    01552
    01553       iter_type
    01554       get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
    01555       ios_base::iostate& __err, string_type& __digits) const
    01556       { return this->do_get(__s, __end, __intl, __io, __err, __digits); }
    01557
    01558     protected:
    01559       virtual
    01560       ~money_get() { }
    01561
    01562       virtual iter_type
    01563       do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
    01564          ios_base::iostate& __err, long double& __units) const;
    01565
    01566       virtual iter_type
    01567       do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
    01568          ios_base::iostate& __err, string_type& __digits) const;
    01569     };
    01570
    01571   template<typename _CharT, typename _InIter>
    01572     locale::id money_get<_CharT, _InIter>::id;
    01573
    01574   template<typename _CharT, typename _OutIter>
    01575     class money_put : public locale::facet
    01576     {
    01577     public:
    01578       typedef _CharT                char_type;
    01579       typedef _OutIter              iter_type;
    01580       typedef basic_string<_CharT>  string_type;
    01581
    01582       static locale::id         id;
    01583
    01584       explicit
    01585       money_put(size_t __refs = 0) : locale::facet(__refs) { }
    01586
    01587       iter_type
    01588       put(iter_type __s, bool __intl, ios_base& __io,
    01589       char_type __fill, long double __units) const
    01590       { return this->do_put(__s, __intl, __io, __fill, __units); }
    01591
    01592       iter_type
    01593       put(iter_type __s, bool __intl, ios_base& __io,
    01594       char_type __fill, const string_type& __digits) const
    01595       { return this->do_put(__s, __intl, __io, __fill, __digits); }
    01596
    01597     protected:
    01598       virtual
    01599       ~money_put() { }
    01600
    01601       virtual iter_type
    01602       do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
    01603          long double __units) const;
    01604
    01605       virtual iter_type
    01606       do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
    01607          const string_type& __digits) const;
    01608     };
    01609
    01610   template<typename _CharT, typename _OutIter>
    01611     locale::id money_put<_CharT, _OutIter>::id;
    01612
    01613
    01614   struct messages_base
    01615   {
    01616     typedef int catalog;
    01617   };
    01618
    01619   template<typename _CharT>
    01620     class messages : public locale::facet, public messages_base
    01621     {
    01622     public:
    01623       // Types:
    01624       typedef _CharT            char_type;
    01625       typedef basic_string<_CharT>  string_type;
    01626
    01627     protected:
    01628       // Underlying "C" library locale information saved from
    01629       // initialization, needed by messages_byname as well.
    01630       __c_locale            _M_c_locale_messages;
    01631 #if 1
    01632       // Only needed if glibc < 2.3
    01633       char*             _M_name_messages;
    01634 #endif
    01635
    01636     public:
    01637       static locale::id         id;
    01638
    01639       explicit
    01640       messages(size_t __refs = 0)
    01641       : locale::facet(__refs)
    01642       {
    01643     _M_name_messages = new char[2];
    01644     strcpy(_M_name_messages, "C");
    01645     _M_c_locale_messages = _S_c_locale;
    01646       }
    01647
    01648       // Non-standard.
    01649       explicit
    01650       messages(__c_locale __cloc, const char* __s, size_t __refs = 0)
    01651       : locale::facet(__refs)
    01652       {
    01653     _M_name_messages = new char[strlen(__s) + 1];
    01654     strcpy(_M_name_messages, __s);
    01655     _M_c_locale_messages = _S_clone_c_locale(__cloc);
    01656       }
    01657
    01658       catalog
    01659       open(const basic_string<char>& __s, const locale& __loc) const
    01660       { return this->do_open(__s, __loc); }
    01661
    01662       // Non-standard and unorthodox, yet effective.
    01663       catalog
    01664       open(const basic_string<char>&, const locale&, const char*) const;
    01665
    01666       string_type
    01667       get(catalog __c, int __set, int __msgid, const string_type& __s) const
    01668       { return this->do_get(__c, __set, __msgid, __s); }
    01669
    01670       void
    01671       close(catalog __c) const
    01672       { return this->do_close(__c); }
    01673
    01674     protected:
    01675       virtual
    01676       ~messages()
    01677        {
    01678      delete [] _M_name_messages;
    01679      _S_destroy_c_locale(_M_c_locale_messages);
    01680        }
    01681
    01682       virtual catalog
    01683       do_open(const basic_string<char>&, const locale&) const;
    01684
    01685       virtual string_type
    01686       do_get(catalog, int, int, const string_type& __dfault) const;
    01687
    01688       virtual void
    01689       do_close(catalog) const;
    01690
    01691       // Returns a locale and codeset-converted string, given a char* message.
    01692       char*
    01693       _M_convert_to_char(const string_type& __msg) const
    01694       {
    01695     // XXX
    01696     return reinterpret_cast<char*>(const_cast<_CharT*>(__msg.c_str()));
    01697       }
    01698
    01699       // Returns a locale and codeset-converted string, given a char* message.
    01700       string_type
    01701       _M_convert_from_char(char* __msg) const
    01702       {
    01703     // Length of message string without terminating null.
    01704     size_t __len = char_traits<char>::length(__msg) - 1;
    01705
    01706     // "everybody can easily convert the string using
    01707     // mbsrtowcs/wcsrtombs or with iconv()"
    01708 #if 0
    01709     // Convert char* to _CharT in locale used to open catalog.
    01710     // XXX need additional template parameter on messages class for this..
    01711     // typedef typename codecvt<char, _CharT, _StateT> __codecvt_type;
    01712     typedef typename codecvt<char, _CharT, mbstate_t> __codecvt_type;
    01713
    01714     __codecvt_type::state_type __state;
    01715     // XXX may need to initialize state.
    01716     //initialize_state(__state._M_init());
    01717
    01718     char* __from_next;
    01719     // XXX what size for this string?
    01720     _CharT* __to = static_cast<_CharT*>(__builtin_alloca(__len + 1));
    01721     const __codecvt_type& __cvt = use_facet<__codecvt_type>(_M_locale_conv);
    01722     __cvt.out(__state, __msg, __msg + __len, __from_next,
    01723           __to, __to + __len + 1, __to_next);
    01724     return string_type(__to);
    01725 #endif
    01726 #if 0
    01727     typedef ctype<_CharT> __ctype_type;
    01728     // const __ctype_type& __cvt = use_facet<__ctype_type>(_M_locale_msg);
    01729     const __ctype_type& __cvt = use_facet<__ctype_type>(locale());
    01730     // XXX Again, proper length of converted string an issue here.
    01731     // For now, assume the converted length is not larger.
    01732     _CharT* __dest = static_cast<_CharT*>(__builtin_alloca(__len + 1));
    01733     __cvt.widen(__msg, __msg + __len, __dest);
    01734     return basic_string<_CharT>(__dest);
    01735 #endif
    01736     return string_type();
    01737       }
    01738      };
    01739
    01740   template<typename _CharT>
    01741     locale::id messages<_CharT>::id;
    01742
    01743   // Specializations for required instantiations.
    01744   template<>
    01745     string
    01746     messages<char>::do_get(catalog, int, int, const string&) const;
    01747
    01748 #ifdef _GLIBCPP_USE_WCHAR_T
    01749   template<>
    01750     wstring
    01751     messages<wchar_t>::do_get(catalog, int, int, const wstring&) const;
    01752 #endif
    01753
    01754   // Include host and configuration specific messages virtual functions.
    01755   #include <bits/messages_members.h>
    01756
    01757   template<typename _CharT>
    01758     class messages_byname : public messages<_CharT>
    01759     {
    01760     public:
    01761       typedef _CharT                char_type;
    01762       typedef basic_string<_CharT>  string_type;
    01763
    01764       explicit
    01765       messages_byname(const char* __s, size_t __refs = 0)
    01766       : messages<_CharT>(__refs)
    01767       {
    01768     delete [] _M_name_messages;
    01769     _M_name_messages = new char[strlen(__s) + 1];
    01770     strcpy(_M_name_messages, __s);
    01771     _S_destroy_c_locale(_M_c_locale_messages);
    01772     _S_create_c_locale(_M_c_locale_messages, __s);
    01773       }
    01774
    01775     protected:
    01776       virtual
    01777       ~messages_byname()
    01778       { }
    01779     };
    01780
    01781
    01782   // Subclause convenience interfaces, inlines.
    01783   // NB: These are inline because, when used in a loop, some compilers
    01784   // can hoist the body out of the loop; then it's just as fast as the
    01785   // C is*() function.
    01786   template<typename _CharT>
    01787     inline bool
    01788     isspace(_CharT __c, const locale& __loc)
    01789     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c); }
    01790
    01791   template<typename _CharT>
    01792     inline bool
    01793     isprint(_CharT __c, const locale& __loc)
    01794     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c); }
    01795
    01796   template<typename _CharT>
    01797     inline bool
    01798     iscntrl(_CharT __c, const locale& __loc)
    01799     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c); }
    01800
    01801   template<typename _CharT>
    01802     inline bool
    01803     isupper(_CharT __c, const locale& __loc)
    01804     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c); }
    01805
    01806   template<typename _CharT>
    01807     inline bool islower(_CharT __c, const locale& __loc)
    01808     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c); }
    01809
    01810   template<typename _CharT>
    01811     inline bool
    01812     isalpha(_CharT __c, const locale& __loc)
    01813     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c); }
    01814
    01815   template<typename _CharT>
    01816     inline bool
    01817     isdigit(_CharT __c, const locale& __loc)
    01818     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c); }
    01819
    01820   template<typename _CharT>
    01821     inline bool
    01822     ispunct(_CharT __c, const locale& __loc)
    01823     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c); }
    01824
    01825   template<typename _CharT>
    01826     inline bool
    01827     isxdigit(_CharT __c, const locale& __loc)
    01828     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c); }
    01829
    01830   template<typename _CharT>
    01831     inline bool
    01832     isalnum(_CharT __c, const locale& __loc)
    01833     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c); }
    01834
    01835   template<typename _CharT>
    01836     inline bool
    01837     isgraph(_CharT __c, const locale& __loc)
    01838     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c); }
    01839
    01840   template<typename _CharT>
    01841     inline _CharT
    01842     toupper(_CharT __c, const locale& __loc)
    01843     { return use_facet<ctype<_CharT> >(__loc).toupper(__c); }
    01844
    01845   template<typename _CharT>
    01846     inline _CharT
    01847     tolower(_CharT __c, const locale& __loc)
    01848     { return use_facet<ctype<_CharT> >(__loc).tolower(__c); }
    01849 } // namespace std
    01850
    01851 #endif