📄 locale_facets.h
字号:
protected: virtual ~ctype_byname() { }; }; // 22.2.1.4 Class ctype_byname specializations. template<> ctype_byname<char>::ctype_byname(const char*, size_t refs); template<> ctype_byname<wchar_t>::ctype_byname(const char*, size_t refs); // 22.2.1.5 Template class codecvt #include <bits/codecvt.h> // 22.2.2 The numeric category. class __num_base { public: // NB: Code depends on the order of _S_atoms_out elements. // Below are the indices into _S_atoms_out. enum { _S_minus, _S_plus, _S_x, _S_X, _S_digits, _S_digits_end = _S_digits + 16, _S_udigits = _S_digits_end, _S_udigits_end = _S_udigits + 16, _S_e = _S_digits + 14, // For scientific notation, 'e' _S_E = _S_udigits + 14, // For scientific notation, 'E' _S_end = _S_udigits_end }; // A list of valid numeric literals for output. This array // contains chars that will be passed through the current locale's // ctype<_CharT>.widen() and then used to render numbers. // For the standard "C" locale, this is // "-+xX0123456789abcdef0123456789ABCDEF". static const char* _S_atoms_out; protected: // String literal of acceptable (narrow) input, for num_get. // "0123456789eEabcdfABCDF" static const char* _S_atoms_in; enum { _M_zero, _M_e = _M_zero + 10, _M_E = _M_zero + 11, _M_size = 21 + 1 }; // num_put // Construct and return valid scanf format for floating point types. static void _S_format_float(const ios_base& __io, char* __fptr, char __mod, streamsize __prec); // Construct and return valid scanf format for integer types. static void _S_format_int(const ios_base& __io, char* __fptr, char __mod, char __modl); }; template<typename _CharT> class __locale_cache; template<typename _CharT> class numpunct : public locale::facet { public: // Types: typedef _CharT char_type; typedef basic_string<_CharT> string_type; friend class __locale_cache<numpunct<_CharT> >; static locale::id id; private: char_type _M_decimal_point; char_type _M_thousands_sep; const char* _M_grouping; const char_type* _M_truename; const char_type* _M_falsename; public: explicit numpunct(size_t __refs = 0) : locale::facet(__refs) { _M_initialize_numpunct(); } explicit numpunct(__c_locale __cloc, size_t __refs = 0) : locale::facet(__refs) { _M_initialize_numpunct(__cloc); } 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 truename() const { return this->do_truename(); } string_type falsename() const { return this->do_falsename(); } protected: virtual ~numpunct(); virtual char_type do_decimal_point() const { return _M_decimal_point; } virtual char_type do_thousands_sep() const { return _M_thousands_sep; } virtual string do_grouping() const { return _M_grouping; } virtual string_type do_truename() const { return _M_truename; } virtual string_type do_falsename() const { return _M_falsename; } // For use at construction time only. void _M_initialize_numpunct(__c_locale __cloc = NULL); }; template<typename _CharT> locale::id numpunct<_CharT>::id; template<> numpunct<char>::~numpunct(); template<> void numpunct<char>::_M_initialize_numpunct(__c_locale __cloc);#ifdef _GLIBCPP_USE_WCHAR_T template<> numpunct<wchar_t>::~numpunct(); template<> void numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc);#endif template<typename _CharT> class numpunct_byname : public numpunct<_CharT> { // Data Member. __c_locale _M_c_locale_numpunct; public: typedef _CharT char_type; typedef basic_string<_CharT> string_type; explicit numpunct_byname(const char* __s, size_t __refs = 0) : numpunct<_CharT>(__refs) { _S_create_c_locale(_M_c_locale_numpunct, __s); _M_initialize_numpunct(_M_c_locale_numpunct); } protected: virtual ~numpunct_byname() { _S_destroy_c_locale(_M_c_locale_numpunct); } }; template<typename _CharT, typename _InIter> class num_get : public locale::facet, public __num_base { public: // Types: typedef _CharT char_type; typedef _InIter iter_type; static locale::id id; explicit num_get(size_t __refs = 0) : locale::facet(__refs) { } iter_type get(iter_type __in, iter_type __end, ios_base& __io, ios_base::iostate& __err, bool& __v) const { return this->do_get(__in, __end, __io, __err, __v); } iter_type get(iter_type __in, iter_type __end, ios_base& __io, ios_base::iostate& __err, long& __v) const { return this->do_get(__in, __end, __io, __err, __v); } iter_type get(iter_type __in, iter_type __end, ios_base& __io, ios_base::iostate& __err, unsigned short& __v) const { return this->do_get(__in, __end, __io, __err, __v); } iter_type get(iter_type __in, iter_type __end, ios_base& __io, ios_base::iostate& __err, unsigned int& __v) const { return this->do_get(__in, __end, __io, __err, __v); } iter_type get(iter_type __in, iter_type __end, ios_base& __io, ios_base::iostate& __err, unsigned long& __v) const { return this->do_get(__in, __end, __io, __err, __v); }#ifdef _GLIBCPP_USE_LONG_LONG iter_type get(iter_type __in, iter_type __end, ios_base& __io, ios_base::iostate& __err, long long& __v) const { return this->do_get(__in, __end, __io, __err, __v); } iter_type get(iter_type __in, iter_type __end, ios_base& __io, ios_base::iostate& __err, unsigned long long& __v) const { return this->do_get(__in, __end, __io, __err, __v); }#endif iter_type get(iter_type __in, iter_type __end, ios_base& __io, ios_base::iostate& __err, float& __v) const { return this->do_get(__in, __end, __io, __err, __v); } iter_type get(iter_type __in, iter_type __end, ios_base& __io, ios_base::iostate& __err, double& __v) const { return this->do_get(__in, __end, __io, __err, __v); } iter_type get(iter_type __in, iter_type __end, ios_base& __io, ios_base::iostate& __err, long double& __v) const { return this->do_get(__in, __end, __io, __err, __v); } iter_type get(iter_type __in, iter_type __end, ios_base& __io, ios_base::iostate& __err, void*& __v) const { return this->do_get(__in, __end, __io, __err, __v); } protected: virtual ~num_get() { } iter_type _M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&, string& __xtrc) const; iter_type _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&, string& __xtrc, int& __base) const; virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const; virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, long&) const; virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, unsigned short&) const; virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, unsigned int&) const; virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, unsigned long&) const;#ifdef _GLIBCPP_USE_LONG_LONG virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, long long&) const; virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, unsigned long long&) const;#endif virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, float&) const; virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, double&) const; virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, long double&) const; virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, void*&) const; }; template<typename _CharT, typename _InIter> locale::id num_get<_CharT, _InIter>::id;#if 0 // Partial specialization for istreambuf_iterator, so can use traits_type. template<typename _CharT> class num_get<_CharT, istreambuf_iterator<_CharT> >; iter_type _M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&, string& __xtrc) const; iter_type _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&, string& __xtrc, int& __base) const; virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;#endif template<typename _CharT, typename _OutIter> class num_put : public locale::facet, public __num_base { public: // Types: typedef _CharT char_type; typedef _OutIter iter_type; static locale::id id; explicit num_put(size_t __refs = 0) : locale::facet(__refs) { } iter_type put(iter_type __s, ios_base& __f, char_type __fill, bool __v) const { return this->do_put(__s, __f, __fill, __v); } iter_type put(iter_type __s, ios_base& __f, char_type __fill, long __v) const { return this->do_put(__s, __f, __fill, __v); } iter_type put(iter_type __s, ios_base& __f, char_type __fill, unsigned long __v) const { return this->do_put(__s, __f, __fill, __v); }#ifdef _GLIBCPP_USE_LONG_LONG iter_type put(iter_type __s, ios_base& __f, char_type __fill, long long __v) const { return this->do_put(__s, __f, __fill, __v); } iter_type put(iter_type __s, ios_base& __f, char_type __fill, unsigned long long __v) const { return this->do_put(__s, __f, __fill, __v); }#endif iter_type put(iter_type __s, ios_base& __f, char_type __fill, double __v) const { return this->do_put(__s, __f, __fill, __v); } iter_type put(iter_type __s, ios_base& __f, char_type __fill, long double __v) const { return this->do_put(__s, __f, __fill, __v); } iter_type put(iter_type __s, ios_base& __f, char_type __fill, const void* __v) const { return this->do_put(__s, __f, __fill, __v); } protected: template<typename _ValueT> iter_type _M_convert_float(iter_type, ios_base& __io, char_type __fill, char __mod, _ValueT __v) const; void _M_group_float(const string& __grouping, char_type __sep, const char_type* __p, char_type* __new, char_type* __cs, int& __len) const; template<typename _ValueT> iter_type _M_convert_int(iter_type, ios_base& __io, char_type __fill, _ValueT __v) const; void _M_group_int(const string& __grouping, char_type __sep, ios_base& __io, char_type* __new, char_type* __cs, int& __len) const; void _M_pad(char_type __fill, streamsize __w, ios_base& __io, char_type* __new, const char_type* __cs, int& __len) const;#if 1 // XXX GLIBCXX_ABI Deprecated, compatibility only. template<typename _ValueT> iter_type _M_convert_int(iter_type, ios_base& __io, char_type __fill, char __mod, char __modl, _ValueT __v) const; iter_type _M_widen_float(iter_type, ios_base& __io, char_type __fill, char* __cs, int __len) const; iter_type _M_widen_int(iter_type, ios_base& __io, char_type __fill, char* __cs, int __len) const; iter_type _M_insert(iter_type, ios_base& __io, char_type __fill, const char_type* __ws, int __len) const;#endif virtual ~num_put() { }; virtual iter_type do_put(iter_type, ios_base&, char_type __fill, bool __v) const; virtual iter_type do_put(iter_type, ios_base&, char_type __fill, long __v) const; virtual iter_type do_put(iter_type, ios_base&, char_type __fill, unsigned long) const;#ifdef _GLIBCPP_USE_LONG_LONG virtual iter_type do_put(iter_type, ios_base&, char_type __fill, long long __v) const; virtual iter_type do_put(iter_type, ios_base&, char_type __fill, unsigned long long) const;#endif virtual iter_type do_put(iter_type, ios_base&, char_type __fill, double __v) const; virtual iter_type do_put(iter_type, ios_base&, char_type __fill, long double __v) const; virtual iter_type do_put(iter_type, ios_base&, char_type __fill, const void* __v) const; }; template <typename _CharT, typename _OutIter> locale::id num_put<_CharT, _OutIter>::id; template<typename _CharT> class collate : public locale::facet { public: // Types: typedef _CharT char_type; typedef basic_string<_CharT> string_type; protected: // Underlying "C" library locale information saved from // initialization, needed by collate_byname as well. __c_locale _M_c_locale_collate; public: static locale::id id; explicit collate(size_t __refs = 0) : locale::facet(__refs) { _M_c_locale_collate = _S_c_locale; } explicit collate(__c_locale __cloc, size_t __refs = 0) : locale::facet(__refs) { _M_c_locale_collate = _S_clone_c_locale(__cloc); } int compare(const _CharT* __lo1, const _CharT* __hi1, const _CharT* __lo2, const _CharT* __hi2) const { return this->do_compare(__lo1, __hi1, __lo2, __hi2); } string_type transform(const _CharT* __lo, const _CharT* __hi) const { return this->do_transform(__lo, __hi); } long hash(const _CharT* __lo, const _CharT* __hi) const { return this->do_hash(__lo, __hi); } // Used to abstract out _CharT bits in virtual member functions, below. int _M_compare(const _CharT*, const _CharT*) const; size_t _M_transform(_CharT*, const _CharT*, size_t) const;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -