• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ __iostring类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中__iostring的典型用法代码示例。如果您正苦于以下问题:C++ __iostring类的具体用法?C++ __iostring怎么用?C++ __iostring使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了__iostring类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: __get_floor_digits

void _STLP_CALL __get_floor_digits(__iostring &out, _STLP_LONG_DOUBLE __x) {
#ifdef USE_SPRINTF_INSTEAD
  char cvtbuf[128];
#  ifndef _STLP_NO_LONG_DOUBLE
#   ifndef N_PLAT_NLM
  snprintf(ARRAY_AND_SIZE(cvtbuf), "%Lf", __x); // check for 1234.56!
#   else
  sprintf(cvtbuf, "%Lf", __x); // check for 1234.56!
#   endif
#  else
  snprintf(ARRAY_AND_SIZE(cvtbuf), "%f", __x);  // check for 1234.56!
#  endif
  char *p = strchr( cvtbuf, '.' );
  if ( p == 0 ) {
    out.append( cvtbuf );
  } else {
    out.append( cvtbuf, p );
  }
#else
  char cvtbuf[NDIG+2];
  char * bp;
  int decpt, sign;
#ifndef _STLP_NO_LONG_DOUBLE
  bp = _Stl_qfcvtR(__x, 0, &decpt, &sign, cvtbuf);
#else
  bp = _Stl_fcvtR(__x, 0, &decpt, &sign, cvtbuf);
#endif

  if (sign) {
    out += '-';
  }
  out.append(bp, bp + decpt);
#endif // USE_PRINTF_INSTEAD
}
开发者ID:RenEvo,项目名称:dead6,代码行数:34,代码来源:num_put_float.cpp


示例2: __read_float

bool _STLP_CALL
__read_float(__iostring& __buf, _InputIter& __in_ite, _InputIter& __end, ios_base& __s, _CharT*) {
  // Create a string, copying characters of the form
  // [+-]? [0-9]* .? [0-9]* ([eE] [+-]? [0-9]+)?

  bool __digits_before_dot /* = false */;
  bool __digits_after_dot = false;
  bool __ok;

  bool   __grouping_ok = true;

  const ctype<_CharT>& __ct = *__STATIC_CAST(const ctype<_CharT>*, __s._M_ctype_facet());
  const numpunct<_CharT>& __numpunct = *__STATIC_CAST(const numpunct<_CharT>*, __s._M_numpunct_facet());
  const string& __grouping = __s._M_grouping(); // cached copy

  _CharT __dot = __numpunct.decimal_point();
  _CharT __sep = __numpunct.thousands_sep();

  _CharT __digits[10];
  _CharT __xplus;
  _CharT __xminus;

  _CharT __pow_e;
  _CharT __pow_E;

  _Initialize_get_float(__ct, __xplus, __xminus, __pow_e, __pow_E, __digits);

  // Get an optional sign
  __in_ite = __copy_sign(__in_ite, __end, __buf, __xplus, __xminus);

  // Get an optional string of digits.
  if (!__grouping.empty())
    __digits_before_dot = __copy_grouped_digits(__in_ite, __end, __buf, __digits,
                                                __sep, __grouping, __grouping_ok);
  else
    __digits_before_dot = __copy_digits(__in_ite, __end, __buf, __digits);

  // Get an optional decimal point, and an optional string of digits.
  if (__in_ite != __end && *__in_ite == __dot) {
    __buf.push_back('.');
    ++__in_ite;
    __digits_after_dot = __copy_digits(__in_ite, __end, __buf, __digits);
  }

  // There have to be some digits, somewhere.
  __ok = __digits_before_dot || __digits_after_dot;

  // Get an optional exponent.
  if (__ok && __in_ite != __end && (*__in_ite == __pow_e || *__in_ite == __pow_E)) {
    __buf.push_back('e');
    ++__in_ite;
    __in_ite = __copy_sign(__in_ite, __end, __buf, __xplus, __xminus);
    __ok = __copy_digits(__in_ite, __end, __buf, __digits);
    // If we have an exponent then the sign
    // is optional but the digits aren't.
  }

  return __ok;
}
开发者ID:inetra,项目名称:peers1,代码行数:59,代码来源:_num_get.c


示例3: __convert_float_buffer

void _STLP_CALL
__convert_float_buffer(__iostring const& str, __iowstring &out,
                       const ctype<wchar_t>& ct, wchar_t dot, bool __check_dot) {
    wchar_t __static_buf[128];
    wchar_t *__beg = __static_buf;
    wchar_t *__end = __static_buf + (sizeof(__static_buf) / sizeof(wchar_t));
    string::const_iterator str_ite(str.begin()), str_end(str.end());

    wchar_t *__cur = __beg;
    //First loop, check the dot char
    if (__check_dot) {
        while (str_ite != str_end) {
            if (*str_ite != '.') {
                *__cur = ct.widen(*str_ite);
            } else {
                *__cur = dot;
                break;
            }
            ++__cur;
            if (__cur == __end) {
                out.append(__beg, __cur);
                __cur = __beg;
            }
            ++str_ite;
        }
    } else {
        if (str_ite != str_end) {
            *__cur = ct.widen(*str_ite);
        }
    }

    if (str_ite != str_end) {
        ++__cur;
        ++str_ite;
        if (__cur == __end) {
            out.append(__beg, __cur);
            __cur = __beg;
        }

        //Second loop, dot has been found, no check anymore
        while (str_ite != str_end) {
            *__cur = ct.widen(*str_ite);
            ++__cur;
            if (__cur == __end) {
                out.append(__beg, __cur);
                __cur = __beg;
            }
            ++str_ite;
        }
    }

    out.append(__beg, __cur);
}
开发者ID:RenEvo,项目名称:dead6,代码行数:53,代码来源:num_put_float.cpp


示例4: __copy_grouped_digits

bool _STLP_CALL
__copy_grouped_digits(_InputIter& __first, _InputIter __last,
                      __iostring& __v, const _CharT * __digits,
                      _CharT __sep, const string& __grouping,
                      bool& __grouping_ok) {
  bool __ok = false;
  char __group_sizes[64];
  char*__group_sizes_end = __group_sizes;
  char __current_group_size = 0;

  for ( ; __first != __last; ++__first) {
    _CharT __c = *__first;
    bool __tmp = __get_fdigit_or_sep(__c, __sep, __digits);
    if (__tmp) {
      if (__c == ',') {
        *__group_sizes_end++ = __current_group_size;
        __current_group_size = 0;
      }
      else {
        __ok = true;
        __v.push_back((char)__c);
        ++__current_group_size;
      }
    }
    else
      break;
  }

  if (__group_sizes_end != __group_sizes)
    *__group_sizes_end++ = __current_group_size;
  __grouping_ok = __valid_grouping(__group_sizes, __group_sizes_end, __grouping.data(), __grouping.data() + __grouping.size());
  return __ok;
}
开发者ID:inetra,项目名称:peers1,代码行数:33,代码来源:_num_get.c


示例5: __adjust_float_buffer

void _STLP_CALL
__adjust_float_buffer(__iostring &str, char dot) {
  if ('.' != dot) {
    size_t __dot_pos = str.find('.');
    if (__dot_pos != string::npos) {
      str[__dot_pos] = dot;
    }
  }
}
开发者ID:RenEvo,项目名称:dead6,代码行数:9,代码来源:num_put_float.cpp


示例6: __put_float

_OutputIter  _STLP_CALL
__put_float(__iostring &__str, _OutputIter __oi,
            ios_base& __f, char __fill,
            char __decimal_point, char __sep, 
            size_t __group_pos, const string& __grouping) {
  if ((__group_pos < __str.size()) && (__str[__group_pos] == '.')) {
    __str[__group_pos] = __decimal_point;
  }

  if (!__grouping.empty()) {
    __insert_grouping(__str, __group_pos,
                      __grouping, __sep, '+', '-', 0);
  }

  return __copy_float_and_fill(__CONST_CAST(char*, __str.data()), 
                               __CONST_CAST(char*, __str.data()) + __str.size(), __oi,
                               __f.flags(), __f.width(0), __fill, '+', '-');
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:18,代码来源:_num_put.c


示例7: __write_float

size_t _STLP_CALL
__write_float(__iostring &buf, ios_base::fmtflags flags, int precision,
              long double x) {
#  ifdef USE_SPRINTF_INSTEAD
  /* If we want 'abitrary' precision, we should use 'abitrary' buffer size
   * below. - ptr
   */
  char static_buf[128];
  // char *static_buf = new char [128+precision];
  char fmtbuf[64];
  int i = fill_fmtbuf(fmtbuf, flags, 'L');
  // snprintf(static_buf, 128+precision, fmtbuf, precision, x);
#   ifndef N_PLAT_NLM
  snprintf(ARRAY_AND_SIZE(static_buf), fmtbuf, precision, x);    
#   else
  sprintf(static_buf, fmtbuf, precision, x);
#   endif
  // we should be able to return buf + sprintf(), but we do not trust'em...
  buf = static_buf;
  // delete [] static_buf;
  return find_if(buf.begin(), buf.end(), GroupPos()) - buf.begin();
#  else
  char cvtbuf[NDIG+2];
  char * bp;
  int decpt, sign;

  switch (flags & ios_base::floatfield) {
  case ios_base::fixed:
    bp = _Stl_qfcvtR(x, (min) (precision, MAXFCVT), &decpt, &sign, cvtbuf);
    break;
  case ios_base::scientific:
    bp = _Stl_qecvtR(x, (min) (precision + 1, MAXECVT), &decpt, &sign, cvtbuf);
    break;
  default :
    bp = _Stl_qecvtR(x, (min) (precision, MAXECVT), &decpt, &sign, cvtbuf);
    break;
  }
  return __format_float(buf, bp, decpt, sign, x, flags, precision, true);
#  endif /* USE_SPRINTF_INSTEAD */
}
开发者ID:RenEvo,项目名称:dead6,代码行数:40,代码来源:num_put_float.cpp


示例8: __copy_sign

_InputIter  _STLP_CALL
__copy_sign(_InputIter __first, _InputIter __last, __iostring& __v,
            _CharT __xplus, _CharT __xminus) {
  if (__first != __last) {
    _CharT __c = *__first;
    if (__c == __xplus)
      ++__first;
    else if (__c == __xminus) {
      __v.push_back('-');
      ++__first;
    }
  }
  return __first;
}
开发者ID:inetra,项目名称:peers1,代码行数:14,代码来源:_num_get.c


示例9: __copy_digits

bool _STLP_CALL
__copy_digits(_InputIter& __first, _InputIter __last,
              __iostring& __v, const _CharT* __digits) {
  bool __ok = false;

  for ( ; __first != __last; ++__first) {
    _CharT __c = *__first;
    if (__get_fdigit(__c, __digits)) {
      __v.push_back((char)__c);
      __ok = true;
    }
    else
      break;
  }
  return __ok;
}
开发者ID:inetra,项目名称:peers1,代码行数:16,代码来源:_num_get.c


示例10: __format_float_fixed

size_t __format_float_fixed(__iostring &buf, const char * bp,
                            int decpt, int sign, bool /* x */,
                            ios_base::fmtflags flags,
                            int precision, bool islong ) {
  size_t __group_pos;
  char static_buf[128];
  int const BUF_SIZE = sizeof(static_buf) - 1;
  char *sbuf = static_buf;

  if (sign && decpt > -precision && *bp != 0)
    *sbuf++ = '-';
  else if (flags & ios_base::showpos)
    *sbuf++ = '+';
  
  int rzero   = 0;
  int nn      = decpt;
  int k       = 0;
  int maxfsig = islong ? 2*MAXFSIG : MAXFSIG;

  do {
    int nnn = (min) (nn, BUF_SIZE);
    nn -= nnn;
    do {
      *sbuf++ = ((nnn <= 0 || *bp == 0 || k >= maxfsig) ?
               '0' : (++k, *bp++));
    } while (--nnn > 0);
    buf.append(static_buf, sbuf);
    sbuf = static_buf;
  } while (nn != 0);

  // decimal point if needed
  __group_pos = buf.size() - 1;
  if (flags & ios_base::showpoint || precision > 0) {
    *sbuf++ = '.';
    ++__group_pos;
  } 

  // digits after decimal point if any
  nn = (min) (precision, MAXFCVT);
  if (precision > nn)
    rzero = precision - nn;
  while (nn != 0) {
    int nnn = (min) (nn, BUF_SIZE);
    nn -= nnn;
    while (--nnn >= 0) {
     *sbuf++ = (++decpt <= 0 || *bp == 0 || k >= maxfsig) ?
               '0' : (++k, *bp++);
    }
    buf.append(static_buf, sbuf);
    sbuf = static_buf;
  }

  // trailing zeros if needed
  while (rzero != 0) {
    int nnn = (min) (rzero, BUF_SIZE);
    rzero -= nnn;
    while (nnn-- > 0) {
      *sbuf++ = '0';
    }
    buf.append(static_buf, sbuf);
    sbuf = static_buf;
  }
  return __group_pos;
}
开发者ID:RenEvo,项目名称:dead6,代码行数:64,代码来源:num_put_float.cpp



注:本文中的__iostring类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ _bstr_t类代码示例发布时间:2022-05-31
下一篇:
C++ _Ty类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap