00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00040 #ifndef _LOCALE_FACETS_H
00041 #define _LOCALE_FACETS_H 1
00042
00043 #pragma GCC system_header
00044
00045 #include <ctime>
00046 #include <cwctype>
00047 #include <iosfwd>
00048 #include <bits/ios_base.h>
00049 #include <streambuf>
00050
00051 namespace std
00052 {
00053
00054 #ifdef _GLIBCXX_USE_WCHAR_T
00055 # define _GLIBCXX_NUM_FACETS 28
00056 #else
00057 # define _GLIBCXX_NUM_FACETS 14
00058 #endif
00059
00060
00061
00062
00063 template<typename _Tv>
00064 void
00065 __convert_to_v(const char* __in, _Tv& __out, ios_base::iostate& __err,
00066 const __c_locale& __cloc);
00067
00068
00069 template<>
00070 void
00071 __convert_to_v(const char*, float&, ios_base::iostate&,
00072 const __c_locale&);
00073
00074 template<>
00075 void
00076 __convert_to_v(const char*, double&, ios_base::iostate&,
00077 const __c_locale&);
00078
00079 template<>
00080 void
00081 __convert_to_v(const char*, long double&, ios_base::iostate&,
00082 const __c_locale&);
00083
00084
00085
00086 template<typename _CharT, typename _Traits>
00087 struct __pad
00088 {
00089 static void
00090 _S_pad(ios_base& __io, _CharT __fill, _CharT* __news,
00091 const _CharT* __olds, const streamsize __newlen,
00092 const streamsize __oldlen, const bool __num);
00093 };
00094
00095
00096
00097
00098
00099
00100 template<typename _CharT>
00101 _CharT*
00102 __add_grouping(_CharT* __s, _CharT __sep,
00103 const char* __gbeg, size_t __gsize,
00104 const _CharT* __first, const _CharT* __last);
00105
00106
00107
00108
00109 template<typename _CharT>
00110 inline
00111 ostreambuf_iterator<_CharT>
00112 __write(ostreambuf_iterator<_CharT> __s, const _CharT* __ws, int __len)
00113 {
00114 __s._M_put(__ws, __len);
00115 return __s;
00116 }
00117
00118
00119 template<typename _CharT, typename _OutIter>
00120 inline
00121 _OutIter
00122 __write(_OutIter __s, const _CharT* __ws, int __len)
00123 {
00124 for (int __j = 0; __j < __len; __j++, ++__s)
00125 *__s = __ws[__j];
00126 return __s;
00127 }
00128
00129
00130
00131
00132 #include <bits/ctype_base.h>
00133
00134
00144 template<typename _CharT>
00145 class __ctype_abstract_base : public locale::facet, public ctype_base
00146 {
00147 public:
00148
00150 typedef _CharT char_type;
00151
00162 bool
00163 is(mask __m, char_type __c) const
00164 { return this->do_is(__m, __c); }
00165
00179 const char_type*
00180 is(const char_type *__lo, const char_type *__hi, mask *__vec) const
00181 { return this->do_is(__lo, __hi, __vec); }
00182
00195 const char_type*
00196 scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
00197 { return this->do_scan_is(__m, __lo, __hi); }
00198
00211 const char_type*
00212 scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
00213 { return this->do_scan_not(__m, __lo, __hi); }
00214
00225 char_type
00226 toupper(char_type __c) const
00227 { return this->do_toupper(__c); }
00228
00240 const char_type*
00241 toupper(char_type *__lo, const char_type* __hi) const
00242 { return this->do_toupper(__lo, __hi); }
00243
00254 char_type
00255 tolower(char_type __c) const
00256 { return this->do_tolower(__c); }
00257
00269 const char_type*
00270 tolower(char_type* __lo, const char_type* __hi) const
00271 { return this->do_tolower(__lo, __hi); }
00272
00286 char_type
00287 widen(char __c) const
00288 { return this->do_widen(__c); }
00289
00305 const char*
00306 widen(const char* __lo, const char* __hi, char_type* __to) const
00307 { return this->do_widen(__lo, __hi, __to); }
00308
00324 char
00325 narrow(char_type __c, char __dfault) const
00326 { return this->do_narrow(__c, __dfault); }
00327
00346 const char_type*
00347 narrow(const char_type* __lo, const char_type* __hi,
00348 char __dfault, char *__to) const
00349 { return this->do_narrow(__lo, __hi, __dfault, __to); }
00350
00351 protected:
00352 explicit
00353 __ctype_abstract_base(size_t __refs = 0): facet(__refs) { }
00354
00355 virtual
00356 ~__ctype_abstract_base() { }
00357
00371 virtual bool
00372 do_is(mask __m, char_type __c) const = 0;
00373
00390 virtual const char_type*
00391 do_is(const char_type* __lo, const char_type* __hi,
00392 mask* __vec) const = 0;
00393
00409 virtual const char_type*
00410 do_scan_is(mask __m, const char_type* __lo,
00411 const char_type* __hi) const = 0;
00412
00428 virtual const char_type*
00429 do_scan_not(mask __m, const char_type* __lo,
00430 const char_type* __hi) const = 0;
00431
00446 virtual char_type
00447 do_toupper(char_type) const = 0;
00448
00463 virtual const char_type*
00464 do_toupper(char_type* __lo, const char_type* __hi) const = 0;
00465
00479 virtual char_type
00480 do_tolower(char_type) const = 0;
00481
00496 virtual const char_type*
00497 do_tolower(char_type* __lo, const char_type* __hi) const = 0;
00498
00515 virtual char_type
00516 do_widen(char) const = 0;
00517
00536 virtual const char*
00537 do_widen(const char* __lo, const char* __hi,
00538 char_type* __dest) const = 0;
00539
00558 virtual char
00559 do_narrow(char_type, char __dfault) const = 0;
00560
00582 virtual const char_type*
00583 do_narrow(const char_type* __lo, const char_type* __hi,
00584 char __dfault, char* __dest) const = 0;
00585 };
00586
00587
00605 template<typename _CharT>
00606 class ctype : public __ctype_abstract_base<_CharT>
00607 {
00608 public:
00609
00610 typedef _CharT char_type;
00611 typedef typename __ctype_abstract_base<_CharT>::mask mask;
00612
00614 static locale::id id;
00615
00616 explicit
00617 ctype(size_t __refs = 0) : __ctype_abstract_base<_CharT>(__refs) { }
00618
00619 protected:
00620 virtual
00621 ~ctype();
00622
00623 virtual bool
00624 do_is(mask __m, char_type __c) const;
00625
00626 virtual const char_type*
00627 do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
00628
00629 virtual const char_type*
00630 do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
00631
00632 virtual const char_type*
00633 do_scan_not(mask __m, const char_type* __lo,
00634 const char_type* __hi) const;
00635
00636 virtual char_type
00637 do_toupper(char_type __c) const;
00638
00639 virtual const char_type*
00640 do_toupper(char_type* __lo, const char_type* __hi) const;
00641
00642 virtual char_type
00643 do_tolower(char_type __c) const;
00644
00645 virtual const char_type*
00646 do_tolower(char_type* __lo, const char_type* __hi) const;
00647
00648 virtual char_type
00649 do_widen(char __c) const;
00650
00651 virtual const char*
00652 do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
00653
00654 virtual char
00655 do_narrow(char_type, char __dfault) const;
00656
00657 virtual const char_type*
00658 do_narrow(const char_type* __lo, const char_type* __hi,
00659 char __dfault, char* __dest) const;
00660 };
00661
00662 template<typename _CharT>
00663 locale::id ctype<_CharT>::id;
00664
00665
00674 template<>
00675 class ctype<char> : public locale::facet, public ctype_base
00676 {
00677 public:
00678
00680 typedef char char_type;
00681
00682 protected:
00683
00684 __c_locale _M_c_locale_ctype;
00685 bool _M_del;
00686 __to_type _M_toupper;
00687 __to_type _M_tolower;
00688 const mask* _M_table;
00689 mutable char _M_widen_ok;
00690 mutable char _M_widen[1 + static_cast<unsigned char>(-1)];
00691 mutable char _M_narrow[1 + static_cast<unsigned char>(-1)];
00692 mutable char _M_narrow_ok;
00693
00694
00695 public:
00697 static locale::id id;
00699 static const size_t table_size = 1 + static_cast<unsigned char>(-1);
00700
00711 explicit
00712 ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0);
00713
00724 explicit
00725 ctype(__c_locale __cloc, const mask* __table = 0, bool __del = false,
00726 size_t __refs = 0);
00727
00737 inline bool
00738 is(mask __m, char __c) const;
00739
00752 inline const char*
00753 is(const char* __lo, const char* __hi, mask* __vec) const;
00754
00766 inline const char*
00767 scan_is(mask __m, const char* __lo, const char* __hi) const;
00768
00780 inline const char*
00781 scan_not(mask __m, const char* __lo, const char* __hi) const;
00782
00795 char_type
00796 toupper(char_type __c) const
00797 { return this->do_toupper(__c); }
00798
00812 const char_type*
00813 toupper(char_type *__lo, const char_type* __hi) const
00814 { return this->do_toupper(__lo, __hi); }
00815
00828 char_type
00829 tolower(char_type __c) const
00830 { return this->do_tolower(__c); }
00831
00845 const char_type*
00846 tolower(char_type* __lo, const char_type* __hi) const
00847 { return this->do_tolower(__lo, __hi); }
00848
00865 char_type
00866 widen(char __c) const
00867 {
00868 if (_M_widen_ok)
00869 return _M_widen[static_cast<unsigned char>(__c)];
00870 this->_M_widen_init();
00871 return this->do_widen(__c);
00872 }
00873
00892 const char*
00893 widen(const char* __lo, const char* __hi, char_type* __to) const
00894 {
00895 if (_M_widen_ok == 1)
00896 {
00897 memcpy(__to, __lo, __hi - __lo);
00898 return __hi;
00899 }
00900 if (!_M_widen_ok)
00901 _M_widen_init();
00902 return this->do_widen(__lo, __hi, __to);
00903 }
00904
00923 char
00924 narrow(char_type __c, char __dfault) const
00925 {
00926 if (_M_narrow[static_cast<unsigned char>(__c)])
00927 return _M_narrow[static_cast<unsigned char>(__c)];
00928 const char __t = do_narrow(__c, __dfault);
00929 if (__t != __dfault)
00930 _M_narrow[static_cast<unsigned char>(__c)] = __t;
00931 return __t;
00932 }
00933
00956 const char_type*
00957 narrow(const char_type* __lo, const char_type* __hi,
00958 char __dfault, char *__to) const
00959 {
00960 if (__builtin_expect(_M_narrow_ok == 1, true))
00961 {
00962 memcpy(__to, __lo, __hi - __lo);
00963 return __hi;
00964 }
00965 if (!_M_narrow_ok)
00966 _M_narrow_init();
00967 return this->do_narrow(__lo, __hi, __dfault, __to);
00968 }
00969
00970 protected:
00973 const mask*
00974 table() const throw()
00975 { return _M_table; }
00976
00978 static const mask*
00979 classic_table() throw();
00980
00987 virtual
00988 ~ctype();
00989
01003 virtual char_type
01004 do_toupper(char_type) const;
01005
01020 virtual const char_type*
01021 do_toupper(char_type* __lo, const char_type* __hi) const;
01022
01036 virtual char_type
01037 do_tolower(char_type) const;
01038
01053 virtual const char_type*
01054 do_tolower(char_type* __lo, const char_type* __hi) const;
01055
01073 virtual char_type
01074 do_widen(char __c) const
01075 { return __c; }
01076
01096 virtual const char*
01097 do_widen(const char* __lo, const char* __hi, char_type* __dest) const
01098 {
01099 memcpy(__dest, __lo, __hi - __lo);
01100 return __hi;
01101 }
01102
01122 virtual char
01123 do_narrow(char_type __c, char) const
01124 { return __c; }
01125
01148 virtual const char_type*
01149 do_narrow(const char_type* __lo, const char_type* __hi,
01150 char, char* __dest) const
01151 {
01152 memcpy(__dest, __lo, __hi - __lo);
01153 return __hi;
01154 }
01155
01156 private:
01157
01158 void _M_widen_init() const
01159 {
01160 char __tmp[sizeof(_M_widen)];
01161 for (size_t __i = 0; __i < sizeof(_M_widen); ++__i)
01162 __tmp[__i] = __i;
01163 do_widen(__tmp, __tmp + sizeof(__tmp), _M_widen);
01164
01165 _M_widen_ok = 1;
01166
01167 if (memcmp(__tmp, _M_widen, sizeof(_M_widen)))
01168 _M_widen_ok = 2;
01169 }
01170
01171
01172
01173
01174 void _M_narrow_init() const
01175 {
01176 char __tmp[sizeof(_M_narrow)];
01177 for (size_t __i = 0; __i < sizeof(_M_narrow); ++__i)
01178 __tmp[__i] = __i;
01179 do_narrow(__tmp, __tmp + sizeof(__tmp), 0, _M_narrow);
01180
01181 _M_narrow_ok = 1;
01182 if (memcmp(__tmp, _M_narrow, sizeof(_M_narrow)))
01183 _M_narrow_ok = 2;
01184 else
01185 {
01186
01187
01188 char __c;
01189 do_narrow(__tmp, __tmp + 1, 1, &__c);
01190 if (__c == 1)
01191 _M_narrow_ok = 2;
01192 }
01193 }
01194 };
01195
01196 template<>
01197 const ctype<char>&
01198 use_facet<ctype<char> >(const locale& __loc);
01199
01200 #ifdef _GLIBCXX_USE_WCHAR_T
01201
01212 template<>
01213 class ctype<wchar_t> : public __ctype_abstract_base<wchar_t>
01214 {
01215 public:
01216
01218 typedef wchar_t char_type;
01219 typedef wctype_t __wmask_type;
01220
01221 protected:
01222 __c_locale _M_c_locale_ctype;
01223
01224
01225 bool _M_narrow_ok;
01226 char _M_narrow[128];
01227 wint_t _M_widen[1 + static_cast<unsigned char>(-1)];
01228
01229
01230 mask _M_bit[16];
01231 __wmask_type _M_wmask[16];
01232
01233 public:
01234
01236 static locale::id id;
01237
01245 explicit
01246 ctype(size_t __refs = 0);
01247
01256 explicit
01257 ctype(__c_locale __cloc, size_t __refs = 0);
01258
01259 protected:
01260 __wmask_type
01261 _M_convert_to_wmask(const mask __m) const;
01262
01264 virtual
01265 ~ctype();
01266
01280 virtual bool
01281 do_is(mask __m, char_type __c) const;
01282
01299 virtual const char_type*
01300 do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
01301
01317 virtual const char_type*
01318 do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
01319
01335 virtual const char_type*
01336 do_scan_not(mask __m, const char_type* __lo,
01337 const char_type* __hi) const;
01338
01352 virtual char_type
01353 do_toupper(char_type) const;
01354
01369 virtual const char_type*
01370 do_toupper(char_type* __lo, const char_type* __hi) const;
01371
01385 virtual char_type
01386 do_tolower(char_type) const;
01387
01402 virtual const char_type*
01403 do_tolower(char_type* __lo, const char_type* __hi) const;
01404
01422 virtual char_type
01423 do_widen(char) const;
01424
01444 virtual const char*
01445 do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
01446
01467 virtual char
01468 do_narrow(char_type, char __dfault) const;
01469
01493 virtual const char_type*
01494 do_narrow(const char_type* __lo, const char_type* __hi,
01495 char __dfault, char* __dest) const;
01496
01497
01498 void
01499 _M_initialize_ctype();
01500 };
01501
01502 template<>
01503 const ctype<wchar_t>&
01504 use_facet<ctype<wchar_t> >(const locale& __loc);
01505 #endif //_GLIBCXX_USE_WCHAR_T
01506
01507
01508 #include <bits/ctype_inline.h>
01509
01511 template<typename _CharT>
01512 class ctype_byname : public ctype<_CharT>
01513 {
01514 public:
01515 typedef _CharT char_type;
01516
01517 explicit
01518 ctype_byname(const char* __s, size_t __refs = 0);
01519
01520 protected:
01521 virtual
01522 ~ctype_byname() { };
01523 };
01524
01526 template<>
01527 ctype_byname<char>::ctype_byname(const char*, size_t refs);
01528
01529 template<>
01530 ctype_byname<wchar_t>::ctype_byname(const char*, size_t refs);
01531
01532
01533 #include <bits/codecvt.h>
01534
01535
01536 class __num_base
01537 {
01538 public:
01539
01540
01541 enum
01542 {
01543 _S_ominus,
01544 _S_oplus,
01545 _S_ox,
01546 _S_oX,
01547 _S_odigits,
01548 _S_odigits_end = _S_odigits + 16,
01549 _S_oudigits = _S_odigits_end,
01550 _S_oudigits_end = _S_oudigits + 16,
01551 _S_oe = _S_odigits + 14,
01552 _S_oE = _S_oudigits + 14,
01553 _S_oend = _S_oudigits_end
01554 };
01555
01556
01557
01558
01559
01560
01561 static const char* _S_atoms_out;
01562
01563
01564
01565 static const char* _S_atoms_in;
01566
01567 enum
01568 {
01569 _S_iminus,
01570 _S_iplus,
01571 _S_ix,
01572 _S_iX,
01573 _S_izero,
01574 _S_ie = _S_izero + 14,
01575 _S_iE = _S_izero + 20,
01576 _S_iend = 26
01577 };
01578
01579
01580
01581 static void
01582 _S_format_float(const ios_base& __io, char* __fptr, char __mod);
01583 };
01584
01585 template<typename _CharT>
01586 struct __numpunct_cache : public locale::facet
01587 {
01588 const char* _M_grouping;
01589 size_t _M_grouping_size;
01590 bool _M_use_grouping;
01591 const _CharT* _M_truename;
01592 size_t _M_truename_size;
01593 const _CharT* _M_falsename;
01594 size_t _M_falsename_size;
01595 _CharT _M_decimal_point;
01596 _CharT _M_thousands_sep;
01597
01598
01599
01600
01601
01602 _CharT _M_atoms_out[__num_base::_S_oend];
01603
01604
01605
01606
01607
01608 _CharT _M_atoms_in[__num_base::_S_iend];
01609
01610 bool _M_allocated;
01611
01612 __numpunct_cache(size_t __refs = 0) : facet(__refs),
01613 _M_grouping(NULL), _M_grouping_size(0), _M_use_grouping(false),
01614 _M_truename(NULL), _M_truename_size(0), _M_falsename(NULL),
01615 _M_falsename_size(0), _M_decimal_point(_CharT()),
01616 _M_thousands_sep(_CharT()), _M_allocated(false)
01617 { }
01618
01619 ~__numpunct_cache();
01620
01621 void
01622 _M_cache(const locale& __loc);
01623
01624 private:
01625 __numpunct_cache&
01626 operator=(const __numpunct_cache&);
01627
01628 explicit
01629 __numpunct_cache(const __numpunct_cache&);
01630 };
01631
01632 template<typename _CharT>
01633 __numpunct_cache<_CharT>::~__numpunct_cache()
01634 {
01635 if (_M_allocated)
01636 {
01637 delete [] _M_grouping;
01638 delete [] _M_truename;
01639 delete [] _M_falsename;
01640 }
01641 }
01642
01656 template<typename _CharT>
01657 class numpunct : public locale::facet
01658 {
01659 public:
01660
01662
01663 typedef _CharT char_type;
01664 typedef basic_string<_CharT> string_type;
01666 typedef __numpunct_cache<_CharT> __cache_type;
01667
01668 protected:
01669 __cache_type* _M_data;
01670
01671 public:
01673 static locale::id id;
01674
01680 explicit
01681 numpunct(size_t __refs = 0) : facet(__refs), _M_data(NULL)
01682 { _M_initialize_numpunct(); }
01683
01693 explicit
01694 numpunct(__cache_type* __cache, size_t __refs = 0)
01695 : facet(__refs), _M_data(__cache)
01696 { _M_initialize_numpunct(); }
01697
01707 explicit
01708 numpunct(__c_locale __cloc, size_t __refs = 0)
01709 : facet(__refs), _M_data(NULL)
01710 { _M_initialize_numpunct(__cloc); }
01711
01721 char_type
01722 decimal_point() const
01723 { return this->do_decimal_point(); }
01724
01734 char_type
01735 thousands_sep() const
01736 { return this->do_thousands_sep(); }
01737
01765 string
01766 grouping() const
01767 { return this->do_grouping(); }
01768
01778 string_type
01779 truename() const
01780 { return this->do_truename(); }
01781
01791 string_type
01792 falsename() const
01793 { return this->do_falsename(); }
01794
01795 protected:
01797 virtual
01798 ~numpunct();
01799
01808 virtual char_type
01809 do_decimal_point() const
01810 { return _M_data->_M_decimal_point; }
01811
01820 virtual char_type
01821 do_thousands_sep() const
01822 { return _M_data->_M_thousands_sep; }
01823
01833 virtual string
01834 do_grouping() const
01835 { return _M_data->_M_grouping; }
01836
01846 virtual string_type
01847 do_truename() const
01848 { return _M_data->_M_truename; }
01849
01859 virtual string_type
01860 do_falsename() const
01861 { return _M_data->_M_falsename; }
01862
01863
01864 void
01865 _M_initialize_numpunct(__c_locale __cloc = NULL);
01866 };
01867
01868 template<typename _CharT>
01869 locale::id numpunct<_CharT>::id;
01870
01871 template<>
01872 numpunct<char>::~numpunct();
01873
01874 template<>
01875 void
01876 numpunct<char>::_M_initialize_numpunct(__c_locale __cloc);
01877
01878 #ifdef _GLIBCXX_USE_WCHAR_T
01879 template<>
01880 numpunct<wchar_t>::~numpunct();
01881
01882 template<>
01883 void
01884 numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc);
01885 #endif
01886
01888 template<typename _CharT>
01889 class numpunct_byname : public numpunct<_CharT>
01890 {
01891 public:
01892 typedef _CharT char_type;
01893 typedef basic_string<_CharT> string_type;
01894
01895 explicit
01896 numpunct_byname(const char* __s, size_t __refs = 0)
01897 : numpunct<_CharT>(__refs)
01898 {
01899 if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
01900 {
01901 __c_locale __tmp;
01902 this->_S_create_c_locale(__tmp, __s);
01903 this->_M_initialize_numpunct(__tmp);
01904 this->_S_destroy_c_locale(__tmp);
01905 }
01906 }
01907
01908 protected:
01909 virtual
01910 ~numpunct_byname() { }
01911 };
01912
01913 _GLIBCXX_BEGIN_LDBL_NAMESPACE
01926 template<typename _CharT, typename _InIter>
01927 class num_get : public locale::facet
01928 {
01929 public:
01930
01932
01933 typedef _CharT char_type;
01934 typedef _InIter iter_type;
01936
01938 static locale::id id;
01939
01947 explicit
01948 num_get(size_t __refs = 0) : facet(__refs) { }
01949
01973 iter_type
01974 get(iter_type __in, iter_type __end, ios_base& __io,
01975 ios_base::iostate& __err, bool& __v) const
01976 { return this->do_get(__in, __end, __io, __err, __v); }
01977
01979
02009 iter_type
02010 get(iter_type __in, iter_type __end, ios_base& __io,
02011 ios_base::iostate& __err, long& __v) const
02012 { return this->do_get(__in, __end, __io, __err, __v); }
02013
02014 iter_type
02015 get(iter_type __in, iter_type __end, ios_base& __io,
02016 ios_base::iostate& __err, unsigned short& __v) const
02017 { return this->do_get(__in, __end, __io, __err, __v); }
02018
02019 iter_type
02020 get(iter_type __in, iter_type __end, ios_base& __io,
02021 ios_base::iostate& __err, unsigned int& __v) const
02022 { return this->do_get(__in, __end, __io, __err, __v); }
02023
02024 iter_type
02025 get(iter_type __in, iter_type __end, ios_base& __io,
02026 ios_base::iostate& __err, unsigned long& __v) const
02027 { return this->do_get(__in, __end, __io, __err, __v); }
02028
02029 #ifdef _GLIBCXX_USE_LONG_LONG
02030 iter_type
02031 get(iter_type __in, iter_type __end, ios_base& __io,
02032 ios_base::iostate& __err, long long& __v) const
02033 { return this->do_get(__in, __end, __io, __err, __v); }
02034
02035 iter_type
02036 get(iter_type __in, iter_type __end, ios_base& __io,
02037 ios_base::iostate& __err, unsigned long long& __v) const
02038 { return this->do_get(__in, __end, __io, __err, __v); }
02039 #endif
02040
02041
02043
02068 iter_type
02069 get(iter_type __in, iter_type __end, ios_base& __io,
02070 ios_base::iostate& __err, float& __v) const
02071 { return this->do_get(__in, __end, __io, __err, __v); }
02072
02073 iter_type
02074 get(iter_type __in, iter_type __end, ios_base& __io,
02075 ios_base::iostate& __err, double& __v) const
02076 { return this->do_get(__in, __end, __io, __err, __v); }
02077
02078 iter_type
02079 get(iter_type __in, iter_type __end, ios_base& __io,
02080 ios_base::iostate& __err, long double& __v) const
02081 { return this->do_get(__in, __end, __io, __err, __v); }
02083
02110 iter_type
02111 get(iter_type __in, iter_type __end, ios_base& __io,
02112 ios_base::iostate& __err, void*& __v) const
02113 { return this->do_get(__in, __end, __io, __err, __v); }
02114
02115 protected:
02117 virtual ~num_get() { }
02118
02119 iter_type
02120 _M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&,
02121 string& __xtrc) const;
02122
02123 template<typename _ValueT>
02124 iter_type
02125 _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&,
02126 _ValueT& __v) const;
02127
02129
02143 virtual iter_type
02144 do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
02145
02146
02147 virtual iter_type
02148 do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, long&) const;
02149
02150 virtual iter_type
02151 do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02152 unsigned short&) const;
02153
02154 virtual iter_type
02155 do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02156 unsigned int&) const;
02157
02158 virtual iter_type
02159 do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02160 unsigned long&) const;
02161
02162 #ifdef _GLIBCXX_USE_LONG_LONG
02163 virtual iter_type
02164 do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02165 long long&) const;
02166
02167 virtual iter_type
02168 do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02169 unsigned long long&) const;
02170 #endif
02171
02172 virtual iter_type
02173 do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02174 float&) const;
02175
02176 virtual iter_type
02177 do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02178 double&) const;
02179
02180
02181 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
02182 virtual iter_type
02183 __do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02184 double&) const;
02185 #else
02186 virtual iter_type
02187 do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02188 long double&) const;
02189 #endif
02190
02191 virtual iter_type
02192 do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02193 void*&) const;
02194
02195
02196 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
02197 virtual iter_type
02198 do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err,
02199 long double&) const;
02200 #endif
02201
02202 };
02203
02204 template<typename _CharT, typename _InIter>
02205 locale::id num_get<_CharT, _InIter>::id;
02206
02207
02219 template<typename _CharT, typename _OutIter>
02220 class num_put : public locale::facet
02221 {
02222 public:
02223
02225
02226 typedef _CharT char_type;
02227 typedef _OutIter iter_type;
02229
02231 static locale::id id;
02232
02240 explicit
02241 num_put(size_t __refs = 0) : facet(__refs) { }
02242
02258 iter_type
02259 put(iter_type __s, ios_base& __f, char_type __fill, bool __v) const
02260 { return this->do_put(__s, __f, __fill, __v); }
02261
02263
02300 iter_type
02301 put(iter_type __s, ios_base& __f, char_type __fill, long __v) const
02302 { return this->do_put(__s, __f, __fill, __v); }
02303
02304 iter_type
02305 put(iter_type __s, ios_base& __f, char_type __fill,
02306 unsigned long __v) const
02307 { return this->do_put(__s, __f, __fill, __v); }
02308
02309 #ifdef _GLIBCXX_USE_LONG_LONG
02310 iter_type
02311 put(iter_type __s, ios_base& __f, char_type __fill, long long __v) const
02312 { return this->do_put(__s, __f, __fill, __v); }
02313
02314 iter_type
02315 put(iter_type __s, ios_base& __f, char_type __fill,
02316 unsigned long long __v) const
02317 { return this->do_put(__s, __f, __fill, __v); }
02318 #endif
02319
02320
02322
02363 iter_type
02364 put(iter_type __s, ios_base& __f, char_type __fill, double __v) const
02365 { return this->do_put(__s, __f, __fill, __v); }
02366
02367 iter_type
02368 put(iter_type __s, ios_base& __f, char_type __fill,
02369 long double __v) const
02370 { return this->do_put(__s, __f, __fill, __v); }
02372
02388 iter_type
02389 put(iter_type __s, ios_base& __f, char_type __fill,
02390 const void* __v) const
02391 { return this->do_put(__s, __f, __fill, __v); }
02392
02393 protected:
02394 template<typename _ValueT>
02395 iter_type
02396 _M_insert_float(iter_type, ios_base& __io, char_type __fill,
02397 char __mod, _ValueT __v) const;
02398
02399 void
02400 _M_group_float(const char* __grouping, size_t __grouping_size,
02401 char_type __sep, const char_type* __p, char_type* __new,
02402 char_type* __cs, int& __len) const;
02403
02404 template<typename _ValueT>
02405 iter_type
02406 _M_insert_int(iter_type, ios_base& __io, char_type __fill,
02407 _ValueT __v) const;
02408
02409 void
02410 _M_group_int(const char* __grouping, size_t __grouping_size,
02411 char_type __sep, ios_base& __io, char_type* __new,
02412 char_type* __cs, int& __len) const;
02413
02414 void
02415 _M_pad(char_type __fill, streamsize __w, ios_base& __io,
02416 char_type* __new, const char_type* __cs, int& __len) const;
02417
02419 virtual
02420 ~num_put() { };
02421
02423
02436 virtual iter_type
02437 do_put(iter_type, ios_base&, char_type __fill, bool __v) const;
02438
02439 virtual iter_type
02440 do_put(iter_type, ios_base&, char_type __fill, long __v) const;
02441
02442 virtual iter_type
02443 do_put(iter_type, ios_base&, char_type __fill, unsigned long) const;
02444
02445 #ifdef _GLIBCXX_USE_LONG_LONG
02446 virtual iter_type
02447 do_put(iter_type, ios_base&, char_type __fill, long long __v) const;
02448
02449 virtual iter_type
02450 do_put(iter_type, ios_base&, char_type __fill, unsigned long long) const;
02451 #endif
02452
02453 virtual iter_type
02454 do_put(iter_type, ios_base&, char_type __fill, double __v) const;
02455
02456
02457 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
02458 virtual iter_type
02459 __do_put(iter_type, ios_base&, char_type __fill, double __v) const;
02460 #else
02461 virtual iter_type
02462 do_put(iter_type, ios_base&, char_type __fill, long double __v) const;
02463 #endif
02464
02465 virtual iter_type
02466 do_put(iter_type, ios_base&, char_type __fill, const void* __v) const;
02467
02468
02469 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
02470 virtual iter_type
02471 do_put(iter_type, ios_base&, char_type __fill, long double __v) const;
02472 #endif
02473
02474 };
02475
02476 template <typename _CharT, typename _OutIter>
02477 locale::id num_put<_CharT, _OutIter>::id;
02478
02479 _GLIBCXX_END_LDBL_NAMESPACE
02480
02493 template<typename _CharT>
02494 class collate : public locale::facet
02495 {
02496 public:
02497
02499
02500 typedef _CharT char_type;
02501 typedef basic_string<_CharT> string_type;
02503
02504 protected:
02505
02506
02507 __c_locale _M_c_locale_collate;
02508
02509 public:
02511 static locale::id id;
02512
02520 explicit
02521 collate(size_t __refs = 0)
02522 : facet(__refs), _M_c_locale_collate(_S_get_c_locale())
02523 { }
02524
02534 explicit
02535 collate(__c_locale __cloc, size_t __refs = 0)
02536 : facet(__refs), _M_c_locale_collate(_S_clone_c_locale(__cloc))
02537 { }
02538
02551 int
02552 compare(const _CharT* __lo1, const _CharT* __hi1,
02553 const _CharT* __lo2, const _CharT* __hi2) const
02554 { return this->do_compare(__lo1, __hi1, __lo2, __hi2); }
02555
02570 string_type
02571 transform(const _CharT* __lo, const _CharT* __hi) const
02572 { return this->do_transform(__lo, __hi); }
02573
02584 long
02585 hash(const _CharT* __lo, const _CharT* __hi) const
02586 { return this->do_hash(__lo, __hi); }
02587
02588
02589 int
02590 _M_compare(const _CharT*, const _CharT*) const;
02591
02592 size_t
02593 _M_transform(_CharT*, const _CharT*, size_t) const;
02594
02595 protected:
02597 virtual
02598 ~collate()
02599 { _S_destroy_c_locale(_M_c_locale_collate); }
02600
02613 virtual int
02614 do_compare(const _CharT* __lo1, const _CharT* __hi1,
02615 const _CharT* __lo2, const _CharT* __hi2) const;
02616
02629 virtual string_type
02630 do_transform(const _CharT* __lo, const _CharT* __hi) const;
02631
02642 virtual long
02643 do_hash(const _CharT* __lo, const _CharT* __hi) const;
02644 };
02645
02646 template<typename _CharT>
02647 locale::id collate<_CharT>::id;
02648
02649
02650 template<>
02651 int
02652 collate<char>::_M_compare(const char*, const char*) const;
02653
02654 template<>
02655 size_t
02656 collate<char>::_M_transform(char*, const char*, size_t) const;
02657
02658 #ifdef _GLIBCXX_USE_WCHAR_T
02659 template<>
02660 int
02661 collate<wchar_t>::_M_compare(const wchar_t*, const wchar_t*) const;
02662
02663 template<>
02664 size_t
02665 collate<wchar_t>::_M_transform(wchar_t*, const wchar_t*, size_t) const;
02666 #endif
02667
02669 template<typename _CharT>
02670 class collate_byname : public collate<_CharT>
02671 {
02672 public:
02674
02675 typedef _CharT char_type;
02676 typedef basic_string<_CharT> string_type;
02678
02679 explicit
02680 collate_byname(const char* __s, size_t __refs = 0)
02681 : collate<_CharT>(__refs)
02682 {
02683 if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
02684 {
02685 this->_S_destroy_c_locale(this->_M_c_locale_collate);
02686 this->_S_create_c_locale(this->_M_c_locale_collate, __s);
02687 }
02688 }
02689
02690 protected:
02691 virtual
02692 ~collate_byname() { }
02693 };
02694
02695
02702 class time_base
02703 {
02704 public:
02705 enum dateorder { no_order, dmy, mdy, ymd, ydm };
02706 };
02707
02708 template<typename _CharT>
02709 struct __timepunct_cache : public locale::facet
02710 {
02711
02712 static const _CharT* _S_timezones[14];
02713
02714 const _CharT* _M_date_format;
02715 const _CharT* _M_date_era_format;
02716 const _CharT* _M_time_format;
02717 const _CharT* _M_time_era_format;
02718 const _CharT* _M_date_time_format;
02719 const _CharT* _M_date_time_era_format;
02720 const _CharT* _M_am;
02721 const _CharT* _M_pm;
02722 const _CharT* _M_am_pm_format;
02723
02724
02725 const _CharT* _M_day1;
02726 const _CharT* _M_day2;
02727 const _CharT* _M_day3;
02728 const _CharT* _M_day4;
02729 const _CharT* _M_day5;
02730 const _CharT* _M_day6;
02731 const _CharT* _M_day7;
02732
02733
02734 const _CharT* _M_aday1;
02735 const _CharT* _M_aday2;
02736 const _CharT* _M_aday3;
02737 const _CharT* _M_aday4;
02738 const _CharT* _M_aday5;
02739 const _CharT* _M_aday6;
02740 const _CharT* _M_aday7;
02741
02742
02743 const _CharT* _M_month01;
02744 const _CharT* _M_month02;
02745 const _CharT* _M_month03;
02746 const _CharT* _M_month04;
02747 const _CharT* _M_month05;
02748 const _CharT* _M_month06;
02749 const _CharT* _M_month07;
02750 const _CharT* _M_month08;
02751 const _CharT* _M_month09;
02752 const _CharT* _M_month10;
02753 const _CharT* _M_month11;
02754 const _CharT* _M_month12;
02755
02756
02757 const _CharT* _M_amonth01;
02758 const _CharT* _M_amonth02;
02759 const _CharT* _M_amonth03;
02760 const _CharT* _M_amonth04;
02761 const _CharT* _M_amonth05;
02762 const _CharT* _M_amonth06;
02763 const _CharT* _M_amonth07;
02764 const _CharT* _M_amonth08;
02765 const _CharT* _M_amonth09;
02766 const _CharT* _M_amonth10;
02767 const _CharT* _M_amonth11;
02768 const _CharT* _M_amonth12;
02769
02770 bool _M_allocated;
02771
02772 __timepunct_cache(size_t __refs = 0) : facet(__refs),
02773 _M_date_format(NULL), _M_date_era_format(NULL), _M_time_format(NULL),
02774 _M_time_era_format(NULL), _M_date_time_format(NULL),
02775 _M_date_time_era_format(NULL), _M_am(NULL), _M_pm(NULL),
02776 _M_am_pm_format(NULL), _M_day1(NULL), _M_day2(NULL), _M_day3(NULL),
02777 _M_day4(NULL), _M_day5(NULL), _M_day6(NULL), _M_day7(NULL),
02778 _M_aday1(NULL), _M_aday2(NULL), _M_aday3(NULL), _M_aday4(NULL),
02779 _M_aday5(NULL), _M_aday6(NULL), _M_aday7(NULL), _M_month01(NULL),
02780 _M_month02(NULL), _M_month03(NULL), _M_month04(NULL), _M_month05(NULL),
02781 _M_month06(NULL), _M_month07(NULL), _M_month08(NULL), _M_month09(NULL),
02782 _M_month10(NULL), _M_month11(NULL), _M_month12(NULL), _M_amonth01(NULL),
02783 _M_amonth02(NULL), _M_amonth03(NULL), _M_amonth04(NULL),
02784 _M_amonth05(NULL), _M_amonth06(NULL), _M_amonth07(NULL),
02785 _M_amonth08(NULL), _M_amonth09(NULL), _M_amonth10(NULL),
02786 _M_amonth11(NULL), _M_amonth12(NULL), _M_allocated(false)
02787 { }
02788
02789 ~__timepunct_cache();
02790
02791 void
02792 _M_cache(const locale& __loc);
02793
02794 private:
02795 __timepunct_cache&
02796 operator=(const __timepunct_cache&);
02797
02798 explicit
02799 __timepunct_cache(const __timepunct_cache&);
02800 };
02801
02802 template<typename _CharT>
02803 __timepunct_cache<_CharT>::~__timepunct_cache()
02804 {
02805 if (_M_allocated)
02806 {
02807
02808 }
02809 }
02810
02811
02812 template<>
02813 const char*
02814 __timepunct_cache<char>::_S_timezones[14];
02815
02816 #ifdef _GLIBCXX_USE_WCHAR_T
02817 template<>
02818 const wchar_t*
02819 __timepunct_cache<wchar_t>::_S_timezones[14];
02820 #endif
02821
02822
02823 template<typename _CharT>
02824 const _CharT* __timepunct_cache<_CharT>::_S_timezones[14];
02825
02826 template<typename _CharT>
02827 class __timepunct : public locale::facet
02828 {
02829 public:
02830
02831 typedef _CharT __char_type;
02832 typedef basic_string<_CharT> __string_type;
02833 typedef __timepunct_cache<_CharT> __cache_type;
02834
02835 protected:
02836 __cache_type* _M_data;
02837 __c_locale _M_c_locale_timepunct;
02838 const char* _M_name_timepunct;
02839
02840 public:
02842 static locale::id id;
02843
02844 explicit
02845 __timepunct(size_t __refs = 0);
02846
02847 explicit
02848 __timepunct(__cache_type* __cache, size_t __refs = 0);
02849
02860 explicit
02861 __timepunct(__c_locale __cloc, const char* __s, size_t __refs = 0);
02862
02863
02864
02865 void
02866 _M_put(_CharT* __s, size_t __maxlen, const _CharT* __format,
02867 const tm* __tm) const;
02868
02869 void
02870 _M_date_formats(const _CharT** __date) const
02871 {
02872
02873 __date[0] = _M_data->_M_date_format;
02874 __date[1] = _M_data->_M_date_era_format;
02875 }
02876
02877 void
02878 _M_time_formats(const _CharT** __time) const
02879 {
02880
02881 __time[0] = _M_data->_M_time_format;
02882 __time[1] = _M_data->_M_time_era_format;
02883 }
02884
02885 void
02886 _M_date_time_formats(const _CharT** __dt) const
02887 {
02888
02889 __dt[0] = _M_data->_M_date_time_format;
02890 __dt[1] = _M_data->_M_date_time_era_format;
02891 }
02892
02893 void
02894 _M_am_pm_format(const _CharT* __ampm) const
02895 { __ampm = _M_data->_M_am_pm_format; }
02896
02897 void
02898 _M_am_pm(const _CharT** __ampm) const
02899 {
02900 __ampm[0] = _M_data->_M_am;
02901 __ampm[1] = _M_data->_M_pm;
02902 }
02903
02904 void
02905 _M_days(const _CharT** __days) const
02906 {
02907 __days[0] = _M_data->_M_day1;
02908 __days[1] = _M_data->_M_day2;
02909 __days[2] = _M_data->_M_day3;
02910 __days[3] = _M_data->_M_day4;
02911 __days[4] = _M_data->_M_day5;
02912 __days[5] = _M_data->_M_day6;
02913 __days[6] = _M_data->_M_day7;
02914 }
02915
02916 void
02917 _M_days_abbreviated(const _CharT** __days) const
02918 {
02919 __days[0] = _M_data->_M_aday1;
02920 __days[1] = _M_data->_M_aday2;
02921 __days[2] = _M_data->_M_aday3;
02922 __days[3] = _M_data->_M_aday4;
02923 __days[4] = _M_data->_M_aday5;
02924 __days[5] = _M_data->_M_aday6;
02925 __days[6] = _M_data->_M_aday7;
02926 }
02927
02928 void
02929 _M_months(const _CharT** __months) const
02930 {
02931 __months[0] = _M_data->_M_month01;
02932 __months[1] = _M_data->_M_month02;
02933 __months[2] = _M_data->_M_month03;
02934 __months[3] = _M_data->_M_month04;
02935 __months[4] = _M_data->_M_month05;
02936 __months[5] = _M_data->_M_month06;
02937 __months[6] = _M_data->_M_month07;
02938 __months[7] = _M_data->_M_month08;
02939 __months[8] = _M_data->_M_month09;
02940 __months[9] = _M_data->_M_month10;
02941 __months[10] = _M_data->_M_month11;
02942 __months[11] = _M_data->_M_month12;
02943 }
02944
02945 void
02946 _M_months_abbreviated(const _CharT** __months) const
02947 {
02948 __months[0] = _M_data->_M_amonth01;
02949 __months[1] = _M_data->_M_amonth02;
02950 __months[2] = _M_data->_M_amonth03;
02951 __months[3] = _M_data->_M_amonth04;
02952 __months[4] = _M_data->_M_amonth05;
02953 __months[5] = _M_data->_M_amonth06;
02954 __months[6] = _M_data->_M_amonth07;
02955 __months[7] = _M_data->_M_amonth08;
02956 __months[8] = _M_data->_M_amonth09;
02957 __months[9] = _M_data->_M_amonth10;
02958 __months[10] = _M_data->_M_amonth11;
02959 __months[11] = _M_data->_M_amonth12;
02960 }
02961
02962 protected:
02963 virtual
02964 ~__timepunct();
02965
02966
02967 void
02968 _M_initialize_timepunct(__c_locale __cloc = NULL);
02969 };
02970
02971 template<typename _CharT>
02972 locale::id __timepunct<_CharT>::id;
02973
02974
02975 template<>
02976 void
02977 __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc);
02978
02979 template<>
02980 void
02981 __timepunct<char>::_M_put(char*, size_t, const char*, const tm*) const;
02982
02983 #ifdef _GLIBCXX_USE_WCHAR_T
02984 template<>
02985 void
02986 __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc);
02987
02988 template<>
02989 void
02990 __timepunct<wchar_t>::_M_put(wchar_t*, size_t, const wchar_t*,
02991 const tm*) const;
02992 #endif
02993
02994
02995 #include <bits/time_members.h>
02996
03009 template<typename _CharT, typename _InIter>
03010 class time_get : public locale::facet, public time_base
03011 {
03012 public:
03013
03015
03016 typedef _CharT char_type;
03017 typedef _InIter iter_type;
03019 typedef basic_string<_CharT> __string_type;
03020
03022 static locale::id id;
03023
03031 explicit
03032 time_get(size_t __refs = 0)
03033 : facet (__refs) { }
03034
03048 dateorder
03049 date_order() const
03050 { return this->do_date_order(); }
03051
03072 iter_type
03073 get_time(iter_type __beg, iter_type __end, ios_base& __io,
03074 ios_base::iostate& __err, tm* __tm) const
03075 { return this->do_get_time(__beg, __end, __io, __err, __tm); }
03076
03097 iter_type
03098 get_date(iter_type __beg, iter_type __end, ios_base& __io,
03099 ios_base::iostate& __err, tm* __tm) const
03100 { return this->do_get_date(__beg, __end, __io, __err, __tm); }
03101
03125 iter_type
03126 get_weekday(iter_type __beg, iter_type __end, ios_base& __io,
03127 ios_base::iostate& __err, tm* __tm) const
03128 { return this->do_get_weekday(__beg, __end, __io, __err, __tm); }
03129
03154 iter_type
03155 get_monthname(iter_type __beg, iter_type __end, ios_base& __io,
03156 ios_base::iostate& __err, tm* __tm) const
03157 { return this->do_get_monthname(__beg, __end, __io, __err, __tm); }
03158
03180 iter_type
03181 get_year(iter_type __beg, iter_type __end, ios_base& __io,
03182 ios_base::iostate& __err, tm* __tm) const
03183 { return this->do_get_year(__beg, __end, __io, __err, __tm); }
03184
03185 protected:
03187 virtual
03188 ~time_get() { }
03189
03200 virtual dateorder
03201 do_date_order() const;
03202
03218 virtual iter_type
03219 do_get_time(iter_type __beg, iter_type __end, ios_base& __io,
03220 ios_base::iostate& __err, tm* __tm) const;
03221
03237 virtual iter_type
03238 do_get_date(iter_type __beg, iter_type __end, ios_base& __io,
03239 ios_base::iostate& __err, tm* __tm) const;
03240
03256 virtual iter_type
03257 do_get_weekday(iter_type __beg, iter_type __end, ios_base&,
03258 ios_base::iostate& __err, tm* __tm) const;
03259
03275 virtual iter_type
03276 do_get_monthname(iter_type __beg, iter_type __end, ios_base&,
03277 ios_base::iostate& __err, tm* __tm) const;
03278
03294 virtual iter_type
03295 do_get_year(iter_type __beg, iter_type __end, ios_base& __io,
03296 ios_base::iostate& __err, tm* __tm) const;
03297
03298
03299 iter_type
03300 _M_extract_num(iter_type __beg, iter_type __end, int& __member,
03301 int __min, int __max, size_t __len,
03302 ios_base& __io, ios_base::iostate& __err) const;
03303
03304
03305
03306 iter_type
03307 _M_extract_name(iter_type __beg, iter_type __end, int& __member,
03308 const _CharT** __names, size_t __indexlen,
03309 ios_base& __io, ios_base::iostate& __err) const;
03310
03311
03312 iter_type
03313 _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io,
03314 ios_base::iostate& __err, tm* __tm,
03315 const _CharT* __format) const;
03316 };
03317
03318 template<typename _CharT, typename _InIter>
03319 locale::id time_get<_CharT, _InIter>::id;
03320
03322 template<typename _CharT, typename _InIter>
03323 class time_get_byname : public time_get<_CharT, _InIter>
03324 {
03325 public:
03326
03327 typedef _CharT char_type;
03328 typedef _InIter iter_type;
03329
03330 explicit
03331 time_get_byname(const char*, size_t __refs = 0)
03332 : time_get<_CharT, _InIter>(__refs) { }
03333
03334 protected:
03335 virtual
03336 ~time_get_byname() { }
03337 };
03338
03350 template<typename _CharT, typename _OutIter>
03351 class time_put : public locale::facet
03352 {
03353 public:
03354
03356
03357 typedef _CharT char_type;
03358 typedef _OutIter iter_type;
03360
03362 static locale::id id;
03363
03371 explicit
03372 time_put(size_t __refs = 0)
03373 : facet(__refs) { }
03374
03390 iter_type
03391 put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
03392 const _CharT* __beg, const _CharT* __end) const;
03393
03410 iter_type
03411 put(iter_type __s, ios_base& __io, char_type __fill,
03412 const tm* __tm, char __format, char __mod = 0) const
03413 { return this->do_put(__s, __io, __fill, __tm, __format, __mod); }
03414
03415 protected:
03417 virtual
03418 ~time_put()
03419 { }
03420
03437 virtual iter_type
03438 do_put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
03439 char __format, char __mod) const;
03440 };
03441
03442 template<typename _CharT, typename _OutIter>
03443 locale::id time_put<_CharT, _OutIter>::id;
03444
03446 template<typename _CharT, typename _OutIter>
03447 class time_put_byname : public time_put<_CharT, _OutIter>
03448 {
03449 public:
03450
03451 typedef _CharT char_type;
03452 typedef _OutIter iter_type;
03453
03454 explicit
03455 time_put_byname(const char*, size_t __refs = 0)
03456 : time_put<_CharT, _OutIter>(__refs)
03457 { };
03458
03459 protected:
03460 virtual
03461 ~time_put_byname() { }
03462 };
03463
03464
03475 class money_base
03476 {
03477 public:
03478 enum part { none, space, symbol, sign, value };
03479 struct pattern { char field[4]; };
03480
03481 static const pattern _S_default_pattern;
03482
03483 enum
03484 {
03485 _S_minus,
03486 _S_zero,
03487 _S_end = 11
03488 };
03489
03490
03491
03492 static const char* _S_atoms;
03493
03494
03495
03496 static pattern
03497 _S_construct_pattern(char __precedes, char __space, char __posn);
03498 };
03499
03500 template<typename _CharT, bool _Intl>
03501 struct __moneypunct_cache : public locale::facet
03502 {
03503 const char* _M_grouping;
03504 size_t _M_grouping_size;
03505 bool _M_use_grouping;
03506 _CharT _M_decimal_point;
03507 _CharT _M_thousands_sep;
03508 const _CharT* _M_curr_symbol;
03509 size_t _M_curr_symbol_size;
03510 const _CharT* _M_positive_sign;
03511 size_t _M_positive_sign_size;
03512 const _CharT* _M_negative_sign;
03513 size_t _M_negative_sign_size;
03514 int _M_frac_digits;
03515 money_base::pattern _M_pos_format;
03516 money_base::pattern _M_neg_format;
03517
03518
03519
03520
03521 _CharT _M_atoms[money_base::_S_end];
03522
03523 bool _M_allocated;
03524
03525 __moneypunct_cache(size_t __refs = 0) : facet(__refs),
03526 _M_grouping(NULL), _M_grouping_size(0), _M_use_grouping(false),
03527 _M_decimal_point(_CharT()), _M_thousands_sep(_CharT()),
03528 _M_curr_symbol(NULL), _M_curr_symbol_size(0),
03529 _M_positive_sign(NULL), _M_positive_sign_size(0),
03530 _M_negative_sign(NULL), _M_negative_sign_size(0),
03531 _M_frac_digits(0),
03532 _M_pos_format(money_base::pattern()),
03533 _M_neg_format(money_base::pattern()), _M_allocated(false)
03534 { }
03535
03536 ~__moneypunct_cache();
03537
03538 void
03539 _M_cache(const locale& __loc);
03540
03541 private:
03542 __moneypunct_cache&
03543 operator=(const __moneypunct_cache&);
03544
03545 explicit
03546 __moneypunct_cache(const __moneypunct_cache&);
03547 };
03548
03549 template<typename _CharT, bool _Intl>
03550 __moneypunct_cache<_CharT, _Intl>::~__moneypunct_cache()
03551 {
03552 if (_M_allocated)
03553 {
03554 delete [] _M_grouping;
03555 delete [] _M_curr_symbol;
03556 delete [] _M_positive_sign;
03557 delete [] _M_negative_sign;
03558 }
03559 }
03560
03567 template<typename _CharT, bool _Intl>
03568 class moneypunct : public locale::facet, public money_base
03569 {
03570 public:
03571
03573
03574 typedef _CharT char_type;
03575 typedef basic_string<_CharT> string_type;
03577 typedef __moneypunct_cache<_CharT, _Intl> __cache_type;
03578
03579 private:
03580 __cache_type* _M_data;
03581
03582 public:
03585 static const bool intl = _Intl;
03587 static locale::id id;
03588
03596 explicit
03597 moneypunct(size_t __refs = 0) : facet(__refs), _M_data(NULL)
03598 { _M_initialize_moneypunct(); }
03599
03608 explicit
03609 moneypunct(__cache_type* __cache, size_t __refs = 0)
03610 : facet(__refs), _M_data(__cache)
03611 { _M_initialize_moneypunct(); }
03612
03623 explicit
03624 moneypunct(__c_locale __cloc, const char* __s, size_t __refs = 0)
03625 : facet(__refs), _M_data(NULL)
03626 { _M_initialize_moneypunct(__cloc, __s); }
03627
03637 char_type
03638 decimal_point() const
03639 { return this->do_decimal_point(); }
03640
03650 char_type
03651 thousands_sep() const
03652 { return this->do_thousands_sep(); }
03653
03679 string
03680 grouping() const
03681 { return this->do_grouping(); }
03682
03692 string_type
03693 curr_symbol() const
03694 { return this->do_curr_symbol(); }
03695
03709 string_type
03710 positive_sign() const
03711 { return this->do_positive_sign(); }
03712
03726 string_type
03727 negative_sign() const
03728 { return this->do_negative_sign(); }
03729
03742 int
03743 frac_digits() const
03744 { return this->do_frac_digits(); }
03745
03747
03777 pattern
03778 pos_format() const
03779 { return this->do_pos_format(); }
03780
03781 pattern
03782 neg_format() const
03783 { return this->do_neg_format(); }
03785
03786 protected:
03788 virtual
03789 ~moneypunct();
03790
03799 virtual char_type
03800 do_decimal_point() const
03801 { return _M_data->_M_decimal_point; }
03802
03811 virtual char_type
03812 do_thousands_sep() const
03813 { return _M_data->_M_thousands_sep; }
03814
03824 virtual string
03825 do_grouping() const
03826 { return _M_data->_M_grouping; }
03827
03837 virtual string_type
03838 do_curr_symbol() const
03839 { return _M_data->_M_curr_symbol; }
03840
03850 virtual string_type
03851 do_positive_sign() const
03852 { return _M_data->_M_positive_sign; }
03853
03863 virtual string_type
03864 do_negative_sign() const
03865 { return _M_data->_M_negative_sign; }
03866
03877 virtual int
03878 do_frac_digits() const
03879 { return _M_data->_M_frac_digits; }
03880
03891 virtual pattern
03892 do_pos_format() const
03893 { return _M_data->_M_pos_format; }
03894
03905 virtual pattern
03906 do_neg_format() const
03907 { return _M_data->_M_neg_format; }
03908
03909
03910 void
03911 _M_initialize_moneypunct(__c_locale __cloc = NULL,
03912 const char* __name = NULL);
03913 };
03914
03915 template<typename _CharT, bool _Intl>
03916 locale::id moneypunct<_CharT, _Intl>::id;
03917
03918 template<typename _CharT, bool _Intl>
03919 const bool moneypunct<_CharT, _Intl>::intl;
03920
03921 template<>
03922 moneypunct<char, true>::~moneypunct();
03923
03924 template<>
03925 moneypunct<char, false>::~moneypunct();
03926
03927 template<>
03928 void
03929 moneypunct<char, true>::_M_initialize_moneypunct(__c_locale, const char*);
03930
03931 template<>
03932 void
03933 moneypunct<char, false>::_M_initialize_moneypunct(__c_locale, const char*);
03934
03935 #ifdef _GLIBCXX_USE_WCHAR_T
03936 template<>
03937 moneypunct<wchar_t, true>::~moneypunct();
03938
03939 template<>
03940 moneypunct<wchar_t, false>::~moneypunct();
03941
03942 template<>
03943 void
03944 moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale,
03945 const char*);
03946
03947 template<>
03948 void
03949 moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale,
03950 const char*);
03951 #endif
03952
03954 template<typename _CharT, bool _Intl>
03955 class moneypunct_byname : public moneypunct<_CharT, _Intl>
03956 {
03957 public:
03958 typedef _CharT char_type;
03959 typedef basic_string<_CharT> string_type;
03960
03961 static const bool intl = _Intl;
03962
03963 explicit
03964 moneypunct_byname(const char* __s, size_t __refs = 0)
03965 : moneypunct<_CharT, _Intl>(__refs)
03966 {
03967 if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
03968 {
03969 __c_locale __tmp;
03970 this->_S_create_c_locale(__tmp, __s);
03971 this->_M_initialize_moneypunct(__tmp);
03972 this->_S_destroy_c_locale(__tmp);
03973 }
03974 }
03975
03976 protected:
03977 virtual
03978 ~moneypunct_byname() { }
03979 };
03980
03981 template<typename _CharT, bool _Intl>
03982 const bool moneypunct_byname<_CharT, _Intl>::intl;
03983
03984 _GLIBCXX_BEGIN_LDBL_NAMESPACE
03997 template<typename _CharT, typename _InIter>
03998 class money_get : public locale::facet
03999 {
04000 public:
04001
04003
04004 typedef _CharT char_type;
04005 typedef _InIter iter_type;
04006 typedef basic_string<_CharT> string_type;
04008
04010 static locale::id id;
04011
04019 explicit
04020 money_get(size_t __refs = 0) : facet(__refs) { }
04021
04049 iter_type
04050 get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
04051 ios_base::iostate& __err, long double& __units) const
04052 { return this->do_get(__s, __end, __intl, __io, __err, __units); }
04053
04079 iter_type
04080 get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
04081 ios_base::iostate& __err, string_type& __digits) const
04082 { return this->do_get(__s, __end, __intl, __io, __err, __digits); }
04083
04084 protected:
04086 virtual
04087 ~money_get() { }
04088
04096
04097 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
04098 virtual iter_type
04099 __do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
04100 ios_base::iostate& __err, double& __units) const;
04101 #else
04102 virtual iter_type
04103 do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
04104 ios_base::iostate& __err, long double& __units) const;
04105 #endif
04106
04114 virtual iter_type
04115 do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
04116 ios_base::iostate& __err, string_type& __digits) const;
04117
04118
04119 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
04120 virtual iter_type
04121 do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
04122 ios_base::iostate& __err, long double& __units) const;
04123 #endif
04124
04125 template<bool _Intl>
04126 iter_type
04127 _M_extract(iter_type __s, iter_type __end, ios_base& __io,
04128 ios_base::iostate& __err, string& __digits) const;
04129 };
04130
04131 template<typename _CharT, typename _InIter>
04132 locale::id money_get<_CharT, _InIter>::id;
04133
04146 template<typename _CharT, typename _OutIter>
04147 class money_put : public locale::facet
04148 {
04149 public:
04151
04152 typedef _CharT char_type;
04153 typedef _OutIter iter_type;
04154 typedef basic_string<_CharT> string_type;
04156
04158 static locale::id id;
04159
04167 explicit
04168 money_put(size_t __refs = 0) : facet(__refs) { }
04169
04187 iter_type
04188 put(iter_type __s, bool __intl, ios_base& __io,
04189 char_type __fill, long double __units) const
04190 { return this->do_put(__s, __intl, __io, __fill, __units); }
04191
04209 iter_type
04210 put(iter_type __s, bool __intl, ios_base& __io,
04211 char_type __fill, const string_type& __digits) const
04212 { return this->do_put(__s, __intl, __io, __fill, __digits); }
04213
04214 protected:
04216 virtual
04217 ~money_put() { }
04218
04237
04238 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
04239 virtual iter_type
04240 __do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
04241 double __units) const;
04242 #else
04243 virtual iter_type
04244 do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
04245 long double __units) const;
04246 #endif
04247
04266 virtual iter_type
04267 do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
04268 const string_type& __digits) const;
04269
04270
04271 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
04272 virtual iter_type
04273 do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
04274 long double __units) const;
04275 #endif
04276
04277 template<bool _Intl>
04278 iter_type
04279 _M_insert(iter_type __s, ios_base& __io, char_type __fill,
04280 const string_type& __digits) const;
04281 };
04282
04283 template<typename _CharT, typename _OutIter>
04284 locale::id money_put<_CharT, _OutIter>::id;
04285
04286 _GLIBCXX_END_LDBL_NAMESPACE
04287
04291 struct messages_base
04292 {
04293 typedef int catalog;
04294 };
04295
04316 template<typename _CharT>
04317 class messages : public locale::facet, public messages_base
04318 {
04319 public:
04320
04322
04323 typedef _CharT char_type;
04324 typedef basic_string<_CharT> string_type;
04326
04327 protected:
04328
04329
04330 __c_locale _M_c_locale_messages;
04331 const char* _M_name_messages;
04332
04333 public:
04335 static locale::id id;
04336
04344 explicit
04345 messages(size_t __refs = 0);
04346
04347
04358 explicit
04359 messages(__c_locale __cloc, const char* __s, size_t __refs = 0);
04360
04361
04362
04363
04364
04365
04366
04367
04368
04369
04370
04371 catalog
04372 open(const basic_string<char>& __s, const locale& __loc) const
04373 { return this->do_open(__s, __loc); }
04374
04375
04376
04377
04378
04379
04380
04381
04382
04383
04384
04385
04386
04387
04388
04389 catalog
04390 open(const basic_string<char>&, const locale&, const char*) const;
04391
04392
04393
04394
04395
04396
04397
04398
04399
04400
04401
04402
04403
04404
04405
04406
04407 string_type
04408 get(catalog __c, int __set, int __msgid, const string_type& __s) const
04409 { return this->do_get(__c, __set, __msgid, __s); }
04410
04411
04412
04413
04414
04415
04416
04417
04418 void
04419 close(catalog __c) const
04420 { return this->do_close(__c); }
04421
04422 protected:
04424 virtual
04425 ~messages();
04426
04427
04428
04429
04430
04431
04432
04433
04434
04435
04436
04437
04438 virtual catalog
04439 do_open(const basic_string<char>&, const locale&) const;
04440
04441
04442
04443
04444
04445
04446
04447
04448
04449
04450
04451
04452
04453
04454
04455
04456
04457 virtual string_type
04458 do_get(catalog, int, int, const string_type& __dfault) const;
04459
04460
04461
04462
04463
04464
04465 virtual void
04466 do_close(catalog) const;
04467
04468
04469 char*
04470 _M_convert_to_char(const string_type& __msg) const
04471 {
04472
04473 return reinterpret_cast<char*>(const_cast<_CharT*>(__msg.c_str()));
04474 }
04475
04476
04477 string_type
04478 _M_convert_from_char(char*) const
04479 {
04480 #if 0
04481
04482 size_t __len = char_traits<char>::length(__msg) - 1;
04483
04484
04485
04486
04487
04488
04489
04490 typedef typename codecvt<char, _CharT, mbstate_t> __codecvt_type;
04491
04492 __codecvt_type::state_type __state;
04493
04494
04495
04496 char* __from_next;
04497
04498 _CharT* __to = static_cast<_CharT*>(__builtin_alloca(__len + 1));
04499 const __codecvt_type& __cvt = use_facet<__codecvt_type>(_M_locale_conv);
04500 __cvt.out(__state, __msg, __msg + __len, __from_next,
04501 __to, __to + __len + 1, __to_next);
04502 return string_type(__to);
04503 #endif
04504 #if 0
04505 typedef ctype<_CharT> __ctype_type;
04506
04507 const __ctype_type& __cvt = use_facet<__ctype_type>(locale());
04508
04509
04510 _CharT* __dest = static_cast<_CharT*>(__builtin_alloca(__len + 1));
04511 __cvt.widen(__msg, __msg + __len, __dest);
04512 return basic_string<_CharT>(__dest);
04513 #endif
04514 return string_type();
04515 }
04516 };
04517
04518 template<typename _CharT>
04519 locale::id messages<_CharT>::id;
04520
04521
04522 template<>
04523 string
04524 messages<char>::do_get(catalog, int, int, const string&) const;
04525
04526 #ifdef _GLIBCXX_USE_WCHAR_T
04527 template<>
04528 wstring
04529 messages<wchar_t>::do_get(catalog, int, int, const wstring&) const;
04530 #endif
04531
04533 template<typename _CharT>
04534 class messages_byname : public messages<_CharT>
04535 {
04536 public:
04537 typedef _CharT char_type;
04538 typedef basic_string<_CharT> string_type;
04539
04540 explicit
04541 messages_byname(const char* __s, size_t __refs = 0);
04542
04543 protected:
04544 virtual
04545 ~messages_byname()
04546 { }
04547 };
04548
04549
04550 #include <bits/messages_members.h>
04551
04552
04553
04554
04555
04556
04557
04559 template<typename _CharT>
04560 inline bool
04561 isspace(_CharT __c, const locale& __loc)
04562 { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c); }
04563
04565 template<typename _CharT>
04566 inline bool
04567 isprint(_CharT __c, const locale& __loc)
04568 { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c); }
04569
04571 template<typename _CharT>
04572 inline bool
04573 iscntrl(_CharT __c, const locale& __loc)
04574 { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c); }
04575
04577 template<typename _CharT>
04578 inline bool
04579 isupper(_CharT __c, const locale& __loc)
04580 { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c); }
04581
04583 template<typename _CharT>
04584 inline bool
04585 islower(_CharT __c, const locale& __loc)
04586 { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c); }
04587
04589 template<typename _CharT>
04590 inline bool
04591 isalpha(_CharT __c, const locale& __loc)
04592 { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c); }
04593
04595 template<typename _CharT>
04596 inline bool
04597 isdigit(_CharT __c, const locale& __loc)
04598 { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c); }
04599
04601 template<typename _CharT>
04602 inline bool
04603 ispunct(_CharT __c, const locale& __loc)
04604 { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c); }
04605
04607 template<typename _CharT>
04608 inline bool
04609 isxdigit(_CharT __c, const locale& __loc)
04610 { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c); }
04611
04613 template<typename _CharT>
04614 inline bool
04615 isalnum(_CharT __c, const locale& __loc)
04616 { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c); }
04617
04619 template<typename _CharT>
04620 inline bool
04621 isgraph(_CharT __c, const locale& __loc)
04622 { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c); }
04623
04625 template<typename _CharT>
04626 inline _CharT
04627 toupper(_CharT __c, const locale& __loc)
04628 { return use_facet<ctype<_CharT> >(__loc).toupper(__c); }
04629
04631 template<typename _CharT>
04632 inline _CharT
04633 tolower(_CharT __c, const locale& __loc)
04634 { return use_facet<ctype<_CharT> >(__loc).tolower(__c); }
04635 }
04636
04637 #endif