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>
57 const __int_type __eof = traits_type::eof();
59 __int_type __c = __sb->
sgetc();
62 while (!traits_type::eq_int_type(__c, __eof)
63 && __ct.
is(ctype_base::space,
64 traits_type::to_char_type(__c)))
70 if (traits_type::eq_int_type(__c, __eof))
77 __throw_exception_again;
91 template<
typename _CharT,
typename _Traits>
92 template<
typename _ValueT>
97 sentry __cerb(*
this,
false);
104 __ng.
get(*
this, 0, *
this, __err, __v);
109 __throw_exception_again;
119 template<
typename _CharT,
typename _Traits>
120 basic_istream<_CharT, _Traits>&
126 sentry __cerb(*
this,
false);
134 __ng.
get(*
this, 0, *
this, __err, __l);
138 if (__l < __gnu_cxx::__numeric_traits<short>::__min)
141 __n = __gnu_cxx::__numeric_traits<short>::__min;
143 else if (__l > __gnu_cxx::__numeric_traits<short>::__max)
146 __n = __gnu_cxx::__numeric_traits<short>::__max;
154 __throw_exception_again;
164 template<
typename _CharT,
typename _Traits>
171 sentry __cerb(*
this,
false);
179 __ng.
get(*
this, 0, *
this, __err, __l);
183 if (__l < __gnu_cxx::__numeric_traits<int>::__min)
186 __n = __gnu_cxx::__numeric_traits<int>::__min;
188 else if (__l > __gnu_cxx::__numeric_traits<int>::__max)
191 __n = __gnu_cxx::__numeric_traits<int>::__max;
199 __throw_exception_again;
209 template<
typename _CharT,
typename _Traits>
215 sentry __cerb(*
this,
false);
216 if (__cerb && __sbout)
221 if (!__copy_streambufs_eof(this->
rdbuf(), __sbout, __ineof))
229 __throw_exception_again;
241 template<
typename _CharT,
typename _Traits>
242 typename basic_istream<_CharT, _Traits>::int_type
246 const int_type __eof = traits_type::eof();
247 int_type __c = __eof;
250 sentry __cerb(*
this,
true);
255 __c = this->
rdbuf()->sbumpc();
257 if (!traits_type::eq_int_type(__c, __eof))
265 __throw_exception_again;
277 template<
typename _CharT,
typename _Traits>
284 sentry __cerb(*
this,
true);
289 const int_type __cb = this->
rdbuf()->sbumpc();
291 if (!traits_type::eq_int_type(__cb, traits_type::eof()))
294 __c = traits_type::to_char_type(__cb);
302 __throw_exception_again;
314 template<
typename _CharT,
typename _Traits>
321 sentry __cerb(*
this,
true);
326 const int_type __idelim = traits_type::to_int_type(__delim);
327 const int_type __eof = traits_type::eof();
329 int_type __c = __sb->
sgetc();
332 && !traits_type::eq_int_type(__c, __eof)
333 && !traits_type::eq_int_type(__c, __idelim))
335 *__s++ = traits_type::to_char_type(__c);
339 if (traits_type::eq_int_type(__c, __eof))
345 __throw_exception_again;
361 template<
typename _CharT,
typename _Traits>
368 sentry __cerb(*
this,
true);
373 const int_type __idelim = traits_type::to_int_type(__delim);
374 const int_type __eof = traits_type::eof();
376 int_type __c = __this_sb->
sgetc();
377 char_type __c2 = traits_type::to_char_type(__c);
379 while (!traits_type::eq_int_type(__c, __eof)
380 && !traits_type::eq_int_type(__c, __idelim)
381 && !traits_type::eq_int_type(__sb.
sputc(__c2), __eof))
384 __c = __this_sb->
snextc();
385 __c2 = traits_type::to_char_type(__c);
387 if (traits_type::eq_int_type(__c, __eof))
393 __throw_exception_again;
405 template<
typename _CharT,
typename _Traits>
412 sentry __cerb(*
this,
true);
417 const int_type __idelim = traits_type::to_int_type(__delim);
418 const int_type __eof = traits_type::eof();
420 int_type __c = __sb->
sgetc();
423 && !traits_type::eq_int_type(__c, __eof)
424 && !traits_type::eq_int_type(__c, __idelim))
426 *__s++ = traits_type::to_char_type(__c);
430 if (traits_type::eq_int_type(__c, __eof))
434 if (traits_type::eq_int_type(__c, __idelim))
446 __throw_exception_again;
465 template<
typename _CharT,
typename _Traits>
471 sentry __cerb(*
this,
true);
477 const int_type __eof = traits_type::eof();
480 if (traits_type::eq_int_type(__sb->
sbumpc(), __eof))
488 __throw_exception_again;
498 template<
typename _CharT,
typename _Traits>
504 sentry __cerb(*
this,
true);
505 if (__cerb && __n > 0)
510 const int_type __eof = traits_type::eof();
512 int_type __c = __sb->
sgetc();
521 bool __large_ignore =
false;
525 && !traits_type::eq_int_type(__c, __eof))
530 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
531 && !traits_type::eq_int_type(__c, __eof))
534 __gnu_cxx::__numeric_traits<streamsize>::__min;
535 __large_ignore =
true;
542 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
544 if (traits_type::eq_int_type(__c, __eof))
550 __throw_exception_again;
560 template<
typename _CharT,
typename _Traits>
566 sentry __cerb(*
this,
true);
567 if (__cerb && __n > 0)
572 const int_type __eof = traits_type::eof();
574 int_type __c = __sb->
sgetc();
577 bool __large_ignore =
false;
581 && !traits_type::eq_int_type(__c, __eof)
582 && !traits_type::eq_int_type(__c, __delim))
587 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
588 && !traits_type::eq_int_type(__c, __eof)
589 && !traits_type::eq_int_type(__c, __delim))
592 __gnu_cxx::__numeric_traits<streamsize>::__min;
593 __large_ignore =
true;
600 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
602 if (traits_type::eq_int_type(__c, __eof))
604 else if (traits_type::eq_int_type(__c, __delim))
607 < __gnu_cxx::__numeric_traits<streamsize>::__max)
615 __throw_exception_again;
625 template<
typename _CharT,
typename _Traits>
626 typename basic_istream<_CharT, _Traits>::int_type
630 int_type __c = traits_type::eof();
632 sentry __cerb(*
this,
true);
638 __c = this->
rdbuf()->sgetc();
639 if (traits_type::eq_int_type(__c, traits_type::eof()))
645 __throw_exception_again;
655 template<
typename _CharT,
typename _Traits>
661 sentry __cerb(*
this,
true);
674 __throw_exception_again;
684 template<
typename _CharT,
typename _Traits>
690 sentry __cerb(*
this,
true);
700 else if (__num == -1)
706 __throw_exception_again;
716 template<
typename _CharT,
typename _Traits>
726 sentry __cerb(*
this,
true);
732 const int_type __eof = traits_type::eof();
735 || traits_type::eq_int_type(__sb->
sputbackc(__c), __eof))
741 __throw_exception_again;
751 template<
typename _CharT,
typename _Traits>
761 sentry __cerb(*
this,
true);
767 const int_type __eof = traits_type::eof();
770 || traits_type::eq_int_type(__sb->
sungetc(), __eof))
776 __throw_exception_again;
786 template<
typename _CharT,
typename _Traits>
794 sentry __cerb(*
this,
true);
812 __throw_exception_again;
822 template<
typename _CharT,
typename _Traits>
823 typename basic_istream<_CharT, _Traits>::pos_type
829 pos_type __ret = pos_type(-1);
830 sentry __cerb(*
this,
true);
842 __throw_exception_again;
850 template<
typename _CharT,
typename _Traits>
859 sentry __cerb(*
this,
true);
868 const pos_type __p = this->
rdbuf()->pubseekpos(__pos,
872 if (__p == pos_type(off_type(-1)))
879 __throw_exception_again;
889 template<
typename _CharT,
typename _Traits>
892 seekg(off_type __off, ios_base::seekdir __dir)
898 sentry __cerb(*
this,
true);
907 const pos_type __p = this->
rdbuf()->pubseekoff(__off, __dir,
911 if (__p == pos_type(off_type(-1)))
918 __throw_exception_again;
929 template<
typename _CharT,
typename _Traits>
934 typedef typename __istream_type::int_type __int_type;
936 typename __istream_type::sentry __cerb(__in,
false);
942 const __int_type __cb = __in.
rdbuf()->sbumpc();
943 if (!_Traits::eq_int_type(__cb, _Traits::eof()))
944 __c = _Traits::to_char_type(__cb);
951 __throw_exception_again;
961 template<
typename _CharT,
typename _Traits>
962 basic_istream<_CharT, _Traits>&
967 typedef typename _Traits::int_type int_type;
968 typedef _CharT char_type;
973 typename __istream_type::sentry __cerb(__in,
false);
981 __num = __gnu_cxx::__numeric_traits<streamsize>::__max;
983 const __ctype_type& __ct = use_facet<__ctype_type>(__in.
getloc());
985 const int_type __eof = _Traits::eof();
986 __streambuf_type* __sb = __in.
rdbuf();
987 int_type __c = __sb->sgetc();
989 while (__extracted < __num - 1
990 && !_Traits::eq_int_type(__c, __eof)
991 && !__ct.is(ctype_base::space,
992 _Traits::to_char_type(__c)))
994 *__s++ = _Traits::to_char_type(__c);
996 __c = __sb->snextc();
998 if (_Traits::eq_int_type(__c, __eof))
1009 __throw_exception_again;
1022 template<
typename _CharT,
typename _Traits>
1023 basic_istream<_CharT, _Traits>&
1028 typedef typename __istream_type::int_type __int_type;
1031 const __ctype_type& __ct = use_facet<__ctype_type>(__in.
getloc());
1032 const __int_type __eof = _Traits::eof();
1033 __streambuf_type* __sb = __in.
rdbuf();
1034 __int_type __c = __sb->sgetc();
1036 while (!_Traits::eq_int_type(__c, __eof)
1037 && __ct.is(ctype_base::space, _Traits::to_char_type(__c)))
1038 __c = __sb->snextc();
1040 if (_Traits::eq_int_type(__c, __eof))
1047 #if _GLIBCXX_EXTERN_TEMPLATE
1048 extern template class basic_istream<char>;
1057 extern template istream& istream::_M_extract(
unsigned short&);
1058 extern template istream& istream::_M_extract(
unsigned int&);
1059 extern template istream& istream::_M_extract(
long&);
1060 extern template istream& istream::_M_extract(
unsigned long&);
1061 extern template istream& istream::_M_extract(
bool&);
1062 #ifdef _GLIBCXX_USE_LONG_LONG
1063 extern template istream& istream::_M_extract(
long long&);
1064 extern template istream& istream::_M_extract(
unsigned long long&);
1066 extern template istream& istream::_M_extract(
float&);
1067 extern template istream& istream::_M_extract(
double&);
1068 extern template istream& istream::_M_extract(
long double&);
1069 extern template istream& istream::_M_extract(
void*&);
1071 extern template class basic_iostream<char>;
1073 #ifdef _GLIBCXX_USE_WCHAR_T
1074 extern template class basic_istream<wchar_t>;
1079 extern template wistream& wistream::_M_extract(
unsigned short&);
1080 extern template wistream& wistream::_M_extract(
unsigned int&);
1081 extern template wistream& wistream::_M_extract(
long&);
1082 extern template wistream& wistream::_M_extract(
unsigned long&);
1083 extern template wistream& wistream::_M_extract(
bool&);
1084 #ifdef _GLIBCXX_USE_LONG_LONG
1085 extern template wistream& wistream::_M_extract(
long long&);
1086 extern template wistream& wistream::_M_extract(
unsigned long long&);
1088 extern template wistream& wistream::_M_extract(
float&);
1089 extern template wistream& wistream::_M_extract(
double&);
1090 extern template wistream& wistream::_M_extract(
long double&);
1091 extern template wistream& wistream::_M_extract(
void*&);
1093 extern template class basic_iostream<wchar_t>;
1097 _GLIBCXX_END_NAMESPACE_VERSION
basic_istream< wchar_t > wistream
Base class for wchar_t input streams.
__istream_type & read(char_type *__s, streamsize __n)
Extraction without delimiters.
__istream_type & putback(char_type __c)
Unextracting a single character.
static const fmtflags skipws
Skips leading white space before certain input operations.
basic_ostream< _CharT, _Traits > * tie() const
Fetches the current tied stream.
Template class basic_istream.
bool fail() const
Fast error checking.
Performs setup work for input streams.
void clear(iostate __state=goodbit)
[Re]sets the error state.
__istream_type & unget()
Unextracting the previous character.
pos_type tellg()
Getting the current read position.
__istream_type & ignore()
Simple extraction.
static const iostate eofbit
Indicates that an input operation reached the end of an input sequence.
fmtflags flags() const
Access to format flags.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
int_type snextc()
Getting the next character.
Thrown as part of forced unwinding.A magic placeholder class that can be caught by reference to recog...
sentry(basic_istream< _CharT, _Traits > &__is, bool __noskipws=false)
The constructor performs all the work.
bool good() const
Fast error checking.
int_type sbumpc()
Getting the next character.
streamsize width() const
Flags access.
int sync()
Synchronizing the stream buffer.
__istream_type & getline(char_type *__s, streamsize __n, char_type __delim)
String extraction.
The actual work of input and output (interface).
int_type get()
Simple extraction.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
Primary class template num_get.This facet encapsulates the code to parse and return a number from a s...
int pubsync()
Calls virtual sync function.
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
void setstate(iostate __state)
Sets additional flags in the error state.
iter_type get(iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, bool &__v) const
Numeric parsing.
basic_streambuf< _CharT, _Traits > * rdbuf() const
Accessing the underlying buffer.
streamsize readsome(char_type *__s, streamsize __n)
Extraction until the buffer is exhausted, but no more.
__istream_type & seekg(pos_type)
Changing the current read position.
int_type peek()
Looking ahead in the stream.
static const openmode in
Open for input. Default for ifstream and fstream.
int_type sungetc()
Moving backwards in the input stream.
iostate rdstate() const
Returns the error state of the stream buffer.
basic_istream< char > istream
Base class for char input streams.
locale getloc() const
Locale access.
basic_istream< _CharT, _Traits > & ws(basic_istream< _CharT, _Traits > &__is)
Quick and easy way to eat whitespace.
__istream_type & operator>>(__istream_type &(*__pf)(__istream_type &))
Interface for manipulators.
static const seekdir cur
Request a seek relative to the current position within the sequence.
static const iostate goodbit
Indicates all is well.
static const iostate badbit
Indicates a loss of integrity in an input or output sequence (such as an irrecoverable read error fro...
bool is(mask __m, char_type __c) const
Test char_type classification.
Primary class template ctype facet.This template class defines classification and conversion function...
int_type sputc(char_type __c)
Entry point for all single-character output functions.
int_type sputbackc(char_type __c)
Pushing characters back into the input stream.
int_type sgetc()
Getting the next character.