35 #define _ISTREAM_TCC 1 37 #pragma GCC system_header 41 namespace std _GLIBCXX_VISIBILITY(default)
43 _GLIBCXX_BEGIN_NAMESPACE_VERSION
45 template<
typename _CharT,
typename _Traits>
56 const __int_type __eof = traits_type::eof();
58 __int_type __c = __sb->
sgetc();
61 while (!traits_type::eq_int_type(__c, __eof)
62 && __ct.
is(ctype_base::space,
63 traits_type::to_char_type(__c)))
69 if (traits_type::eq_int_type(__c, __eof))
83 template<
typename _CharT,
typename _Traits>
84 template<
typename _ValueT>
89 sentry __cerb(*
this,
false);
96 __ng.
get(*
this, 0, *
this, __err, __v);
101 __throw_exception_again;
111 template<
typename _CharT,
typename _Traits>
112 basic_istream<_CharT, _Traits>&
118 sentry __cerb(*
this,
false);
126 __ng.
get(*
this, 0, *
this, __err, __l);
130 if (__l < __gnu_cxx::__numeric_traits<short>::__min)
133 __n = __gnu_cxx::__numeric_traits<short>::__min;
135 else if (__l > __gnu_cxx::__numeric_traits<short>::__max)
138 __n = __gnu_cxx::__numeric_traits<short>::__max;
146 __throw_exception_again;
156 template<
typename _CharT,
typename _Traits>
163 sentry __cerb(*
this,
false);
171 __ng.
get(*
this, 0, *
this, __err, __l);
175 if (__l < __gnu_cxx::__numeric_traits<int>::__min)
178 __n = __gnu_cxx::__numeric_traits<int>::__min;
180 else if (__l > __gnu_cxx::__numeric_traits<int>::__max)
183 __n = __gnu_cxx::__numeric_traits<int>::__max;
191 __throw_exception_again;
201 template<
typename _CharT,
typename _Traits>
207 sentry __cerb(*
this,
false);
208 if (__cerb && __sbout)
213 if (!__copy_streambufs_eof(this->
rdbuf(), __sbout, __ineof))
221 __throw_exception_again;
233 template<
typename _CharT,
typename _Traits>
234 typename basic_istream<_CharT, _Traits>::int_type
238 const int_type __eof = traits_type::eof();
242 sentry __cerb(*
this,
true);
247 __c = this->
rdbuf()->sbumpc();
249 if (!traits_type::eq_int_type(__c, __eof))
257 __throw_exception_again;
269 template<
typename _CharT,
typename _Traits>
276 sentry __cerb(*
this,
true);
283 if (!traits_type::eq_int_type(__cb, traits_type::eof()))
286 __c = traits_type::to_char_type(__cb);
294 __throw_exception_again;
306 template<
typename _CharT,
typename _Traits>
313 sentry __cerb(*
this,
true);
318 const int_type __idelim = traits_type::to_int_type(__delim);
319 const int_type __eof = traits_type::eof();
324 && !traits_type::eq_int_type(__c, __eof)
325 && !traits_type::eq_int_type(__c, __idelim))
327 *__s++ = traits_type::to_char_type(__c);
331 if (traits_type::eq_int_type(__c, __eof))
337 __throw_exception_again;
353 template<
typename _CharT,
typename _Traits>
360 sentry __cerb(*
this,
true);
365 const int_type __idelim = traits_type::to_int_type(__delim);
366 const int_type __eof = traits_type::eof();
369 char_type __c2 = traits_type::to_char_type(__c);
371 while (!traits_type::eq_int_type(__c, __eof)
372 && !traits_type::eq_int_type(__c, __idelim)
373 && !traits_type::eq_int_type(__sb.
sputc(__c2), __eof))
376 __c = __this_sb->
snextc();
377 __c2 = traits_type::to_char_type(__c);
379 if (traits_type::eq_int_type(__c, __eof))
385 __throw_exception_again;
397 template<
typename _CharT,
typename _Traits>
404 sentry __cerb(*
this,
true);
409 const int_type __idelim = traits_type::to_int_type(__delim);
410 const int_type __eof = traits_type::eof();
415 && !traits_type::eq_int_type(__c, __eof)
416 && !traits_type::eq_int_type(__c, __idelim))
418 *__s++ = traits_type::to_char_type(__c);
422 if (traits_type::eq_int_type(__c, __eof))
426 if (traits_type::eq_int_type(__c, __idelim))
438 __throw_exception_again;
457 template<
typename _CharT,
typename _Traits>
463 sentry __cerb(*
this,
true);
469 const int_type __eof = traits_type::eof();
472 if (traits_type::eq_int_type(__sb->
sbumpc(), __eof))
480 __throw_exception_again;
490 template<
typename _CharT,
typename _Traits>
496 sentry __cerb(*
this,
true);
497 if (__cerb && __n > 0)
502 const int_type __eof = traits_type::eof();
513 bool __large_ignore =
false;
517 && !traits_type::eq_int_type(__c, __eof))
522 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
523 && !traits_type::eq_int_type(__c, __eof))
526 __gnu_cxx::__numeric_traits<streamsize>::__min;
527 __large_ignore =
true;
534 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
536 if (traits_type::eq_int_type(__c, __eof))
542 __throw_exception_again;
552 template<
typename _CharT,
typename _Traits>
558 sentry __cerb(*
this,
true);
559 if (__cerb && __n > 0)
564 const int_type __eof = traits_type::eof();
569 bool __large_ignore =
false;
573 && !traits_type::eq_int_type(__c, __eof)
574 && !traits_type::eq_int_type(__c, __delim))
579 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
580 && !traits_type::eq_int_type(__c, __eof)
581 && !traits_type::eq_int_type(__c, __delim))
584 __gnu_cxx::__numeric_traits<streamsize>::__min;
585 __large_ignore =
true;
592 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
594 if (traits_type::eq_int_type(__c, __eof))
596 else if (traits_type::eq_int_type(__c, __delim))
599 < __gnu_cxx::__numeric_traits<streamsize>::__max)
607 __throw_exception_again;
617 template<
typename _CharT,
typename _Traits>
618 typename basic_istream<_CharT, _Traits>::int_type
624 sentry __cerb(*
this,
true);
630 __c = this->
rdbuf()->sgetc();
631 if (traits_type::eq_int_type(__c, traits_type::eof()))
637 __throw_exception_again;
647 template<
typename _CharT,
typename _Traits>
653 sentry __cerb(*
this,
true);
666 __throw_exception_again;
676 template<
typename _CharT,
typename _Traits>
682 sentry __cerb(*
this,
true);
692 else if (__num == -1)
698 __throw_exception_again;
708 template<
typename _CharT,
typename _Traits>
718 sentry __cerb(*
this,
true);
724 const int_type __eof = traits_type::eof();
727 || traits_type::eq_int_type(__sb->
sputbackc(__c), __eof))
733 __throw_exception_again;
743 template<
typename _CharT,
typename _Traits>
753 sentry __cerb(*
this,
true);
759 const int_type __eof = traits_type::eof();
762 || traits_type::eq_int_type(__sb->
sungetc(), __eof))
768 __throw_exception_again;
778 template<
typename _CharT,
typename _Traits>
786 sentry __cerb(*
this,
true);
804 __throw_exception_again;
814 template<
typename _CharT,
typename _Traits>
815 typename basic_istream<_CharT, _Traits>::pos_type
822 sentry __cerb(*
this,
true);
834 __throw_exception_again;
842 template<
typename _CharT,
typename _Traits>
851 sentry __cerb(*
this,
true);
871 __throw_exception_again;
881 template<
typename _CharT,
typename _Traits>
890 sentry __cerb(*
this,
true);
910 __throw_exception_again;
921 template<
typename _CharT,
typename _Traits>
926 typedef typename __istream_type::int_type __int_type;
928 typename __istream_type::sentry __cerb(__in,
false);
934 const __int_type __cb = __in.
rdbuf()->sbumpc();
935 if (!_Traits::eq_int_type(__cb, _Traits::eof()))
936 __c = _Traits::to_char_type(__cb);
943 __throw_exception_again;
953 template<
typename _CharT,
typename _Traits>
954 basic_istream<_CharT, _Traits>&
959 typedef typename _Traits::int_type int_type;
960 typedef _CharT char_type;
965 typename __istream_type::sentry __cerb(__in,
false);
973 __num = __gnu_cxx::__numeric_traits<streamsize>::__max;
975 const __ctype_type& __ct = use_facet<__ctype_type>(__in.
getloc());
977 const int_type __eof = _Traits::eof();
978 __streambuf_type* __sb = __in.
rdbuf();
979 int_type __c = __sb->sgetc();
981 while (__extracted < __num - 1
982 && !_Traits::eq_int_type(__c, __eof)
983 && !__ct.is(ctype_base::space,
984 _Traits::to_char_type(__c)))
986 *__s++ = _Traits::to_char_type(__c);
988 __c = __sb->snextc();
990 if (_Traits::eq_int_type(__c, __eof))
1001 __throw_exception_again;
1014 template<
typename _CharT,
typename _Traits>
1015 basic_istream<_CharT, _Traits>&
1020 typedef typename __istream_type::int_type __int_type;
1023 const __ctype_type& __ct = use_facet<__ctype_type>(__in.
getloc());
1024 const __int_type __eof = _Traits::eof();
1025 __streambuf_type* __sb = __in.
rdbuf();
1026 __int_type __c = __sb->sgetc();
1028 while (!_Traits::eq_int_type(__c, __eof)
1029 && __ct.is(ctype_base::space, _Traits::to_char_type(__c)))
1030 __c = __sb->snextc();
1032 if (_Traits::eq_int_type(__c, __eof))
1039 #if _GLIBCXX_EXTERN_TEMPLATE 1040 extern template class basic_istream<char>;
1049 extern template istream& istream::_M_extract(
unsigned short&);
1050 extern template istream& istream::_M_extract(
unsigned int&);
1051 extern template istream& istream::_M_extract(
long&);
1052 extern template istream& istream::_M_extract(
unsigned long&);
1053 extern template istream& istream::_M_extract(
bool&);
1054 #ifdef _GLIBCXX_USE_LONG_LONG 1055 extern template istream& istream::_M_extract(
long long&);
1056 extern template istream& istream::_M_extract(
unsigned long long&);
1058 extern template istream& istream::_M_extract(
float&);
1059 extern template istream& istream::_M_extract(
double&);
1060 extern template istream& istream::_M_extract(
long double&);
1061 extern template istream& istream::_M_extract(
void*&);
1063 extern template class basic_iostream<char>;
1065 #ifdef _GLIBCXX_USE_WCHAR_T 1066 extern template class basic_istream<wchar_t>;
1071 extern template wistream& wistream::_M_extract(
unsigned short&);
1072 extern template wistream& wistream::_M_extract(
unsigned int&);
1073 extern template wistream& wistream::_M_extract(
long&);
1074 extern template wistream& wistream::_M_extract(
unsigned long&);
1075 extern template wistream& wistream::_M_extract(
bool&);
1076 #ifdef _GLIBCXX_USE_LONG_LONG 1077 extern template wistream& wistream::_M_extract(
long long&);
1078 extern template wistream& wistream::_M_extract(
unsigned long long&);
1080 extern template wistream& wistream::_M_extract(
float&);
1081 extern template wistream& wistream::_M_extract(
double&);
1082 extern template wistream& wistream::_M_extract(
long double&);
1083 extern template wistream& wistream::_M_extract(
void*&);
1085 extern template class basic_iostream<wchar_t>;
1089 _GLIBCXX_END_NAMESPACE_VERSION
static const openmode in
Open for input. Default for ifstream and fstream.
__istream_type & ignore()
Simple extraction.
sentry(basic_istream< _CharT, _Traits > &__is, bool __noskipws=false)
The constructor performs all the work.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
__istream_type & putback(char_type __c)
Unextracting a single character.
static const iostate badbit
Indicates a loss of integrity in an input or output sequence (such as an irrecoverable read error fro...
int sync()
Synchronizing the stream buffer.
_Traits::pos_type pos_type
static const iostate eofbit
Indicates that an input operation reached the end of an input sequence.
__istream_type & getline(char_type *__s, streamsize __n, char_type __delim)
String extraction.
int_type sgetc()
Getting the next character.
__istream_type & seekg(pos_type)
Changing the current read position.
void setstate(iostate __state)
Sets additional flags in the error state.
int_type peek()
Looking ahead in the stream.
int_type get()
Simple extraction.
bool is(mask __m, char_type __c) const
Test char_type classification.
static const iostate goodbit
Indicates all is well.
int pubsync()
Calls virtual sync function.
_Traits::off_type off_type
fmtflags flags() const
Access to format flags.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
int_type sungetc()
Moving backwards in the input stream.
__istream_type & unget()
Unextracting the previous character.
Primary class template ctype facet.This template class defines classification and conversion function...
basic_streambuf< _CharT, _Traits > * rdbuf() const
Accessing the underlying buffer.
int_type snextc()
Getting the next character.
streamsize readsome(char_type *__s, streamsize __n)
Extraction until the buffer is exhausted, but no more.
void clear(iostate __state=goodbit)
[Re]sets the error state.
ISO C++ entities toplevel namespace is std.
streamsize width() const
Flags access.
_Traits::int_type int_type
static const seekdir cur
Request a seek relative to the current position within the sequence.
Primary class template num_get.This facet encapsulates the code to parse and return a number from a s...
int_type sputbackc(char_type __c)
Pushing characters back into the input stream.
locale getloc() const
Locale access.
int_type sputc(char_type __c)
Entry point for all single-character output functions.
iter_type get(iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, bool &__v) const
Numeric parsing.
Template class basic_istream.
Performs setup work for input streams.
int_type sbumpc()
Getting the next character.
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
basic_istream< char > istream
Base class for char input streams.
bool good() const
Fast error checking.
iostate rdstate() const
Returns the error state of the stream buffer.
basic_ostream< _CharT, _Traits > * tie() const
Fetches the current tied stream.
bool fail() const
Fast error checking.
basic_istream< _CharT, _Traits > & ws(basic_istream< _CharT, _Traits > &__is)
Quick and easy way to eat whitespace.
static const fmtflags skipws
Skips leading white space before certain input operations.
basic_istream< wchar_t > wistream
Base class for wchar_t input streams.
__istream_type & read(char_type *__s, streamsize __n)
Extraction without delimiters.
pos_type tellg()
Getting the current read position.
Thrown as part of forced unwinding.A magic placeholder class that can be caught by reference to recog...
__istream_type & operator>>(__istream_type &(*__pf)(__istream_type &))
Interface for manipulators.
The actual work of input and output (interface).