Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. // Locale support -*- C++ -*-
  2.  
  3. // Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
  4. //
  5. // This file is part of the GNU ISO C++ Library.  This library is free
  6. // software; you can redistribute it and/or modify it under the
  7. // terms of the GNU General Public License as published by the
  8. // Free Software Foundation; either version 2, or (at your option)
  9. // any later version.
  10.  
  11. // This library is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. // GNU General Public License for more details.
  15.  
  16. // You should have received a copy of the GNU General Public License along
  17. // with this library; see the file COPYING.  If not, write to the Free
  18. // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  19. // USA.
  20.  
  21. // As a special exception, you may use this file as part of a free software
  22. // library without restriction.  Specifically, if other files instantiate
  23. // templates or use macros or inline functions from this file, or you compile
  24. // this file and link it with other files to produce an executable, this
  25. // file does not by itself cause the resulting executable to be covered by
  26. // the GNU General Public License.  This exception does not however
  27. // invalidate any other reasons why the executable file might be covered by
  28. // the GNU General Public License.
  29.  
  30. //
  31. // ISO C++ 14882: 22.1  Locales
  32. //
  33.  
  34. // Warning: this file is not meant for user inclusion.  Use <locale>.
  35.  
  36. #ifndef _CPP_BITS_LOCFACETS_H
  37. #define _CPP_BITS_LOCFACETS_H   1
  38.  
  39. #pragma GCC system_header
  40.  
  41. #include <bits/std_ctime.h>     // For struct tm
  42. #include <bits/std_ios.h>       // For ios_base
  43. #ifdef _GLIBCPP_USE_WCHAR_T
  44. # include <langinfo.h>          // For codecvt
  45. # include <bits/std_cwctype.h>  // For wctype_t
  46. # include <iconv.h>             // For codecvt using iconv, iconv_t
  47. #endif
  48.  
  49. namespace std
  50. {
  51.   // 22.2.1.1  Template class ctype
  52.   // Include host-specific ctype enums for ctype_base.
  53.   #include <bits/ctype_base.h>
  54.  
  55.   // __ctype_abstract_base is the common base for ctype<_CharT>.  
  56.   template<typename _CharT>
  57.     class __ctype_abstract_base : public locale::facet, public ctype_base
  58.     {
  59.     public:
  60.       // Types:
  61.       typedef _CharT char_type;
  62.  
  63.       bool
  64.       is(mask __m, char_type __c) const
  65.       { return this->do_is(__m, __c); }
  66.  
  67.       const char_type*
  68.       is(const char_type *__lo, const char_type *__hi, mask *__vec) const  
  69.       { return this->do_is(__lo, __hi, __vec); }
  70.  
  71.       const char_type*
  72.       scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
  73.       { return this->do_scan_is(__m, __lo, __hi); }
  74.  
  75.       const char_type*
  76.       scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
  77.       { return this->do_scan_not(__m, __lo, __hi); }
  78.  
  79.       char_type
  80.       toupper(char_type __c) const
  81.       { return this->do_toupper(__c); }
  82.  
  83.       const char_type*
  84.       toupper(char_type *__lo, const char_type* __hi) const
  85.       { return this->do_toupper(__lo, __hi); }
  86.  
  87.       char_type
  88.       tolower(char_type __c) const
  89.       { return this->do_tolower(__c); }
  90.  
  91.       const char_type*
  92.       tolower(char_type* __lo, const char_type* __hi) const
  93.       { return this->do_tolower(__lo, __hi); }
  94.  
  95.       char_type
  96.       widen(char __c) const
  97.       { return this->do_widen(__c); }
  98.  
  99.       const char*
  100.       widen(const char* __lo, const char* __hi, char_type* __to) const
  101.       { return this->do_widen(__lo, __hi, __to); }
  102.  
  103.       char
  104.       narrow(char_type __c, char __dfault) const
  105.       { return this->do_narrow(__c, __dfault); }
  106.  
  107.       const char_type*
  108.       narrow(const char_type* __lo, const char_type* __hi,
  109.               char __dfault, char *__to) const
  110.       { return this->do_narrow(__lo, __hi, __dfault, __to); }
  111.  
  112.     protected:
  113.       explicit
  114.       __ctype_abstract_base(size_t __refs = 0): locale::facet(__refs) { }
  115.  
  116.       virtual
  117.       ~__ctype_abstract_base() { }
  118.      
  119.       virtual bool
  120.       do_is(mask __m, char_type __c) const = 0;
  121.  
  122.       virtual const char_type*
  123.       do_is(const char_type* __lo, const char_type* __hi,
  124.             mask* __vec) const = 0;
  125.  
  126.       virtual const char_type*
  127.       do_scan_is(mask __m, const char_type* __lo,
  128.                  const char_type* __hi) const = 0;
  129.  
  130.       virtual const char_type*
  131.       do_scan_not(mask __m, const char_type* __lo,
  132.                   const char_type* __hi) const = 0;
  133.  
  134.       virtual char_type
  135.       do_toupper(char_type) const = 0;
  136.  
  137.       virtual const char_type*
  138.       do_toupper(char_type* __lo, const char_type* __hi) const = 0;
  139.  
  140.       virtual char_type
  141.       do_tolower(char_type) const = 0;
  142.  
  143.       virtual const char_type*
  144.       do_tolower(char_type* __lo, const char_type* __hi) const = 0;
  145.      
  146.       virtual char_type
  147.       do_widen(char) const = 0;
  148.  
  149.       virtual const char*
  150.       do_widen(const char* __lo, const char* __hi,
  151.                char_type* __dest) const = 0;
  152.  
  153.       virtual char
  154.       do_narrow(char_type, char __dfault) const = 0;
  155.  
  156.       virtual const char_type*
  157.       do_narrow(const char_type* __lo, const char_type* __hi,
  158.                  char __dfault, char* __dest) const = 0;
  159.     };
  160.  
  161.   // NB: Generic, mostly useless implementation.
  162.   template<typename _CharT>
  163.     class ctype : public __ctype_abstract_base<_CharT>
  164.     {
  165.     public:
  166.       // Types:
  167.       typedef _CharT                    char_type;
  168.       typedef typename ctype::mask      mask;
  169.  
  170.       explicit
  171.       ctype(size_t __refs = 0) : __ctype_abstract_base<_CharT>(__refs) { }
  172.  
  173.       static locale::id id;
  174.  
  175.    protected:
  176.       virtual
  177.       ~ctype() { }
  178.  
  179.       virtual bool
  180.       do_is(mask __m, char_type __c) const
  181.       { return false; }
  182.  
  183.       virtual const char_type*
  184.       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const
  185.       { return __hi; }
  186.  
  187.       virtual const char_type*
  188.       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
  189.       { return __hi; }
  190.  
  191.       virtual const char_type*
  192.       do_scan_not(mask __m, const char_type* __lo,
  193.                   const char_type* __hi) const
  194.       { return __hi; }
  195.  
  196.       virtual char_type
  197.       do_toupper(char_type __c) const
  198.       { return __c; }
  199.  
  200.       virtual const char_type*
  201.       do_toupper(char_type* __lo, const char_type* __hi) const
  202.       { return __hi; }
  203.  
  204.       virtual char_type
  205.       do_tolower(char_type __c) const
  206.       { return __c; }
  207.  
  208.       virtual const char_type*
  209.       do_tolower(char_type* __lo, const char_type* __hi) const
  210.       { return __hi; }
  211.      
  212.       virtual char_type
  213.       do_widen(char __c) const
  214.       { return char_type(); }
  215.  
  216.       virtual const char*
  217.       do_widen(const char* __lo, const char* __hi, char_type* __dest) const
  218.       { return __hi; }
  219.  
  220.       virtual char
  221.       do_narrow(char_type, char __dfault) const
  222.       { return __dfault; }
  223.  
  224.       virtual const char_type*
  225.       do_narrow(const char_type* __lo, const char_type* __hi,
  226.                 char __dfault, char* __dest) const
  227.       { return __hi; }
  228.     };
  229.  
  230.   template<typename _CharT>
  231.     locale::id ctype<_CharT>::id;
  232.  
  233.   // 22.2.1.3  ctype specializations
  234.   template<>
  235.     class ctype<char> : public __ctype_abstract_base<char>
  236.     {
  237.     public:
  238.       // Types:
  239.       typedef char             char_type;
  240.  
  241.     private:
  242.       // Data Members:
  243.       bool                     _M_del;
  244.       __to_type const&         _M_toupper;
  245.       __to_type const&         _M_tolower;
  246.       const mask* const&       _M_ctable;
  247.       const mask*              _M_table;
  248.      
  249.     public:
  250.       static locale::id        id;
  251.       static const size_t      table_size = 1 + static_cast<unsigned char>(-1);
  252.  
  253.       explicit
  254.       ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0);
  255.  
  256.       inline bool
  257.       is(mask __m, char __c) const;
  258.  
  259.       inline const char*
  260.       is(const char* __lo, const char* __hi, mask* __vec) const;
  261.  
  262.       inline const char*
  263.       scan_is(mask __m, const char* __lo, const char* __hi) const;
  264.  
  265.       inline const char*
  266.       scan_not(mask __m, const char* __lo, const char* __hi) const;
  267.      
  268.     protected:
  269.       virtual
  270.       ~ctype();
  271.  
  272.       const mask*
  273.       table() const throw()
  274.       { return _M_table; }
  275.  
  276.       const mask*
  277.       classic_table() throw()
  278.       { return _M_ctable; }
  279.  
  280.       virtual bool
  281.       do_is(mask __m, char_type __c) const;
  282.  
  283.       virtual const char_type*
  284.       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
  285.  
  286.       virtual const char_type*
  287.       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
  288.  
  289.       virtual const char_type*
  290.       do_scan_not(mask __m, const char_type* __lo,
  291.                   const char_type* __hi) const;
  292.  
  293.       virtual char_type
  294.       do_toupper(char_type) const;
  295.  
  296.       virtual const char_type*
  297.       do_toupper(char_type* __lo, const char_type* __hi) const;
  298.  
  299.       virtual char_type
  300.       do_tolower(char_type) const;
  301.  
  302.       virtual const char_type*
  303.       do_tolower(char_type* __lo, const char_type* __hi) const;
  304.      
  305.       virtual char_type
  306.       do_widen(char) const;
  307.  
  308.       virtual const char*
  309.       do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
  310.  
  311.       virtual char
  312.       do_narrow(char_type, char __dfault) const;
  313.  
  314.       virtual const char_type*
  315.       do_narrow(const char_type* __lo, const char_type* __hi,
  316.                  char __dfault, char* __dest) const;
  317.     };
  318.  
  319.   template<>
  320.     const ctype<char>&
  321.     use_facet<ctype<char> >(const locale& __loc);
  322.  
  323. #ifdef _GLIBCPP_USE_WCHAR_T
  324.   // ctype<wchar_t> specialization
  325.   template<>
  326.     class ctype<wchar_t> : public __ctype_abstract_base<wchar_t>
  327.     {
  328.     public:
  329.       // Types:
  330.       typedef wchar_t          char_type;
  331.       typedef wctype_t         __wmask_type;
  332.  
  333.       // Data Members:
  334.       static locale::id        id;
  335.  
  336.       explicit
  337.       ctype(size_t __refs = 0);
  338.  
  339.     protected:
  340.       __wmask_type
  341.       _M_convert_to_wmask(const mask __m) const;
  342.  
  343.       virtual
  344.       ~ctype();
  345.  
  346.       virtual bool
  347.       do_is(mask __m, char_type __c) const;
  348.  
  349.       virtual const char_type*
  350.       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
  351.  
  352.       virtual const char_type*
  353.       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
  354.  
  355.       virtual const char_type*
  356.       do_scan_not(mask __m, const char_type* __lo,
  357.                   const char_type* __hi) const;
  358.  
  359.       virtual char_type
  360.       do_toupper(char_type) const;
  361.  
  362.       virtual const char_type*
  363.       do_toupper(char_type* __lo, const char_type* __hi) const;
  364.  
  365.       virtual char_type
  366.       do_tolower(char_type) const;
  367.  
  368.       virtual const char_type*
  369.       do_tolower(char_type* __lo, const char_type* __hi) const;
  370.      
  371.       virtual char_type
  372.       do_widen(char) const;
  373.  
  374.       virtual const char*
  375.       do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
  376.  
  377.       virtual char
  378.       do_narrow(char_type, char __dfault) const;
  379.  
  380.       virtual const char_type*
  381.       do_narrow(const char_type* __lo, const char_type* __hi,
  382.                  char __dfault, char* __dest) const;
  383.  
  384.     };
  385.  
  386.   template<>
  387.     const ctype<wchar_t>&
  388.     use_facet<ctype<wchar_t> >(const locale& __loc);
  389. #endif //_GLIBCPP_USE_WCHAR_T
  390.  
  391.   // Include host-specific ctype inlines.
  392.   #include <bits/ctype_inline.h>
  393.  
  394.   // 22.2.1.2  Template class ctype_byname
  395.   template<typename _CharT>
  396.     class ctype_byname : public ctype<_CharT>
  397.     {
  398.     public:
  399.       typedef _CharT            char_type;
  400.  
  401.       explicit
  402.       ctype_byname(const char*, size_t __refs = 0);
  403.  
  404.     protected:
  405.       virtual
  406.       ~ctype_byname() { }
  407.     };
  408.  
  409.   // 22.2.1.4  Class ctype_byname specialization
  410.   template<>
  411.     ctype_byname<char>::ctype_byname(const char*, size_t refs);
  412.  
  413.  
  414.   // 22.2.1.5  Template class codecvt
  415.   #include <bits/codecvt.h>
  416.  
  417.   template<typename _CharT, typename _InIter>
  418.     class _Numeric_get;  // forward
  419.  
  420.   // _Format_cache holds the information extracted from the numpunct<>
  421.   // and moneypunct<> facets in a form optimized for parsing and
  422.   // formatting.  It is stored via a void* pointer in the pword()
  423.   // array of an iosbase object passed to the _get and _put facets.
  424.   // NB: contains no user-serviceable parts.
  425.   template<typename _CharT>
  426.     class _Format_cache
  427.     {
  428.     public:
  429.       // Types:
  430.       typedef _CharT                            char_type;
  431.       typedef char_traits<_CharT>               traits_type;
  432.       typedef basic_string<_CharT>              string_type;
  433.       typedef typename string_type::size_type   size_type;
  434.  
  435.       // Forward decls and Friends:
  436.       friend class locale;
  437.       template<typename _Char, typename _InIter>
  438.         friend class _Numeric_get;
  439.       friend class num_get<_CharT>;
  440.       friend class num_put<_CharT>;
  441.       friend class time_get<_CharT>;
  442.       friend class money_get<_CharT>;
  443.       friend class time_put<_CharT>;
  444.       friend class money_put<_CharT>;
  445.  
  446.       // Data Members:
  447.  
  448.       // ios_base::pword() reserved cell
  449.       static int                _S_pword_ix;
  450.  
  451.       // True iff data members are consistent with the current locale,
  452.       // ie imbue sets this to false.
  453.       bool                      _M_valid;
  454.  
  455.       // A list of valid numeric literals: for the standard "C" locale,
  456.       // this would usually be: "-+xX0123456789abcdef0123456789ABCDEF"
  457.       static const char         _S_literals[];
  458.  
  459.       // NB: Code depends on the order of definitions of the names
  460.       // these are indices into _S_literals, above.
  461.       // This string is formatted for putting, not getting. (output, not input)
  462.       enum
  463.       {  
  464.         _S_minus,
  465.         _S_plus,
  466.         _S_x,
  467.         _S_X,
  468.         _S_digits,
  469.         _S_digits_end = _S_digits + 16,
  470.         _S_udigits = _S_digits_end,  
  471.         _S_udigits_end = _S_udigits + 16,
  472.         _S_ee = _S_digits + 14, // For scientific notation, 'E'
  473.         _S_Ee = _S_udigits + 14 // For scientific notation, 'e'
  474.       };
  475.  
  476.       // The sign used to separate decimal values: for standard US
  477.       // locales, this would usually be: "."
  478.       // Abstracted from numpunct::decimal_point().
  479.       char_type                 _M_decimal_point;
  480.  
  481.       // The sign used to separate groups of digits into smaller
  482.       // strings that the eye can parse with less difficulty: for
  483.       // standard US locales, this would usually be: ","
  484.       // Abstracted from numpunct::thousands_sep().
  485.       char_type                 _M_thousands_sep;
  486.  
  487.       // However the US's "false" and "true" are translated.
  488.       // From numpunct::truename() and numpunct::falsename(), respectively.
  489.       string_type               _M_truename;
  490.       string_type               _M_falsename;
  491.  
  492.       // If we are checking groupings. This should be equivalent to
  493.       // numpunct::groupings().size() != 0
  494.       bool                      _M_use_grouping;
  495.  
  496.       // If we are using numpunct's groupings, this is the current
  497.       // grouping string in effect (from numpunct::grouping()).
  498.       string                    _M_grouping;
  499.  
  500.       _Format_cache();
  501.  
  502.       ~_Format_cache() throw() { }
  503.  
  504.       // Given a member of the ios heirarchy as an argument, extract
  505.       // out all the current formatting information into a
  506.       // _Format_cache object and return a pointer to it.
  507.       static _Format_cache<_CharT>*
  508.       _S_get(ios_base& __ios);
  509.  
  510.       void
  511.       _M_populate(ios_base&);
  512.  
  513.       static void
  514.       _S_callback(ios_base::event __event, ios_base& __ios, int __ix) throw();
  515.     };
  516.  
  517.   template<typename _CharT>
  518.     int _Format_cache<_CharT>::_S_pword_ix;
  519.  
  520.   template<typename _CharT>
  521.     const char _Format_cache<_CharT>::
  522.     _S_literals[] = "-+xX0123456789abcdef0123456789ABCDEF";
  523.  
  524.    template<> _Format_cache<char>::_Format_cache();
  525. #ifdef _GLIBCPP_USE_WCHAR_T
  526.    template<> _Format_cache<wchar_t>::_Format_cache();
  527. #endif
  528.  
  529.   // _Numeric_get is used by num_get, money_get, and time_get to help
  530.   // in parsing out numbers.
  531.   template<typename _CharT, typename _InIter>
  532.     class _Numeric_get
  533.     {
  534.     public:
  535.       // Types:
  536.       typedef _CharT     char_type;
  537.       typedef _InIter    iter_type;
  538.  
  539.       // Forward decls and Friends:
  540.       template<typename _Char, typename _InIterT>
  541.       friend class num_get;
  542.       template<typename _Char, typename _InIterT>
  543.       friend class time_get;
  544.       template<typename _Char, typename _InIterT>
  545.       friend class money_get;
  546.       template<typename _Char, typename _InIterT>
  547.       friend class num_put;
  548.       template<typename _Char, typename _InIterT>
  549.       friend class time_put;
  550.       template<typename _Char, typename _InIterT>
  551.       friend class money_put;
  552.  
  553.     private:
  554.       explicit
  555.       _Numeric_get() { }
  556.  
  557.       virtual
  558.       ~_Numeric_get() { }
  559.  
  560.       iter_type
  561.       _M_get_digits(iter_type __in, iter_type __end) const;
  562.     };
  563.  
  564.   template<typename _CharT, typename _InIter>
  565.     class num_get : public locale::facet
  566.     {
  567.     public:
  568.       // Types:
  569.       typedef _CharT                    char_type;
  570.       typedef _InIter                   iter_type;
  571.       typedef char_traits<_CharT>       __traits_type;
  572.  
  573.       static locale::id id;
  574.  
  575.       explicit
  576.       num_get(size_t __refs = 0) : locale::facet(__refs) { }
  577.  
  578.       iter_type
  579.       get(iter_type __in, iter_type __end, ios_base& __io,
  580.           ios_base::iostate& __err, bool& __v) const
  581.       { return do_get(__in, __end, __io, __err, __v); }
  582.  
  583. #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
  584.       iter_type
  585.       get(iter_type __in, iter_type __end, ios_base& __io,
  586.           ios_base::iostate& __err, short& __v) const
  587.       { return do_get(__in, __end, __io, __err, __v); }
  588.  
  589.       iter_type
  590.       get(iter_type __in, iter_type __end, ios_base& __io,
  591.           ios_base::iostate& __err, int& __v)   const
  592.       { return do_get(__in, __end, __io, __err, __v); }
  593. #endif
  594.  
  595.       iter_type
  596.       get(iter_type __in, iter_type __end, ios_base& __io,
  597.           ios_base::iostate& __err, long& __v) const
  598.       { return do_get(__in, __end, __io, __err, __v); }
  599.  
  600. #ifdef _GLIBCPP_USE_LONG_LONG
  601.       iter_type
  602.       get(iter_type __in, iter_type __end, ios_base& __io,
  603.           ios_base::iostate& __err, long long& __v) const
  604.       { return do_get(__in, __end, __io, __err, __v); }
  605. #endif
  606.  
  607.       iter_type
  608.       get(iter_type __in, iter_type __end, ios_base& __io,
  609.           ios_base::iostate& __err, unsigned short& __v) const
  610.       { return do_get(__in, __end, __io, __err, __v); }
  611.  
  612.       iter_type
  613.       get(iter_type __in, iter_type __end, ios_base& __io,
  614.           ios_base::iostate& __err, unsigned int& __v)   const
  615.       { return do_get(__in, __end, __io, __err, __v); }
  616.  
  617.       iter_type
  618.       get(iter_type __in, iter_type __end, ios_base& __io,
  619.           ios_base::iostate& __err, unsigned long& __v)  const
  620.       { return do_get(__in, __end, __io, __err, __v); }
  621.  
  622. #ifdef _GLIBCPP_USE_LONG_LONG
  623.       iter_type
  624.       get(iter_type __in, iter_type __end, ios_base& __io,
  625.           ios_base::iostate& __err, unsigned long long& __v)  const
  626.       { return do_get(__in, __end, __io, __err, __v); }
  627. #endif
  628.  
  629.       iter_type
  630.       get(iter_type __in, iter_type __end, ios_base& __io,
  631.           ios_base::iostate& __err, float& __v) const
  632.       { return do_get(__in, __end, __io, __err, __v); }
  633.  
  634.       iter_type
  635.       get(iter_type __in, iter_type __end, ios_base& __io,
  636.           ios_base::iostate& __err, double& __v) const
  637.       { return do_get(__in, __end, __io, __err, __v); }
  638.  
  639.       iter_type
  640.       get(iter_type __in, iter_type __end, ios_base& __io,
  641.           ios_base::iostate& __err, long double& __v) const
  642.       { return do_get(__in, __end, __io, __err, __v); }
  643.  
  644.       iter_type
  645.       get(iter_type __in, iter_type __end, ios_base& __io,
  646.           ios_base::iostate& __err, void*& __v) const
  647.       { return do_get(__in, __end, __io, __err, __v); }      
  648.  
  649.     protected:
  650.       virtual ~num_get() { }
  651.  
  652.       // This consolidates the extraction, storage and
  653.       // error-processing parts of the do_get(...) overloaded member
  654.       // functions.
  655.       // NB: This is specialized for char.
  656.       void
  657.       _M_extract(iter_type __beg, iter_type __end, ios_base& __io,
  658.                  ios_base::iostate& __err, char* __xtrc,
  659.                  int& __base, bool __fp = true) const;
  660.  
  661.       virtual iter_type
  662.       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
  663.  
  664. #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
  665.       virtual iter_type
  666.       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, short&) const;
  667.       virtual iter_type
  668.       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, int&) const;
  669. #endif
  670.       virtual iter_type
  671.       do_get (iter_type, iter_type, ios_base&, ios_base::iostate&, long&) const;
  672. #ifdef _GLIBCPP_USE_LONG_LONG
  673.       virtual iter_type
  674.       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
  675.              long long&) const;
  676. #endif
  677.       virtual iter_type
  678.       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
  679.               unsigned short&) const;
  680.       virtual iter_type
  681.       do_get(iter_type, iter_type, ios_base&,
  682.               ios_base::iostate& __err, unsigned int&) const;
  683.       virtual iter_type
  684.       do_get(iter_type, iter_type, ios_base&,
  685.               ios_base::iostate& __err, unsigned long&) const;
  686. #ifdef _GLIBCPP_USE_LONG_LONG
  687.       virtual iter_type
  688.       do_get(iter_type, iter_type, ios_base&,
  689.              ios_base::iostate& __err, unsigned long long&) const;
  690. #endif
  691.       virtual iter_type
  692.       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
  693.              float&) const;
  694.  
  695.       virtual iter_type
  696.       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
  697.              double&) const;
  698.  
  699.       virtual iter_type
  700.       do_get(iter_type, iter_type, ios_base&,
  701.              ios_base::iostate& __err, long double&) const;
  702.  
  703.       virtual iter_type
  704.       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
  705.              void*&) const;
  706.     };
  707.  
  708.   template<typename _CharT, typename _InIter>
  709.     locale::id num_get<_CharT, _InIter>::id;
  710.  
  711.   // Declare specialized extraction member function.
  712.   template<>
  713.     void
  714.     num_get<char, istreambuf_iterator<char> >::    
  715.     _M_extract(istreambuf_iterator<char> __beg,
  716.                istreambuf_iterator<char> __end, ios_base& __io,
  717.                ios_base::iostate& __err, char* __xtrc,
  718.                int& __base, bool __fp) const;
  719.  
  720.   // _Numeric_put is used by num_put, money_put, and time_put
  721.   //   to help in formatting out numbers.
  722.   template<typename _CharT, typename _OutIter>
  723.     class _Numeric_put
  724.     {
  725.     public:
  726.       typedef _CharT      char_type;
  727.       typedef _OutIter    iter_type;
  728.     protected:
  729.       explicit
  730.       _Numeric_put() { }
  731.  
  732.       virtual
  733.       ~_Numeric_put() { }
  734.     };
  735.  
  736.   template<typename _CharT, typename _OutIter>
  737.     class num_put : public locale::facet
  738.     {
  739.     public:
  740.       // Types:
  741.       typedef _CharT       char_type;
  742.       typedef _OutIter     iter_type;
  743.  
  744.       static locale::id id;
  745.  
  746.       explicit
  747.       num_put(size_t __refs = 0) : locale::facet(__refs) { }
  748.  
  749.       iter_type
  750.       put(iter_type __s, ios_base& __f, char_type __fill, bool __v) const
  751.       { return do_put(__s, __f, __fill, __v); }
  752.  
  753.       iter_type
  754.       put(iter_type __s, ios_base& __f, char_type __fill, long __v) const
  755.       { return do_put(__s, __f, __fill, __v); }
  756.  
  757.       iter_type
  758.       put(iter_type __s, ios_base& __f, char_type __fill,
  759.           unsigned long __v) const
  760.       { return do_put(__s, __f, __fill, __v); }
  761.  
  762. #ifdef _GLIBCPP_USE_LONG_LONG
  763.       iter_type
  764.       put(iter_type __s, ios_base& __f, char_type __fill, long long __v) const
  765.       { return do_put(__s, __f, __fill, __v); }
  766.  
  767.       iter_type
  768.       put(iter_type __s, ios_base& __f, char_type __fill,
  769.           unsigned long long __v) const
  770.       { return do_put(__s, __f, __fill, __v); }
  771. #endif
  772.  
  773.       iter_type
  774.       put(iter_type __s, ios_base& __f, char_type __fill, double __v) const
  775.       { return do_put(__s, __f, __fill, __v); }
  776.  
  777.       iter_type
  778.       put(iter_type __s, ios_base& __f, char_type __fill,
  779.           long double __v) const
  780.       { return do_put(__s, __f, __fill, __v); }
  781.  
  782.       iter_type
  783.       put(iter_type __s, ios_base& __f, char_type __fill,
  784.           const void* __v) const
  785.       { return do_put(__s, __f, __fill, __v); }
  786.  
  787.     protected:
  788.       virtual
  789.       ~num_put() { };
  790.  
  791.       virtual iter_type
  792.       do_put(iter_type, ios_base&, char_type __fill, bool __v) const;
  793.  
  794.       virtual iter_type
  795.       do_put(iter_type, ios_base&, char_type __fill, long __v) const;
  796.  
  797. #ifdef _GLIBCPP_USE_LONG_LONG
  798.       virtual iter_type
  799.       do_put(iter_type, ios_base&, char_type __fill, long long __v) const;
  800. #endif
  801.  
  802.       virtual iter_type
  803.       do_put(iter_type, ios_base&, char_type __fill, unsigned long) const;
  804.  
  805. #ifdef _GLIBCPP_USE_LONG_LONG
  806.       virtual iter_type
  807.       do_put(iter_type, ios_base&, char_type __fill, unsigned long long) const;
  808. #endif
  809.  
  810.       virtual iter_type
  811.       do_put(iter_type, ios_base&, char_type __fill, double __v) const;
  812.  
  813.       virtual iter_type
  814.       do_put(iter_type, ios_base&, char_type __fill, long double __v) const;
  815.  
  816.       virtual iter_type
  817.       do_put(iter_type, ios_base&, char_type __fill, const void* __v) const;
  818.     };
  819.  
  820.   template <typename _CharT, typename _OutIter>
  821.     locale::id num_put<_CharT, _OutIter>::id;
  822.  
  823.   template<typename _CharT>
  824.     class numpunct : public locale::facet
  825.     {
  826.     public:
  827.       // Types:
  828.       typedef _CharT                    char_type;
  829.       typedef basic_string<_CharT>      string_type;
  830.  
  831.       static locale::id id;
  832.  
  833.     private:
  834.       char_type         _M_decimal_point;
  835.       char_type         _M_thousands_sep;
  836.       string            _M_grouping;
  837.       string_type       _M_truename;
  838.       string_type       _M_falsename;
  839.  
  840.     public:
  841.       explicit
  842.       numpunct(size_t __refs = 0) : locale::facet(__refs)
  843.       { _M_initialize_numpunct(); }
  844.  
  845.       explicit
  846.       numpunct(__c_locale __cloc, size_t __refs = 0) : locale::facet(__refs)
  847.       { _M_initialize_numpunct(__cloc); }
  848.  
  849.       char_type    
  850.       decimal_point() const
  851.       { return do_decimal_point(); }
  852.  
  853.       char_type    
  854.       thousands_sep() const
  855.       { return do_thousands_sep(); }
  856.  
  857.       string      
  858.       grouping() const
  859.       { return do_grouping(); }
  860.  
  861.       string_type  
  862.       truename() const
  863.       { return do_truename(); }
  864.  
  865.       string_type  
  866.       falsename() const
  867.       { return do_falsename(); }
  868.  
  869.     protected:
  870.       virtual
  871.       ~numpunct() { }
  872.  
  873.       virtual char_type    
  874.       do_decimal_point() const
  875.       { return _M_decimal_point; }
  876.  
  877.       virtual char_type    
  878.       do_thousands_sep() const
  879.       { return _M_thousands_sep; }
  880.  
  881.       virtual string
  882.       do_grouping() const
  883.       { return _M_grouping; }
  884.  
  885.       virtual string_type  
  886.       do_truename() const
  887.       { return _M_truename; }
  888.  
  889.       virtual string_type  
  890.       do_falsename() const
  891.       { return _M_falsename; }
  892.  
  893.       // For use at construction time only.
  894.       void
  895.       _M_initialize_numpunct(__c_locale __cloc = NULL);
  896.     };
  897.  
  898.   template<typename _CharT>
  899.     locale::id numpunct<_CharT>::id;
  900.  
  901.   template<typename _CharT>
  902.     void
  903.     numpunct<_CharT>::_M_initialize_numpunct(__c_locale /*__cloc*/)
  904.     {
  905.       // NB: Cannot be made generic.
  906.     }
  907.  
  908.   template<>
  909.     void
  910.     numpunct<char>::_M_initialize_numpunct(__c_locale __cloc);
  911. #ifdef _GLIBCPP_USE_WCHAR_T
  912.   template<>
  913.     void
  914.     numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc);
  915. #endif
  916.  
  917.  
  918.   template<typename _CharT>
  919.     class numpunct_byname : public numpunct<_CharT>
  920.     {
  921.       __c_locale                        _M_c_locale_numpunct;
  922.     public:
  923.       typedef _CharT                    char_type;
  924.       typedef basic_string<_CharT>      string_type;
  925.  
  926.       explicit
  927.       numpunct_byname(const char* __s, size_t __refs = 0)
  928.       : numpunct<_CharT>(__refs)
  929.       {
  930.         _S_create_c_locale(_M_c_locale_numpunct, __s);
  931.         _M_initialize_numpunct(_M_c_locale_numpunct);  
  932.       }
  933.  
  934.     protected:
  935.       virtual
  936.       ~numpunct_byname()
  937.       { _S_destroy_c_locale(_M_c_locale_numpunct); }
  938.     };
  939.  
  940.  
  941.   template<typename _CharT>
  942.     class collate : public locale::facet
  943.     {
  944.     public:
  945.       // Types:
  946.       typedef _CharT               char_type;
  947.       typedef basic_string<_CharT> string_type;
  948.  
  949.       static locale::id id;
  950.  
  951.       explicit
  952.       collate(size_t __refs = 0) : locale::facet(__refs) { }
  953.  
  954.       int
  955.       compare(const _CharT* __lo1, const _CharT* __hi1,
  956.               const _CharT* __lo2, const _CharT* __hi2) const
  957.       { return this->do_compare(__lo1, __hi1, __lo2, __hi2); }
  958.  
  959.       string_type
  960.       transform(const _CharT* __lo, const _CharT* __hi) const
  961.       { return this->do_transform(__lo, __hi); }
  962.  
  963.       long
  964.       hash(const _CharT* __lo, const _CharT* __hi) const
  965.       { return this->do_hash(__lo, __hi); }
  966.      
  967.   protected:
  968.       ~collate() { } // virtual
  969.  
  970.       virtual int  
  971.       do_compare(const _CharT* __lo1, const _CharT* __hi1,
  972.                  const _CharT* __lo2, const _CharT* __hi2) const;
  973.  
  974.       virtual string_type
  975.       do_transform(const _CharT* __lo, const _CharT* __hi) const;
  976.  
  977.       virtual long  
  978.       do_hash(const _CharT* __lo, const _CharT* __hi) const;
  979.     };
  980.  
  981.   template<typename _CharT>
  982.     locale::id collate<_CharT>::id;
  983.  
  984.   // Required specializations.
  985.   template<>
  986.     int
  987.     collate<char>::do_compare(const char* __lo1, const char* __hi1,
  988.                               const char* __lo2, const char* __hi2) const;
  989.  
  990.   template<>
  991.     string
  992.     collate<char>::do_transform(const char* __lo, const char* __hi) const;
  993.  
  994.   template<>
  995.     long
  996.     collate<char>::do_hash(const char* __lo, const char* __hi) const;
  997. #ifdef _GLIBCPP_USE_WCHAR_T
  998.   template<>
  999.     int
  1000.     collate<wchar_t>::do_compare(const wchar_t* __lo1, const wchar_t* __hi1,
  1001.                                  const wchar_t* __lo2,
  1002.                                  const wchar_t* __hi2) const;
  1003.  
  1004.   template<>
  1005.     wstring
  1006.     collate<wchar_t>::do_transform(const wchar_t* __lo,
  1007.                                    const wchar_t* __hi) const;
  1008.  
  1009.   template<>
  1010.     long
  1011.     collate<wchar_t>::do_hash(const wchar_t* __lo, const wchar_t* __hi) const;
  1012. #endif
  1013.  
  1014.   template<typename _CharT>
  1015.     class collate_byname : public collate<_CharT>
  1016.     {
  1017.     public:
  1018.       // Types:
  1019.       typedef _CharT               char_type;
  1020.       typedef basic_string<_CharT> string_type;
  1021.  
  1022.       explicit
  1023.       collate_byname(const char*, size_t __refs = 0);
  1024.  
  1025.     protected:
  1026.       virtual
  1027.       ~collate_byname() { }
  1028.     };
  1029.  
  1030.   template<>
  1031.     collate_byname<char>::collate_byname(const char*, size_t __refs);
  1032. #ifdef _GLIBCPP_USE_WCHAR_T
  1033.   template<>
  1034.     collate_byname<wchar_t>::collate_byname(const char*, size_t __refs);
  1035. #endif
  1036.  
  1037.   class time_base
  1038.   {
  1039.   public:
  1040.     enum dateorder { no_order, dmy, mdy, ymd, ydm };
  1041.   };
  1042.  
  1043.   template<typename _CharT, typename _InIter>
  1044.     class time_get : public locale::facet, public time_base
  1045.     {
  1046.     public:
  1047.       // Types:
  1048.       typedef _CharT     char_type;
  1049.       typedef _InIter    iter_type;
  1050.  
  1051.       static locale::id id;
  1052.  
  1053.       explicit
  1054.       time_get(size_t __refs = 0)
  1055.       : locale::facet (__refs), _M_daynames(0), _M_monthnames(0) { }
  1056.  
  1057.       dateorder
  1058.       date_order()  const
  1059.       { return do_date_order(); }
  1060.  
  1061.       iter_type
  1062.       get_time(iter_type __s, iter_type __end, ios_base& __f,
  1063.                ios_base::iostate& __err, tm* __t)  const
  1064.       { return do_get_time(__s, __end, __f, __err, __t); }
  1065.  
  1066.       iter_type
  1067.       get_date(iter_type __s, iter_type __end, ios_base& __f,
  1068.                ios_base::iostate& __err, tm* __t)  const
  1069.       { return do_get_date(__s, __end, __f, __err, __t); }
  1070.  
  1071.       iter_type
  1072.       get_weekday(iter_type __s, iter_type __end, ios_base& __f,
  1073.                   ios_base::iostate& __err, tm* __t) const
  1074.       { return do_get_weekday(__s,__end,__f,__err,__t); }
  1075.  
  1076.       iter_type
  1077.       get_monthname(iter_type __s, iter_type __end, ios_base& __f,
  1078.                     ios_base::iostate& __err, tm* __t) const
  1079.       { return do_get_monthname(__s,__end,__f,__err,__t); }
  1080.  
  1081.       iter_type
  1082.       get_year(iter_type __s, iter_type __end, ios_base& __f,
  1083.                ios_base::iostate& __err, tm* __t) const
  1084.       { return do_get_year(__s,__end,__f,__err,__t); }
  1085.  
  1086.     protected:
  1087.       virtual
  1088.       ~time_get()
  1089.       {      
  1090.         delete [] _M_monthnames;
  1091.         delete [] _M_daynames;
  1092.       }
  1093.  
  1094.       virtual dateorder
  1095.       do_date_order()  const
  1096.       { return time_base::ymd; }
  1097.  
  1098.       virtual iter_type
  1099.       do_get_time(iter_type __s, iter_type /*__end*/, ios_base&,
  1100.                   ios_base::iostate& /*__err*/, tm* /*__t*/) const
  1101.       { return __s; }
  1102.  
  1103.       virtual iter_type
  1104.       do_get_date(iter_type __s, iter_type /*__end*/, ios_base&,
  1105.                   ios_base::iostate& /*__err*/, tm* /*__t*/) const
  1106.       { return __s; }
  1107.  
  1108.       virtual iter_type
  1109.       do_get_weekday(iter_type __s, iter_type __end, ios_base&,
  1110.                      ios_base::iostate& __err, tm* __t) const;
  1111.  
  1112.       virtual iter_type
  1113.       do_get_monthname(iter_type __s, iter_type __end, ios_base&,
  1114.                        ios_base::iostate& __err, tm* __t) const;
  1115.  
  1116.       virtual iter_type
  1117.       do_get_year(iter_type __s, iter_type /*__end*/, ios_base&,
  1118.                    ios_base::iostate& /*__err*/, tm* /*__t*/) const
  1119.       { return __s; }
  1120.  
  1121.       mutable basic_string<_CharT>* _M_daynames;
  1122.       mutable basic_string<_CharT>* _M_monthnames;
  1123.     };
  1124.  
  1125.   template<typename _CharT, typename _InIter>
  1126.     locale::id time_get<_CharT, _InIter>::id;
  1127.  
  1128.   template<typename _CharT, typename _InIter>
  1129.     class time_get_byname : public time_get<_CharT, _InIter>
  1130.     {
  1131.     public:
  1132.       typedef _CharT     char_type;
  1133.       typedef _InIter    iter_type;
  1134.  
  1135.       explicit
  1136.       time_get_byname(const char*, size_t __refs = 0)
  1137.       : time_get<_CharT, _InIter>(__refs) { }
  1138.     protected:
  1139.       virtual
  1140.       ~time_get_byname() { }
  1141.     };
  1142.  
  1143.   template<typename _CharT, typename _OutIter>
  1144.     class time_put : public locale::facet, public time_base
  1145.     {
  1146.     public:
  1147.       typedef _CharT     char_type;
  1148.       typedef _OutIter   iter_type;
  1149.  
  1150.       static locale::id id;
  1151.  
  1152.       explicit
  1153.       time_put(size_t __refs = 0) : locale::facet (__refs) { }
  1154.  
  1155.       // NB: this is a nonvirtual, calls do_put in a loop.
  1156.       iter_type
  1157.       put(iter_type __s, ios_base& /*__f*/, char_type /*__fill*/,
  1158.           const tm* /*__tmb*/, const _CharT* /*__pattern*/,
  1159.           const _CharT* /*__pat_end*/) const
  1160.       { return __s; }
  1161.  
  1162.       iter_type
  1163.       put(iter_type __s, ios_base& __f, char_type __fill,
  1164.           const tm* __tmb, char __format, char __modifier = 0) const
  1165.       { return do_put(__s, __f, __fill, __tmb, __format, __modifier); }
  1166.  
  1167.     protected:
  1168.       virtual
  1169.       ~time_put() { }
  1170.  
  1171.       virtual iter_type
  1172.       do_put(iter_type __s, ios_base&, char_type, const tm* /*__t*/,
  1173.              char /*__format*/, char /*__mod*/) const
  1174.       { return __s; }
  1175.     };
  1176.  
  1177.   template<typename _CharT, typename _OutIter>
  1178.     locale::id time_put<_CharT, _OutIter>::id;
  1179.  
  1180.   template<typename _CharT, typename _OutIter>
  1181.     class time_put_byname : public time_put<_CharT, _OutIter>
  1182.     {
  1183.     public:
  1184.       typedef _CharT     char_type;
  1185.       typedef _OutIter   iter_type;
  1186.  
  1187.       explicit
  1188.       time_put_byname(const char*, size_t __refs = 0)
  1189.       : time_put<_CharT, _OutIter> (__refs) { }
  1190.  
  1191.     protected:
  1192.       virtual
  1193.       ~time_put_byname() { }
  1194.     };
  1195.  
  1196.  
  1197.   template<typename _CharT, typename _InIter>
  1198.     class money_get : public locale::facet
  1199.     {
  1200.     public:
  1201.       typedef _CharT        char_type;
  1202.       typedef _InIter       iter_type;
  1203.       typedef basic_string<_CharT> string_type;
  1204.  
  1205.       static locale::id id;
  1206.  
  1207.       explicit
  1208.       money_get(size_t __refs = 0) : locale::facet(__refs) { }
  1209.  
  1210.       iter_type
  1211.       get(iter_type __s, iter_type __end, bool __intl,
  1212.           ios_base& __f, ios_base::iostate& __err, long double& __units) const
  1213.       { return do_get(__s, __end, __intl, __f, __err, __units); }
  1214.  
  1215.       iter_type
  1216.       get(iter_type __s, iter_type __end, bool __intl, ios_base& __f,
  1217.            ios_base::iostate& __err, string_type& __digits) const
  1218.       { return do_get(__s, __end, __intl, __f, __err, __digits); }
  1219.  
  1220.     protected:
  1221.       virtual
  1222.       ~money_get() { }
  1223.  
  1224.       virtual iter_type
  1225.       do_get(iter_type __s, iter_type /*__end*/, bool /*__intl*/,
  1226.              ios_base& /*__io*/, ios_base::iostate& /*__err*/,
  1227.              long double& /*__units*/) const
  1228.       { return __s; }
  1229.  
  1230.       virtual iter_type
  1231.       do_get(iter_type __s, iter_type /*__end*/, bool /*__intl*/,
  1232.              ios_base& /*__io*/, ios_base::iostate& /*__err*/,
  1233.              string_type& /*__digits*/) const
  1234.       { return __s; }
  1235.     };
  1236.  
  1237.   template<typename _CharT, typename _InIter>
  1238.     locale::id money_get<_CharT, _InIter>::id;
  1239.  
  1240.   template<typename _CharT, typename _OutIter>
  1241.     class money_put : public locale::facet
  1242.     {
  1243.     public:
  1244.       typedef _CharT              char_type;
  1245.       typedef _OutIter            iter_type;
  1246.       typedef basic_string<_CharT> string_type;
  1247.  
  1248.       static locale::id id;
  1249.  
  1250.       explicit
  1251.       money_put(size_t __refs = 0) : locale::facet(__refs) { }
  1252.  
  1253.       iter_type
  1254.       put(iter_type __s, bool __intl, ios_base& __f,
  1255.           char_type __fill, long double __units) const
  1256.       { return do_put(__s, __intl, __f, __fill, __units); }
  1257.  
  1258.       iter_type
  1259.       put(iter_type __s, bool __intl, ios_base& __f,
  1260.           char_type __fill, const string_type& __digits) const
  1261.       { return do_put(__s, __intl, __f, __fill, __digits); }
  1262.  
  1263.     protected:
  1264.       virtual
  1265.       ~money_put() { }
  1266.  
  1267.       virtual iter_type
  1268.       do_put(iter_type __s, bool, ios_base& /*__io*/, char_type /*__fill*/,
  1269.              long double /*__units*/) const
  1270.       { return __s; }
  1271.  
  1272.       virtual iter_type
  1273.       do_put(iter_type __s, bool, ios_base& /*__io*/, char_type /*__fill*/,
  1274.              const string_type& /*__digits*/) const
  1275.       { return __s; }
  1276.     };
  1277.  
  1278.   template<typename _CharT, typename _OutIter>
  1279.     locale::id money_put<_CharT, _OutIter>::id;
  1280.  
  1281.   struct money_base
  1282.   {
  1283.     enum part { none, space, symbol, sign, value };
  1284.     struct pattern { char field[4]; };
  1285.  
  1286.     static const pattern _S_default_pattern;
  1287.  
  1288.     // Construct and return valid pattern consisting of some combination of:
  1289.     // space none symbol sign value
  1290.     static pattern
  1291.     _S_construct_pattern(char __preceeds, char __space, char __posn);
  1292.   };
  1293.  
  1294.   template<typename _CharT, bool _Intl>
  1295.     class moneypunct : public locale::facet, public money_base
  1296.     {
  1297.     public:
  1298.       // Types:
  1299.       typedef _CharT                    char_type;
  1300.       typedef basic_string<_CharT>      string_type;
  1301.  
  1302.       static const bool intl = _Intl;
  1303.       static locale::id id;
  1304.  
  1305.     private:
  1306.       char_type         _M_decimal_point;
  1307.       char_type         _M_thousands_sep;
  1308.       string            _M_grouping;
  1309.       string_type       _M_curr_symbol;
  1310.       string_type       _M_positive_sign;
  1311.       string_type       _M_negative_sign;
  1312.       int               _M_frac_digits;
  1313.       pattern           _M_pos_format;
  1314.       pattern           _M_neg_format;
  1315.  
  1316.     public:
  1317.       explicit
  1318.       moneypunct(size_t __refs = 0) : locale::facet(__refs)
  1319.       { _M_initialize_moneypunct(); }
  1320.  
  1321.       explicit
  1322.       moneypunct(__c_locale __cloc, size_t __refs = 0) : locale::facet(__refs)
  1323.       { _M_initialize_moneypunct(__cloc); }
  1324.  
  1325.       char_type
  1326.       decimal_point() const
  1327.       { return this->do_decimal_point(); }
  1328.      
  1329.       char_type
  1330.       thousands_sep() const
  1331.       { return this->do_thousands_sep(); }
  1332.      
  1333.       string
  1334.       grouping() const
  1335.       { return this->do_grouping(); }
  1336.  
  1337.       string_type  
  1338.       curr_symbol() const
  1339.       { return this->do_curr_symbol(); }
  1340.  
  1341.       string_type  
  1342.       positive_sign() const
  1343.       { return this->do_positive_sign(); }
  1344.  
  1345.       string_type  
  1346.       negative_sign() const
  1347.       { return this->do_negative_sign(); }
  1348.  
  1349.       int          
  1350.       frac_digits() const
  1351.       { return this->do_frac_digits(); }
  1352.  
  1353.       pattern      
  1354.       pos_format() const
  1355.       { return this->do_pos_format(); }
  1356.  
  1357.       pattern      
  1358.       neg_format() const
  1359.       { return this->do_neg_format(); }
  1360.  
  1361.     protected:
  1362.       virtual
  1363.       ~moneypunct() { }
  1364.  
  1365.       virtual char_type
  1366.       do_decimal_point() const
  1367.       { return _M_decimal_point; }
  1368.      
  1369.       virtual char_type
  1370.       do_thousands_sep() const
  1371.       { return _M_thousands_sep; }
  1372.      
  1373.       virtual string
  1374.       do_grouping() const
  1375.       { return _M_grouping; }
  1376.  
  1377.       virtual string_type  
  1378.       do_curr_symbol()   const
  1379.       { return _M_curr_symbol; }
  1380.  
  1381.       virtual string_type  
  1382.       do_positive_sign() const
  1383.       { return _M_positive_sign; }
  1384.  
  1385.       virtual string_type  
  1386.       do_negative_sign() const
  1387.       { return _M_negative_sign; }
  1388.  
  1389.       virtual int          
  1390.       do_frac_digits() const
  1391.       { return _M_frac_digits; }
  1392.  
  1393.       virtual pattern      
  1394.       do_pos_format() const
  1395.       { return _M_pos_format; }
  1396.  
  1397.       virtual pattern      
  1398.       do_neg_format() const
  1399.       { return _M_neg_format; }
  1400.  
  1401.       // For use at construction time only.
  1402.       void
  1403.       _M_initialize_moneypunct(__c_locale __cloc = NULL);
  1404.     };
  1405.  
  1406.   template<typename _CharT, bool _Intl>
  1407.     locale::id moneypunct<_CharT, _Intl>::id;
  1408.  
  1409.   template<typename _CharT, bool _Intl>
  1410.     const bool moneypunct<_CharT, _Intl>::intl;
  1411.  
  1412.   template<typename _CharT, bool _Intl>
  1413.     void
  1414.     moneypunct<_CharT, _Intl>::_M_initialize_moneypunct(__c_locale /*__cloc*/)
  1415.     {
  1416.       // NB: Cannot be made generic.
  1417.     }
  1418.  
  1419.   template<>
  1420.     void
  1421.     moneypunct<char>::_M_initialize_moneypunct(__c_locale __cloc);
  1422. #ifdef _GLIBCPP_USE_WCHAR_T
  1423.   template<>
  1424.     void
  1425.     moneypunct<wchar_t>::_M_initialize_moneypunct(__c_locale __cloc);
  1426. #endif
  1427.  
  1428.   template<typename _CharT, bool _Intl>
  1429.     class moneypunct_byname : public moneypunct<_CharT, _Intl>
  1430.     {
  1431.       __c_locale                        _M_c_locale_moneypunct;
  1432.     public:
  1433.       typedef _CharT                    char_type;
  1434.       typedef basic_string<_CharT>      string_type;
  1435.  
  1436.       static const bool intl = _Intl;
  1437.  
  1438.       explicit
  1439.       moneypunct_byname(const char* __s, size_t __refs = 0)
  1440.       : moneypunct<_CharT, _Intl>(__refs)
  1441.       {
  1442.         _S_create_c_locale(_M_c_locale_moneypunct, __s);
  1443.         _M_initialize_moneypunct(_M_c_locale_moneypunct);      
  1444.       }
  1445.  
  1446.     protected:
  1447.       virtual
  1448.       ~moneypunct_byname()
  1449.       { _S_destroy_c_locale(_M_c_locale_moneypunct); }
  1450.     };
  1451.  
  1452.   template<typename _CharT, bool _Intl>
  1453.     const bool moneypunct_byname<_CharT, _Intl>::intl;
  1454.  
  1455.  
  1456.   struct messages_base
  1457.   {
  1458.     typedef int catalog;
  1459.   };
  1460.  
  1461.   template<typename _CharT>
  1462.     class messages : public locale::facet, public messages_base
  1463.     {
  1464.     public:
  1465.       typedef _CharT                    char_type;
  1466.       typedef basic_string<_CharT>      string_type;
  1467.  
  1468.       static locale::id id;
  1469.  
  1470.       explicit
  1471.       messages(size_t __refs = 0) : locale::facet(__refs) { }
  1472.  
  1473.       catalog
  1474.       open(const basic_string<char>& __s, const locale& __loc) const
  1475.       { return do_open(__s, __loc); }
  1476.  
  1477.       string_type  
  1478.       get(catalog __c, int __set, int __msgid, const string_type& __s) const
  1479.       { return do_get(__c,__set,__msgid,__s); }
  1480.  
  1481.       void
  1482.       close(catalog __c) const
  1483.       { return do_close(__c); }
  1484.  
  1485.     protected:
  1486.       virtual
  1487.       ~messages() { }
  1488.  
  1489.       // NB: Probably these should be pure, and implemented only in
  1490.       //  specializations of messages<>.  But for now...
  1491.       virtual catalog
  1492.       do_open(const basic_string<char>&, const locale&) const
  1493.       { return 0; }
  1494.  
  1495.       virtual string_type  
  1496.       do_get(catalog, int, int /*__msgid*/, const string_type& __dfault) const
  1497.       { return __dfault; }
  1498.  
  1499.       virtual void    
  1500.       do_close(catalog) const { }
  1501.     };
  1502.  
  1503.   template<typename _CharT>
  1504.     locale::id messages<_CharT>::id;
  1505.  
  1506.   template<typename _CharT>
  1507.     class messages_byname : public messages<_CharT>
  1508.     {
  1509.     public:
  1510.       typedef _CharT char_type;
  1511.       typedef basic_string<_CharT> string_type;
  1512.  
  1513.       explicit
  1514.       messages_byname(const char*, size_t __refs = 0);
  1515.  
  1516.     protected:
  1517.       virtual
  1518.       ~messages_byname() { }
  1519.     };
  1520.  
  1521.   template<>
  1522.     messages_byname<char>::messages_byname(const char*, size_t __refs);
  1523. #ifdef _GLIBCPP_USE_WCHAR_T
  1524.   template<>
  1525.     messages_byname<wchar_t>::messages_byname(const char*, size_t __refs);
  1526. #endif
  1527.  
  1528.   // Subclause convenience interfaces, inlines
  1529.   // NB: these are inline
  1530.   // because, when used in a loop, some compilers can hoist the body
  1531.   // out of the loop; then it's just as fast as the C is*() function.
  1532.   template<typename _CharT>
  1533.     inline bool
  1534.     isspace(_CharT __c, const locale& __loc)
  1535.     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c); }
  1536.  
  1537.   template<typename _CharT>
  1538.     inline bool
  1539.     isprint(_CharT __c, const locale& __loc)
  1540.     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c); }
  1541.  
  1542.   template<typename _CharT>
  1543.     inline bool
  1544.     iscntrl(_CharT __c, const locale& __loc)
  1545.     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c); }
  1546.  
  1547.   template<typename _CharT>
  1548.     inline bool
  1549.     isupper(_CharT __c, const locale& __loc)
  1550.     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c); }
  1551.  
  1552.   template<typename _CharT>
  1553.     inline bool islower(_CharT __c, const locale& __loc)
  1554.     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c); }
  1555.  
  1556.   template<typename _CharT>
  1557.     inline bool
  1558.     isalpha(_CharT __c, const locale& __loc)
  1559.     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c); }
  1560.  
  1561.   template<typename _CharT>
  1562.     inline bool
  1563.     isdigit(_CharT __c, const locale& __loc)
  1564.     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c); }
  1565.  
  1566.   template<typename _CharT>
  1567.     inline bool
  1568.     ispunct(_CharT __c, const locale& __loc)
  1569.     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c); }
  1570.  
  1571.   template<typename _CharT>
  1572.     inline bool
  1573.     isxdigit(_CharT __c, const locale& __loc)
  1574.     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c); }
  1575.  
  1576.   template<typename _CharT>
  1577.     inline bool
  1578.     isalnum(_CharT __c, const locale& __loc)
  1579.     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c); }
  1580.  
  1581.   template<typename _CharT>
  1582.     inline bool
  1583.     isgraph(_CharT __c, const locale& __loc)
  1584.     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c); }
  1585.  
  1586.   template<typename _CharT>
  1587.     inline _CharT
  1588.     toupper(_CharT __c, const locale& __loc)
  1589.     { return use_facet<ctype<_CharT> >(__loc).toupper(__c); }
  1590.  
  1591.   template<typename _CharT>
  1592.     inline _CharT
  1593.     tolower(_CharT __c, const locale& __loc)
  1594.     { return use_facet<ctype<_CharT> >(__loc).tolower(__c); }
  1595. } // namespace std
  1596.  
  1597. #endif  /* _CPP_BITS_LOCFACETS_H */
  1598.  
  1599. // Local Variables:
  1600. // mode:c++
  1601. // End:
  1602.