예제 #1
0
파일: _num_get.c 프로젝트: inetra/peers1
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;
}
예제 #2
0
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);
}
예제 #3
0
_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;
}
예제 #4
0
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;
}
예제 #5
0
_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);
}
예제 #6
0
_OutputIter  _STLP_CALL
__put_float(__iostring &__str, _OutputIter __oi,
            ios_base& __f, wchar_t __fill,
            wchar_t __decimal_point, wchar_t __sep, 
            size_t __group_pos, const string& __grouping) {
  const ctype<wchar_t>& __ct = *__STATIC_CAST(const ctype<wchar_t>*, __f._M_ctype_facet());

  __iowstring __wbuf;
  __convert_float_buffer(__str, __wbuf, __ct, __decimal_point);

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

  return __copy_float_and_fill(__CONST_CAST(wchar_t*, __wbuf.data()), 
                               __CONST_CAST(wchar_t*, __wbuf.data()) + __wbuf.size(), __oi,
                               __f.flags(), __f.width(0), __fill, __ct.widen('+'), __ct.widen('-')); 
}