Example #1
0
bool
__get_monetary_value(_InIt& __first, _InIt __last, _OuIt __out_ite,
                     const ctype<_CharT>& _c_type,
                     _CharT __point, int __frac_digits, _CharT __sep,
                     const string& __grouping, bool &__syntax_ok) {
  if (__first == __last || !_c_type.is(ctype_base::digit, *__first))
    return false;

  char __group_sizes[128];
  char* __group_sizes_end = __grouping.empty()? 0 : __group_sizes;
  char   __current_group_size = 0;

  while (__first != __last) {
    if (_c_type.is(ctype_base::digit, *__first)) {
      ++__current_group_size;
      *__out_ite++ = *__first++;
    }
    else if (__group_sizes_end) {
      if (*__first == __sep) {
        *__group_sizes_end++ = __current_group_size;
        __current_group_size = 0;
        ++__first;
      }
      else break;
    }
    else
      break;
  }

  if (__grouping.empty())
    __syntax_ok = true;
  else {
    if (__group_sizes_end != __group_sizes)
      *__group_sizes_end++ = __current_group_size;
    
    __syntax_ok = __valid_grouping(__group_sizes, __group_sizes_end,
                                   __grouping.data(), __grouping.data()+ __grouping.size());  
    
    if (__first == __last || *__first != __point) {
      for (int __digits = 0; __digits != __frac_digits; ++__digits)
        *__out_ite++ = _CharT('0');
      return true; // OK not to have decimal point
    }
  }

  ++__first;

  int __digits = 0;

  while (__first != __last && _c_type.is(ctype_base::digit, *__first)) {
      *__out_ite++ = *__first++;
     ++__digits;
  }

  __syntax_ok = __syntax_ok && (__digits == __frac_digits);

  return true;
}
Example #2
0
 bool operator()(argument_type __c) const {
   return _Traits::eq(__c, argument_type()) || 
          _M_ctype->is(ctype_base::space, __c);
 }
Example #3
0
 bool operator()(argument_type __c) const
   { return !_M_ctype->is(ctype_base::space, __c); }