⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 locale_facets.h

📁 gcc3.2.1源代码
💻 H
📖 第 1 页 / 共 4 页
字号:
      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(); }      string_type        positive_sign() const      { return this->do_positive_sign(); }      string_type        negative_sign() const      { return this->do_negative_sign(); }      int                frac_digits() const      { return this->do_frac_digits(); }      pattern            pos_format() const      { return this->do_pos_format(); }      pattern            neg_format() const      { return this->do_neg_format(); }    protected:      virtual       ~moneypunct();      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_curr_symbol()   const      { return _M_curr_symbol; }      virtual string_type        do_positive_sign() const      { return _M_positive_sign; }      virtual string_type        do_negative_sign() const      { return _M_negative_sign; }      virtual int                do_frac_digits() const      { return _M_frac_digits; }      virtual pattern            do_pos_format() const      { return _M_pos_format; }      virtual pattern            do_neg_format() const      { return _M_neg_format; }      // For use at construction time only.       void        _M_initialize_moneypunct(__c_locale __cloc = NULL, 				const char* __name = NULL);    };  template<typename _CharT, bool _Intl>    locale::id moneypunct<_CharT, _Intl>::id;  template<typename _CharT, bool _Intl>    const bool moneypunct<_CharT, _Intl>::intl;  template<>    moneypunct<char, true>::~moneypunct();  template<>    moneypunct<char, false>::~moneypunct();  template<>     void    moneypunct<char, true>::_M_initialize_moneypunct(__c_locale, const char*);  template<>     void    moneypunct<char, false>::_M_initialize_moneypunct(__c_locale, const char*);#ifdef _GLIBCPP_USE_WCHAR_T  template<>    moneypunct<wchar_t, true>::~moneypunct();  template<>    moneypunct<wchar_t, false>::~moneypunct();  template<>     void    moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale, 							const char*);  template<>     void    moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale, 							 const char*);#endif  template<typename _CharT, bool _Intl>    class moneypunct_byname : public moneypunct<_CharT, _Intl>    {      __c_locale			_M_c_locale_moneypunct;    public:      typedef _CharT 			char_type;      typedef basic_string<_CharT> 	string_type;      static const bool intl = _Intl;      explicit       moneypunct_byname(const char* __s, size_t __refs = 0)      : moneypunct<_CharT, _Intl>(__refs)      {	_S_create_c_locale(_M_c_locale_moneypunct, __s);	_M_initialize_moneypunct(_M_c_locale_moneypunct);	      }    protected:      virtual       ~moneypunct_byname()       { _S_destroy_c_locale(_M_c_locale_moneypunct); }    };  template<typename _CharT, bool _Intl>    const bool moneypunct_byname<_CharT, _Intl>::intl;  template<typename _CharT, typename _InIter>    class money_get : public locale::facet    {    public:      // Types:      typedef _CharT        		char_type;      typedef _InIter       		iter_type;      typedef basic_string<_CharT> 	string_type;      static locale::id 		id;      explicit       money_get(size_t __refs = 0) : locale::facet(__refs) { }      iter_type       get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, 	  ios_base::iostate& __err, long double& __units) const      { return this->do_get(__s, __end, __intl, __io, __err, __units); }      iter_type       get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, 	  ios_base::iostate& __err, string_type& __digits) const      { return this->do_get(__s, __end, __intl, __io, __err, __digits); }    protected:      virtual       ~money_get() { }      virtual iter_type       do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, 	     ios_base::iostate& __err, long double& __units) const;      virtual iter_type       do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, 	     ios_base::iostate& __err, string_type& __digits) const;    };  template<typename _CharT, typename _InIter>    locale::id money_get<_CharT, _InIter>::id;  template<typename _CharT, typename _OutIter>    class money_put : public locale::facet    {    public:      typedef _CharT              	char_type;      typedef _OutIter            	iter_type;      typedef basic_string<_CharT>	string_type;      static locale::id 		id;      explicit       money_put(size_t __refs = 0) : locale::facet(__refs) { }      iter_type       put(iter_type __s, bool __intl, ios_base& __io,	  char_type __fill, long double __units) const      { return this->do_put(__s, __intl, __io, __fill, __units); }      iter_type       put(iter_type __s, bool __intl, ios_base& __io,	  char_type __fill, const string_type& __digits) const      { return this->do_put(__s, __intl, __io, __fill, __digits); }    protected:      virtual       ~money_put() { }      virtual iter_type      do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,	     long double __units) const;      virtual iter_type      do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,	     const string_type& __digits) const;    };  template<typename _CharT, typename _OutIter>    locale::id money_put<_CharT, _OutIter>::id;  struct messages_base  {    typedef int catalog;  };  template<typename _CharT>    class messages : public locale::facet, public messages_base    {    public:      // Types:      typedef _CharT 			char_type;      typedef basic_string<_CharT> 	string_type;    protected:      // Underlying "C" library locale information saved from      // initialization, needed by messages_byname as well.      __c_locale			_M_c_locale_messages;#if 1      // Only needed if glibc < 2.3      char*				_M_name_messages;#endif    public:      static locale::id 		id;      explicit       messages(size_t __refs = 0)       : locale::facet(__refs)      { 	_M_name_messages = new char[2];	strcpy(_M_name_messages, "C");	_M_c_locale_messages = _S_c_locale;       }      // Non-standard.      explicit       messages(__c_locale __cloc, const char* __s, size_t __refs = 0)       : locale::facet(__refs)      { 	_M_name_messages = new char[strlen(__s) + 1];	strcpy(_M_name_messages, __s);	_M_c_locale_messages = _S_clone_c_locale(__cloc);       }      catalog       open(const basic_string<char>& __s, const locale& __loc) const      { return this->do_open(__s, __loc); }      // Non-standard and unorthodox, yet effective.      catalog       open(const basic_string<char>&, const locale&, const char*) const;      string_type        get(catalog __c, int __set, int __msgid, const string_type& __s) const      { return this->do_get(__c, __set, __msgid, __s); }      void       close(catalog __c) const      { return this->do_close(__c); }    protected:      virtual       ~messages()       { 	 delete [] _M_name_messages;	 _S_destroy_c_locale(_M_c_locale_messages);        }      virtual catalog       do_open(const basic_string<char>&, const locale&) const;      virtual string_type        do_get(catalog, int, int, const string_type& __dfault) const;      virtual void          do_close(catalog) const;      // Returns a locale and codeset-converted string, given a char* message.      char*      _M_convert_to_char(const string_type& __msg) const      {	// XXX	return reinterpret_cast<char*>(const_cast<_CharT*>(__msg.c_str()));      }      // Returns a locale and codeset-converted string, given a char* message.      string_type      _M_convert_from_char(char* __msg) const      {	// Length of message string without terminating null.	size_t __len = char_traits<char>::length(__msg) - 1;	// "everybody can easily convert the string using	// mbsrtowcs/wcsrtombs or with iconv()"#if 0	// Convert char* to _CharT in locale used to open catalog.	// XXX need additional template parameter on messages class for this..	// typedef typename codecvt<char, _CharT, _StateT> __codecvt_type;	typedef typename codecvt<char, _CharT, mbstate_t> __codecvt_type;      	__codecvt_type::state_type __state;	// XXX may need to initialize state.	//initialize_state(__state._M_init());		char* __from_next;	// XXX what size for this string?	_CharT* __to = static_cast<_CharT*>(__builtin_alloca(__len + 1));	const __codecvt_type& __cvt = use_facet<__codecvt_type>(_M_locale_conv);	__cvt.out(__state, __msg, __msg + __len, __from_next,		  __to, __to + __len + 1, __to_next);	return string_type(__to);#endif#if 0	typedef ctype<_CharT> __ctype_type;	// const __ctype_type& __cvt = use_facet<__ctype_type>(_M_locale_msg);	const __ctype_type& __cvt = use_facet<__ctype_type>(locale());	// XXX Again, proper length of converted string an issue here.	// For now, assume the converted length is not larger.	_CharT* __dest = static_cast<_CharT*>(__builtin_alloca(__len + 1));	__cvt.widen(__msg, __msg + __len, __dest);	return basic_string<_CharT>(__dest);#endif	return string_type();      }     };  template<typename _CharT>    locale::id messages<_CharT>::id;  // Specializations for required instantiations.  template<>    string    messages<char>::do_get(catalog, int, int, const string&) const;#ifdef _GLIBCPP_USE_WCHAR_T  template<>    wstring    messages<wchar_t>::do_get(catalog, int, int, const wstring&) const;#endif  // Include host and configuration specific messages virtual functions.  #include <bits/messages_members.h>  template<typename _CharT>    class messages_byname : public messages<_CharT>    {    public:      typedef _CharT               	char_type;      typedef basic_string<_CharT> 	string_type;      explicit       messages_byname(const char* __s, size_t __refs = 0)      : messages<_CharT>(__refs)       { 	delete [] _M_name_messages;	_M_name_messages = new char[strlen(__s) + 1];	strcpy(_M_name_messages, __s);	_S_destroy_c_locale(_M_c_locale_messages);	_S_create_c_locale(_M_c_locale_messages, __s);       }    protected:      virtual       ~messages_byname()       { }    };  // Subclause convenience interfaces, inlines.  // NB: These are inline because, when used in a loop, some compilers  // can hoist the body out of the loop; then it's just as fast as the  // C is*() function.  template<typename _CharT>    inline bool     isspace(_CharT __c, const locale& __loc)    { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c); }  template<typename _CharT>    inline bool     isprint(_CharT __c, const locale& __loc)    { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c); }  template<typename _CharT>    inline bool     iscntrl(_CharT __c, const locale& __loc)    { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c); }  template<typename _CharT>    inline bool     isupper(_CharT __c, const locale& __loc)    { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c); }  template<typename _CharT>    inline bool islower(_CharT __c, const locale& __loc)    { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c); }  template<typename _CharT>    inline bool     isalpha(_CharT __c, const locale& __loc)    { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c); }  template<typename _CharT>    inline bool     isdigit(_CharT __c, const locale& __loc)    { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c); }  template<typename _CharT>    inline bool     ispunct(_CharT __c, const locale& __loc)    { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c); }  template<typename _CharT>    inline bool     isxdigit(_CharT __c, const locale& __loc)    { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c); }  template<typename _CharT>    inline bool     isalnum(_CharT __c, const locale& __loc)    { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c); }  template<typename _CharT>    inline bool     isgraph(_CharT __c, const locale& __loc)    { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c); }  template<typename _CharT>    inline _CharT     toupper(_CharT __c, const locale& __loc)    { return use_facet<ctype<_CharT> >(__loc).toupper(__c); }  template<typename _CharT>    inline _CharT     tolower(_CharT __c, const locale& __loc)    { return use_facet<ctype<_CharT> >(__loc).tolower(__c); }} // namespace std#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -