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>
58 const __int_type __eof = traits_type::eof();
60 __int_type __c = __sb->
sgetc();
63 while (!traits_type::eq_int_type(__c, __eof)
64 && __ct.
is(ctype_base::space,
65 traits_type::to_char_type(__c)))
71 if (traits_type::eq_int_type(__c, __eof))
78 __throw_exception_again;
93 template<
typename _CharT,
typename _Traits>
94 template<
typename _ValueT>
99 sentry __cerb(*
this,
false);
106 __ng.
get(*
this, 0, *
this, __err, __v);
111 __throw_exception_again;
121 template<
typename _CharT,
typename _Traits>
122 basic_istream<_CharT, _Traits>&
128 sentry __cerb(*
this,
false);
136 __ng.
get(*
this, 0, *
this, __err, __l);
140 if (__l < __gnu_cxx::__numeric_traits<short>::__min)
143 __n = __gnu_cxx::__numeric_traits<short>::__min;
145 else if (__l > __gnu_cxx::__numeric_traits<short>::__max)
148 __n = __gnu_cxx::__numeric_traits<short>::__max;
156 __throw_exception_again;
166 template<
typename _CharT,
typename _Traits>
173 sentry __cerb(*
this,
false);
181 __ng.
get(*
this, 0, *
this, __err, __l);
185 if (__l < __gnu_cxx::__numeric_traits<int>::__min)
188 __n = __gnu_cxx::__numeric_traits<int>::__min;
190 else if (__l > __gnu_cxx::__numeric_traits<int>::__max)
193 __n = __gnu_cxx::__numeric_traits<int>::__max;
201 __throw_exception_again;
211 template<
typename _CharT,
typename _Traits>
212 basic_istream<_CharT, _Traits>&
217 sentry __cerb(*
this,
false);
218 if (__cerb && __sbout)
223 if (!__copy_streambufs_eof(this->
rdbuf(), __sbout, __ineof))
231 __throw_exception_again;
243 template<
typename _CharT,
typename _Traits>
244 typename basic_istream<_CharT, _Traits>::int_type
248 const int_type __eof = traits_type::eof();
249 int_type __c = __eof;
252 sentry __cerb(*
this,
true);
257 __c = this->
rdbuf()->sbumpc();
259 if (!traits_type::eq_int_type(__c, __eof))
267 __throw_exception_again;
279 template<
typename _CharT,
typename _Traits>
280 basic_istream<_CharT, _Traits>&
286 sentry __cerb(*
this,
true);
291 const int_type __cb = this->
rdbuf()->sbumpc();
293 if (!traits_type::eq_int_type(__cb, traits_type::eof()))
296 __c = traits_type::to_char_type(__cb);
304 __throw_exception_again;
316 template<
typename _CharT,
typename _Traits>
323 sentry __cerb(*
this,
true);
328 const int_type __idelim = traits_type::to_int_type(__delim);
329 const int_type __eof = traits_type::eof();
331 int_type __c = __sb->
sgetc();
334 && !traits_type::eq_int_type(__c, __eof)
335 && !traits_type::eq_int_type(__c, __idelim))
337 *__s++ = traits_type::to_char_type(__c);
341 if (traits_type::eq_int_type(__c, __eof))
347 __throw_exception_again;
363 template<
typename _CharT,
typename _Traits>
364 basic_istream<_CharT, _Traits>&
370 sentry __cerb(*
this,
true);
375 const int_type __idelim = traits_type::to_int_type(__delim);
376 const int_type __eof = traits_type::eof();
379 char_type __c2 = traits_type::to_char_type(__c);
380 unsigned long long __gcount = 0;
382 while (!traits_type::eq_int_type(__c, __eof)
383 && !traits_type::eq_int_type(__c, __idelim)
384 && !traits_type::eq_int_type(__sb.
sputc(__c2), __eof))
387 __c = __this_sb->
snextc();
388 __c2 = traits_type::to_char_type(__c);
390 if (traits_type::eq_int_type(__c, __eof))
394 if (__gcount <= __gnu_cxx::__numeric_traits<streamsize>::__max)
397 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
402 __throw_exception_again;
414 template<
typename _CharT,
typename _Traits>
415 basic_istream<_CharT, _Traits>&
421 sentry __cerb(*
this,
true);
426 const int_type __idelim = traits_type::to_int_type(__delim);
427 const int_type __eof = traits_type::eof();
429 int_type __c = __sb->
sgetc();
432 && !traits_type::eq_int_type(__c, __eof)
433 && !traits_type::eq_int_type(__c, __idelim))
435 *__s++ = traits_type::to_char_type(__c);
439 if (traits_type::eq_int_type(__c, __eof))
443 if (traits_type::eq_int_type(__c, __idelim))
455 __throw_exception_again;
474 template<
typename _CharT,
typename _Traits>
480 sentry __cerb(*
this,
true);
489 if (traits_type::eq_int_type(__sb->
sbumpc(), __eof))
497 __throw_exception_again;
507 template<
typename _CharT,
typename _Traits>
513 sentry __cerb(*
this,
true);
514 if (__cerb && __n > 0)
519 const int_type __eof = traits_type::eof();
521 int_type __c = __sb->
sgetc();
530 bool __large_ignore =
false;
534 && !traits_type::eq_int_type(__c, __eof))
539 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
540 && !traits_type::eq_int_type(__c, __eof))
543 __gnu_cxx::__numeric_traits<streamsize>::__min;
544 __large_ignore =
true;
550 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max)
553 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
555 if (traits_type::eq_int_type(__c, __eof))
560 if (traits_type::eq_int_type(__c, __eof))
567 __throw_exception_again;
577 template<
typename _CharT,
typename _Traits>
578 basic_istream<_CharT, _Traits>&
583 sentry __cerb(*
this,
true);
584 if (__cerb && __n > 0)
589 const int_type __eof = traits_type::eof();
594 bool __large_ignore =
false;
598 && !traits_type::eq_int_type(__c, __eof)
599 && !traits_type::eq_int_type(__c, __delim))
604 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
605 && !traits_type::eq_int_type(__c, __eof)
606 && !traits_type::eq_int_type(__c, __delim))
609 __gnu_cxx::__numeric_traits<streamsize>::__min;
610 __large_ignore =
true;
616 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max)
619 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
621 if (traits_type::eq_int_type(__c, __eof))
632 if (traits_type::eq_int_type(__c, __eof))
644 __throw_exception_again;
654 template<
typename _CharT,
typename _Traits>
655 typename basic_istream<_CharT, _Traits>::int_type
659 int_type __c = traits_type::eof();
661 sentry __cerb(*
this,
true);
667 __c = this->
rdbuf()->sgetc();
668 if (traits_type::eq_int_type(__c, traits_type::eof()))
674 __throw_exception_again;
684 template<
typename _CharT,
typename _Traits>
690 sentry __cerb(*
this,
true);
703 __throw_exception_again;
713 template<
typename _CharT,
typename _Traits>
719 sentry __cerb(*
this,
true);
729 else if (__num == -1)
735 __throw_exception_again;
745 template<
typename _CharT,
typename _Traits>
746 basic_istream<_CharT, _Traits>&
755 sentry __cerb(*
this,
true);
761 const int_type __eof = traits_type::eof();
764 || traits_type::eq_int_type(__sb->
sputbackc(__c), __eof))
770 __throw_exception_again;
780 template<
typename _CharT,
typename _Traits>
790 sentry __cerb(*
this,
true);
796 const int_type __eof = traits_type::eof();
799 || traits_type::eq_int_type(__sb->
sungetc(), __eof))
805 __throw_exception_again;
815 template<
typename _CharT,
typename _Traits>
823 sentry __cerb(*
this,
true);
841 __throw_exception_again;
851 template<
typename _CharT,
typename _Traits>
852 typename basic_istream<_CharT, _Traits>::pos_type
858 pos_type __ret = pos_type(-1);
859 sentry __cerb(*
this,
true);
871 __throw_exception_again;
879 template<
typename _CharT,
typename _Traits>
882 seekg(pos_type __pos)
888 sentry __cerb(*
this,
true);
897 const pos_type __p = this->
rdbuf()->pubseekpos(__pos,
901 if (__p == pos_type(off_type(-1)))
908 __throw_exception_again;
918 template<
typename _CharT,
typename _Traits>
921 seekg(off_type __off, ios_base::seekdir __dir)
927 sentry __cerb(*
this,
true);
936 const pos_type __p = this->
rdbuf()->pubseekoff(__off, __dir,
940 if (__p == pos_type(off_type(-1)))
947 __throw_exception_again;
958 template<
typename _CharT,
typename _Traits>
963 typedef typename __istream_type::int_type __int_type;
965 typename __istream_type::sentry __cerb(__in,
false);
971 const __int_type __cb = __in.
rdbuf()->sbumpc();
972 if (!_Traits::eq_int_type(__cb, _Traits::eof()))
973 __c = _Traits::to_char_type(__cb);
980 __throw_exception_again;
990 template<
typename _CharT,
typename _Traits>
992 __istream_extract(basic_istream<_CharT, _Traits>& __in, _CharT* __s,
995 typedef basic_istream<_CharT, _Traits> __istream_type;
996 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
997 typedef typename _Traits::int_type int_type;
998 typedef _CharT char_type;
999 typedef ctype<_CharT> __ctype_type;
1003 typename __istream_type::sentry __cerb(__in,
false);
1010 if (0 < __width && __width < __num)
1013 const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
1015 const int_type __eof = _Traits::eof();
1016 __streambuf_type* __sb = __in.rdbuf();
1017 int_type __c = __sb->
sgetc();
1019 while (__extracted < __num - 1
1020 && !_Traits::eq_int_type(__c, __eof)
1021 && !__ct.is(ctype_base::space,
1022 _Traits::to_char_type(__c)))
1024 *__s++ = _Traits::to_char_type(__c);
1026 __c = __sb->snextc();
1029 if (__extracted < __num - 1
1030 && _Traits::eq_int_type(__c, __eof))
1041 __throw_exception_again;
1049 __in.setstate(__err);
1053 template<
typename _CharT,
typename _Traits>
1054 basic_istream<_CharT, _Traits>&
1059 typedef typename __istream_type::int_type __int_type;
1064 typename __istream_type::sentry __cerb(__in,
true);
1070 const __ctype_type& __ct = use_facet<__ctype_type>(__in.
getloc());
1071 const __int_type __eof = _Traits::eof();
1072 __streambuf_type* __sb = __in.
rdbuf();
1073 __int_type __c = __sb->sgetc();
1077 if (_Traits::eq_int_type(__c, __eof))
1082 if (!__ct.is(ctype_base::space, _Traits::to_char_type(__c)))
1084 __c = __sb->snextc();
1090 __throw_exception_again;
1104 #if _GLIBCXX_EXTERN_TEMPLATE
1105 extern template class basic_istream<char>;
1111 extern template istream& istream::_M_extract(
unsigned short&);
1112 extern template istream& istream::_M_extract(
unsigned int&);
1113 extern template istream& istream::_M_extract(
long&);
1114 extern template istream& istream::_M_extract(
unsigned long&);
1115 extern template istream& istream::_M_extract(
bool&);
1116 #ifdef _GLIBCXX_USE_LONG_LONG
1117 extern template istream& istream::_M_extract(
long long&);
1118 extern template istream& istream::_M_extract(
unsigned long long&);
1120 extern template istream& istream::_M_extract(
float&);
1121 extern template istream& istream::_M_extract(
double&);
1122 extern template istream& istream::_M_extract(
long double&);
1123 extern template istream& istream::_M_extract(
void*&);
1125 extern template class basic_iostream<char>;
1127 #ifdef _GLIBCXX_USE_WCHAR_T
1128 extern template class basic_istream<wchar_t>;
1133 extern template wistream& wistream::_M_extract(
unsigned short&);
1134 extern template wistream& wistream::_M_extract(
unsigned int&);
1135 extern template wistream& wistream::_M_extract(
long&);
1136 extern template wistream& wistream::_M_extract(
unsigned long&);
1137 extern template wistream& wistream::_M_extract(
bool&);
1138 #ifdef _GLIBCXX_USE_LONG_LONG
1139 extern template wistream& wistream::_M_extract(
long long&);
1140 extern template wistream& wistream::_M_extract(
unsigned long long&);
1142 extern template wistream& wistream::_M_extract(
float&);
1143 extern template wistream& wistream::_M_extract(
double&);
1144 extern template wistream& wistream::_M_extract(
long double&);
1145 extern template wistream& wistream::_M_extract(
void*&);
1147 extern template class basic_iostream<wchar_t>;
1151 _GLIBCXX_END_NAMESPACE_VERSION
basic_istream< char > istream
Base class for char input streams.
basic_istream< wchar_t > wistream
Base class for wchar_t input streams.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
ISO C++ entities toplevel namespace is std.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
basic_istream< _CharT, _Traits > & ws(basic_istream< _CharT, _Traits > &__is)
Quick and easy way to eat whitespace.
void clear(iostate __state=goodbit)
[Re]sets the error state.
basic_ostream< _CharT, _Traits > * tie() const
Fetches the current tied stream.
basic_streambuf< _CharT, _Traits > * rdbuf() const
Accessing the underlying buffer.
void setstate(iostate __state)
Sets additional flags in the error state.
iostate rdstate() const
Returns the error state of the stream buffer.
bool good() const
Fast error checking.
bool fail() const
Fast error checking.
_Traits::int_type int_type
The actual work of input and output (interface).
int_type snextc()
Getting the next character.
int_type sbumpc()
Getting the next character.
int_type sungetc()
Moving backwards in the input stream.
int_type sgetc()
Getting the next character.
int pubsync()
Calls virtual sync function.
int_type sputbackc(char_type __c)
Pushing characters back into the input stream.
int_type sputc(char_type __c)
Entry point for all single-character output functions.
Template class basic_istream.
__istream_type & seekg(pos_type)
Changing the current read position.
int_type get()
Simple extraction.
streamsize readsome(char_type *__s, streamsize __n)
Extraction until the buffer is exhausted, but no more.
int_type peek()
Looking ahead in the stream.
__istream_type & unget()
Unextracting the previous character.
pos_type tellg()
Getting the current read position.
__istream_type & ignore()
Simple extraction.
__istream_type & read(char_type *__s, streamsize __n)
Extraction without delimiters.
__istream_type & putback(char_type __c)
Unextracting a single character.
__istream_type & getline(char_type *__s, streamsize __n, char_type __delim)
String extraction.
int sync()
Synchronizing the stream buffer.
__istream_type & operator>>(__istream_type &(*__pf)(__istream_type &))
Interface for manipulators.
Performs setup work for input streams.
sentry(basic_istream< _CharT, _Traits > &__is, bool __noskipws=false)
The constructor performs all the work.
Thrown as part of forced unwinding.
static const fmtflags skipws
Skips leading white space before certain input operations.
_Ios_Iostate iostate
This is a bitmask type.
static const seekdir cur
Request a seek relative to the current position within the sequence.
static const openmode in
Open for input. Default for ifstream and fstream.
fmtflags flags() const
Access to format flags.
static const iostate eofbit
Indicates that an input operation reached the end of an input 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...
locale getloc() const
Locale access.
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
bool is(mask __m, char_type __c) const
Test char_type classification.
Primary class template ctype facet.
Primary class template num_get.
iter_type get(iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, bool &__v) const
Numeric parsing.