Пример #1
0
basic_istream<_CharT, _Traits>& __STL_CALL
getline(basic_istream<_CharT, _Traits>& __is,
        basic_string<_CharT,_Traits,_Alloc>& __s,
        _CharT __delim)
{
    __STL_USING_VENDOR_STD
    typedef basic_istream<_CharT, _Traits> __istream;
    size_t __nread = 0;
    typename basic_istream<_CharT, _Traits>::sentry __sentry(__is, true);
    if (__sentry) {
        basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf();
        __s.clear();

        while (__nread < __s.max_size()) {
            int __c1 = __buf->sbumpc();
            if (_Traits::eq_int_type(__c1, _Traits::eof())) {
                __is.setstate(__istream::eofbit);
                break;
            }
            else {
                ++__nread;
                _CharT __c = _Traits::to_char_type(__c1);
                if (!_Traits::eq(__c, __delim))
                    __s.push_back(__c);
                else
                    break;              // Character is extracted but not appended.
            }
        }
    }
    if (__nread == 0 || __nread >= __s.max_size())
        __is.setstate(__istream::failbit);

    return __is;
}
Пример #2
0
basic_istream<C>& operator>>(basic_istream<C>& in, stack<T>& s)
{
	char ch;
	stack<T> s1;
	try {
		in>>ch; if(ch!='(')
				throw "no (";
		in>>ch; if(ch==')'){ 
				s=stack<T>();
				return in;
			}
		in.putback(ch);
		while(ch!=')') 
		{
			T t;
			in>>t;
			s1.push(t);
			in>>ch;
			if(ch!=',' && ch!=')')
				throw "no ',' or ')'";
		}
	}
	catch(const char* s)
	{
		cout<<"error "<<s<<endl;
//		exit(0);
	}
	s = s1;
	return in;
}
Пример #3
0
ios_base::iostate _STLP_CALL 
_M_get_num(basic_istream<_CharT, _Traits>& __that, _Number& __val) {
  typedef typename basic_istream<_CharT, _Traits>::sentry _Sentry;
  ios_base::iostate __err = 0;
  _Sentry __sentry( __that );     // Skip whitespace.
  if (__sentry) {
    typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> > _Num_get;
    _STLP_TRY {
      ((const _Num_get&)use_facet<_Num_get>(__that.getloc())).get(istreambuf_iterator<_CharT, _Traits>(__that.rdbuf()),
                                                                  0, __that, __err, __val);
    }
    _STLP_CATCH_ALL {
      __that._M_handle_exception(ios_base::badbit);
    }
    if (__err) __that.setstate(__err);
  }
  return __err;
}
Пример #4
0
basic_istream<_CharT, _Traits>& _STLP_CALL
ws(basic_istream<_CharT, _Traits>& __is)
{
  typedef typename basic_istream<_CharT, _Traits>::sentry      _Sentry;
  _Sentry __sentry(__is, _No_Skip_WS()); // Don't skip whitespace.
  if (__sentry)
    __is._M_skip_whitespace(false);
  return __is;
}
Пример #5
0
ios_base::iostate _STLP_CALL
__get_num(basic_istream<_CharT, _Traits>& __that, _Number& __val) {
  typedef typename basic_istream<_CharT, _Traits>::sentry _Sentry;
  ios_base::iostate __err = 0;
  _Sentry __sentry( __that );     // Skip whitespace.
  if (__sentry) {
    typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> > _Num_get;
    _STLP_TRY {
      // Do not remove additional parenthesis around use_facet instanciation, some compilers (VC6)
      // require it when building the library.
      (use_facet<_Num_get>(__that.getloc())).get(istreambuf_iterator<_CharT, _Traits>(__that.rdbuf()),
                                               0, __that, __err, __val);
    }
    _STLP_CATCH_ALL {
      __that._M_handle_exception(ios_base::badbit);
    }
    if (__err) __that.setstate(__err);
  }
  return __err;
}
static void processCommand(void (Context::*f)(const string &, float, float, const string &), basic_istream<char> &stream)
{
	string name, transform;
	float a, b;

	getline(stream, name);
	stream >> a;
	stream >> b;
	stream.ignore(2, '\n');
	getline(stream, transform);

	(Context::GetActive()->*f)(name, a, b, transform);
}
Пример #7
0
bool
_M_init_noskip(basic_istream<_CharT, _Traits>& __is){
  if (__is.good()) {
    if (__is.tie())
      __is.tie()->flush();
    
    if (!__is.rdbuf())
      __is.setstate(ios_base::badbit);
  }
  else
    __is.setstate(ios_base::failbit);
  return __is.good();
}
Пример #8
0
bool
_M_init_skip(basic_istream<_CharT, _Traits>& __is) {
  if (__is.good()) {
    if (__is.tie())
      __is.tie()->flush();
    
    __is._M_skip_whitespace(true);
  }
  
  if (!__is.good()) {
    __is.setstate(ios_base::failbit);
    return false;
  } else
    return true;
}
Пример #9
0
basic_istream<CharType> & 
operator>>(basic_istream<CharType> &is, boost::int64_t & t){
    CharType d;
    do{
        d = is.get();
    }
    while(::isspace(d));
    bool negative = (d == '-');
    if(negative)
        d = is.get();
    unsigned int radix;
    if(is.flags() & (int)std::ios_base::hex)
        radix = 16;
    else
    if(is.flags() & (int)std::ios_base::oct)
        radix = 8;
    else
    //if(s.flags() & (int)std::ios_base::dec)
        radix =  10;
    t = 0;
    do{
        if('0' <= d && d <= '9')
            t = t * radix + (d - '0');
        else
        if('a' <= d && d <= 'f')
            t = t * radix + (d - 'a' + 10);
        else
            break;
        d = is.get();
    }
    while(!is.fail());
    // restore the delimiter
    is.putback(d);
    is.clear();
    if(negative)
        t = -t;
    return is;
}
Пример #10
0
basic_istream<_CharT, _Traits>& __STL_CALL
operator>>(basic_istream<_CharT, _Traits>& __is,
           basic_string<_CharT,_Traits, _Alloc>& __s)
{
# ifndef __STL_HAS_NO_NAMESPACES
#  ifdef __SGI_STL_OWN_IOSTREAMS
using __STL_VENDOR_CSTD::size_t;
#  else
using namespace __STL_VENDOR_STD;
#  endif
# endif

    typedef basic_istream<_CharT, _Traits> __istream;
    typename __istream::sentry __sentry(__is);

    if (__sentry) {
        basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf();
        typedef ctype<_CharT> _C_type;
        const locale& __loc = __is.getloc();
#ifdef __SGI_STL_OWN_IOSTREAMS
const _C_type& _Ctype = use_facet<_C_type>(__loc);
#else
# if defined (__STL_MSVC) && (__STL_MSVC <= 1200 )
const _C_type& _Ctype = use_facet(__loc , ( _C_type * ) 0, true);
# elif defined (__SUNPRO_CC)
const _C_type& _Ctype = use_facet(__loc , ( _C_type * ) 0);
# else
const _C_type& _Ctype = use_facet<_C_type>(__loc);
# endif
#endif
__s.clear();
size_t __n = __is.width(0);
if (__n == 0)
__n = __STATIC_CAST(size_t,-1);
else
__s.reserve(__n);


        while (__n-- > 0) {
            typename _Traits::int_type __c1 = __buf->sbumpc();
            if (_Traits::eq_int_type(__c1, _Traits::eof())) {
                __is.setstate(__istream::eofbit);
                break;
            }
            else {
                _CharT __c = _Traits::to_char_type(__c1);

                if (_Ctype.is(_C_type::space, __c)) {
                    if (_Traits::eq_int_type(__buf->sputbackc(__c), _Traits::eof()))
                        __is.setstate(__istream::failbit);
                    break;
                }
                else
                    __s.push_back(__c);
            }
        }

        // If we have read no characters, then set failbit.
        if (__s.size() == 0)
            __is.setstate(__istream::failbit);
    }
    else
        __is.setstate(__istream::failbit);

    return __is;
}