# locale_facets.h

Go to the documentation of this file.

    00001 // Locale support -*- C++ -*-
    00002
    00003 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    00004 // 2006, 2007
    00005 // Free Software Foundation, Inc.
    00006 //
    00007 // This file is part of the GNU ISO C++ Library.  This library is free
    00008 // software; you can redistribute it and/or modify it under the
    00009 // terms of the GNU General Public License as published by the
    00010 // Free Software Foundation; either version 2, or (at your option)
    00011 // any later version.
    00012
    00013 // This library is distributed in the hope that it will be useful,
    00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00016 // GNU General Public License for more details.
    00017
    00018 // You should have received a copy of the GNU General Public License along
    00019 // with this library; see the file COPYING.  If not, write to the Free
    00020 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
    00021 // USA.
    00022
    00023 // As a special exception, you may use this file as part of a free software
    00024 // library without restriction.  Specifically, if other files instantiate
    00025 // templates or use macros or inline functions from this file, or you compile
    00026 // this file and link it with other files to produce an executable, this
    00027 // file does not by itself cause the resulting executable to be covered by
    00028 // the GNU General Public License.  This exception does not however
    00029 // invalidate any other reasons why the executable file might be covered by
    00030 // the GNU General Public License.
    00031
    00032 /** @file locale_facets.h
    00033  *  This is an internal header file, included by other library headers.
    00034  *  You should not attempt to use it directly.
    00035  */
    00036
    00037 //
    00038 // ISO C++ 14882: 22.1  Locales
    00039 //
    00040
    00041 #ifndef _LOCALE_FACETS_H
    00042 #define _LOCALE_FACETS_H 1
    00043
    00044 #pragma GCC system_header
    00045
    00046 #include <cwctype>  // For wctype_t
    00047 #include <cctype>
    00048 #include <bits/ctype_base.h>
    00049 #include <iosfwd>
    00050 #include <bits/ios_base.h>  // For ios_base, ios_base::iostate
    00051 #include <streambuf>
    00052 #include <bits/cpp_type_traits.h>
    00053 #include <ext/type_traits.h>
    00054 #include <ext/numeric_traits.h>
    00055 #include <bits/streambuf_iterator.h>
    00056
    00057 _GLIBCXX_BEGIN_NAMESPACE(std)
    00058
    00059   // NB: Don't instantiate required wchar_t facets if no wchar_t support.
    00060 #ifdef _GLIBCXX_USE_WCHAR_T
    00061 # define  _GLIBCXX_NUM_FACETS 28
    00062 #else
    00063 # define  _GLIBCXX_NUM_FACETS 14
    00064 #endif
    00065
    00066   // Convert string to numeric value of type _Tv and store results.
    00067   // NB: This is specialized for all required types, there is no
    00068   // generic definition.
    00069   template<typename _Tv>
    00070     void
    00071     __convert_to_v(const char* __in, _Tv& __out, ios_base::iostate& __err,
    00072            const __c_locale& __cloc);
    00073
    00074   // Explicit specializations for required types.
    00075   template<>
    00076     void
    00077     __convert_to_v(const char*, float&, ios_base::iostate&,
    00078            const __c_locale&);
    00079
    00080   template<>
    00081     void
    00082     __convert_to_v(const char*, double&, ios_base::iostate&,
    00083            const __c_locale&);
    00084
    00085   template<>
    00086     void
    00087     __convert_to_v(const char*, long double&, ios_base::iostate&,
    00088            const __c_locale&);
    00089
    00090   // NB: __pad is a struct, rather than a function, so it can be
    00091   // partially-specialized.
    00092   template<typename _CharT, typename _Traits>
    00093     struct __pad
    00094     {
    00095       static void
    00096       _S_pad(ios_base& __io, _CharT __fill, _CharT* __news,
    00097          const _CharT* __olds, const streamsize __newlen,
    00098          const streamsize __oldlen);
    00099     };
    00100
    00101   // Used by both numeric and monetary facets.
    00102   // Inserts "group separator" characters into an array of characters.
    00103   // It's recursive, one iteration per group.  It moves the characters
    00104   // in the buffer this way: "xxxx12345" -> "12,345xxx".  Call this
    00105   // only with __gsize != 0.
    00106   template<typename _CharT>
    00107     _CharT*
    00108     __add_grouping(_CharT* __s, _CharT __sep,
    00109            const char* __gbeg, size_t __gsize,
    00110            const _CharT* __first, const _CharT* __last);
    00111
    00112   // This template permits specializing facet output code for
    00113   // ostreambuf_iterator.  For ostreambuf_iterator, sputn is
    00114   // significantly more efficient than incrementing iterators.
    00115   template<typename _CharT>
    00116     inline
    00117     ostreambuf_iterator<_CharT>
    00118     __write(ostreambuf_iterator<_CharT> __s, const _CharT* __ws, int __len)
    00119     {
    00120       __s._M_put(__ws, __len);
    00121       return __s;
    00122     }
    00123
    00124   // This is the unspecialized form of the template.
    00125   template<typename _CharT, typename _OutIter>
    00126     inline
    00127     _OutIter
    00128     __write(_OutIter __s, const _CharT* __ws, int __len)
    00129     {
    00130       for (int __j = 0; __j < __len; __j++, ++__s)
    00131     *__s = __ws[__j];
    00132       return __s;
    00133     }
    00134
    00135
    00136   // 22.2.1.1  Template class ctype
    00137   // Include host and configuration specific ctype enums for ctype_base.
    00138
    00139   // Common base for ctype<_CharT>.
    00140   /**
    00141    *  @brief  Common base for ctype facet
    00142    *
    00143    *  This template class provides implementations of the public functions
    00144    *  that forward to the protected virtual functions.
    00145    *
    00146    *  This template also provides abstract stubs for the protected virtual
    00147    *  functions.
    00148   */
    00149   template<typename _CharT>
    00150     class __ctype_abstract_base : public locale::facet, public ctype_base
    00151     {
    00152     public:
    00153       // Types:
    00154       /// Typedef for the template parameter
    00155       typedef _CharT char_type;
    00156
    00157       /**
    00158        *  @brief  Test char_type classification.
    00159        *
    00160        *  This function finds a mask M for @a c and compares it to mask @a m.
    00161        *  It does so by returning the value of ctype<char_type>::do_is().
    00162        *
    00163        *  @param c  The char_type to compare the mask of.
    00164        *  @param m  The mask to compare against.
    00165        *  @return  (M & m) != 0.
    00166       */
    00167       bool
    00168       is(mask __m, char_type __c) const
    00169       { return this->do_is(__m, __c); }
    00170
    00171       /**
    00172        *  @brief  Return a mask array.
    00173        *
    00174        *  This function finds the mask for each char_type in the range [lo,hi)
    00175        *  and successively writes it to vec.  vec must have as many elements
    00176        *  as the char array.  It does so by returning the value of
    00177        *  ctype<char_type>::do_is().
    00178        *
    00179        *  @param lo  Pointer to start of range.
    00180        *  @param hi  Pointer to end of range.
    00181        *  @param vec  Pointer to an array of mask storage.
    00182        *  @return  @a hi.
    00183       */
    00184       const char_type*
    00185       is(const char_type *__lo, const char_type *__hi, mask *__vec) const
    00186       { return this->do_is(__lo, __hi, __vec); }
    00187
    00188       /**
    00189        *  @brief  Find char_type matching a mask
    00190        *
    00191        *  This function searches for and returns the first char_type c in
    00192        *  [lo,hi) for which is(m,c) is true.  It does so by returning
    00193        *  ctype<char_type>::do_scan_is().
    00194        *
    00195        *  @param m  The mask to compare against.
    00196        *  @param lo  Pointer to start of range.
    00197        *  @param hi  Pointer to end of range.
    00198        *  @return  Pointer to matching char_type if found, else @a hi.
    00199       */
    00200       const char_type*
    00201       scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
    00202       { return this->do_scan_is(__m, __lo, __hi); }
    00203
    00204       /**
    00205        *  @brief  Find char_type not matching a mask
    00206        *
    00207        *  This function searches for and returns the first char_type c in
    00208        *  [lo,hi) for which is(m,c) is false.  It does so by returning
    00209        *  ctype<char_type>::do_scan_not().
    00210        *
    00211        *  @param m  The mask to compare against.
    00212        *  @param lo  Pointer to first char in range.
    00213        *  @param hi  Pointer to end of range.
    00214        *  @return  Pointer to non-matching char if found, else @a hi.
    00215       */
    00216       const char_type*
    00217       scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
    00218       { return this->do_scan_not(__m, __lo, __hi); }
    00219
    00220       /**
    00221        *  @brief  Convert to uppercase.
    00222        *
    00223        *  This function converts the argument to uppercase if possible.
    00224        *  If not possible (for example, '2'), returns the argument.  It does
    00225        *  so by returning ctype<char_type>::do_toupper().
    00226        *
    00227        *  @param c  The char_type to convert.
    00228        *  @return  The uppercase char_type if convertible, else @a c.
    00229       */
    00230       char_type
    00231       toupper(char_type __c) const
    00232       { return this->do_toupper(__c); }
    00233
    00234       /**
    00235        *  @brief  Convert array to uppercase.
    00236        *
    00237        *  This function converts each char_type in the range [lo,hi) to
    00238        *  uppercase if possible.  Other elements remain untouched.  It does so
    00239        *  by returning ctype<char_type>:: do_toupper(lo, hi).
    00240        *
    00241        *  @param lo  Pointer to start of range.
    00242        *  @param hi  Pointer to end of range.
    00243        *  @return  @a hi.
    00244       */
    00245       const char_type*
    00246       toupper(char_type *__lo, const char_type* __hi) const
    00247       { return this->do_toupper(__lo, __hi); }
    00248
    00249       /**
    00250        *  @brief  Convert to lowercase.
    00251        *
    00252        *  This function converts the argument to lowercase if possible.  If
    00253        *  not possible (for example, '2'), returns the argument.  It does so
    00254        *  by returning ctype<char_type>::do_tolower(c).
    00255        *
    00256        *  @param c  The char_type to convert.
    00257        *  @return  The lowercase char_type if convertible, else @a c.
    00258       */
    00259       char_type
    00260       tolower(char_type __c) const
    00261       { return this->do_tolower(__c); }
    00262
    00263       /**
    00264        *  @brief  Convert array to lowercase.
    00265        *
    00266        *  This function converts each char_type in the range [lo,hi) to
    00267        *  lowercase if possible.  Other elements remain untouched.  It does so
    00268        *  by returning ctype<char_type>:: do_tolower(lo, hi).
    00269        *
    00270        *  @param lo  Pointer to start of range.
    00271        *  @param hi  Pointer to end of range.
    00272        *  @return  @a hi.
    00273       */
    00274       const char_type*
    00275       tolower(char_type* __lo, const char_type* __hi) const
    00276       { return this->do_tolower(__lo, __hi); }
    00277
    00278       /**
    00279        *  @brief  Widen char to char_type
    00280        *
    00281        *  This function converts the char argument to char_type using the
    00282        *  simplest reasonable transformation.  It does so by returning
    00283        *  ctype<char_type>::do_widen(c).
    00284        *
    00285        *  Note: this is not what you want for codepage conversions.  See
    00286        *  codecvt for that.
    00287        *
    00288        *  @param c  The char to convert.
    00289        *  @return  The converted char_type.
    00290       */
    00291       char_type
    00292       widen(char __c) const
    00293       { return this->do_widen(__c); }
    00294
    00295       /**
    00296        *  @brief  Widen array to char_type
    00297        *
    00298        *  This function converts each char in the input to char_type using the
    00299        *  simplest reasonable transformation.  It does so by returning
    00300        *  ctype<char_type>::do_widen(c).
    00301        *
    00302        *  Note: this is not what you want for codepage conversions.  See
    00303        *  codecvt for that.
    00304        *
    00305        *  @param lo  Pointer to start of range.
    00306        *  @param hi  Pointer to end of range.
    00307        *  @param to  Pointer to the destination array.
    00308        *  @return  @a hi.
    00309       */
    00310       const char*
    00311       widen(const char* __lo, const char* __hi, char_type* __to) const
    00312       { return this->do_widen(__lo, __hi, __to); }
    00313
    00314       /**
    00315        *  @brief  Narrow char_type to char
    00316        *
    00317        *  This function converts the char_type to char using the simplest
    00318        *  reasonable transformation.  If the conversion fails, dfault is
    00319        *  returned instead.  It does so by returning
    00320        *  ctype<char_type>::do_narrow(c).
    00321        *
    00322        *  Note: this is not what you want for codepage conversions.  See
    00323        *  codecvt for that.
    00324        *
    00325        *  @param c  The char_type to convert.
    00326        *  @param dfault  Char to return if conversion fails.
    00327        *  @return  The converted char.
    00328       */
    00329       char
    00330       narrow(char_type __c, char __dfault) const
    00331       { return this->do_narrow(__c, __dfault); }
    00332
    00333       /**
    00334        *  @brief  Narrow array to char array
    00335        *
    00336        *  This function converts each char_type in the input to char using the
    00337        *  simplest reasonable transformation and writes the results to the
    00338        *  destination array.  For any char_type in the input that cannot be
    00339        *  converted, @a dfault is used instead.  It does so by returning
    00340        *  ctype<char_type>::do_narrow(lo, hi, dfault, to).
    00341        *
    00342        *  Note: this is not what you want for codepage conversions.  See
    00343        *  codecvt for that.
    00344        *
    00345        *  @param lo  Pointer to start of range.
    00346        *  @param hi  Pointer to end of range.
    00347        *  @param dfault  Char to use if conversion fails.
    00348        *  @param to  Pointer to the destination array.
    00349        *  @return  @a hi.
    00350       */
    00351       const char_type*
    00352       narrow(const char_type* __lo, const char_type* __hi,
    00353           char __dfault, char *__to) const
    00354       { return this->do_narrow(__lo, __hi, __dfault, __to); }
    00355
    00356     protected:
    00357       explicit
    00358       __ctype_abstract_base(size_t __refs = 0): facet(__refs) { }
    00359
    00360       virtual
    00361       ~__ctype_abstract_base() { }
    00362
    00363       /**
    00364        *  @brief  Test char_type classification.
    00365        *
    00366        *  This function finds a mask M for @a c and compares it to mask @a m.
    00367        *
    00368        *  do_is() is a hook for a derived facet to change the behavior of
    00369        *  classifying.  do_is() must always return the same result for the
    00370        *  same input.
    00371        *
    00372        *  @param c  The char_type to find the mask of.
    00373        *  @param m  The mask to compare against.
    00374        *  @return  (M & m) != 0.
    00375       */
    00376       virtual bool
    00377       do_is(mask __m, char_type __c) const = 0;
    00378
    00379       /**
    00380        *  @brief  Return a mask array.
    00381        *
    00382        *  This function finds the mask for each char_type in the range [lo,hi)
    00383        *  and successively writes it to vec.  vec must have as many elements
    00384        *  as the input.
    00385        *
    00386        *  do_is() is a hook for a derived facet to change the behavior of
    00387        *  classifying.  do_is() must always return the same result for the
    00388        *  same input.
    00389        *
    00390        *  @param lo  Pointer to start of range.
    00391        *  @param hi  Pointer to end of range.
    00392        *  @param vec  Pointer to an array of mask storage.
    00393        *  @return  @a hi.
    00394       */
    00395       virtual const char_type*
    00396       do_is(const char_type* __lo, const char_type* __hi,
    00397         mask* __vec) const = 0;
    00398
    00399       /**
    00400        *  @brief  Find char_type matching mask
    00401        *
    00402        *  This function searches for and returns the first char_type c in
    00403        *  [lo,hi) for which is(m,c) is true.
    00404        *
    00405        *  do_scan_is() is a hook for a derived facet to change the behavior of
    00406        *  match searching.  do_is() must always return the same result for the
    00407        *  same input.
    00408        *
    00409        *  @param m  The mask to compare against.
    00410        *  @param lo  Pointer to start of range.
    00411        *  @param hi  Pointer to end of range.
    00412        *  @return  Pointer to a matching char_type if found, else @a hi.
    00413       */
    00414       virtual const char_type*
    00415       do_scan_is(mask __m, const char_type* __lo,
    00416          const char_type* __hi) const = 0;
    00417
    00418       /**
    00419        *  @brief  Find char_type not matching mask
    00420        *
    00421        *  This function searches for and returns a pointer to the first
    00422        *  char_type c of [lo,hi) for which is(m,c) is false.
    00423        *
    00424        *  do_scan_is() is a hook for a derived facet to change the behavior of
    00425        *  match searching.  do_is() must always return the same result for the
    00426        *  same input.
    00427        *
    00428        *  @param m  The mask to compare against.
    00429        *  @param lo  Pointer to start of range.
    00430        *  @param hi  Pointer to end of range.
    00431        *  @return  Pointer to a non-matching char_type if found, else @a hi.
    00432       */
    00433       virtual const char_type*
    00434       do_scan_not(mask __m, const char_type* __lo,
    00435           const char_type* __hi) const = 0;
    00436
    00437       /**
    00438        *  @brief  Convert to uppercase.
    00439        *
    00440        *  This virtual function converts the char_type argument to uppercase
    00441        *  if possible.  If not possible (for example, '2'), returns the
    00442        *  argument.
    00443        *
    00444        *  do_toupper() is a hook for a derived facet to change the behavior of
    00445        *  uppercasing.  do_toupper() must always return the same result for
    00446        *  the same input.
    00447        *
    00448        *  @param c  The char_type to convert.
    00449        *  @return  The uppercase char_type if convertible, else @a c.
    00450       */
    00451       virtual char_type
    00452       do_toupper(char_type) const = 0;
    00453
    00454       /**
    00455        *  @brief  Convert array to uppercase.
    00456        *
    00457        *  This virtual function converts each char_type in the range [lo,hi)
    00458        *  to uppercase if possible.  Other elements remain untouched.
    00459        *
    00460        *  do_toupper() is a hook for a derived facet to change the behavior of
    00461        *  uppercasing.  do_toupper() must always return the same result for
    00462        *  the same input.
    00463        *
    00464        *  @param lo  Pointer to start of range.
    00465        *  @param hi  Pointer to end of range.
    00466        *  @return  @a hi.
    00467       */
    00468       virtual const char_type*
    00469       do_toupper(char_type* __lo, const char_type* __hi) const = 0;
    00470
    00471       /**
    00472        *  @brief  Convert to lowercase.
    00473        *
    00474        *  This virtual function converts the argument to lowercase if
    00475        *  possible.  If not possible (for example, '2'), returns the argument.
    00476        *
    00477        *  do_tolower() is a hook for a derived facet to change the behavior of
    00478        *  lowercasing.  do_tolower() must always return the same result for
    00479        *  the same input.
    00480        *
    00481        *  @param c  The char_type to convert.
    00482        *  @return  The lowercase char_type if convertible, else @a c.
    00483       */
    00484       virtual char_type
    00485       do_tolower(char_type) const = 0;
    00486
    00487       /**
    00488        *  @brief  Convert array to lowercase.
    00489        *
    00490        *  This virtual function converts each char_type in the range [lo,hi)
    00491        *  to lowercase if possible.  Other elements remain untouched.
    00492        *
    00493        *  do_tolower() is a hook for a derived facet to change the behavior of
    00494        *  lowercasing.  do_tolower() must always return the same result for
    00495        *  the same input.
    00496        *
    00497        *  @param lo  Pointer to start of range.
    00498        *  @param hi  Pointer to end of range.
    00499        *  @return  @a hi.
    00500       */
    00501       virtual const char_type*
    00502       do_tolower(char_type* __lo, const char_type* __hi) const = 0;
    00503
    00504       /**
    00505        *  @brief  Widen char
    00506        *
    00507        *  This virtual function converts the char to char_type using the
    00508        *  simplest reasonable transformation.
    00509        *
    00510        *  do_widen() is a hook for a derived facet to change the behavior of
    00511        *  widening.  do_widen() must always return the same result for the
    00512        *  same input.
    00513        *
    00514        *  Note: this is not what you want for codepage conversions.  See
    00515        *  codecvt for that.
    00516        *
    00517        *  @param c  The char to convert.
    00518        *  @return  The converted char_type
    00519       */
    00520       virtual char_type
    00521       do_widen(char) const = 0;
    00522
    00523       /**
    00524        *  @brief  Widen char array
    00525        *
    00526        *  This function converts each char in the input to char_type using the
    00527        *  simplest reasonable transformation.
    00528        *
    00529        *  do_widen() is a hook for a derived facet to change the behavior of
    00530        *  widening.  do_widen() must always return the same result for the
    00531        *  same input.
    00532        *
    00533        *  Note: this is not what you want for codepage conversions.  See
    00534        *  codecvt for that.
    00535        *
    00536        *  @param lo  Pointer to start range.
    00537        *  @param hi  Pointer to end of range.
    00538        *  @param to  Pointer to the destination array.
    00539        *  @return  @a hi.
    00540       */
    00541       virtual const char*
    00542       do_widen(const char* __lo, const char* __hi,
    00543            char_type* __dest) const = 0;
    00544
    00545       /**
    00546        *  @brief  Narrow char_type to char
    00547        *
    00548        *  This virtual function converts the argument to char using the
    00549        *  simplest reasonable transformation.  If the conversion fails, dfault
    00550        *  is returned instead.
    00551        *
    00552        *  do_narrow() is a hook for a derived facet to change the behavior of
    00553        *  narrowing.  do_narrow() must always return the same result for the
    00554        *  same input.
    00555        *
    00556        *  Note: this is not what you want for codepage conversions.  See
    00557        *  codecvt for that.
    00558        *
    00559        *  @param c  The char_type to convert.
    00560        *  @param dfault  Char to return if conversion fails.
    00561        *  @return  The converted char.
    00562       */
    00563       virtual char
    00564       do_narrow(char_type, char __dfault) const = 0;
    00565
    00566       /**
    00567        *  @brief  Narrow char_type array to char
    00568        *
    00569        *  This virtual function converts each char_type in the range [lo,hi) to
    00570        *  char using the simplest reasonable transformation and writes the
    00571        *  results to the destination array.  For any element in the input that
    00572        *  cannot be converted, @a dfault is used instead.
    00573        *
    00574        *  do_narrow() is a hook for a derived facet to change the behavior of
    00575        *  narrowing.  do_narrow() must always return the same result for the
    00576        *  same input.
    00577        *
    00578        *  Note: this is not what you want for codepage conversions.  See
    00579        *  codecvt for that.
    00580        *
    00581        *  @param lo  Pointer to start of range.
    00582        *  @param hi  Pointer to end of range.
    00583        *  @param dfault  Char to use if conversion fails.
    00584        *  @param to  Pointer to the destination array.
    00585        *  @return  @a hi.
    00586       */
    00587       virtual const char_type*
    00588       do_narrow(const char_type* __lo, const char_type* __hi,
    00589         char __dfault, char* __dest) const = 0;
    00590     };
    00591
    00592   // NB: Generic, mostly useless implementation.
    00593   /**
    00594    *  @brief  Template ctype facet
    00595    *
    00596    *  This template class defines classification and conversion functions for
    00597    *  character sets.  It wraps <cctype> functionality.  Ctype gets used by
    00598    *  streams for many I/O operations.
    00599    *
    00600    *  This template provides the protected virtual functions the developer
    00601    *  will have to replace in a derived class or specialization to make a
    00602    *  working facet.  The public functions that access them are defined in
    00603    *  __ctype_abstract_base, to allow for implementation flexibility.  See
    00604    *  ctype<wchar_t> for an example.  The functions are documented in
    00605    *  __ctype_abstract_base.
    00606    *
    00607    *  Note: implementations are provided for all the protected virtual
    00608    *  functions, but will likely not be useful.
    00609   */
    00610   template<typename _CharT>
    00611     class ctype : public __ctype_abstract_base<_CharT>
    00612     {
    00613     public:
    00614       // Types:
    00615       typedef _CharT            char_type;
    00616       typedef typename __ctype_abstract_base<_CharT>::mask mask;
    00617
    00618       /// The facet id for ctype<char_type>
    00619       static locale::id         id;
    00620
    00621       explicit
    00622       ctype(size_t __refs = 0) : __ctype_abstract_base<_CharT>(__refs) { }
    00623
    00624    protected:
    00625       virtual
    00626       ~ctype();
    00627
    00628       virtual bool
    00629       do_is(mask __m, char_type __c) const;
    00630
    00631       virtual const char_type*
    00632       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
    00633
    00634       virtual const char_type*
    00635       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
    00636
    00637       virtual const char_type*
    00638       do_scan_not(mask __m, const char_type* __lo,
    00639           const char_type* __hi) const;
    00640
    00641       virtual char_type
    00642       do_toupper(char_type __c) const;
    00643
    00644       virtual const char_type*
    00645       do_toupper(char_type* __lo, const char_type* __hi) const;
    00646
    00647       virtual char_type
    00648       do_tolower(char_type __c) const;
    00649
    00650       virtual const char_type*
    00651       do_tolower(char_type* __lo, const char_type* __hi) const;
    00652
    00653       virtual char_type
    00654       do_widen(char __c) const;
    00655
    00656       virtual const char*
    00657       do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
    00658
    00659       virtual char
    00660       do_narrow(char_type, char __dfault) const;
    00661
    00662       virtual const char_type*
    00663       do_narrow(const char_type* __lo, const char_type* __hi,
    00664         char __dfault, char* __dest) const;
    00665     };
    00666
    00667   template<typename _CharT>
    00668     locale::id ctype<_CharT>::id;
    00669
    00670   // 22.2.1.3  ctype<char> specialization.
    00671   /**
    00672    *  @brief  The ctype<char> specialization.
    00673    *
    00674    *  This class defines classification and conversion functions for
    00675    *  the char type.  It gets used by char streams for many I/O
    00676    *  operations.  The char specialization provides a number of
    00677    *  optimizations as well.
    00678   */
    00679   template<>
    00680     class ctype<char> : public locale::facet, public ctype_base
    00681     {
    00682     public:
    00683       // Types:
    00684       /// Typedef for the template parameter char.
    00685       typedef char      char_type;
    00686
    00687     protected:
    00688       // Data Members:
    00689       __c_locale        _M_c_locale_ctype;
    00690       bool          _M_del;
    00691       __to_type         _M_toupper;
    00692       __to_type         _M_tolower;
    00693       const mask*       _M_table;
    00694       mutable char      _M_widen_ok;
    00695       mutable char      _M_widen[1 + static_cast<unsigned char>(-1)];
    00696       mutable char      _M_narrow[1 + static_cast<unsigned char>(-1)];
    00697       mutable char      _M_narrow_ok;   // 0 uninitialized, 1 init,
    00698                         // 2 memcpy can't be used
    00699
    00700     public:
    00701       /// The facet id for ctype<char>
    00702       static locale::id        id;
    00703       /// The size of the mask table.  It is SCHAR_MAX + 1.
    00704       static const size_t      table_size = 1 + static_cast<unsigned char>(-1);
    00705
    00706       /**
    00707        *  @brief  Constructor performs initialization.
    00708        *
    00709        *  This is the constructor provided by the standard.
    00710        *
    00711        *  @param table If non-zero, table is used as the per-char mask.
    00712        *               Else classic_table() is used.
    00713        *  @param del   If true, passes ownership of table to this facet.
    00714        *  @param refs  Passed to the base facet class.
    00715       */
    00716       explicit
    00717       ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0);
    00718
    00719       /**
    00720        *  @brief  Constructor performs static initialization.
    00721        *
    00722        *  This constructor is used to construct the initial C locale facet.
    00723        *
    00724        *  @param cloc  Handle to C locale data.
    00725        *  @param table If non-zero, table is used as the per-char mask.
    00726        *  @param del   If true, passes ownership of table to this facet.
    00727        *  @param refs  Passed to the base facet class.
    00728       */
    00729       explicit
    00730       ctype(__c_locale __cloc, const mask* __table = 0, bool __del = false,
    00731         size_t __refs = 0);
    00732
    00733       /**
    00734        *  @brief  Test char classification.
    00735        *
    00736        *  This function compares the mask table[c] to @a m.
    00737        *
    00738        *  @param c  The char to compare the mask of.
    00739        *  @param m  The mask to compare against.
    00740        *  @return  True if m & table[c] is true, false otherwise.
    00741       */
    00742       inline bool
    00743       is(mask __m, char __c) const;
    00744
    00745       /**
    00746        *  @brief  Return a mask array.
    00747        *
    00748        *  This function finds the mask for each char in the range [lo, hi) and
    00749        *  successively writes it to vec.  vec must have as many elements as
    00750        *  the char array.
    00751        *
    00752        *  @param lo  Pointer to start of range.
    00753        *  @param hi  Pointer to end of range.
    00754        *  @param vec  Pointer to an array of mask storage.
    00755        *  @return  @a hi.
    00756       */
    00757       inline const char*
    00758       is(const char* __lo, const char* __hi, mask* __vec) const;
    00759
    00760       /**
    00761        *  @brief  Find char matching a mask
    00762        *
    00763        *  This function searches for and returns the first char in [lo,hi) for
    00764        *  which is(m,char) is true.
    00765        *
    00766        *  @param m  The mask to compare against.
    00767        *  @param lo  Pointer to start of range.
    00768        *  @param hi  Pointer to end of range.
    00769        *  @return  Pointer to a matching char if found, else @a hi.
    00770       */
    00771       inline const char*
    00772       scan_is(mask __m, const char* __lo, const char* __hi) const;
    00773
    00774       /**
    00775        *  @brief  Find char not matching a mask
    00776        *
    00777        *  This function searches for and returns a pointer to the first char
    00778        *  in [lo,hi) for which is(m,char) is false.
    00779        *
    00780        *  @param m  The mask to compare against.
    00781        *  @param lo  Pointer to start of range.
    00782        *  @param hi  Pointer to end of range.
    00783        *  @return  Pointer to a non-matching char if found, else @a hi.
    00784       */
    00785       inline const char*
    00786       scan_not(mask __m, const char* __lo, const char* __hi) const;
    00787
    00788       /**
    00789        *  @brief  Convert to uppercase.
    00790        *
    00791        *  This function converts the char argument to uppercase if possible.
    00792        *  If not possible (for example, '2'), returns the argument.
    00793        *
    00794        *  toupper() acts as if it returns ctype<char>::do_toupper(c).
    00795        *  do_toupper() must always return the same result for the same input.
    00796        *
    00797        *  @param c  The char to convert.
    00798        *  @return  The uppercase char if convertible, else @a c.
    00799       */
    00800       char_type
    00801       toupper(char_type __c) const
    00802       { return this->do_toupper(__c); }
    00803
    00804       /**
    00805        *  @brief  Convert array to uppercase.
    00806        *
    00807        *  This function converts each char in the range [lo,hi) to uppercase
    00808        *  if possible.  Other chars remain untouched.
    00809        *
    00810        *  toupper() acts as if it returns ctype<char>:: do_toupper(lo, hi).
    00811        *  do_toupper() must always return the same result for the same input.
    00812        *
    00813        *  @param lo  Pointer to first char in range.
    00814        *  @param hi  Pointer to end of range.
    00815        *  @return  @a hi.
    00816       */
    00817       const char_type*
    00818       toupper(char_type *__lo, const char_type* __hi) const
    00819       { return this->do_toupper(__lo, __hi); }
    00820
    00821       /**
    00822        *  @brief  Convert to lowercase.
    00823        *
    00824        *  This function converts the char argument to lowercase if possible.
    00825        *  If not possible (for example, '2'), returns the argument.
    00826        *
    00827        *  tolower() acts as if it returns ctype<char>::do_tolower(c).
    00828        *  do_tolower() must always return the same result for the same input.
    00829        *
    00830        *  @param c  The char to convert.
    00831        *  @return  The lowercase char if convertible, else @a c.
    00832       */
    00833       char_type
    00834       tolower(char_type __c) const
    00835       { return this->do_tolower(__c); }
    00836
    00837       /**
    00838        *  @brief  Convert array to lowercase.
    00839        *
    00840        *  This function converts each char in the range [lo,hi) to lowercase
    00841        *  if possible.  Other chars remain untouched.
    00842        *
    00843        *  tolower() acts as if it returns ctype<char>:: do_tolower(lo, hi).
    00844        *  do_tolower() must always return the same result for the same input.
    00845        *
    00846        *  @param lo  Pointer to first char in range.
    00847        *  @param hi  Pointer to end of range.
    00848        *  @return  @a hi.
    00849       */
    00850       const char_type*
    00851       tolower(char_type* __lo, const char_type* __hi) const
    00852       { return this->do_tolower(__lo, __hi); }
    00853
    00854       /**
    00855        *  @brief  Widen char
    00856        *
    00857        *  This function converts the char to char_type using the simplest
    00858        *  reasonable transformation.  For an underived ctype<char> facet, the
    00859        *  argument will be returned unchanged.
    00860        *
    00861        *  This function works as if it returns ctype<char>::do_widen(c).
    00862        *  do_widen() must always return the same result for the same input.
    00863        *
    00864        *  Note: this is not what you want for codepage conversions.  See
    00865        *  codecvt for that.
    00866        *
    00867        *  @param c  The char to convert.
    00868        *  @return  The converted character.
    00869       */
    00870       char_type
    00871       widen(char __c) const
    00872       {
    00873     if (_M_widen_ok)
    00874       return _M_widen[static_cast<unsigned char>(__c)];
    00875     this->_M_widen_init();
    00876     return this->do_widen(__c);
    00877       }
    00878
    00879       /**
    00880        *  @brief  Widen char array
    00881        *
    00882        *  This function converts each char in the input to char using the
    00883        *  simplest reasonable transformation.  For an underived ctype<char>
    00884        *  facet, the argument will be copied unchanged.
    00885        *
    00886        *  This function works as if it returns ctype<char>::do_widen(c).
    00887        *  do_widen() must always return the same result for the same input.
    00888        *
    00889        *  Note: this is not what you want for codepage conversions.  See
    00890        *  codecvt for that.
    00891        *
    00892        *  @param lo  Pointer to first char in range.
    00893        *  @param hi  Pointer to end of range.
    00894        *  @param to  Pointer to the destination array.
    00895        *  @return  @a hi.
    00896       */
    00897       const char*
    00898       widen(const char* __lo, const char* __hi, char_type* __to) const
    00899       {
    00900     if (_M_widen_ok == 1)
    00901       {
    00902         __builtin_memcpy(__to, __lo, __hi - __lo);
    00903         return __hi;
    00904       }
    00905     if (!_M_widen_ok)
    00906       _M_widen_init();
    00907     return this->do_widen(__lo, __hi, __to);
    00908       }
    00909
    00910       /**
    00911        *  @brief  Narrow char
    00912        *
    00913        *  This function converts the char to char using the simplest
    00914        *  reasonable transformation.  If the conversion fails, dfault is
    00915        *  returned instead.  For an underived ctype<char> facet, @a c
    00916        *  will be returned unchanged.
    00917        *
    00918        *  This function works as if it returns ctype<char>::do_narrow(c).
    00919        *  do_narrow() must always return the same result for the same input.
    00920        *
    00921        *  Note: this is not what you want for codepage conversions.  See
    00922        *  codecvt for that.
    00923        *
    00924        *  @param c  The char to convert.
    00925        *  @param dfault  Char to return if conversion fails.
    00926        *  @return  The converted character.
    00927       */
    00928       char
    00929       narrow(char_type __c, char __dfault) const
    00930       {
    00931     if (_M_narrow[static_cast<unsigned char>(__c)])
    00932       return _M_narrow[static_cast<unsigned char>(__c)];
    00933     const char __t = do_narrow(__c, __dfault);
    00934     if (__t != __dfault)
    00935       _M_narrow[static_cast<unsigned char>(__c)] = __t;
    00936     return __t;
    00937       }
    00938
    00939       /**
    00940        *  @brief  Narrow char array
    00941        *
    00942        *  This function converts each char in the input to char using the
    00943        *  simplest reasonable transformation and writes the results to the
    00944        *  destination array.  For any char in the input that cannot be
    00945        *  converted, @a dfault is used instead.  For an underived ctype<char>
    00946        *  facet, the argument will be copied unchanged.
    00947        *
    00948        *  This function works as if it returns ctype<char>::do_narrow(lo, hi,
    00949        *  dfault, to).  do_narrow() must always return the same result for the
    00950        *  same input.
    00951        *
    00952        *  Note: this is not what you want for codepage conversions.  See
    00953        *  codecvt for that.
    00954        *
    00955        *  @param lo  Pointer to start of range.
    00956        *  @param hi  Pointer to end of range.
    00957        *  @param dfault  Char to use if conversion fails.
    00958        *  @param to  Pointer to the destination array.
    00959        *  @return  @a hi.
    00960       */
    00961       const char_type*
    00962       narrow(const char_type* __lo, const char_type* __hi,
    00963          char __dfault, char *__to) const
    00964       {
    00965     if (__builtin_expect(_M_narrow_ok == 1, true))
    00966       {
    00967         __builtin_memcpy(__to, __lo, __hi - __lo);
    00968         return __hi;
    00969       }
    00970     if (!_M_narrow_ok)
    00971       _M_narrow_init();
    00972     return this->do_narrow(__lo, __hi, __dfault, __to);
    00973       }
    00974
    00975       // _GLIBCXX_RESOLVE_LIB_DEFECTS
    00976       // DR 695. ctype<char>::classic_table() not accessible.
    00977       /// Returns a pointer to the mask table provided to the constructor, or
    00978       /// the default from classic_table() if none was provided.
    00979       const mask*
    00980       table() const throw()
    00981       { return _M_table; }
    00982
    00983       /// Returns a pointer to the C locale mask table.
    00984       static const mask*
    00985       classic_table() throw();
    00986     protected:
    00987
    00988       /**
    00989        *  @brief  Destructor.
    00990        *
    00991        *  This function deletes table() if @a del was true in the
    00992        *  constructor.
    00993       */
    00994       virtual
    00995       ~ctype();
    00996
    00997       /**
    00998        *  @brief  Convert to uppercase.
    00999        *
    01000        *  This virtual function converts the char argument to uppercase if
    01001        *  possible.  If not possible (for example, '2'), returns the argument.
    01002        *
    01003        *  do_toupper() is a hook for a derived facet to change the behavior of
    01004        *  uppercasing.  do_toupper() must always return the same result for
    01005        *  the same input.
    01006        *
    01007        *  @param c  The char to convert.
    01008        *  @return  The uppercase char if convertible, else @a c.
    01009       */
    01010       virtual char_type
    01011       do_toupper(char_type) const;
    01012
    01013       /**
    01014        *  @brief  Convert array to uppercase.
    01015        *
    01016        *  This virtual function converts each char in the range [lo,hi) to
    01017        *  uppercase if possible.  Other chars remain untouched.
    01018        *
    01019        *  do_toupper() is a hook for a derived facet to change the behavior of
    01020        *  uppercasing.  do_toupper() must always return the same result for
    01021        *  the same input.
    01022        *
    01023        *  @param lo  Pointer to start of range.
    01024        *  @param hi  Pointer to end of range.
    01025        *  @return  @a hi.
    01026       */
    01027       virtual const char_type*
    01028       do_toupper(char_type* __lo, const char_type* __hi) const;
    01029
    01030       /**
    01031        *  @brief  Convert to lowercase.
    01032        *
    01033        *  This virtual function converts the char argument to lowercase if
    01034        *  possible.  If not possible (for example, '2'), returns the argument.
    01035        *
    01036        *  do_tolower() is a hook for a derived facet to change the behavior of
    01037        *  lowercasing.  do_tolower() must always return the same result for
    01038        *  the same input.
    01039        *
    01040        *  @param c  The char to convert.
    01041        *  @return  The lowercase char if convertible, else @a c.
    01042       */
    01043       virtual char_type
    01044       do_tolower(char_type) const;
    01045
    01046       /**
    01047        *  @brief  Convert array to lowercase.
    01048        *
    01049        *  This virtual function converts each char in the range [lo,hi) to
    01050        *  lowercase if possible.  Other chars remain untouched.
    01051        *
    01052        *  do_tolower() is a hook for a derived facet to change the behavior of
    01053        *  lowercasing.  do_tolower() must always return the same result for
    01054        *  the same input.
    01055        *
    01056        *  @param lo  Pointer to first char in range.
    01057        *  @param hi  Pointer to end of range.
    01058        *  @return  @a hi.
    01059       */
    01060       virtual const char_type*
    01061       do_tolower(char_type* __lo, const char_type* __hi) const;
    01062
    01063       /**
    01064        *  @brief  Widen char
    01065        *
    01066        *  This virtual function converts the char to char using the simplest
    01067        *  reasonable transformation.  For an underived ctype<char> facet, the
    01068        *  argument will be returned unchanged.
    01069        *
    01070        *  do_widen() is a hook for a derived facet to change the behavior of
    01071        *  widening.  do_widen() must always return the same result for the
    01072        *  same input.
    01073        *
    01074        *  Note: this is not what you want for codepage conversions.  See
    01075        *  codecvt for that.
    01076        *
    01077        *  @param c  The char to convert.
    01078        *  @return  The converted character.
    01079       */
    01080       virtual char_type
    01081       do_widen(char __c) const
    01082       { return __c; }
    01083
    01084       /**
    01085        *  @brief  Widen char array
    01086        *
    01087        *  This function converts each char in the range [lo,hi) to char using
    01088        *  the simplest reasonable transformation.  For an underived
    01089        *  ctype<char> facet, the argument will be copied unchanged.
    01090        *
    01091        *  do_widen() is a hook for a derived facet to change the behavior of
    01092        *  widening.  do_widen() must always return the same result for the
    01093        *  same input.
    01094        *
    01095        *  Note: this is not what you want for codepage conversions.  See
    01096        *  codecvt for that.
    01097        *
    01098        *  @param lo  Pointer to start of range.
    01099        *  @param hi  Pointer to end of range.
    01100        *  @param to  Pointer to the destination array.
    01101        *  @return  @a hi.
    01102       */
    01103       virtual const char*
    01104       do_widen(const char* __lo, const char* __hi, char_type* __dest) const
    01105       {
    01106     __builtin_memcpy(__dest, __lo, __hi - __lo);
    01107     return __hi;
    01108       }
    01109
    01110       /**
    01111        *  @brief  Narrow char
    01112        *
    01113        *  This virtual function converts the char to char using the simplest
    01114        *  reasonable transformation.  If the conversion fails, dfault is
    01115        *  returned instead.  For an underived ctype<char> facet, @a c will be
    01116        *  returned unchanged.
    01117        *
    01118        *  do_narrow() is a hook for a derived facet to change the behavior of
    01119        *  narrowing.  do_narrow() must always return the same result for the
    01120        *  same input.
    01121        *
    01122        *  Note: this is not what you want for codepage conversions.  See
    01123        *  codecvt for that.
    01124        *
    01125        *  @param c  The char to convert.
    01126        *  @param dfault  Char to return if conversion fails.
    01127        *  @return  The converted char.
    01128       */
    01129       virtual char
    01130       do_narrow(char_type __c, char) const
    01131       { return __c; }
    01132
    01133       /**
    01134        *  @brief  Narrow char array to char array
    01135        *
    01136        *  This virtual function converts each char in the range [lo,hi) to
    01137        *  char using the simplest reasonable transformation and writes the
    01138        *  results to the destination array.  For any char in the input that
    01139        *  cannot be converted, @a dfault is used instead.  For an underived
    01140        *  ctype<char> facet, the argument will be copied unchanged.
    01141        *
    01142        *  do_narrow() is a hook for a derived facet to change the behavior of
    01143        *  narrowing.  do_narrow() must always return the same result for the
    01144        *  same input.
    01145        *
    01146        *  Note: this is not what you want for codepage conversions.  See
    01147        *  codecvt for that.
    01148        *
    01149        *  @param lo  Pointer to start of range.
    01150        *  @param hi  Pointer to end of range.
    01151        *  @param dfault  Char to use if conversion fails.
    01152        *  @param to  Pointer to the destination array.
    01153        *  @return  @a hi.
    01154       */
    01155       virtual const char_type*
    01156       do_narrow(const char_type* __lo, const char_type* __hi,
    01157         char, char* __dest) const
    01158       {
    01159     __builtin_memcpy(__dest, __lo, __hi - __lo);
    01160     return __hi;
    01161       }
    01162
    01163     private:
    01164
    01165       void _M_widen_init() const
    01166       {
    01167     char __tmp[sizeof(_M_widen)];
    01168     for (size_t __i = 0; __i < sizeof(_M_widen); ++__i)
    01169       __tmp[__i] = __i;
    01170     do_widen(__tmp, __tmp + sizeof(__tmp), _M_widen);
    01171
    01172     _M_widen_ok = 1;
    01173     // Set _M_widen_ok to 2 if memcpy can't be used.
    01174     if (__builtin_memcmp(__tmp, _M_widen, sizeof(_M_widen)))
    01175       _M_widen_ok = 2;
    01176       }
    01177
    01178       // Fill in the narrowing cache and flag whether all values are
    01179       // valid or not.  _M_narrow_ok is set to 2 if memcpy can't
    01180       // be used.
    01181       void _M_narrow_init() const
    01182       {
    01183     char __tmp[sizeof(_M_narrow)];
    01184     for (size_t __i = 0; __i < sizeof(_M_narrow); ++__i)
    01185       __tmp[__i] = __i;
    01186     do_narrow(__tmp, __tmp + sizeof(__tmp), 0, _M_narrow);
    01187
    01188     _M_narrow_ok = 1;
    01189     if (__builtin_memcmp(__tmp, _M_narrow, sizeof(_M_narrow)))
    01190       _M_narrow_ok = 2;
    01191     else
    01192       {
    01193         // Deal with the special case of zero: renarrow with a
    01194         // different default and compare.
    01195         char __c;
    01196         do_narrow(__tmp, __tmp + 1, 1, &__c);
    01197         if (__c == 1)
    01198           _M_narrow_ok = 2;
    01199       }
    01200       }
    01201     };
    01202
    01203   template<>
    01204     const ctype<char>&
    01205     use_facet<ctype<char> >(const locale& __loc);
    01206
    01207 #ifdef _GLIBCXX_USE_WCHAR_T
    01208   // 22.2.1.3  ctype<wchar_t> specialization
    01209   /**
    01210    *  @brief  The ctype<wchar_t> specialization.
    01211    *
    01212    *  This class defines classification and conversion functions for the
    01213    *  wchar_t type.  It gets used by wchar_t streams for many I/O operations.
    01214    *  The wchar_t specialization provides a number of optimizations as well.
    01215    *
    01216    *  ctype<wchar_t> inherits its public methods from
    01217    *  __ctype_abstract_base<wchar_t>.
    01218   */
    01219   template<>
    01220     class ctype<wchar_t> : public __ctype_abstract_base<wchar_t>
    01221     {
    01222     public:
    01223       // Types:
    01224       /// Typedef for the template parameter wchar_t.
    01225       typedef wchar_t       char_type;
    01226       typedef wctype_t      __wmask_type;
    01227
    01228     protected:
    01229       __c_locale        _M_c_locale_ctype;
    01230
    01231       // Pre-computed narrowed and widened chars.
    01232       bool                      _M_narrow_ok;
    01233       char                      _M_narrow[128];
    01234       wint_t                    _M_widen[1 + static_cast<unsigned char>(-1)];
    01235
    01236       // Pre-computed elements for do_is.
    01237       mask                      _M_bit[16];
    01238       __wmask_type              _M_wmask[16];
    01239
    01240     public:
    01241       // Data Members:
    01242       /// The facet id for ctype<wchar_t>
    01243       static locale::id     id;
    01244
    01245       /**
    01246        *  @brief  Constructor performs initialization.
    01247        *
    01248        *  This is the constructor provided by the standard.
    01249        *
    01250        *  @param refs  Passed to the base facet class.
    01251       */
    01252       explicit
    01253       ctype(size_t __refs = 0);
    01254
    01255       /**
    01256        *  @brief  Constructor performs static initialization.
    01257        *
    01258        *  This constructor is used to construct the initial C locale facet.
    01259        *
    01260        *  @param cloc  Handle to C locale data.
    01261        *  @param refs  Passed to the base facet class.
    01262       */
    01263       explicit
    01264       ctype(__c_locale __cloc, size_t __refs = 0);
    01265
    01266     protected:
    01267       __wmask_type
    01268       _M_convert_to_wmask(const mask __m) const;
    01269
    01270       /// Destructor
    01271       virtual
    01272       ~ctype();
    01273
    01274       /**
    01275        *  @brief  Test wchar_t classification.
    01276        *
    01277        *  This function finds a mask M for @a c and compares it to mask @a m.
    01278        *
    01279        *  do_is() is a hook for a derived facet to change the behavior of
    01280        *  classifying.  do_is() must always return the same result for the
    01281        *  same input.
    01282        *
    01283        *  @param c  The wchar_t to find the mask of.
    01284        *  @param m  The mask to compare against.
    01285        *  @return  (M & m) != 0.
    01286       */
    01287       virtual bool
    01288       do_is(mask __m, char_type __c) const;
    01289
    01290       /**
    01291        *  @brief  Return a mask array.
    01292        *
    01293        *  This function finds the mask for each wchar_t in the range [lo,hi)
    01294        *  and successively writes it to vec.  vec must have as many elements
    01295        *  as the input.
    01296        *
    01297        *  do_is() is a hook for a derived facet to change the behavior of
    01298        *  classifying.  do_is() must always return the same result for the
    01299        *  same input.
    01300        *
    01301        *  @param lo  Pointer to start of range.
    01302        *  @param hi  Pointer to end of range.
    01303        *  @param vec  Pointer to an array of mask storage.
    01304        *  @return  @a hi.
    01305       */
    01306       virtual const char_type*
    01307       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
    01308
    01309       /**
    01310        *  @brief  Find wchar_t matching mask
    01311        *
    01312        *  This function searches for and returns the first wchar_t c in
    01313        *  [lo,hi) for which is(m,c) is true.
    01314        *
    01315        *  do_scan_is() is a hook for a derived facet to change the behavior of
    01316        *  match searching.  do_is() must always return the same result for the
    01317        *  same input.
    01318        *
    01319        *  @param m  The mask to compare against.
    01320        *  @param lo  Pointer to start of range.
    01321        *  @param hi  Pointer to end of range.
    01322        *  @return  Pointer to a matching wchar_t if found, else @a hi.
    01323       */
    01324       virtual const char_type*
    01325       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
    01326
    01327       /**
    01328        *  @brief  Find wchar_t not matching mask
    01329        *
    01330        *  This function searches for and returns a pointer to the first
    01331        *  wchar_t c of [lo,hi) for which is(m,c) is false.
    01332        *
    01333        *  do_scan_is() is a hook for a derived facet to change the behavior of
    01334        *  match searching.  do_is() must always return the same result for the
    01335        *  same input.
    01336        *
    01337        *  @param m  The mask to compare against.
    01338        *  @param lo  Pointer to start of range.
    01339        *  @param hi  Pointer to end of range.
    01340        *  @return  Pointer to a non-matching wchar_t if found, else @a hi.
    01341       */
    01342       virtual const char_type*
    01343       do_scan_not(mask __m, const char_type* __lo,
    01344           const char_type* __hi) const;
    01345
    01346       /**
    01347        *  @brief  Convert to uppercase.
    01348        *
    01349        *  This virtual function converts the wchar_t argument to uppercase if
    01350        *  possible.  If not possible (for example, '2'), returns the argument.
    01351        *
    01352        *  do_toupper() is a hook for a derived facet to change the behavior of
    01353        *  uppercasing.  do_toupper() must always return the same result for
    01354        *  the same input.
    01355        *
    01356        *  @param c  The wchar_t to convert.
    01357        *  @return  The uppercase wchar_t if convertible, else @a c.
    01358       */
    01359       virtual char_type
    01360       do_toupper(char_type) const;
    01361
    01362       /**
    01363        *  @brief  Convert array to uppercase.
    01364        *
    01365        *  This virtual function converts each wchar_t in the range [lo,hi) to
    01366        *  uppercase if possible.  Other elements remain untouched.
    01367        *
    01368        *  do_toupper() is a hook for a derived facet to change the behavior of
    01369        *  uppercasing.  do_toupper() must always return the same result for
    01370        *  the same input.
    01371        *
    01372        *  @param lo  Pointer to start of range.
    01373        *  @param hi  Pointer to end of range.
    01374        *  @return  @a hi.
    01375       */
    01376       virtual const char_type*
    01377       do_toupper(char_type* __lo, const char_type* __hi) const;
    01378
    01379       /**
    01380        *  @brief  Convert to lowercase.
    01381        *
    01382        *  This virtual function converts the argument to lowercase if
    01383        *  possible.  If not possible (for example, '2'), returns the argument.
    01384        *
    01385        *  do_tolower() is a hook for a derived facet to change the behavior of
    01386        *  lowercasing.  do_tolower() must always return the same result for
    01387        *  the same input.
    01388        *
    01389        *  @param c  The wchar_t to convert.
    01390        *  @return  The lowercase wchar_t if convertible, else @a c.
    01391       */
    01392       virtual char_type
    01393       do_tolower(char_type) const;
    01394
    01395       /**
    01396        *  @brief  Convert array to lowercase.
    01397        *
    01398        *  This virtual function converts each wchar_t in the range [lo,hi) to
    01399        *  lowercase if possible.  Other elements remain untouched.
    01400        *
    01401        *  do_tolower() is a hook for a derived facet to change the behavior of
    01402        *  lowercasing.  do_tolower() must always return the same result for
    01403        *  the same input.
    01404        *
    01405        *  @param lo  Pointer to start of range.
    01406        *  @param hi  Pointer to end of range.
    01407        *  @return  @a hi.
    01408       */
    01409       virtual const char_type*
    01410       do_tolower(char_type* __lo, const char_type* __hi) const;
    01411
    01412       /**
    01413        *  @brief  Widen char to wchar_t
    01414        *
    01415        *  This virtual function converts the char to wchar_t using the
    01416        *  simplest reasonable transformation.  For an underived ctype<wchar_t>
    01417        *  facet, the argument will be cast to wchar_t.
    01418        *
    01419        *  do_widen() is a hook for a derived facet to change the behavior of
    01420        *  widening.  do_widen() must always return the same result for the
    01421        *  same input.
    01422        *
    01423        *  Note: this is not what you want for codepage conversions.  See
    01424        *  codecvt for that.
    01425        *
    01426        *  @param c  The char to convert.
    01427        *  @return  The converted wchar_t.
    01428       */
    01429       virtual char_type
    01430       do_widen(char) const;
    01431
    01432       /**
    01433        *  @brief  Widen char array to wchar_t array
    01434        *
    01435        *  This function converts each char in the input to wchar_t using the
    01436        *  simplest reasonable transformation.  For an underived ctype<wchar_t>
    01437        *  facet, the argument will be copied, casting each element to wchar_t.
    01438        *
    01439        *  do_widen() is a hook for a derived facet to change the behavior of
    01440        *  widening.  do_widen() must always return the same result for the
    01441        *  same input.
    01442        *
    01443        *  Note: this is not what you want for codepage conversions.  See
    01444        *  codecvt for that.
    01445        *
    01446        *  @param lo  Pointer to start range.
    01447        *  @param hi  Pointer to end of range.
    01448        *  @param to  Pointer to the destination array.
    01449        *  @return  @a hi.
    01450       */
    01451       virtual const char*
    01452       do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
    01453
    01454       /**
    01455        *  @brief  Narrow wchar_t to char
    01456        *
    01457        *  This virtual function converts the argument to char using
    01458        *  the simplest reasonable transformation.  If the conversion
    01459        *  fails, dfault is returned instead.  For an underived
    01460        *  ctype<wchar_t> facet, @a c will be cast to char and
    01461        *  returned.
    01462        *
    01463        *  do_narrow() is a hook for a derived facet to change the
    01464        *  behavior of narrowing.  do_narrow() must always return the
    01465        *  same result for the same input.
    01466        *
    01467        *  Note: this is not what you want for codepage conversions.  See
    01468        *  codecvt for that.
    01469        *
    01470        *  @param c  The wchar_t to convert.
    01471        *  @param dfault  Char to return if conversion fails.
    01472        *  @return  The converted char.
    01473       */
    01474       virtual char
    01475       do_narrow(char_type, char __dfault) const;
    01476
    01477       /**
    01478        *  @brief  Narrow wchar_t array to char array
    01479        *
    01480        *  This virtual function converts each wchar_t in the range [lo,hi) to
    01481        *  char using the simplest reasonable transformation and writes the
    01482        *  results to the destination array.  For any wchar_t in the input that
    01483        *  cannot be converted, @a dfault is used instead.  For an underived
    01484        *  ctype<wchar_t> facet, the argument will be copied, casting each
    01485        *  element to char.
    01486        *
    01487        *  do_narrow() is a hook for a derived facet to change the behavior of
    01488        *  narrowing.  do_narrow() must always return the same result for the
    01489        *  same input.
    01490        *
    01491        *  Note: this is not what you want for codepage conversions.  See
    01492        *  codecvt for that.
    01493        *
    01494        *  @param lo  Pointer to start of range.
    01495        *  @param hi  Pointer to end of range.
    01496        *  @param dfault  Char to use if conversion fails.
    01497        *  @param to  Pointer to the destination array.
    01498        *  @return  @a hi.
    01499       */
    01500       virtual const char_type*
    01501       do_narrow(const char_type* __lo, const char_type* __hi,
    01502         char __dfault, char* __dest) const;
    01503
    01504       // For use at construction time only.
    01505       void
    01506       _M_initialize_ctype();
    01507     };
    01508
    01509   template<>
    01510     const ctype<wchar_t>&
    01511     use_facet<ctype<wchar_t> >(const locale& __loc);
    01512 #endif //_GLIBCXX_USE_WCHAR_T
    01513
    01514   /// class ctype_byname [22.2.1.2].
    01515   template<typename _CharT>
    01516     class ctype_byname : public ctype<_CharT>
    01517     {
    01518     public:
    01519       typedef typename ctype<_CharT>::mask  mask;
    01520
    01521       explicit
    01522       ctype_byname(const char* __s, size_t __refs = 0);
    01523
    01524     protected:
    01525       virtual
    01526       ~ctype_byname() { };
    01527     };
    01528
    01529   /// 22.2.1.4  Class ctype_byname specializations.
    01530   template<>
    01531     class ctype_byname<char> : public ctype<char>
    01532     {
    01533     public:
    01534       explicit
    01535       ctype_byname(const char* __s, size_t __refs = 0);
    01536
    01537     protected:
    01538       virtual
    01539       ~ctype_byname();
    01540     };
    01541
    01542 #ifdef _GLIBCXX_USE_WCHAR_T
    01543   template<>
    01544     class ctype_byname<wchar_t> : public ctype<wchar_t>
    01545     {
    01546     public:
    01547       explicit
    01548       ctype_byname(const char* __s, size_t __refs = 0);
    01549
    01550     protected:
    01551       virtual
    01552       ~ctype_byname();
    01553     };
    01554 #endif
    01555
    01556 _GLIBCXX_END_NAMESPACE
    01557
    01558 // Include host and configuration specific ctype inlines.
    01559 #include <bits/ctype_inline.h>
    01560
    01561 _GLIBCXX_BEGIN_NAMESPACE(std)
    01562
    01563   // 22.2.2  The numeric category.
    01564   class __num_base
    01565   {
    01566   public:
    01567     // NB: Code depends on the order of _S_atoms_out elements.
    01568     // Below are the indices into _S_atoms_out.
    01569     enum
    01570       {
    01571         _S_ominus,
    01572         _S_oplus,
    01573         _S_ox,
    01574         _S_oX,
    01575         _S_odigits,
    01576         _S_odigits_end = _S_odigits + 16,
    01577         _S_oudigits = _S_odigits_end,
    01578         _S_oudigits_end = _S_oudigits + 16,
    01579         _S_oe = _S_odigits + 14,  // For scientific notation, 'e'
    01580         _S_oE = _S_oudigits + 14, // For scientific notation, 'E'
    01581     _S_oend = _S_oudigits_end
    01582       };
    01583
    01584     // A list of valid numeric literals for output.  This array
    01585     // contains chars that will be passed through the current locale's
    01586     // ctype<_CharT>.widen() and then used to render numbers.
    01587     // For the standard "C" locale, this is
    01588     // "-+xX0123456789abcdef0123456789ABCDEF".
    01589     static const char* _S_atoms_out;
    01590
    01591     // String literal of acceptable (narrow) input, for num_get.
    01592     // "-+xX0123456789abcdefABCDEF"
    01593     static const char* _S_atoms_in;
    01594
    01595     enum
    01596     {
    01597       _S_iminus,
    01598       _S_iplus,
    01599       _S_ix,
    01600       _S_iX,
    01601       _S_izero,
    01602       _S_ie = _S_izero + 14,
    01603       _S_iE = _S_izero + 20,
    01604       _S_iend = 26
    01605     };
    01606
    01607     // num_put
    01608     // Construct and return valid scanf format for floating point types.
    01609     static void
    01610     _S_format_float(const ios_base& __io, char* __fptr, char __mod);
    01611   };
    01612
    01613   template<typename _CharT>
    01614     struct __numpunct_cache : public locale::facet
    01615     {
    01616       const char*           _M_grouping;
    01617       size_t                            _M_grouping_size;
    01618       bool              _M_use_grouping;
    01619       const _CharT*         _M_truename;
    01620       size_t                            _M_truename_size;
    01621       const _CharT*         _M_falsename;
    01622       size_t                            _M_falsename_size;
    01623       _CharT                _M_decimal_point;
    01624       _CharT                _M_thousands_sep;
    01625
    01626       // A list of valid numeric literals for output: in the standard
    01627       // "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF".
    01628       // This array contains the chars after having been passed
    01629       // through the current locale's ctype<_CharT>.widen().
    01630       _CharT                _M_atoms_out[__num_base::_S_oend];
    01631
    01632       // A list of valid numeric literals for input: in the standard
    01633       // "C" locale, this is "-+xX0123456789abcdefABCDEF"
    01634       // This array contains the chars after having been passed
    01635       // through the current locale's ctype<_CharT>.widen().
    01636       _CharT                _M_atoms_in[__num_base::_S_iend];
    01637
    01638       bool              _M_allocated;
    01639
    01640       __numpunct_cache(size_t __refs = 0) : facet(__refs),
    01641       _M_grouping(NULL), _M_grouping_size(0), _M_use_grouping(false),
    01642       _M_truename(NULL), _M_truename_size(0), _M_falsename(NULL),
    01643       _M_falsename_size(0), _M_decimal_point(_CharT()),
    01644       _M_thousands_sep(_CharT()), _M_allocated(false)
    01645       { }
    01646
    01647       ~__numpunct_cache();
    01648
    01649       void
    01650       _M_cache(const locale& __loc);
    01651
    01652     private:
    01653       __numpunct_cache&
    01654       operator=(const __numpunct_cache&);
    01655
    01656       explicit
    01657       __numpunct_cache(const __numpunct_cache&);
    01658     };
    01659
    01660   template<typename _CharT>
    01661     __numpunct_cache<_CharT>::~__numpunct_cache()
    01662     {
    01663       if (_M_allocated)
    01664     {
    01665       delete [] _M_grouping;
    01666       delete [] _M_truename;
    01667       delete [] _M_falsename;
    01668     }
    01669     }
    01670
    01671   /**
    01672    *  @brief  Numpunct facet.
    01673    *
    01674    *  This facet stores several pieces of information related to printing and
    01675    *  scanning numbers, such as the decimal point character.  It takes a
    01676    *  template parameter specifying the char type.  The numpunct facet is
    01677    *  used by streams for many I/O operations involving numbers.
    01678    *
    01679    *  The numpunct template uses protected virtual functions to provide the
    01680    *  actual results.  The public accessors forward the call to the virtual
    01681    *  functions.  These virtual functions are hooks for developers to
    01682    *  implement the behavior they require from a numpunct facet.
    01683   */
    01684   template<typename _CharT>
    01685     class numpunct : public locale::facet
    01686     {
    01687     public:
    01688       // Types:
    01689       //@{
    01690       /// Public typedefs
    01691       typedef _CharT            char_type;
    01692       typedef basic_string<_CharT>  string_type;
    01693       //@}
    01694       typedef __numpunct_cache<_CharT>  __cache_type;
    01695
    01696     protected:
    01697       __cache_type*         _M_data;
    01698
    01699     public:
    01700       /// Numpunct facet id.
    01701       static locale::id         id;
    01702
    01703       /**
    01704        *  @brief  Numpunct constructor.
    01705        *
    01706        *  @param  refs  Refcount to pass to the base class.
    01707        */
    01708       explicit
    01709       numpunct(size_t __refs = 0) : facet(__refs), _M_data(NULL)
    01710       { _M_initialize_numpunct(); }
    01711
    01712       /**
    01713        *  @brief  Internal constructor.  Not for general use.
    01714        *
    01715        *  This is a constructor for use by the library itself to set up the
    01716        *  predefined locale facets.
    01717        *
    01718        *  @param  cache  __numpunct_cache object.
    01719        *  @param  refs  Refcount to pass to the base class.
    01720        */
    01721       explicit
    01722       numpunct(__cache_type* __cache, size_t __refs = 0)
    01723       : facet(__refs), _M_data(__cache)
    01724       { _M_initialize_numpunct(); }
    01725
    01726       /**
    01727        *  @brief  Internal constructor.  Not for general use.
    01728        *
    01729        *  This is a constructor for use by the library itself to set up new
    01730        *  locales.
    01731        *
    01732        *  @param  cloc  The "C" locale.
    01733        *  @param  refs  Refcount to pass to the base class.
    01734        */
    01735       explicit
    01736       numpunct(__c_locale __cloc, size_t __refs = 0)
    01737       : facet(__refs), _M_data(NULL)
    01738       { _M_initialize_numpunct(__cloc); }
    01739
    01740       /**
    01741        *  @brief  Return decimal point character.
    01742        *
    01743        *  This function returns a char_type to use as a decimal point.  It
    01744        *  does so by returning returning
    01745        *  numpunct<char_type>::do_decimal_point().
    01746        *
    01747        *  @return  @a char_type representing a decimal point.
    01748       */
    01749       char_type
    01750       decimal_point() const
    01751       { return this->do_decimal_point(); }
    01752
    01753       /**
    01754        *  @brief  Return thousands separator character.
    01755        *
    01756        *  This function returns a char_type to use as a thousands
    01757        *  separator.  It does so by returning returning
    01758        *  numpunct<char_type>::do_thousands_sep().
    01759        *
    01760        *  @return  char_type representing a thousands separator.
    01761       */
    01762       char_type
    01763       thousands_sep() const
    01764       { return this->do_thousands_sep(); }
    01765
    01766       /**
    01767        *  @brief  Return grouping specification.
    01768        *
    01769        *  This function returns a string representing groupings for the
    01770        *  integer part of a number.  Groupings indicate where thousands
    01771        *  separators should be inserted in the integer part of a number.
    01772        *
    01773        *  Each char in the return string is interpret as an integer
    01774        *  rather than a character.  These numbers represent the number
    01775        *  of digits in a group.  The first char in the string
    01776        *  represents the number of digits in the least significant
    01777        *  group.  If a char is negative, it indicates an unlimited
    01778        *  number of digits for the group.  If more chars from the
    01779        *  string are required to group a number, the last char is used
    01780        *  repeatedly.
    01781        *
    01782        *  For example, if the grouping() returns "\003\002" and is
    01783        *  applied to the number 123456789, this corresponds to
    01784        *  12,34,56,789.  Note that if the string was "32", this would
    01785        *  put more than 50 digits into the least significant group if
    01786        *  the character set is ASCII.
    01787        *
    01788        *  The string is returned by calling
    01789        *  numpunct<char_type>::do_grouping().
    01790        *
    01791        *  @return  string representing grouping specification.
    01792       */
    01793       string
    01794       grouping() const
    01795       { return this->do_grouping(); }
    01796
    01797       /**
    01798        *  @brief  Return string representation of bool true.
    01799        *
    01800        *  This function returns a string_type containing the text
    01801        *  representation for true bool variables.  It does so by calling
    01802        *  numpunct<char_type>::do_truename().
    01803        *
    01804        *  @return  string_type representing printed form of true.
    01805       */
    01806       string_type
    01807       truename() const
    01808       { return this->do_truename(); }
    01809
    01810       /**
    01811        *  @brief  Return string representation of bool false.
    01812        *
    01813        *  This function returns a string_type containing the text
    01814        *  representation for false bool variables.  It does so by calling
    01815        *  numpunct<char_type>::do_falsename().
    01816        *
    01817        *  @return  string_type representing printed form of false.
    01818       */
    01819       string_type
    01820       falsename() const
    01821       { return this->do_falsename(); }
    01822
    01823     protected:
    01824       /// Destructor.
    01825       virtual
    01826       ~numpunct();
    01827
    01828       /**
    01829        *  @brief  Return decimal point character.
    01830        *
    01831        *  Returns a char_type to use as a decimal point.  This function is a
    01832        *  hook for derived classes to change the value returned.
    01833        *
    01834        *  @return  @a char_type representing a decimal point.
    01835       */
    01836       virtual char_type
    01837       do_decimal_point() const
    01838       { return _M_data->_M_decimal_point; }
    01839
    01840       /**
    01841        *  @brief  Return thousands separator character.
    01842        *
    01843        *  Returns a char_type to use as a thousands separator.  This function
    01844        *  is a hook for derived classes to change the value returned.
    01845        *
    01846        *  @return  @a char_type representing a thousands separator.
    01847       */
    01848       virtual char_type
    01849       do_thousands_sep() const
    01850       { return _M_data->_M_thousands_sep; }
    01851
    01852       /**
    01853        *  @brief  Return grouping specification.
    01854        *
    01855        *  Returns a string representing groupings for the integer part of a
    01856        *  number.  This function is a hook for derived classes to change the
    01857        *  value returned.  @see grouping() for details.
    01858        *
    01859        *  @return  String representing grouping specification.
    01860       */
    01861       virtual string
    01862       do_grouping() const
    01863       { return _M_data->_M_grouping; }
    01864
    01865       /**
    01866        *  @brief  Return string representation of bool true.
    01867        *
    01868        *  Returns a string_type containing the text representation for true
    01869        *  bool variables.  This function is a hook for derived classes to
    01870        *  change the value returned.
    01871        *
    01872        *  @return  string_type representing printed form of true.
    01873       */
    01874       virtual string_type
    01875       do_truename() const
    01876       { return _M_data->_M_truename; }
    01877
    01878       /**
    01879        *  @brief  Return string representation of bool false.
    01880        *
    01881        *  Returns a string_type containing the text representation for false
    01882        *  bool variables.  This function is a hook for derived classes to
    01883        *  change the value returned.
    01884        *
    01885        *  @return  string_type representing printed form of false.
    01886       */
    01887       virtual string_type
    01888       do_falsename() const
    01889       { return _M_data->_M_falsename; }
    01890
    01891       // For use at construction time only.
    01892       void
    01893       _M_initialize_numpunct(__c_locale __cloc = NULL);
    01894     };
    01895
    01896   template<typename _CharT>
    01897     locale::id numpunct<_CharT>::id;
    01898
    01899   template<>
    01900     numpunct<char>::~numpunct();
    01901
    01902   template<>
    01903     void
    01904     numpunct<char>::_M_initialize_numpunct(__c_locale __cloc);
    01905
    01906 #ifdef _GLIBCXX_USE_WCHAR_T
    01907   template<>
    01908     numpunct<wchar_t>::~numpunct();
    01909
    01910   template<>
    01911     void
    01912     numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc);
    01913 #endif
    01914
    01915   /// class numpunct_byname [22.2.3.2].
    01916   template<typename _CharT>
    01917     class numpunct_byname : public numpunct<_CharT>
    01918     {
    01919     public:
    01920       typedef _CharT            char_type;
    01921       typedef basic_string<_CharT>  string_type;
    01922
    01923       explicit
    01924       numpunct_byname(const char* __s, size_t __refs = 0)
    01925       : numpunct<_CharT>(__refs)
    01926       {
    01927     if (__builtin_strcmp(__s, "C") != 0
    01928         && __builtin_strcmp(__s, "POSIX") != 0)
    01929       {
    01930         __c_locale __tmp;
    01931         this->_S_create_c_locale(__tmp, __s);
    01932         this->_M_initialize_numpunct(__tmp);
    01933         this->_S_destroy_c_locale(__tmp);
    01934       }
    01935       }
    01936
    01937     protected:
    01938       virtual
    01939       ~numpunct_byname() { }
    01940     };
    01941
    01942 _GLIBCXX_BEGIN_LDBL_NAMESPACE
    01943
    01944   /**
    01945    *  @brief  Facet for parsing number strings.
    01946    *
    01947    *  This facet encapsulates the code to parse and return a number
    01948    *  from a string.  It is used by the istream numeric extraction
    01949    *  operators.
    01950    *
    01951    *  The num_get template uses protected virtual functions to provide the
    01952    *  actual results.  The public accessors forward the call to the virtual
    01953    *  functions.  These virtual functions are hooks for developers to
    01954    *  implement the behavior they require from the num_get facet.
    01955   */
    01956   template<typename _CharT, typename _InIter>
    01957     class num_get : public locale::facet
    01958     {
    01959     public:
    01960       // Types:
    01961       //@{
    01962       /// Public typedefs
    01963       typedef _CharT            char_type;
    01964       typedef _InIter           iter_type;
    01965       //@}
    01966
    01967       /// Numpunct facet id.
    01968       static locale::id         id;
    01969
    01970       /**
    01971        *  @brief  Constructor performs initialization.
    01972        *
    01973        *  This is the constructor provided by the standard.
    01974        *
    01975        *  @param refs  Passed to the base facet class.
    01976       */
    01977       explicit
    01978       num_get(size_t __refs = 0) : facet(__refs) { }
    01979
    01980       /**
    01981        *  @brief  Numeric parsing.
    01982        *
    01983        *  Parses the input stream into the bool @a v.  It does so by calling
    01984        *  num_get::do_get().
    01985        *
    01986        *  If ios_base::boolalpha is set, attempts to read
    01987        *  ctype<CharT>::truename() or ctype<CharT>::falsename().  Sets
    01988        *  @a v to true or false if successful.  Sets err to
    01989        *  ios_base::failbit if reading the string fails.  Sets err to
    01990        *  ios_base::eofbit if the stream is emptied.
    01991        *
    01992        *  If ios_base::boolalpha is not set, proceeds as with reading a long,
    01993        *  except if the value is 1, sets @a v to true, if the value is 0, sets
    01994        *  @a v to false, and otherwise set err to ios_base::failbit.
    01995        *
    01996        *  @param  in  Start of input stream.
    01997        *  @param  end  End of input stream.
    01998        *  @param  io  Source of locale and flags.
    01999        *  @param  err  Error flags to set.
    02000        *  @param  v  Value to format and insert.
    02001        *  @return  Iterator after reading.
    02002       */
    02003       iter_type
    02004       get(iter_type __in, iter_type __end, ios_base& __io,
    02005       ios_base::iostate& __err, bool& __v) const
    02006       { return this->do_get(__in, __end, __io, __err, __v); }
    02007
    02008       //@{
    02009       /**
    02010        *  @brief  Numeric parsing.
    02011        *
    02012        *  Parses the input stream into the integral variable @a v.  It does so
    02013        *  by calling num_get::do_get().
    02014        *
    02015        *  Parsing is affected by the flag settings in @a io.
    02016        *
    02017        *  The basic parse is affected by the value of io.flags() &
    02018        *  ios_base::basefield.  If equal to ios_base::oct, parses like the
    02019        *  scanf %o specifier.  Else if equal to ios_base::hex, parses like %X
    02020        *  specifier.  Else if basefield equal to 0, parses like the %i
    02021        *  specifier.  Otherwise, parses like %d for signed and %u for unsigned
    02022        *  types.  The matching type length modifier is also used.
    02023        *
    02024        *  Digit grouping is interpreted according to numpunct::grouping() and
    02025        *  numpunct::thousands_sep().  If the pattern of digit groups isn't
    02026        *  consistent, sets err to ios_base::failbit.
    02027        *
    02028        *  If parsing the string yields a valid value for @a v, @a v is set.
    02029        *  Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
    02030        *  Sets err to ios_base::eofbit if the stream is emptied.
    02031        *
    02032        *  @param  in  Start of input stream.
    02033        *  @param  end  End of input stream.
    02034        *  @param  io  Source of locale and flags.
    02035        *  @param  err  Error flags to set.
    02036        *  @param  v  Value to format and insert.
    02037        *  @return  Iterator after reading.
    02038       */
    02039       iter_type
    02040       get(iter_type __in, iter_type __end, ios_base& __io,
    02041       ios_base::iostate& __err, long& __v) const
    02042       { return this->do_get(__in, __end, __io, __err, __v); }
    02043
    02044       iter_type
    02045       get(iter_type __in, iter_type __end, ios_base& __io,
    02046       ios_base::iostate& __err, unsigned short& __v) const
    02047       { return this->do_get(__in, __end, __io, __err, __v); }
    02048
    02049       iter_type
    02050       get(iter_type __in, iter_type __end, ios_base& __io,
    02051       ios_base::iostate& __err, unsigned int& __v)   const
    02052       { return this->do_get(__in, __end, __io, __err, __v); }
    02053
    02054       iter_type
    02055       get(iter_type __in, iter_type __end, ios_base& __io,
    02056       ios_base::iostate& __err, unsigned long& __v)  const
    02057       { return this->do_get(__in, __end, __io, __err, __v); }
    02058
    02059 #ifdef _GLIBCXX_USE_LONG_LONG
    02060       iter_type
    02061       get(iter_type __in, iter_type __end, ios_base& __io,
    02062       ios_base::iostate& __err, long long& __v) const
    02063       { return this->do_get(__in, __end, __io, __err, __v); }
    02064
    02065       iter_type
    02066       get(iter_type __in, iter_type __end, ios_base& __io,
    02067       ios_base::iostate& __err, unsigned long long& __v)  const
    02068       { return this->do_get(__in, __end, __io, __err, __v); }
    02069 #endif
    02070       //@}
    02071
    02072       //@{
    02073       /**
    02074        *  @brief  Numeric parsing.
    02075        *
    02076        *  Parses the input stream into the integral variable @a v.  It does so
    02077        *  by calling num_get::do_get().
    02078        *
    02079        *  The input characters are parsed like the scanf %g specifier.  The
    02080        *  matching type length modifier is also used.
    02081        *
    02082        *  The decimal point character used is numpunct::decimal_point().
    02083        *  Digit grouping is interpreted according to numpunct::grouping() and
    02084        *  numpunct::thousands_sep().  If the pattern of digit groups isn't
    02085        *  consistent, sets err to ios_base::failbit.
    02086        *
    02087        *  If parsing the string yields a valid value for @a v, @a v is set.
    02088        *  Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
    02089        *  Sets err to ios_base::eofbit if the stream is emptied.
    02090        *
    02091        *  @param  in  Start of input stream.
    02092        *  @param  end  End of input stream.
    02093        *  @param  io  Source of locale and flags.
    02094        *  @param  err  Error flags to set.
    02095        *  @param  v  Value to format and insert.
    02096        *  @return  Iterator after reading.
    02097       */
    02098       iter_type
    02099       get(iter_type __in, iter_type __end, ios_base& __io,
    02100       ios_base::iostate& __err, float& __v) const
    02101       { return this->do_get(__in, __end, __io, __err, __v); }
    02102
    02103       iter_type
    02104       get(iter_type __in, iter_type __end, ios_base& __io,
    02105       ios_base::iostate& __err, double& __v) const
    02106       { return this->do_get(__in, __end, __io, __err, __v); }
    02107
    02108       iter_type
    02109       get(iter_type __in, iter_type __end, ios_base& __io,
    02110       ios_base::iostate& __err, long double& __v) const
    02111       { return this->do_get(__in, __end, __io, __err, __v); }
    02112       //@}
    02113
    02114       /**
    02115        *  @brief  Numeric parsing.
    02116        *
    02117        *  Parses the input stream into the pointer variable @a v.  It does so
    02118        *  by calling num_get::do_get().
    02119        *
    02120        *  The input characters are parsed like the scanf %p specifier.
    02121        *
    02122        *  Digit grouping is interpreted according to numpunct::grouping() and
    02123        *  numpunct::thousands_sep().  If the pattern of digit groups isn't
    02124        *  consistent, sets err to ios_base::failbit.
    02125        *
    02126        *  Note that the digit grouping effect for pointers is a bit ambiguous
    02127        *  in the standard and shouldn't be relied on.  See DR 344.
    02128        *
    02129        *  If parsing the string yields a valid value for @a v, @a v is set.
    02130        *  Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
    02131        *  Sets err to ios_base::eofbit if the stream is emptied.
    02132        *
    02133        *  @param  in  Start of input stream.
    02134        *  @param  end  End of input stream.
    02135        *  @param  io  Source of locale and flags.
    02136        *  @param  err  Error flags to set.
    02137        *  @param  v  Value to format and insert.
    02138        *  @return  Iterator after reading.
    02139       */
    02140       iter_type
    02141       get(iter_type __in, iter_type __end, ios_base& __io,
    02142       ios_base::iostate& __err, void*& __v) const
    02143       { return this->do_get(__in, __end, __io, __err, __v); }
    02144
    02145     protected:
    02146       /// Destructor.
    02147       virtual ~num_get() { }
    02148
    02149       iter_type
    02150       _M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&,
    02151                string& __xtrc) const;
    02152
    02153       template<typename _ValueT>
    02154         iter_type
    02155         _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&,
    02156                _ValueT& __v) const;
    02157
    02158       template<typename _CharT2>
    02159       typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, int>::__type
    02160         _M_find(const _CharT2*, size_t __len, _CharT2 __c) const
    02161         {
    02162       int __ret = -1;
    02163       if (__len <= 10)
    02164         {
    02165           if (__c >= _CharT2('0') && __c < _CharT2(_CharT2('0') + __len))
    02166         __ret = __c - _CharT2('0');
    02167         }
    02168       else
    02169         {
    02170           if (__c >= _CharT2('0') && __c <= _CharT2('9'))
    02171         __ret = __c - _CharT2('0');
    02172           else if (__c >= _CharT2('a') && __c <= _CharT2('f'))
    02173         __ret = 10 + (__c - _CharT2('a'));
    02174           else if (__c >= _CharT2('A') && __c <= _CharT2('F'))
    02175         __ret = 10 + (__c - _CharT2('A'));
    02176         }
    02177       return __ret;
    02178     }
    02179
    02180       template<typename _CharT2>
    02181       typename __gnu_cxx::__enable_if<!__is_char<_CharT2>::__value,
    02182                       int>::__type
    02183         _M_find(const _CharT2* __zero, size_t __len, _CharT2 __c) const
    02184         {
    02185       int __ret = -1;
    02186       const char_type* __q = char_traits<_CharT2>::find(__zero, __len, __c);
    02187       if (__q)
    02188         {
    02189           __ret = __q - __zero;
    02190           if (__ret > 15)
    02191         __ret -= 6;
    02192         }
    02193       return __ret;
    02194     }
    02195
    02196       //@{
    02197       /**
    02198        *  @brief  Numeric parsing.
    02199        *
    02200        *  Parses the input stream into the variable @a v.  This function is a
    02201        *  hook for derived classes to change the value returned.  @see get()
    02202        *  for more details.
    02203        *
    02204        *  @param  in  Start of input stream.
    02205        *  @param  end  End of input stream.
    02206        *  @param  io  Source of locale and flags.
    02207        *  @param  err  Error flags to set.
    02208        *  @param  v  Value to format and insert.
    02209        *  @return  Iterator after reading.
    02210       */
    02211       virtual iter_type
    02212       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
    02213
    02214
    02215       virtual iter_type
    02216       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, long&) const;
    02217
    02218       virtual iter_type
    02219       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    02220           unsigned short&) const;
    02221
    02222       virtual iter_type
    02223       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    02224          unsigned int&) const;
    02225
    02226       virtual iter_type
    02227       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    02228          unsigned long&) const;
    02229
    02230 #ifdef _GLIBCXX_USE_LONG_LONG
    02231       virtual iter_type
    02232       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    02233          long long&) const;
    02234
    02235       virtual iter_type
    02236       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    02237          unsigned long long&) const;
    02238 #endif
    02239
    02240       virtual iter_type
    02241       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    02242          float&) const;
    02243
    02244       virtual iter_type
    02245       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    02246          double&) const;
    02247
    02248       // XXX GLIBCXX_ABI Deprecated
    02249 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
    02250       virtual iter_type
    02251       __do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    02252            double&) const;
    02253 #else
    02254       virtual iter_type
    02255       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    02256          long double&) const;
    02257 #endif
    02258
    02259       virtual iter_type
    02260       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    02261          void*&) const;
    02262
    02263       // XXX GLIBCXX_ABI Deprecated
    02264 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
    02265       virtual iter_type
    02266       do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
    02267          long double&) const;
    02268 #endif
    02269       //@}
    02270     };
    02271
    02272   template<typename _CharT, typename _InIter>
    02273     locale::id num_get<_CharT, _InIter>::id;
    02274
    02275
    02276   /**
    02277    *  @brief  Facet for converting numbers to strings.
    02278    *
    02279    *  This facet encapsulates the code to convert a number to a string.  It is
    02280    *  used by the ostream numeric insertion operators.
    02281    *
    02282    *  The num_put template uses protected virtual functions to provide the
    02283    *  actual results.  The public accessors forward the call to the virtual
    02284    *  functions.  These virtual functions are hooks for developers to
    02285    *  implement the behavior they require from the num_put facet.
    02286   */
    02287   template<typename _CharT, typename _OutIter>
    02288     class num_put : public locale::facet
    02289     {
    02290     public:
    02291       // Types:
    02292       //@{
    02293       /// Public typedefs
    02294       typedef _CharT        char_type;
    02295       typedef _OutIter      iter_type;
    02296       //@}
    02297
    02298       /// Numpunct facet id.
    02299       static locale::id     id;
    02300
    02301       /**
    02302        *  @brief  Constructor performs initialization.
    02303        *
    02304        *  This is the constructor provided by the standard.
    02305        *
    02306        *  @param refs  Passed to the base facet class.
    02307       */
    02308       explicit
    02309       num_put(size_t __refs = 0) : facet(__refs) { }
    02310
    02311       /**
    02312        *  @brief  Numeric formatting.
    02313        *
    02314        *  Formats the boolean @a v and inserts it into a stream.  It does so
    02315        *  by calling num_put::do_put().
    02316        *
    02317        *  If ios_base::boolalpha is set, writes ctype<CharT>::truename() or
    02318        *  ctype<CharT>::falsename().  Otherwise formats @a v as an int.
    02319        *
    02320        *  @param  s  Stream to write to.
    02321        *  @param  io  Source of locale and flags.
    02322        *  @param  fill  Char_type to use for filling.
    02323        *  @param  v  Value to format and insert.
    02324        *  @return  Iterator after writing.
    02325       */
    02326       iter_type
    02327       put(iter_type __s, ios_base& __f, char_type __fill, bool __v) const
    02328       { return this->do_put(__s, __f, __fill, __v); }
    02329
    02330       //@{
    02331       /**
    02332        *  @brief  Numeric formatting.
    02333        *
    02334        *  Formats the integral value @a v and inserts it into a
    02335        *  stream.  It does so by calling num_put::do_put().
    02336        *
    02337        *  Formatting is affected by the flag settings in @a io.
    02338        *
    02339        *  The basic format is affected by the value of io.flags() &
    02340        *  ios_base::basefield.  If equal to ios_base::oct, formats like the
    02341        *  printf %o specifier.  Else if equal to ios_base::hex, formats like
    02342        *  %x or %X with ios_base::uppercase unset or set respectively.
    02343        *  Otherwise, formats like %d, %ld, %lld for signed and %u, %lu, %llu
    02344        *  for unsigned values.  Note that if both oct and hex are set, neither
    02345        *  will take effect.
    02346        *
    02347        *  If ios_base::showpos is set, '+' is output before positive values.
    02348        *  If ios_base::showbase is set, '0' precedes octal values (except 0)
    02349        *  and '0[xX]' precedes hex values.
    02350        *
    02351        *  Thousands separators are inserted according to numpunct::grouping()
    02352        *  and numpunct::thousands_sep().  The decimal point character used is
    02353        *  numpunct::decimal_point().
    02354        *
    02355        *  If io.width() is non-zero, enough @a fill characters are inserted to
    02356        *  make the result at least that wide.  If
    02357        *  (io.flags() & ios_base::adjustfield) == ios_base::left, result is
    02358        *  padded at the end.  If ios_base::internal, then padding occurs
    02359        *  immediately after either a '+' or '-' or after '0x' or '0X'.
    02360        *  Otherwise, padding occurs at the beginning.
    02361        *
    02362        *  @param  s  Stream to write to.
    02363        *  @param  io  Source of locale and flags.
    02364        *  @param  fill  Char_type to use for filling.
    02365        *  @param  v  Value to format and insert.
    02366        *  @return  Iterator after writing.
    02367       */
    02368       iter_type
    02369       put(iter_type __s, ios_base& __f, char_type __fill, long __v) const
    02370       { return this->do_put(__s, __f, __fill, __v); }
    02371
    02372       iter_type
    02373       put(iter_type __s, ios_base& __f, char_type __fill,
    02374       unsigned long __v) const
    02375       { return this->do_put(__s, __f, __fill, __v); }
    02376
    02377 #ifdef _GLIBCXX_USE_LONG_LONG
    02378       iter_type
    02379       put(iter_type __s, ios_base& __f, char_type __fill, long long __v) const
    02380       { return this->do_put(__s, __f, __fill, __v); }
    02381
    02382       iter_type
    02383       put(iter_type __s, ios_base& __f, char_type __fill,
    02384       unsigned long long __v) const
    02385       { return this->do_put(__s, __f, __fill, __v); }
    02386 #endif
    02387       //@}
    02388
    02389       //@{
    02390       /**
    02391        *  @brief  Numeric formatting.
    02392        *
    02393        *  Formats the floating point value @a v and inserts it into a stream.
    02394        *  It does so by calling num_put::do_put().
    02395        *
    02396        *  Formatting is affected by the flag settings in @a io.
    02397        *
    02398        *  The basic format is affected by the value of io.flags() &
    02399        *  ios_base::floatfield.  If equal to ios_base::fixed, formats like the
    02400        *  printf %f specifier.  Else if equal to ios_base::scientific, formats
    02401        *  like %e or %E with ios_base::uppercase unset or set respectively.
    02402        *  Otherwise, formats like %g or %G depending on uppercase.  Note that
    02403        *  if both fixed and scientific are set, the effect will also be like
    02404        *  %g or %G.
    02405        *
    02406        *  The output precision is given by io.precision().  This precision is
    02407        *  capped at numeric_limits::digits10 + 2 (different for double and
    02408        *  long double).  The default precision is 6.
    02409        *
    02410        *  If ios_base::showpos is set, '+' is output before positive values.
    02411        *  If ios_base::showpoint is set, a decimal point will always be
    02412        *  output.
    02413        *
    02414        *  Thousands separators are inserted according to numpunct::grouping()
    02415        *  and numpunct::thousands_sep().  The decimal point character used is
    02416        *  numpunct::decimal_point().
    02417        *
    02418        *  If io.width() is non-zero, enough @a fill characters are inserted to
    02419        *  make the result at least that wide.  If
    02420        *  (io.flags() & ios_base::adjustfield) == ios_base::left, result is
    02421        *  padded at the end.  If ios_base::internal, then padding occurs
    02422        *  immediately after either a '+' or '-' or after '0x' or '0X'.
    02423        *  Otherwise, padding occurs at the beginning.
    02424        *
    02425        *  @param  s  Stream to write to.
    02426        *  @param  io  Source of locale and flags.
    02427        *  @param  fill  Char_type to use for filling.
    02428        *  @param  v  Value to format and insert.
    02429        *  @return  Iterator after writing.
    02430       */
    02431       iter_type
    02432       put(iter_type __s, ios_base& __f, char_type __fill, double __v) const
    02433       { return this->do_put(__s, __f, __fill, __v); }
    02434
    02435       iter_type
    02436       put(iter_type __s, ios_base& __f, char_type __fill,
    02437       long double __v) const
    02438       { return this->do_put(__s, __f, __fill, __v); }
    02439       //@}
    02440
    02441       /**
    02442        *  @brief  Numeric formatting.
    02443        *
    02444        *  Formats the pointer value @a v and inserts it into a stream.  It
    02445        *  does so by calling num_put::do_put().
    02446        *
    02447        *  This function formats @a v as an unsigned long with ios_base::hex
    02448        *  and ios_base::showbase set.
    02449        *
    02450        *  @param  s  Stream to write to.
    02451        *  @param  io  Source of locale and flags.
    02452        *  @param  fill  Char_type to use for filling.
    02453        *  @param  v  Value to format and insert.
    02454        *  @return  Iterator after writing.
    02455       */
    02456       iter_type
    02457       put(iter_type __s, ios_base& __f, char_type __fill,
    02458       const void* __v) const
    02459       { return this->do_put(__s, __f, __fill, __v); }
    02460
    02461     protected:
    02462       template<typename _ValueT>
    02463         iter_type
    02464         _M_insert_float(iter_type, ios_base& __io, char_type __fill,
    02465             char __mod, _ValueT __v) const;
    02466
    02467       void
    02468       _M_group_float(const char* __grouping, size_t __grouping_size,
    02469              char_type __sep, const char_type* __p, char_type* __new,
    02470              char_type* __cs, int& __len) const;
    02471
    02472       template<typename _ValueT>
    02473         iter_type
    02474         _M_insert_int(iter_type, ios_base& __io, char_type __fill,
    02475               _ValueT __v) const;
    02476
    02477       void
    02478       _M_group_int(const char* __grouping, size_t __grouping_size,
    02479            char_type __sep, ios_base& __io, char_type* __new,
    02480            char_type* __cs, int& __len) const;
    02481
    02482       void
    02483       _M_pad(char_type __fill, streamsize __w, ios_base& __io,
    02484          char_type* __new, const char_type* __cs, int& __len) const;
    02485
    02486       /// Destructor.
    02487       virtual
    02488       ~num_put() { };
    02489
    02490       //@{
    02491       /**
    02492        *  @brief  Numeric formatting.
    02493        *
    02494        *  These functions do the work of formatting numeric values and
    02495        *  inserting them into a stream. This function is a hook for derived
    02496        *  classes to change the value returned.
    02497        *
    02498        *  @param  s  Stream to write to.
    02499        *  @param  io  Source of locale and flags.
    02500        *  @param  fill  Char_type to use for filling.
    02501        *  @param  v  Value to format and insert.
    02502        *  @return  Iterator after writing.
    02503       */
    02504       virtual iter_type
    02505       do_put(iter_type, ios_base&, char_type __fill, bool __v) const;
    02506
    02507       virtual iter_type
    02508       do_put(iter_type, ios_base&, char_type __fill, long __v) const;
    02509
    02510       virtual iter_type
    02511       do_put(iter_type, ios_base&, char_type __fill, unsigned long) const;
    02512
    02513 #ifdef _GLIBCXX_USE_LONG_LONG
    02514       virtual iter_type
    02515       do_put(iter_type, ios_base&, char_type __fill, long long __v) const;
    02516
    02517       virtual iter_type
    02518       do_put(iter_type, ios_base&, char_type __fill, unsigned long long) const;
    02519 #endif
    02520
    02521       virtual iter_type
    02522       do_put(iter_type, ios_base&, char_type __fill, double __v) const;
    02523
    02524       // XXX GLIBCXX_ABI Deprecated
    02525 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
    02526       virtual iter_type
    02527       __do_put(iter_type, ios_base&, char_type __fill, double __v) const;
    02528 #else
    02529       virtual iter_type
    02530       do_put(iter_type, ios_base&, char_type __fill, long double __v) const;
    02531 #endif
    02532
    02533       virtual iter_type
    02534       do_put(iter_type, ios_base&, char_type __fill, const void* __v) const;
    02535
    02536       // XXX GLIBCXX_ABI Deprecated
    02537 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
    02538       virtual iter_type
    02539       do_put(iter_type, ios_base&, char_type __fill, long double __v) const;
    02540 #endif
    02541       //@}
    02542     };
    02543
    02544   template <typename _CharT, typename _OutIter>
    02545     locale::id num_put<_CharT, _OutIter>::id;
    02546
    02547 _GLIBCXX_END_LDBL_NAMESPACE
    02548
    02549   // Subclause convenience interfaces, inlines.
    02550   // NB: These are inline because, when used in a loop, some compilers
    02551   // can hoist the body out of the loop; then it's just as fast as the
    02552   // C is*() function.
    02553
    02554   /// Convenience interface to ctype.is(ctype_base::space, __c).
    02555   template<typename _CharT>
    02556     inline bool
    02557     isspace(_CharT __c, const locale& __loc)
    02558     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c); }
    02559
    02560   /// Convenience interface to ctype.is(ctype_base::print, __c).
    02561   template<typename _CharT>
    02562     inline bool
    02563     isprint(_CharT __c, const locale& __loc)
    02564     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c); }
    02565
    02566   /// Convenience interface to ctype.is(ctype_base::cntrl, __c).
    02567   template<typename _CharT>
    02568     inline bool
    02569     iscntrl(_CharT __c, const locale& __loc)
    02570     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c); }
    02571
    02572   /// Convenience interface to ctype.is(ctype_base::upper, __c).
    02573   template<typename _CharT>
    02574     inline bool
    02575     isupper(_CharT __c, const locale& __loc)
    02576     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c); }
    02577
    02578   /// Convenience interface to ctype.is(ctype_base::lower, __c).
    02579   template<typename _CharT>
    02580     inline bool
    02581     islower(_CharT __c, const locale& __loc)
    02582     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c); }
    02583
    02584   /// Convenience interface to ctype.is(ctype_base::alpha, __c).
    02585   template<typename _CharT>
    02586     inline bool
    02587     isalpha(_CharT __c, const locale& __loc)
    02588     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c); }
    02589
    02590   /// Convenience interface to ctype.is(ctype_base::digit, __c).
    02591   template<typename _CharT>
    02592     inline bool
    02593     isdigit(_CharT __c, const locale& __loc)
    02594     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c); }
    02595
    02596   /// Convenience interface to ctype.is(ctype_base::punct, __c).
    02597   template<typename _CharT>
    02598     inline bool
    02599     ispunct(_CharT __c, const locale& __loc)
    02600     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c); }
    02601
    02602   /// Convenience interface to ctype.is(ctype_base::xdigit, __c).
    02603   template<typename _CharT>
    02604     inline bool
    02605     isxdigit(_CharT __c, const locale& __loc)
    02606     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c); }
    02607
    02608   /// Convenience interface to ctype.is(ctype_base::alnum, __c).
    02609   template<typename _CharT>
    02610     inline bool
    02611     isalnum(_CharT __c, const locale& __loc)
    02612     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c); }
    02613
    02614   /// Convenience interface to ctype.is(ctype_base::graph, __c).
    02615   template<typename _CharT>
    02616     inline bool
    02617     isgraph(_CharT __c, const locale& __loc)
    02618     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c); }
    02619
    02620   /// Convenience interface to ctype.toupper(__c).
    02621   template<typename _CharT>
    02622     inline _CharT
    02623     toupper(_CharT __c, const locale& __loc)
    02624     { return use_facet<ctype<_CharT> >(__loc).toupper(__c); }
    02625
    02626   /// Convenience interface to ctype.tolower(__c).
    02627   template<typename _CharT>
    02628     inline _CharT
    02629     tolower(_CharT __c, const locale& __loc)
    02630     { return use_facet<ctype<_CharT> >(__loc).tolower(__c); }
    02631
    02632 _GLIBCXX_END_NAMESPACE
    02633
    02634 #ifndef _GLIBCXX_EXPORT_TEMPLATE
    02635 # include <bits/locale_facets.tcc>
    02636 #endif
    02637
    02638 #endif