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

📄 codecvt_specializations.h

📁 俄罗斯高人Mamaich的Pocket gcc编译器(运行在PocketPC上)的全部源代码。
💻 H
📖 第 1 页 / 共 2 页
字号:
      virtual int       do_length(const state_type&, const extern_type* __from, 		const extern_type* __end, size_t __max) const;      virtual int       do_max_length() const throw();    };  template<typename _InternT, typename _ExternT>    locale::id     codecvt<_InternT, _ExternT, __enc_traits>::id;  // This adaptor works around the signature problems of the second  // argument to iconv():  SUSv2 and others use 'const char**', but glibc 2.2  // uses 'char**', which matches the POSIX 1003.1-2001 standard.  // Using this adaptor, g++ will do the work for us.  template<typename _T>    inline size_t    __iconv_adaptor(size_t(*__func)(iconv_t, _T, size_t*, char**, size_t*),                    iconv_t __cd, char** __inbuf, size_t* __inbytes,                    char** __outbuf, size_t* __outbytes)    { return __func(__cd, (_T)__inbuf, __inbytes, __outbuf, __outbytes); }  template<typename _InternT, typename _ExternT>    codecvt_base::result    codecvt<_InternT, _ExternT, __enc_traits>::    do_out(state_type& __state, const intern_type* __from, 	   const intern_type* __from_end, const intern_type*& __from_next,	   extern_type* __to, extern_type* __to_end,	   extern_type*& __to_next) const    {      result __ret = codecvt_base::error;      if (__state._M_good())	{	  typedef state_type::__desc_type	__desc_type;	  const __desc_type* __desc = __state._M_get_out_descriptor();	  const size_t __fmultiple = sizeof(intern_type);	  size_t __fbytes = __fmultiple * (__from_end - __from);	  const size_t __tmultiple = sizeof(extern_type);	  size_t __tbytes = __tmultiple * (__to_end - __to); 	  	  // Argument list for iconv specifies a byte sequence. Thus,	  // all to/from arrays must be brutally casted to char*.	  char* __cto = reinterpret_cast<char*>(__to);	  char* __cfrom;	  size_t __conv;	  // Some encodings need a byte order marker as the first item	  // in the byte stream, to designate endian-ness. The default	  // value for the byte order marker is NULL, so if this is	  // the case, it's not necessary and we can just go on our	  // merry way.	  int __int_bom = __state._M_get_internal_bom();	  if (__int_bom)	    {	  	      size_t __size = __from_end - __from;	      intern_type* __cfixed = static_cast<intern_type*>(__builtin_alloca(sizeof(intern_type) * (__size + 1)));	      __cfixed[0] = static_cast<intern_type>(__int_bom);	      char_traits<intern_type>::copy(__cfixed + 1, __from, __size);	      __cfrom = reinterpret_cast<char*>(__cfixed);	      __conv = __iconv_adaptor(iconv, *__desc, &__cfrom,                                        &__fbytes, &__cto, &__tbytes); 	    }	  else	    {	      intern_type* __cfixed = const_cast<intern_type*>(__from);	      __cfrom = reinterpret_cast<char*>(__cfixed);	      __conv = __iconv_adaptor(iconv, *__desc, &__cfrom, &__fbytes, 				       &__cto, &__tbytes); 	    }	  if (__conv != size_t(-1))	    {	      __from_next = reinterpret_cast<const intern_type*>(__cfrom);	      __to_next = reinterpret_cast<extern_type*>(__cto);	      __ret = codecvt_base::ok;	    }	  else 	    {	      if (__fbytes < __fmultiple * (__from_end - __from))		{		  __from_next = reinterpret_cast<const intern_type*>(__cfrom);		  __to_next = reinterpret_cast<extern_type*>(__cto);		  __ret = codecvt_base::partial;		}	      else		__ret = codecvt_base::error;	    }	}      return __ret;     }  template<typename _InternT, typename _ExternT>    codecvt_base::result    codecvt<_InternT, _ExternT, __enc_traits>::    do_unshift(state_type& __state, extern_type* __to, 	       extern_type* __to_end, extern_type*& __to_next) const    {      result __ret = codecvt_base::error;      if (__state._M_good())	{	  typedef state_type::__desc_type	__desc_type;	  const __desc_type* __desc = __state._M_get_in_descriptor();	  const size_t __tmultiple = sizeof(intern_type);	  size_t __tlen = __tmultiple * (__to_end - __to); 	  	  // Argument list for iconv specifies a byte sequence. Thus,	  // all to/from arrays must be brutally casted to char*.	  char* __cto = reinterpret_cast<char*>(__to);	  size_t __conv = __iconv_adaptor(iconv,*__desc, NULL, NULL,                                          &__cto, &__tlen); 	  	  if (__conv != size_t(-1))	    {	      __to_next = reinterpret_cast<extern_type*>(__cto);	      if (__tlen == __tmultiple * (__to_end - __to))		__ret = codecvt_base::noconv;	      else if (__tlen == 0)		__ret = codecvt_base::ok;	      else		__ret = codecvt_base::partial;	    }	  else 	    __ret = codecvt_base::error;	}      return __ret;     }     template<typename _InternT, typename _ExternT>    codecvt_base::result    codecvt<_InternT, _ExternT, __enc_traits>::    do_in(state_type& __state, const extern_type* __from, 	  const extern_type* __from_end, const extern_type*& __from_next,	  intern_type* __to, intern_type* __to_end, 	  intern_type*& __to_next) const    {       result __ret = codecvt_base::error;      if (__state._M_good())	{	  typedef state_type::__desc_type	__desc_type;	  const __desc_type* __desc = __state._M_get_in_descriptor();	  const size_t __fmultiple = sizeof(extern_type);	  size_t __flen = __fmultiple * (__from_end - __from);	  const size_t __tmultiple = sizeof(intern_type);	  size_t __tlen = __tmultiple * (__to_end - __to); 	  	  // Argument list for iconv specifies a byte sequence. Thus,	  // all to/from arrays must be brutally casted to char*.	  char* __cto = reinterpret_cast<char*>(__to);	  char* __cfrom;	  size_t __conv;	  // Some encodings need a byte order marker as the first item	  // in the byte stream, to designate endian-ness. The default	  // value for the byte order marker is NULL, so if this is	  // the case, it's not necessary and we can just go on our	  // merry way.	  int __ext_bom = __state._M_get_external_bom();	  if (__ext_bom)	    {	  	      size_t __size = __from_end - __from;	      extern_type* __cfixed =  static_cast<extern_type*>(__builtin_alloca(sizeof(extern_type) * (__size + 1)));	      __cfixed[0] = static_cast<extern_type>(__ext_bom);	      char_traits<extern_type>::copy(__cfixed + 1, __from, __size);	      __cfrom = reinterpret_cast<char*>(__cfixed);	      __conv = __iconv_adaptor(iconv, *__desc, &__cfrom,                                       &__flen, &__cto, &__tlen); 	    }	  else	    {	      extern_type* __cfixed = const_cast<extern_type*>(__from);	      __cfrom = reinterpret_cast<char*>(__cfixed);	      __conv = __iconv_adaptor(iconv, *__desc, &__cfrom,                                       &__flen, &__cto, &__tlen); 	    }	  	  if (__conv != size_t(-1))	    {	      __from_next = reinterpret_cast<const extern_type*>(__cfrom);	      __to_next = reinterpret_cast<intern_type*>(__cto);	      __ret = codecvt_base::ok;	    }	  else 	    {	      if (__flen < static_cast<size_t>(__from_end - __from))		{		  __from_next = reinterpret_cast<const extern_type*>(__cfrom);		  __to_next = reinterpret_cast<intern_type*>(__cto);		  __ret = codecvt_base::partial;		}	      else		__ret = codecvt_base::error;	    }	}      return __ret;     }    template<typename _InternT, typename _ExternT>    int     codecvt<_InternT, _ExternT, __enc_traits>::    do_encoding() const throw()    {      int __ret = 0;      if (sizeof(_ExternT) <= sizeof(_InternT))	__ret = sizeof(_InternT)/sizeof(_ExternT);      return __ret;     }    template<typename _InternT, typename _ExternT>    bool     codecvt<_InternT, _ExternT, __enc_traits>::    do_always_noconv() const throw()    { return false; }    template<typename _InternT, typename _ExternT>    int     codecvt<_InternT, _ExternT, __enc_traits>::    do_length(const state_type&, const extern_type* __from, 	      const extern_type* __end, size_t __max) const    { return min(__max, static_cast<size_t>(__end - __from)); }#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS// 74.  Garbled text for codecvt::do_max_length  template<typename _InternT, typename _ExternT>    int     codecvt<_InternT, _ExternT, __enc_traits>::    do_max_length() const throw()    { return 1; }#endif

⌨️ 快捷键说明

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