locale_facets.h

来自「ARM Linux Tool 各种代码包括MTD」· C头文件 代码 · 共 1,602 行 · 第 1/3 页

H
1,602
字号
      { return do_get_date(__s, __end, __f, __err, __t); }      iter_type       get_weekday(iter_type __s, iter_type __end, ios_base& __f,		  ios_base::iostate& __err, tm* __t) const      { return do_get_weekday(__s,__end,__f,__err,__t); }      iter_type       get_monthname(iter_type __s, iter_type __end, ios_base& __f, 		    ios_base::iostate& __err, tm* __t) const      { return do_get_monthname(__s,__end,__f,__err,__t); }      iter_type       get_year(iter_type __s, iter_type __end, ios_base& __f,	       ios_base::iostate& __err, tm* __t) const      { return do_get_year(__s,__end,__f,__err,__t); }    protected:      virtual       ~time_get()       {      	delete [] _M_monthnames; 	delete [] _M_daynames;       }      virtual dateorder       do_date_order()  const      { return time_base::ymd; }      virtual iter_type       do_get_time(iter_type __s, iter_type /*__end*/, ios_base&,		  ios_base::iostate& /*__err*/, tm* /*__t*/) const      { return __s; }      virtual iter_type       do_get_date(iter_type __s, iter_type /*__end*/, ios_base&,		  ios_base::iostate& /*__err*/, tm* /*__t*/) const      { return __s; }      virtual iter_type       do_get_weekday(iter_type __s, iter_type __end, ios_base&,		     ios_base::iostate& __err, tm* __t) const;      virtual iter_type       do_get_monthname(iter_type __s, iter_type __end, ios_base&, 		       ios_base::iostate& __err, tm* __t) const;      virtual iter_type       do_get_year(iter_type __s, iter_type /*__end*/, ios_base&,		   ios_base::iostate& /*__err*/, tm* /*__t*/) const      { return __s; }      mutable basic_string<_CharT>* _M_daynames;      mutable basic_string<_CharT>* _M_monthnames;    };  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:      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:      typedef _CharT     char_type;      typedef _OutIter   iter_type;      static locale::id id;      explicit       time_put(size_t __refs = 0) : locale::facet (__refs) { }      // NB: this is a nonvirtual, calls do_put in a loop.      iter_type       put(iter_type __s, ios_base& /*__f*/, char_type /*__fill*/,          const tm* /*__tmb*/, const _CharT* /*__pattern*/,          const _CharT* /*__pat_end*/) const      { return __s; }      iter_type       put(iter_type __s, ios_base& __f, char_type __fill,	  const tm* __tmb, char __format, char __modifier = 0) const      { return do_put(__s, __f, __fill, __tmb, __format, __modifier); }    protected:      virtual       ~time_put() { }      virtual iter_type       do_put(iter_type __s, ios_base&, char_type, const tm* /*__t*/, 	     char /*__format*/, char /*__mod*/) const      { return __s; }    };  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:      typedef _CharT     char_type;      typedef _OutIter   iter_type;      explicit       time_put_byname(const char*, size_t __refs = 0)       : time_put<_CharT, _OutIter> (__refs) { }    protected:      virtual       ~time_put_byname() { }    };  template<typename _CharT, typename _InIter>    class money_get : public locale::facet    {    public:      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& __f, ios_base::iostate& __err, long double& __units) const      { return do_get(__s, __end, __intl, __f, __err, __units); }      iter_type       get(iter_type __s, iter_type __end, bool __intl, ios_base& __f, 	   ios_base::iostate& __err, string_type& __digits) const      { return do_get(__s, __end, __intl, __f, __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      { return __s; }      virtual iter_type       do_get(iter_type __s, iter_type /*__end*/, bool /*__intl*/,             ios_base& /*__io*/, ios_base::iostate& /*__err*/,             string_type& /*__digits*/) const      { return __s; }    };  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& __f,	  char_type __fill, long double __units) const      { return do_put(__s, __intl, __f, __fill, __units); }      iter_type       put(iter_type __s, bool __intl, ios_base& __f,	  char_type __fill, const string_type& __digits) const      { return do_put(__s, __intl, __f, __fill, __digits); }    protected:      virtual       ~money_put() { }      virtual iter_type      do_put(iter_type __s, bool, ios_base& /*__io*/, char_type /*__fill*/,	     long double /*__units*/) const      { return __s; }      virtual iter_type      do_put(iter_type __s, bool, ios_base& /*__io*/, char_type /*__fill*/,	     const string_type& /*__digits*/) const      { return __s; }    };  template<typename _CharT, typename _OutIter>    locale::id money_put<_CharT, _OutIter>::id;  struct money_base  {    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 __preceeds, 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:      char_type 	_M_decimal_point;      char_type 	_M_thousands_sep;      string 		_M_grouping;      string_type 	_M_curr_symbol;      string_type 	_M_positive_sign;      string_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, size_t __refs = 0) : locale::facet(__refs)      { _M_initialize_moneypunct(__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        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);    };  template<typename _CharT, bool _Intl>    locale::id moneypunct<_CharT, _Intl>::id;  template<typename _CharT, bool _Intl>    const bool moneypunct<_CharT, _Intl>::intl;  template<typename _CharT, bool _Intl>    void    moneypunct<_CharT, _Intl>::_M_initialize_moneypunct(__c_locale /*__cloc*/)    {       // NB: Cannot be made generic.     }  template<>     void    moneypunct<char>::_M_initialize_moneypunct(__c_locale __cloc);#ifdef _GLIBCPP_USE_WCHAR_T  template<>     void    moneypunct<wchar_t>::_M_initialize_moneypunct(__c_locale __cloc);#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;  struct messages_base  {    typedef int catalog;  };  template<typename _CharT>    class messages : public locale::facet, public messages_base    {    public:      typedef _CharT 			char_type;      typedef basic_string<_CharT> 	string_type;      static locale::id id;      explicit       messages(size_t __refs = 0) : locale::facet(__refs) { }      catalog       open(const basic_string<char>& __s, const locale& __loc) const      { return do_open(__s, __loc); }      string_type        get(catalog __c, int __set, int __msgid, const string_type& __s) const      { return do_get(__c,__set,__msgid,__s); }      void       close(catalog __c) const      { return do_close(__c); }    protected:      virtual       ~messages() { }      // NB: Probably these should be pure, and implemented only in      //  specializations of messages<>.  But for now...      virtual catalog       do_open(const basic_string<char>&, const locale&) const      { return 0; }      virtual string_type        do_get(catalog, int, int /*__msgid*/, const string_type& __dfault) const      { return __dfault; }      virtual void          do_close(catalog) const { }    };  template<typename _CharT>    locale::id messages<_CharT>::id;  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*, size_t __refs = 0);    protected:      virtual       ~messages_byname() { }    };  template<>    messages_byname<char>::messages_byname(const char*, size_t __refs);#ifdef _GLIBCPP_USE_WCHAR_T  template<>    messages_byname<wchar_t>::messages_byname(const char*, size_t __refs);#endif  // 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	/* _CPP_BITS_LOCFACETS_H */// Local Variables:// mode:c++// End:

⌨️ 快捷键说明

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