📄 locale_facets.h
字号:
protected: virtual ~collate() { _S_destroy_c_locale(_M_c_locale_collate); } virtual int do_compare(const _CharT* __lo1, const _CharT* __hi1, const _CharT* __lo2, const _CharT* __hi2) const; virtual string_type do_transform(const _CharT* __lo, const _CharT* __hi) const; virtual long do_hash(const _CharT* __lo, const _CharT* __hi) const; }; template<typename _CharT> locale::id collate<_CharT>::id; // Specializations. template<> int collate<char>::_M_compare(const char*, const char*) const; template<> size_t collate<char>::_M_transform(char*, const char*, size_t) const;#ifdef _GLIBCPP_USE_WCHAR_T template<> int collate<wchar_t>::_M_compare(const wchar_t*, const wchar_t*) const; template<> size_t collate<wchar_t>::_M_transform(wchar_t*, const wchar_t*, size_t) const;#endif template<typename _CharT> class collate_byname : public collate<_CharT> { public: typedef _CharT char_type; typedef basic_string<_CharT> string_type; explicit collate_byname(const char* __s, size_t __refs = 0) : collate<_CharT>(__refs) { _S_destroy_c_locale(_M_c_locale_collate); _S_create_c_locale(_M_c_locale_collate, __s); } protected: virtual ~collate_byname() { } }; class time_base { public: enum dateorder { no_order, dmy, mdy, ymd, ydm }; }; template<typename _CharT> class __timepunct : public locale::facet { public: // Types: typedef _CharT __char_type; typedef basic_string<_CharT> __string_type; static locale::id id; // List of all known timezones, with GMT first. static const _CharT* _S_timezones[14]; protected: __c_locale _M_c_locale_timepunct; char* _M_name_timepunct; const _CharT* _M_date_format; const _CharT* _M_date_era_format; const _CharT* _M_time_format; const _CharT* _M_time_era_format; const _CharT* _M_date_time_format; const _CharT* _M_date_time_era_format; const _CharT* _M_am; const _CharT* _M_pm; const _CharT* _M_am_pm_format; // Day names, starting with "C"'s Sunday. const _CharT* _M_day1; const _CharT* _M_day2; const _CharT* _M_day3; const _CharT* _M_day4; const _CharT* _M_day5; const _CharT* _M_day6; const _CharT* _M_day7; // Abbreviated day names, starting with "C"'s Sun. const _CharT* _M_day_a1; const _CharT* _M_day_a2; const _CharT* _M_day_a3; const _CharT* _M_day_a4; const _CharT* _M_day_a5; const _CharT* _M_day_a6; const _CharT* _M_day_a7; // Month names, starting with "C"'s January. const _CharT* _M_month01; const _CharT* _M_month02; const _CharT* _M_month03; const _CharT* _M_month04; const _CharT* _M_month05; const _CharT* _M_month06; const _CharT* _M_month07; const _CharT* _M_month08; const _CharT* _M_month09; const _CharT* _M_month10; const _CharT* _M_month11; const _CharT* _M_month12; // Abbreviated month names, starting with "C"'s Jan. const _CharT* _M_month_a01; const _CharT* _M_month_a02; const _CharT* _M_month_a03; const _CharT* _M_month_a04; const _CharT* _M_month_a05; const _CharT* _M_month_a06; const _CharT* _M_month_a07; const _CharT* _M_month_a08; const _CharT* _M_month_a09; const _CharT* _M_month_a10; const _CharT* _M_month_a11; const _CharT* _M_month_a12; public: explicit __timepunct(size_t __refs = 0); explicit __timepunct(__c_locale __cloc, const char* __s, size_t __refs = 0); void _M_put(_CharT* __s, size_t __maxlen, const _CharT* __format, const tm* __tm) const; void _M_date_formats(const _CharT** __date) const { // Always have default first. __date[0] = _M_date_format; __date[1] = _M_date_era_format; } void _M_time_formats(const _CharT** __time) const { // Always have default first. __time[0] = _M_time_format; __time[1] = _M_time_era_format; } void _M_ampm(const _CharT** __ampm) const { __ampm[0] = _M_am; __ampm[1] = _M_pm; } void _M_date_time_formats(const _CharT** __dt) const { // Always have default first. __dt[0] = _M_date_time_format; __dt[1] = _M_date_time_era_format; } void _M_days(const _CharT** __days) const { __days[0] = _M_day1; __days[1] = _M_day2; __days[2] = _M_day3; __days[3] = _M_day4; __days[4] = _M_day5; __days[5] = _M_day6; __days[6] = _M_day7; } void _M_days_abbreviated(const _CharT** __days) const { __days[0] = _M_day_a1; __days[1] = _M_day_a2; __days[2] = _M_day_a3; __days[3] = _M_day_a4; __days[4] = _M_day_a5; __days[5] = _M_day_a6; __days[6] = _M_day_a7; } void _M_months(const _CharT** __months) const { __months[0] = _M_month01; __months[1] = _M_month02; __months[2] = _M_month03; __months[3] = _M_month04; __months[4] = _M_month05; __months[5] = _M_month06; __months[6] = _M_month07; __months[7] = _M_month08; __months[8] = _M_month09; __months[9] = _M_month10; __months[10] = _M_month11; __months[11] = _M_month12; } void _M_months_abbreviated(const _CharT** __months) const { __months[0] = _M_month_a01; __months[1] = _M_month_a02; __months[2] = _M_month_a03; __months[3] = _M_month_a04; __months[4] = _M_month_a05; __months[5] = _M_month_a06; __months[6] = _M_month_a07; __months[7] = _M_month_a08; __months[8] = _M_month_a09; __months[9] = _M_month_a10; __months[10] = _M_month_a11; __months[11] = _M_month_a12; } protected: virtual ~__timepunct(); // For use at construction time only. void _M_initialize_timepunct(__c_locale __cloc = NULL); }; template<typename _CharT> locale::id __timepunct<_CharT>::id; // Specializations. template<> const char* __timepunct<char>::_S_timezones[14]; template<> void __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc); template<> void __timepunct<char>::_M_put(char*, size_t, const char*, const tm*) const;#ifdef _GLIBCPP_USE_WCHAR_T template<> const wchar_t* __timepunct<wchar_t>::_S_timezones[14]; template<> void __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc); template<> void __timepunct<wchar_t>::_M_put(wchar_t*, size_t, const wchar_t*, const tm*) const;#endif // Generic. template<typename _CharT> const _CharT* __timepunct<_CharT>::_S_timezones[14]; // Include host and configuration specific timepunct functions. #include <bits/time_members.h> template<typename _CharT, typename _InIter> class time_get : public locale::facet, public time_base { public: // Types: typedef _CharT char_type; typedef _InIter iter_type; typedef basic_string<_CharT> __string_type; static locale::id id; explicit time_get(size_t __refs = 0) : locale::facet (__refs) { } dateorder date_order() const { return this->do_date_order(); } iter_type get_time(iter_type __beg, iter_type __end, ios_base& __io, ios_base::iostate& __err, tm* __tm) const { return this->do_get_time(__beg, __end, __io, __err, __tm); } iter_type get_date(iter_type __beg, iter_type __end, ios_base& __io, ios_base::iostate& __err, tm* __tm) const { return this->do_get_date(__beg, __end, __io, __err, __tm); } iter_type get_weekday(iter_type __beg, iter_type __end, ios_base& __io, ios_base::iostate& __err, tm* __tm) const { return this->do_get_weekday(__beg, __end, __io, __err, __tm); } iter_type get_monthname(iter_type __beg, iter_type __end, ios_base& __io, ios_base::iostate& __err, tm* __tm) const { return this->do_get_monthname(__beg, __end, __io, __err, __tm); } iter_type get_year(iter_type __beg, iter_type __end, ios_base& __io, ios_base::iostate& __err, tm* __tm) const { return this->do_get_year(__beg, __end, __io, __err, __tm); } protected: virtual ~time_get() { } virtual dateorder do_date_order() const; virtual iter_type do_get_time(iter_type __beg, iter_type __end, ios_base& __io, ios_base::iostate& __err, tm* __tm) const; virtual iter_type do_get_date(iter_type __beg, iter_type __end, ios_base& __io, ios_base::iostate& __err, tm* __tm) const; virtual iter_type do_get_weekday(iter_type __beg, iter_type __end, ios_base&, ios_base::iostate& __err, tm* __tm) const; virtual iter_type do_get_monthname(iter_type __beg, iter_type __end, ios_base&, ios_base::iostate& __err, tm* __tm) const; virtual iter_type do_get_year(iter_type __beg, iter_type __end, ios_base& __io, ios_base::iostate& __err, tm* __tm) const; // Extract numeric component of length __len. void _M_extract_num(iter_type& __beg, iter_type& __end, int& __member, int __min, int __max, size_t __len, const ctype<_CharT>& __ctype, ios_base::iostate& __err) const; // Extract day or month name, or any unique array of string // literals in a const _CharT* array. void _M_extract_name(iter_type& __beg, iter_type& __end, int& __member, const _CharT** __names, size_t __indexlen, ios_base::iostate& __err) const; // Extract on a component-by-component basis, via __format argument. void _M_extract_via_format(iter_type& __beg, iter_type& __end, ios_base& __io, ios_base::iostate& __err, tm* __tm, const _CharT* __format) const; }; template<typename _CharT, typename _InIter> locale::id time_get<_CharT, _InIter>::id; template<typename _CharT, typename _InIter> class time_get_byname : public time_get<_CharT, _InIter> { public: // Types: typedef _CharT char_type; typedef _InIter iter_type; explicit time_get_byname(const char*, size_t __refs = 0) : time_get<_CharT, _InIter>(__refs) { } protected: virtual ~time_get_byname() { } }; template<typename _CharT, typename _OutIter> class time_put : public locale::facet, public time_base { public: // Types: typedef _CharT char_type; typedef _OutIter iter_type; static locale::id id; explicit time_put(size_t __refs = 0) : locale::facet(__refs) { } iter_type put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm, const _CharT* __beg, const _CharT* __end) const; iter_type put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm, char __format, char __mod = 0) const { return this->do_put(__s, __io, __fill, __tm, __format, __mod); } protected: virtual ~time_put() { } virtual iter_type do_put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm, char __format, char __mod) const; }; template<typename _CharT, typename _OutIter> locale::id time_put<_CharT, _OutIter>::id; template<typename _CharT, typename _OutIter> class time_put_byname : public time_put<_CharT, _OutIter> { public: // Types: typedef _CharT char_type; typedef _OutIter iter_type; explicit time_put_byname(const char* /*__s*/, size_t __refs = 0) : time_put<_CharT, _OutIter>(__refs) { }; protected: virtual ~time_put_byname() { } }; class money_base { public: enum part { none, space, symbol, sign, value }; struct pattern { char field[4]; }; static const pattern _S_default_pattern; // Construct and return valid pattern consisting of some combination of: // space none symbol sign value static pattern _S_construct_pattern(char __precedes, char __space, char __posn); }; template<typename _CharT, bool _Intl> class moneypunct : public locale::facet, public money_base { public: // Types: typedef _CharT char_type; typedef basic_string<_CharT> string_type; static const bool intl = _Intl; static locale::id id; private: const char* _M_grouping; char_type _M_decimal_point; char_type _M_thousands_sep; const char_type* _M_curr_symbol; const char_type* _M_positive_sign; const char_type* _M_negative_sign; int _M_frac_digits; pattern _M_pos_format; pattern _M_neg_format; public: explicit moneypunct(size_t __refs = 0) : locale::facet(__refs) { _M_initialize_moneypunct(); } explicit moneypunct(__c_locale __cloc, const char* __s, size_t __refs = 0) : locale::facet(__refs) { _M_initialize_moneypunct(__cloc, __s); } char_type decimal_point() const { return this->do_decimal_point(); } char_type thousands_sep() const { return this->do_thousands_sep(); } string grouping() const { return this->do_grouping(); } string_type curr_symbol() const { return this->do_curr_symbol(); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -