当前位置: 首页>>代码示例>>C++>>正文


C++ ios_base类代码示例

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


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

示例1: putHex

num_put<Pt::Char, ostreambuf_iterator<Pt::Char> >::iter_type
num_put<Pt::Char, ostreambuf_iterator<Pt::Char> >::do_put(iter_type s, ios_base& f, char_type fill, const void* ptr) const
{
    std::size_t val = reinterpret_cast<std::size_t>(ptr);
    putHex(s, val, f.flags(), f.width(0), fill);
    return s;
}
开发者ID:3Nigma,项目名称:frayon,代码行数:7,代码来源:Facets.cpp

示例2: do_put

num_put<Pt::Char, ostreambuf_iterator<Pt::Char> >::iter_type
num_put<Pt::Char, ostreambuf_iterator<Pt::Char> >::do_put(iter_type s, ios_base& f, char_type fill, bool val) const
{
    if( 0 == (f.flags() & ios_base::boolalpha) )
        return do_put(s, f, fill, static_cast<long>(val));
    
    typedef Pt::Char char_type;
    const numpunct<char_type>& np = use_facet< numpunct<char_type> >( f.getloc() );
 
    Pt::String str = val ? np.truename() : np.falsename();
 
    streamsize width = f.width(0);
   
    if( str.size() >= static_cast<std::size_t>(width) )
    {
        return std::copy(str.begin(), str.end(), s);
    }

    streamsize pad = width - str.size();
    ios_base::fmtflags dir = f.flags() & ios_base::adjustfield;

    if (dir == ios_base::left) 
    {
       std::copy(str.begin(), str.end(), s);
       std::fill_n(s, pad, fill);
       return s;
    }

    // right/internal padding 
    std::fill_n(s, pad, fill);
    return std::copy(str.begin(), str.end(), s);
}
开发者ID:3Nigma,项目名称:frayon,代码行数:32,代码来源:Facets.cpp

示例3: if

_InputIter
num_get<_CharT, _InputIter>::do_get(_InputIter __in, _InputIter __end,
                                    ios_base& __s,
                                    ios_base::iostate& __err, bool& __x) const
{
  if (__s.flags() & ios_base::boolalpha) {
    locale __loc = __s.getloc();
    const _Numpunct& __np = *(const _Numpunct*)__s._M_numpunct_facet();
    //    const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc) ;
//    const ctype<_CharT>& __ct =    use_facet<ctype<_CharT> >(__loc) ;

    const basic_string<_CharT> __truename  = __np.truename();
    const basic_string<_CharT> __falsename = __np.falsename();
    bool __true_ok  = true;
    bool __false_ok = true;

    size_t __n = 0;
    for ( ; __in != __end; ++__in) {
      _CharT __c = *__in;
      __true_ok  = __true_ok  && (__c == __truename[__n]);
      __false_ok = __false_ok && (__c == __falsename[__n]);
      ++__n;

      if ((!__true_ok && !__false_ok) ||
          (__true_ok  && __n >= __truename.size()) ||
          (__false_ok && __n >= __falsename.size())) {
	++__in;
        break;
      }
    }
    if (__true_ok  && __n < __truename.size())  __true_ok  = false;
    if (__false_ok && __n < __falsename.size()) __false_ok = false;
    
    if (__true_ok || __false_ok) {
      __err = ios_base::goodbit;
      __x = __true_ok;
    }
    else
      __err = ios_base::failbit;

    if (__in == __end)
      __err |= ios_base::eofbit;

    return __in;
  }

  else {
    long __lx;
    _InputIter __tmp = this->do_get(__in, __end, __s, __err, __lx);
    if (!(__err & ios_base::failbit)) {
      if (__lx == 0)
        __x = false;
      else if (__lx == 1)
        __x = true;
      else
        __err |= ios_base::failbit;
    }
    return __tmp;
  }
}
开发者ID:SwgSavior,项目名称:services,代码行数:60,代码来源:_num_get.c

示例4: _M_read_float

bool _STLP_CALL
_M_read_float(string& __buf, _InputIter& __in, _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 = *(const ctype<_CharT>*)__s._M_ctype_facet();
  const numpunct<_CharT>& __numpunct = *(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 = __copy_sign(__in, __end, __buf, __xplus, __xminus);

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

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

  // There have to be some digits, somewhere.
  __ok = __digits_before_dot || __digits_after_dot;
  
  // Get an optional exponent.
  if (__ok && __in != __end && (*__in == __pow_e || *__in == __pow_E)) {
    __buf.push_back('e');
    ++__in;
    __in = __copy_sign(__in, __end, __buf, __xplus, __xminus);
    __ok = __copy_digits(__in, __end, __buf, __digits);
    // If we have an exponent then the sign 
    // is optional but the digits aren't.
  }
  
  return __ok;
}
开发者ID:SwgSavior,项目名称:services,代码行数:60,代码来源:_num_get.c

示例5: __get_base_or_zero

int
__get_base_or_zero(_InputIter& __in_ite, _InputIter& __end, ios_base& __str, _CharT*) {
  _CharT __atoms[5];
  const ctype<_CharT>& __c_type = *__STATIC_CAST(const ctype<_CharT>*, __str._M_ctype_facet());

  __c_type.widen(__narrow_atoms(), __narrow_atoms() + 5, __atoms);

  bool __negative = false;
  _CharT __c = *__in_ite;

  if (__c == __atoms[1] /* __xminus_char */ ) {
    __negative = true;
    ++__in_ite;
  }
  else if (__c == __atoms[0] /* __xplus_char */ )
    ++__in_ite;

  int __base;
  int __valid_zero = 0;

  ios_base::fmtflags __basefield = __str.flags() & ios_base::basefield;

  switch (__basefield) {
  case ios_base::oct:
    __base = 8;
    break;
  case ios_base::dec:
    __base = 10;
    break;
  case ios_base::hex:
    __base = 16;
    if (__in_ite != __end && *__in_ite == __atoms[2] /* __zero_char */ ) {
      ++__in_ite;
      if (__in_ite != __end &&
          (*__in_ite == __atoms[3] /* __x_char */ || *__in_ite == __atoms[4] /* __X_char */ ))
        ++__in_ite;
      else
        __valid_zero = 1; // That zero is valid by itself.
    }
    break;
  default:
    if (__in_ite != __end && *__in_ite == __atoms[2] /* __zero_char */ ) {
      ++__in_ite;
      if (__in_ite != __end &&
          (*__in_ite == __atoms[3] /* __x_char */ || *__in_ite == __atoms[4] /* __X_char */ )) {
        ++__in_ite;
        __base = 16;
      }
      else
        {
          __base = 8;
          __valid_zero = 1; // That zero is still valid by itself.
        }
    }
    else
      __base = 10;
    break;
  }
  return (__base << 2) | ((int)__negative << 1) | __valid_zero;
}
开发者ID:inetra,项目名称:peers1,代码行数:60,代码来源:_num_get.c

示例6: _M_do_put_float

_OutputIter _STLP_CALL
_M_do_put_float(_OutputIter __s, ios_base& __f,
                _CharT __fill, _Float __x) {
  __iostring __buf;

  size_t __group_pos = __write_float(__buf, __f.flags(), (int)__f.precision(), __x);
  
  const numpunct<_CharT>& __np = *__STATIC_CAST(const numpunct<_CharT>*, __f._M_numpunct_facet());

  return __put_float(__buf, __s, __f, __fill,
                     __np.decimal_point(), __np.thousands_sep(), 
                     __group_pos, __f._M_grouping());
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:13,代码来源:_num_put.c

示例7: _M_do_get_integer

_InputIter _STLP_CALL
_M_do_get_integer(_InputIter& __in, _InputIter& __end, ios_base& __str,
                  ios_base::iostate& __err, _Integer& __val, _CharT* __pc) 
{

#if defined(__HP_aCC) && (__HP_aCC == 1)
  bool _IsSigned = !((_Integer)(-1) > 0);
#else
  typedef typename __bool2type<numeric_limits<_Integer>::is_signed>::_Ret _IsSigned;
#endif

  const numpunct<_CharT>& __numpunct = *(const numpunct<_CharT>*)__str._M_numpunct_facet();
  const string& __grouping = __str._M_grouping(); // cached copy

  const int __base_or_zero = _M_get_base_or_zero(__in, __end, __str, __pc);
  int  __got = __base_or_zero & 1;

  bool __result;

  if (__in == __end) {      // We may have already read a 0.  If so,

    if (__got > 0) {       // the result is 0 even if we're at eof.
      __val = 0;
      __result = true;
    }
    else
      __result = false;    
  } else {

    const bool __negative = __base_or_zero & 2;
    const int __base = __base_or_zero >> 2;

#if defined(__HP_aCC) && (__HP_aCC == 1)
     if (_IsSigned)
       __result = __get_integer(__in, __end, __base,  __val, __got, __negative, __numpunct.thousands_sep(), __grouping, __true_type() );
     else
      __result = __get_integer(__in, __end, __base,  __val, __got, __negative, __numpunct.thousands_sep(), __grouping, __false_type() );
#else
    __result = __get_integer(__in, __end, __base,  __val, __got, __negative, __numpunct.thousands_sep(), __grouping, _IsSigned());
# endif
  }

  __err = __STATIC_CAST(ios_base::iostate, __result ? ios_base::goodbit : ios_base::failbit);

  if (__in == __end)
    __err |= ios_base::eofbit;
  return __in;
}
开发者ID:SwgSavior,项目名称:services,代码行数:48,代码来源:_num_get.c

示例8: __get_money_digits_aux

inline void __get_money_digits_aux (__iowstring &__wbuf, ios_base &__f, _STLP_LONG_DOUBLE __x) {
  __iostring __buf;
  __get_floor_digits(__buf, __x);

  const ctype<wchar_t>& __ct = *__STATIC_CAST(const ctype<wchar_t>*, __f._M_ctype_facet());
  __convert_float_buffer(__buf, __wbuf, __ct, wchar_t(0), false);
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:7,代码来源:_num_put.c

示例9: while

_OutputIter
time_put<_Ch,_OutputIter>::put(_OutputIter __s, ios_base& __f, _Ch __fill,
			       const tm* __tmb,
			       const _Ch* __pat, const _Ch* __pat_end) const 
{
  //  locale __loc = __f.getloc();
  //  const ctype<_Ch>& _Ct = use_facet<ctype<_Ch> >(__loc); 
  const ctype<_Ch>& _Ct = *(ctype<_Ch>*)__f._M_ctype_facet(); 
  while (__pat != __pat_end) {
    char __c = _Ct.narrow(*__pat, 0);
    if (__c == '%') {
      char __mod = 0;
      ++__pat;
      __c = _Ct.narrow(*__pat++, 0);
      if(__c == '#') { // MS extension
        __mod = __c;
        __c = _Ct.narrow(*__pat++, 0);
      }
      __s = do_put(__s, __f, __fill, __tmb, __c, __mod);
    }
    else
      *__s++ = *__pat++;
  }
  return __s;
}
开发者ID:RaymondLiao,项目名称:elektronika,代码行数:25,代码来源:_time_facets.c

示例10: switch

num_get< Pt::Char, istreambuf_iterator<Pt::Char> >::iter_type
num_get< Pt::Char, istreambuf_iterator<Pt::Char> >::do_get(iter_type it, iter_type end, 
                                                           ios_base& stream, ios_base::iostate& state, 
                                                           unsigned long long& val) const
{
    bool ok = false;
    switch(stream.flags() & ios_base::basefield) 
    {
        case ios_base::oct:
            it = Pt::parseInt(it, end, val, Pt::OctalFormat<Pt::Char>(), ok);
            break;
        case ios_base::hex:
            it = Pt::parseInt(it, end, val, Pt::HexFormat<Pt::Char>(), ok);
            break;
        default:
            it = Pt::parseInt(it, end, val, Pt::DecimalFormat<Pt::Char>(), ok);
            break;
    }

    if( ok )
        state = ios_base::goodbit;
    else
        state = ios_base::failbit;

    if (it == end)
        state |= ios_base::eofbit;

    return it;
}
开发者ID:3Nigma,项目名称:frayon,代码行数:29,代码来源:Facets.cpp

示例11: __do_get_integer

_InputIter _STLP_CALL
__do_get_integer(_InputIter& __in_ite, _InputIter& __end, ios_base& __str,
                 ios_base::iostate& __err, _Integer& __val, _CharT* /*__pc*/) {
  locale __loc = __str.getloc();
  const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);

#if defined (__HP_aCC) && (__HP_aCC == 1)
  bool _IsSigned = !((_Integer)(-1) > 0);
#else
  typedef typename is_signed<_Integer>::type::type _IsSigned;
#endif

  const int __base_or_zero = __get_base_or_zero(__in_ite, __end, __str.flags(), __ctype);
  int  __got = __base_or_zero & 1;

  bool __result;

  if (__in_ite == __end) {      // We may have already read a 0.  If so,

    if (__got > 0) {       // the result is 0 even if we're at eof.
      __val = 0;
      __result = true;
    }
    else
      __result = false;
  }
  else {
    const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
    const bool __negative = (__base_or_zero & 2) != 0;
    const int __base = __base_or_zero >> 2;

#if defined (__HP_aCC) && (__HP_aCC == 1)
    if (_IsSigned)
      __result = __get_integer(__in_ite, __end, __base,  __val, __got, __negative, __np.thousands_sep(), __np.grouping(), __true_type() );
    else
      __result = __get_integer(__in_ite, __end, __base,  __val, __got, __negative, __np.thousands_sep(), __np.grouping(), __false_type() );
#else
    __result = __get_integer(__in_ite, __end, __base,  __val, __got, __negative, __np.thousands_sep(), __np.grouping(), _IsSigned());
# endif
  }

  __err = __STATIC_CAST(ios_base::iostate, __result ? ios_base::goodbit : ios_base::failbit);

  if (__in_ite == __end)
    __err |= ios_base::eofbit;
  return __in_ite;
}
开发者ID:miaozhendaoren,项目名称:K2SAR_EMS,代码行数:47,代码来源:_num_get.c

示例12: __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

示例13:

_InputIter
num_get<_CharT, _InputIter>::do_get(_InputIter __in_ite, _InputIter __end,
                                    ios_base& __s,
                                    ios_base::iostate& __err, bool& __x) const {
  if (__s.flags() & ios_base::boolalpha) {
    locale __loc = __s.getloc();
    const _Numpunct& __np = *__STATIC_CAST(const _Numpunct*, __s._M_numpunct_facet());
    //    const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc) ;
//    const ctype<_CharT>& __ct =    use_facet<ctype<_CharT> >(__loc) ;

    const basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > __truename  = __np.truename();
    const basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > __falsename = __np.falsename();
    bool __true_ok  = true;
    bool __false_ok = true;

    size_t __n = 0;
    for ( ; __in_ite != __end; ++__in_ite) {
      _CharT __c = *__in_ite;
      __true_ok  = __true_ok  && (__c == __truename[__n]);
      __false_ok = __false_ok && (__c == __falsename[__n]);
      ++__n;

      if ((!__true_ok && !__false_ok) ||
          (__true_ok  && __n >= __truename.size()) ||
          (__false_ok && __n >= __falsename.size())) {
        ++__in_ite;
        break;
      }
    }
    if (__true_ok  && __n < __truename.size())  __true_ok  = false;
    if (__false_ok && __n < __falsename.size()) __false_ok = false;

    if (__true_ok || __false_ok) {
      __err = ios_base::goodbit;
      __x = __true_ok;
    }
    else
      __err = ios_base::failbit;

    if (__in_ite == __end)
      __err |= ios_base::eofbit;

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

示例14: __put_time

_OuIt _STLP_CALL
__put_time(char * __first, char * __last, _OuIt __out,
           const ios_base& __s, wchar_t) {
    const ctype<wchar_t>& __ct = *(ctype<wchar_t>*)__s._M_ctype_facet();
    wchar_t __wbuf[64];
    __ct.widen(__first, __last, __wbuf);
    ptrdiff_t __len = __last - __first;
    wchar_t * __eend = __wbuf + __len;
    return copy((wchar_t*)__wbuf, __eend, __out);
}
开发者ID:RaymondLiao,项目名称:elektronika,代码行数:10,代码来源:_time_facets.c

示例15: __do_get_float

_InputIter _STLP_CALL
__do_get_float(_InputIter& __in_ite, _InputIter& __end, ios_base& __str,
               ios_base::iostate& __err, _Float& __val, _CharT* /*__pc*/) {
  locale __loc = __str.getloc();
  const ctype<_CharT> &__ctype = use_facet<ctype<_CharT> >(__loc);
  const numpunct<_CharT> &__numpunct = use_facet<numpunct<_CharT> >(__loc);

  __iostring __buf ;
  bool __ok = __read_float(__buf, __in_ite, __end, __ctype, __numpunct);
  if (__ok) {
    __string_to_float(__buf, __val);
    __err = ios_base::goodbit;
  }
  else {
    __err = ios_base::failbit;
  }
  if (__in_ite == __end)
    __err |= ios_base::eofbit;
  return __in_ite;
}
开发者ID:miaozhendaoren,项目名称:K2SAR_EMS,代码行数:20,代码来源:_num_get.c


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