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

📄 _num_put.c

📁 symbian 上的stl_port进过编译的。
💻 C
📖 第 1 页 / 共 2 页
字号:
typedef unsigned long __umax_int_t;#endif_STLP_DECLSPEC const char* _STLP_CALL __hex_char_table_lo();_STLP_DECLSPEC const char* _STLP_CALL __hex_char_table_hi();template <class _Integer>inline char* _STLP_CALL__write_decimal_backward(char* __ptr, _Integer __x, ios_base::fmtflags __flags, const __true_type& /* is_signed */) {  const bool __negative = __x < 0 ;  __max_int_t __temp = __x;  __umax_int_t __utemp = __negative?-__temp:__temp;  for (; __utemp != 0; __utemp /= 10)    *--__ptr = (char)((int)(__utemp % 10) + '0');  // put sign if needed or requested  if (__negative)    *--__ptr = '-';  else if (__flags & ios_base::showpos)    *--__ptr = '+';  return __ptr;}template <class _Integer>inline char* _STLP_CALL__write_decimal_backward(char* __ptr, _Integer __x, ios_base::fmtflags __flags, const __false_type& /* is_signed */) {  for (; __x != 0; __x /= 10)    *--__ptr = (char)((int)(__x % 10) + '0');  // put sign if requested  if (__flags & ios_base::showpos)    *--__ptr = '+';  return __ptr;}template <class _Integer>char* _STLP_CALL__write_integer_backward(char* __buf, ios_base::fmtflags __flags, _Integer __x) {  char* __ptr = __buf;  if (__x == 0) {    *--__ptr = '0';    if ((__flags & ios_base::showpos) && ((__flags & (ios_base::oct | ios_base::hex)) == 0))      *--__ptr = '+';    // oct or hex base shall not be added to the 0 value (see '#' flag in C formating strings)  }  else {    switch (__flags & ios_base::basefield) {      case ios_base::oct:        {          __umax_int_t __temp = __x;          // if the size of integer is less than 8, clear upper part          if ( sizeof(__x) < 8  && sizeof(__umax_int_t) >= 8 )            __temp &= 0xFFFFFFFF;          for (; __temp != 0; __temp >>=3)            *--__ptr = (char)((((unsigned)__temp)& 0x7) + '0');          // put leading '0' if showbase is set          if (__flags & ios_base::showbase)            *--__ptr = '0';        }        break;      case ios_base::hex:        {          const char* __table_ptr = (__flags & ios_base::uppercase) ?            __hex_char_table_hi() : __hex_char_table_lo();          __umax_int_t __temp = __x;          // if the size of integer is less than 8, clear upper part          if ( sizeof(__x) < 8  && sizeof(__umax_int_t) >= 8 )            __temp &= 0xFFFFFFFF;          for (; __temp != 0; __temp >>=4)            *--__ptr = __table_ptr[((unsigned)__temp & 0xF)];          if (__flags & ios_base::showbase) {            *--__ptr = __table_ptr[16];            *--__ptr = '0';          }        }        break;      //case ios_base::dec:      default:        {#if defined(__HP_aCC) && (__HP_aCC == 1)          bool _IsSigned = !((_Integer)-1 > 0);          if (_IsSigned)            __ptr = __write_decimal_backward(__ptr, __x, __flags, __true_type() );          else            __ptr = __write_decimal_backward(__ptr, __x, __flags, __false_type() );#else          typedef typename __bool2type<numeric_limits<_Integer>::is_signed>::_Ret _IsSigned;          __ptr = __write_decimal_backward(__ptr, __x, __flags, _IsSigned());#endif        }        break;    }  }  // return pointer to beginning of the string  return __ptr;}template <class _CharT, class _OutputIter, class _Integer>_OutputIter _STLP_CALL__do_put_integer(_OutputIter __s, ios_base& __f, _CharT __fill, _Integer __x) {  // buffer size = number of bytes * number of digit necessary in the smallest Standard base (base 8, 3 digits/byte)  //               plus the longest base representation '0x'  // Do not use __buf_size to define __buf static buffer, some compilers (HP aCC) do not accept const variable as  // the specification of a static buffer size.  char __buf[sizeof(_Integer) * 3 + 2];  const ptrdiff_t __buf_size = sizeof(__buf) / sizeof(char);  ios_base::fmtflags __flags = __f.flags();  char* __ibeg = __write_integer_backward((char*)__buf+__buf_size, __flags, __x);  return __put_integer(__ibeg, (char*)__buf+__buf_size, __s, __f, __flags, __fill);}_STLP_MOVE_TO_STD_NAMESPACE//// num_put<>//#if (_STLP_STATIC_TEMPLATE_DATA > 0)#  if !defined (__BORLANDC__)template <class _CharT, class _OutputIterator>locale::id num_put<_CharT, _OutputIterator>::id;#  endif#  if (defined (__CYGWIN__) || defined (__MINGW32__)) && \       defined (_STLP_USE_DYNAMIC_LIB) && !defined (__BUILDING_STLPORT)/* * Under cygwin, when STLport is used as a shared library, the id needs * to be specified as imported otherwise they will be duplicated in the * calling executable. */template <>_STLP_DECLSPEC locale::id num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id;/*template <>_STLP_DECLSPEC locale::id num_put<char, char*>::id;*/#    if !defined (_STLP_NO_WCHAR_T)template <>_STLP_DECLSPEC locale::id num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;/*template <>_STLP_DECLSPEC locale::id num_put<wchar_t, wchar_t*>::id;*/#    endif#  endif /* __CYGWIN__ && _STLP_USE_DYNAMIC_LIB */#else /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) *///typedef num_put<char, char*> num_put_char;typedef num_put<char, ostreambuf_iterator<char, char_traits<char> > > num_put_char_2;//__DECLARE_INSTANCE(locale::id, num_put_char::id, );__DECLARE_INSTANCE(locale::id, num_put_char_2::id, );#  if !defined (_STLP_NO_WCHAR_T)//typedef num_put<wchar_t, wchar_t*> num_put_wchar_t;typedef num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > num_put_wchar_t_2;//__DECLARE_INSTANCE(locale::id, num_put_wchar_t::id, );__DECLARE_INSTANCE(locale::id, num_put_wchar_t_2::id, );#  endif#endif /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */// issue 118#if !defined (_STLP_NO_BOOL)template <class _CharT, class _OutputIter>_OutputIternum_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f,                                     char_type __fill,  bool __val) const {  if (!(__f.flags() & ios_base::boolalpha))    return this->do_put(__s, __f, __fill, __STATIC_CAST(long,__val));  locale __loc = __f.getloc();  //  typedef numpunct<_CharT> _Punct;  //  const _Punct& __np = use_facet<_Punct>(__loc);  const numpunct<_CharT>& __np = *__STATIC_CAST(const numpunct<_CharT>*, __f._M_numpunct_facet());  basic_string<_CharT> __str = __val ? __np.truename() : __np.falsename();  // Reuse __copy_integer_and_fill.  Since internal padding makes no  // sense for bool, though, make sure we use something else instead.  // The last two argument to __copy_integer_and_fill are dummies.  ios_base::fmtflags __flags = __f.flags();  if ((__flags & ios_base::adjustfield) == ios_base::internal)    __flags = (__flags & ~ios_base::adjustfield) | ios_base::right;  return _STLP_PRIV __copy_integer_and_fill(__str.c_str(), __str.size(), __s,                                            __flags, __f.width(0), __fill,                                            (_CharT) 0, (_CharT) 0);}#endiftemplate <class _CharT, class _OutputIter>_OutputIternum_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,                                     long __val) const{ return _STLP_PRIV __do_put_integer(__s, __f, __fill, __val); }template <class _CharT, class _OutputIter>_OutputIternum_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,                                     unsigned long __val) const{ return _STLP_PRIV __do_put_integer(__s, __f, __fill, __val); }template <class _CharT, class _OutputIter>_OutputIternum_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,                                     double __val) const{ return _STLP_PRIV __do_put_float(__s, __f, __fill, __val); }#if !defined (_STLP_NO_LONG_DOUBLE)template <class _CharT, class _OutputIter>_OutputIternum_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,                                     long double __val) const{ return _STLP_PRIV __do_put_float(__s, __f, __fill, __val); }#endif#if defined (_STLP_LONG_LONG)template <class _CharT, class _OutputIter>_OutputIternum_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,                                     _STLP_LONG_LONG __val) const{ return _STLP_PRIV __do_put_integer(__s, __f, __fill, __val); }template <class _CharT, class _OutputIter>_OutputIternum_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,                                     unsigned _STLP_LONG_LONG __val) const{ return _STLP_PRIV __do_put_integer(__s, __f, __fill, __val); }#endif /* _STLP_LONG_LONG */// lib.facet.num.put.virtuals "12 For conversion from void* the specifier is %p."template <class _CharT, class _OutputIter>_OutputIternum_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT /*__fill*/,                                     const void* __val) const {  const ctype<_CharT>& __c_type = *__STATIC_CAST(const ctype<_CharT>*, __f._M_ctype_facet());  ios_base::fmtflags __save_flags = __f.flags();  __f.setf(ios_base::hex, ios_base::basefield);  __f.setf(ios_base::showbase);  __f.setf(ios_base::internal, ios_base::adjustfield);  __f.width((sizeof(void*) * 2) + 2); // digits in pointer type plus '0x' prefix# if defined(_STLP_LONG_LONG) && !defined(__MRC__) //*ty 11/24/2001 - MrCpp can not cast from void* to long long  _OutputIter result = this->do_put(__s, __f, __c_type.widen('0'), __REINTERPRET_CAST(unsigned _STLP_LONG_LONG,__val));# else  _OutputIter result = this->do_put(__s, __f, __c_type.widen('0'), __REINTERPRET_CAST(unsigned long,__val));# endif  __f.flags(__save_flags);  return result;}_STLP_END_NAMESPACE#endif /* _STLP_NUM_PUT_C */// Local Variables:// mode:C++// End:

⌨️ 快捷键说明

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