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

📄 locale_facets.h

📁 openRisc2000编译链接器等,用于i386 cygwin
💻 H
📖 第 1 页 / 共 5 页
字号:
  {  public:    // NB: Code depends on the order of _S_atoms_out elements.    // Below are the indices into _S_atoms_out.    enum      {        _S_ominus,        _S_oplus,        _S_ox,        _S_oX,        _S_odigits,        _S_odigits_end = _S_odigits + 16,        _S_oudigits = _S_odigits_end,        _S_oudigits_end = _S_oudigits + 16,        _S_oe = _S_odigits + 14,  // For scientific notation, 'e'        _S_oE = _S_oudigits + 14, // For scientific notation, 'E'	_S_oend = _S_oudigits_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;    // String literal of acceptable (narrow) input, for num_get.    // "-+xX0123456789abcdefABCDEF"    static const char* _S_atoms_in;    enum    {      _S_iminus,      _S_iplus,      _S_ix,      _S_iX,      _S_izero,      _S_ie = _S_izero + 14,      _S_iE = _S_izero + 20,      _S_iend = 26    };    // 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);  };  template<typename _CharT>    struct __numpunct_cache : public locale::facet    {      const char*			_M_grouping;      size_t                            _M_grouping_size;      bool				_M_use_grouping;      const _CharT*			_M_truename;      size_t                            _M_truename_size;      const _CharT*			_M_falsename;      size_t                            _M_falsename_size;      _CharT				_M_decimal_point;      _CharT				_M_thousands_sep;      // A list of valid numeric literals for output: in the standard      // "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF".      // This array contains the chars after having been passed      // through the current locale's ctype<_CharT>.widen().      _CharT				_M_atoms_out[__num_base::_S_oend];      // A list of valid numeric literals for input: in the standard      // "C" locale, this is "-+xX0123456789abcdefABCDEF"      // This array contains the chars after having been passed      // through the current locale's ctype<_CharT>.widen().      _CharT				_M_atoms_in[__num_base::_S_iend];      bool				_M_allocated;      __numpunct_cache(size_t __refs = 0) : facet(__refs),      _M_grouping(NULL), _M_grouping_size(0), _M_use_grouping(false),      _M_truename(NULL), _M_truename_size(0), _M_falsename(NULL),      _M_falsename_size(0), _M_decimal_point(_CharT()),      _M_thousands_sep(_CharT()), _M_allocated(false)      { }      ~__numpunct_cache();      void      _M_cache(const locale& __loc);    private:      __numpunct_cache&      operator=(const __numpunct_cache&);            explicit      __numpunct_cache(const __numpunct_cache&);    };  template<typename _CharT>    __numpunct_cache<_CharT>::~__numpunct_cache()    {      if (_M_allocated)	{	  delete [] _M_grouping;	  delete [] _M_truename;	  delete [] _M_falsename;	}    }  /**   *  @brief  Numpunct facet.   *   *  This facet stores several pieces of information related to printing and   *  scanning numbers, such as the decimal point character.  It takes a   *  template parameter specifying the char type.  The numpunct facet is   *  used by streams for many I/O operations involving numbers.   *   *  The numpunct template uses protected virtual functions to provide the   *  actual results.  The public accessors forward the call to the virtual   *  functions.  These virtual functions are hooks for developers to   *  implement the behavior they require from a numpunct facet.  */  template<typename _CharT>    class numpunct : public locale::facet    {    public:      // Types:      //@{      /// Public typedefs      typedef _CharT			char_type;      typedef basic_string<_CharT>	string_type;      //@}      typedef __numpunct_cache<_CharT>  __cache_type;    protected:      __cache_type*			_M_data;    public:      /// Numpunct facet id.      static locale::id			id;      /**       *  @brief  Numpunct constructor.       *       *  @param  refs  Refcount to pass to the base class.       */      explicit      numpunct(size_t __refs = 0) : facet(__refs), _M_data(NULL)      { _M_initialize_numpunct(); }      /**       *  @brief  Internal constructor.  Not for general use.       *       *  This is a constructor for use by the library itself to set up the       *  predefined locale facets.       *       *  @param  cache  __numpunct_cache object.       *  @param  refs  Refcount to pass to the base class.       */      explicit      numpunct(__cache_type* __cache, size_t __refs = 0)      : facet(__refs), _M_data(__cache)      { _M_initialize_numpunct(); }      /**       *  @brief  Internal constructor.  Not for general use.       *       *  This is a constructor for use by the library itself to set up new       *  locales.       *       *  @param  cloc  The "C" locale.       *  @param  refs  Refcount to pass to the base class.       */      explicit      numpunct(__c_locale __cloc, size_t __refs = 0)      : facet(__refs), _M_data(NULL)      { _M_initialize_numpunct(__cloc); }      /**       *  @brief  Return decimal point character.       *       *  This function returns a char_type to use as a decimal point.  It       *  does so by returning returning       *  numpunct<char_type>::do_decimal_point().       *       *  @return  @a char_type representing a decimal point.      */      char_type      decimal_point() const      { return this->do_decimal_point(); }      /**       *  @brief  Return thousands separator character.       *       *  This function returns a char_type to use as a thousands       *  separator.  It does so by returning returning       *  numpunct<char_type>::do_thousands_sep().       *       *  @return  char_type representing a thousands separator.      */      char_type      thousands_sep() const      { return this->do_thousands_sep(); }      /**       *  @brief  Return grouping specification.       *       *  This function returns a string representing groupings for the       *  integer part of a number.  Groupings indicate where thousands       *  separators should be inserted in the integer part of a number.       *       *  Each char in the return string is interpret as an integer       *  rather than a character.  These numbers represent the number       *  of digits in a group.  The first char in the string       *  represents the number of digits in the least significant       *  group.  If a char is negative, it indicates an unlimited       *  number of digits for the group.  If more chars from the       *  string are required to group a number, the last char is used       *  repeatedly.       *       *  For example, if the grouping() returns "\003\002" and is       *  applied to the number 123456789, this corresponds to       *  12,34,56,789.  Note that if the string was "32", this would       *  put more than 50 digits into the least significant group if       *  the character set is ASCII.       *       *  The string is returned by calling       *  numpunct<char_type>::do_grouping().       *       *  @return  string representing grouping specification.      */      string      grouping() const      { return this->do_grouping(); }      /**       *  @brief  Return string representation of bool true.       *       *  This function returns a string_type containing the text       *  representation for true bool variables.  It does so by calling       *  numpunct<char_type>::do_truename().       *       *  @return  string_type representing printed form of true.      */      string_type      truename() const      { return this->do_truename(); }      /**       *  @brief  Return string representation of bool false.       *       *  This function returns a string_type containing the text       *  representation for false bool variables.  It does so by calling       *  numpunct<char_type>::do_falsename().       *       *  @return  string_type representing printed form of false.      */      string_type      falsename() const      { return this->do_falsename(); }    protected:      /// Destructor.      virtual      ~numpunct();      /**       *  @brief  Return decimal point character.       *       *  Returns a char_type to use as a decimal point.  This function is a       *  hook for derived classes to change the value returned.       *       *  @return  @a char_type representing a decimal point.      */      virtual char_type      do_decimal_point() const      { return _M_data->_M_decimal_point; }      /**       *  @brief  Return thousands separator character.       *       *  Returns a char_type to use as a thousands separator.  This function       *  is a hook for derived classes to change the value returned.       *       *  @return  @a char_type representing a thousands separator.      */      virtual char_type      do_thousands_sep() const      { return _M_data->_M_thousands_sep; }      /**       *  @brief  Return grouping specification.       *       *  Returns a string representing groupings for the integer part of a       *  number.  This function is a hook for derived classes to change the       *  value returned.  @see grouping() for details.       *       *  @return  String representing grouping specification.      */      virtual string      do_grouping() const      { return _M_data->_M_grouping; }      /**       *  @brief  Return string representation of bool true.       *       *  Returns a string_type containing the text representation for true       *  bool variables.  This function is a hook for derived classes to       *  change the value returned.       *       *  @return  string_type representing printed form of true.      */      virtual string_type      do_truename() const      { return _M_data->_M_truename; }      /**       *  @brief  Return string representation of bool false.       *       *  Returns a string_type containing the text representation for false       *  bool variables.  This function is a hook for derived classes to       *  change the value returned.       *       *  @return  string_type representing printed form of false.      */      virtual string_type      do_falsename() const      { return _M_data->_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 _GLIBCXX_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>    {    public:      typedef _CharT			char_type;      typedef basic_string<_CharT>	string_type;      explicit      numpunct_byname(const char* __s, size_t __refs = 0)      : numpunct<_CharT>(__refs)      {	if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)	  {	    __c_locale __tmp;	    this->_S_create_c_locale(__tmp, __s);	    this->_M_initialize_numpunct(__tmp);	    this->_S_destroy_c_locale(__tmp);	  }      }    protected:      virtual      ~numpunct_byname() { }    };  /**   *  @brief  Facet for parsing number strings.   *   *  This facet encapsulates the code to parse and return a number   *  from a string.  It is used by the istream numeric extraction   *  operators.   *   *  The num_get templ

⌨️ 快捷键说明

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