35 #define _ISTREAM_TCC 1 37 #ifdef _GLIBCXX_SYSHDR 38 #pragma GCC system_header 41 #pragma GCC diagnostic push 42 #pragma GCC diagnostic ignored "-Wc++11-extensions" // extern template 46 namespace std _GLIBCXX_VISIBILITY(default)
48 _GLIBCXX_BEGIN_NAMESPACE_VERSION
50 template<
typename _CharT,
typename _Traits>
63 const __int_type __eof = traits_type::eof();
65 __int_type __c = __sb->
sgetc();
68 while (!traits_type::eq_int_type(__c, __eof)
69 && __ct.
is(ctype_base::space,
70 traits_type::to_char_type(__c)))
76 if (traits_type::eq_int_type(__c, __eof))
83 __throw_exception_again;
98 template<
typename _CharT,
typename _Traits>
99 template<
typename _ValueT>
104 sentry __cerb(*
this,
false);
110 #ifndef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT 114 = use_facet<__num_get_type>(this->_M_ios_locale);
116 __ng.
get(*
this, 0, *
this, __err, __v);
121 __throw_exception_again;
131 template<
typename _CharT,
typename _Traits>
132 basic_istream<_CharT, _Traits>&
138 sentry __cerb(*
this,
false);
145 #ifndef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT 149 = use_facet<__num_get_type>(this->_M_ios_locale);
151 __ng.
get(*
this, 0, *
this, __err, __l);
155 if (__l < __gnu_cxx::__numeric_traits<short>::__min)
158 __n = __gnu_cxx::__numeric_traits<short>::__min;
160 else if (__l > __gnu_cxx::__numeric_traits<short>::__max)
163 __n = __gnu_cxx::__numeric_traits<short>::__max;
171 __throw_exception_again;
181 template<
typename _CharT,
typename _Traits>
188 sentry __cerb(*
this,
false);
195 #ifndef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT 199 = use_facet<__num_get_type>(this->_M_ios_locale);
201 __ng.
get(*
this, 0, *
this, __err, __l);
205 if (__l < __gnu_cxx::__numeric_traits<int>::__min)
208 __n = __gnu_cxx::__numeric_traits<int>::__min;
210 else if (__l > __gnu_cxx::__numeric_traits<int>::__max)
213 __n = __gnu_cxx::__numeric_traits<int>::__max;
221 __throw_exception_again;
231 template<
typename _CharT,
typename _Traits>
237 sentry __cerb(*
this,
false);
238 if (__cerb && __sbout)
243 if (!__copy_streambufs_eof(this->
rdbuf(), __sbout, __ineof))
251 __throw_exception_again;
263 template<
typename _CharT,
typename _Traits>
264 typename basic_istream<_CharT, _Traits>::int_type
268 const int_type __eof = traits_type::eof();
272 sentry __cerb(*
this,
true);
277 __c = this->
rdbuf()->sbumpc();
279 if (!traits_type::eq_int_type(__c, __eof))
287 __throw_exception_again;
299 template<
typename _CharT,
typename _Traits>
306 sentry __cerb(*
this,
true);
313 if (!traits_type::eq_int_type(__cb, traits_type::eof()))
316 __c = traits_type::to_char_type(__cb);
324 __throw_exception_again;
336 template<
typename _CharT,
typename _Traits>
343 sentry __cerb(*
this,
true);
348 const int_type __idelim = traits_type::to_int_type(__delim);
349 const int_type __eof = traits_type::eof();
354 && !traits_type::eq_int_type(__c, __eof)
355 && !traits_type::eq_int_type(__c, __idelim))
357 *__s++ = traits_type::to_char_type(__c);
361 if (traits_type::eq_int_type(__c, __eof))
367 __throw_exception_again;
383 template<
typename _CharT,
typename _Traits>
390 sentry __cerb(*
this,
true);
395 const int_type __idelim = traits_type::to_int_type(__delim);
396 const int_type __eof = traits_type::eof();
399 char_type __c2 = traits_type::to_char_type(__c);
400 #pragma GCC diagnostic push 401 #pragma GCC diagnostic ignored "-Wlong-long" 402 unsigned long long __gcount = 0;
403 #pragma GCC diagnostic pop 405 while (!traits_type::eq_int_type(__c, __eof)
406 && !traits_type::eq_int_type(__c, __idelim)
407 && !traits_type::eq_int_type(__sb.
sputc(__c2), __eof))
410 __c = __this_sb->
snextc();
411 __c2 = traits_type::to_char_type(__c);
413 if (traits_type::eq_int_type(__c, __eof))
417 if (__gcount <= __gnu_cxx::__numeric_traits<streamsize>::__max)
420 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
425 __throw_exception_again;
437 template<
typename _CharT,
typename _Traits>
444 sentry __cerb(*
this,
true);
449 const int_type __idelim = traits_type::to_int_type(__delim);
450 const int_type __eof = traits_type::eof();
455 && !traits_type::eq_int_type(__c, __eof)
456 && !traits_type::eq_int_type(__c, __idelim))
458 *__s++ = traits_type::to_char_type(__c);
462 if (traits_type::eq_int_type(__c, __eof))
466 if (traits_type::eq_int_type(__c, __idelim))
478 __throw_exception_again;
497 template<
typename _CharT,
typename _Traits>
503 sentry __cerb(*
this,
true);
509 const int_type __eof = traits_type::eof();
512 if (traits_type::eq_int_type(__sb->
sbumpc(), __eof))
520 __throw_exception_again;
530 template<
typename _CharT,
typename _Traits>
536 sentry __cerb(*
this,
true);
537 if (__cerb && __n > 0)
542 const int_type __eof = traits_type::eof();
553 bool __large_ignore =
false;
557 && !traits_type::eq_int_type(__c, __eof))
562 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
563 && !traits_type::eq_int_type(__c, __eof))
566 __gnu_cxx::__numeric_traits<streamsize>::__min;
567 __large_ignore =
true;
573 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max)
576 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
578 if (traits_type::eq_int_type(__c, __eof))
583 if (traits_type::eq_int_type(__c, __eof))
590 __throw_exception_again;
600 template<
typename _CharT,
typename _Traits>
606 sentry __cerb(*
this,
true);
607 if (__cerb && __n > 0)
612 const int_type __eof = traits_type::eof();
617 bool __large_ignore =
false;
621 && !traits_type::eq_int_type(__c, __eof)
622 && !traits_type::eq_int_type(__c, __delim))
627 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
628 && !traits_type::eq_int_type(__c, __eof)
629 && !traits_type::eq_int_type(__c, __delim))
632 __gnu_cxx::__numeric_traits<streamsize>::__min;
633 __large_ignore =
true;
639 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max)
642 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
644 if (traits_type::eq_int_type(__c, __eof))
655 if (traits_type::eq_int_type(__c, __eof))
667 __throw_exception_again;
677 template<
typename _CharT,
typename _Traits>
678 typename basic_istream<_CharT, _Traits>::int_type
684 sentry __cerb(*
this,
true);
690 __c = this->
rdbuf()->sgetc();
691 if (traits_type::eq_int_type(__c, traits_type::eof()))
697 __throw_exception_again;
707 template<
typename _CharT,
typename _Traits>
713 sentry __cerb(*
this,
true);
726 __throw_exception_again;
736 template<
typename _CharT,
typename _Traits>
742 sentry __cerb(*
this,
true);
752 else if (__num == -1)
758 __throw_exception_again;
768 template<
typename _CharT,
typename _Traits>
778 sentry __cerb(*
this,
true);
784 const int_type __eof = traits_type::eof();
787 || traits_type::eq_int_type(__sb->
sputbackc(__c), __eof))
793 __throw_exception_again;
803 template<
typename _CharT,
typename _Traits>
813 sentry __cerb(*
this,
true);
819 const int_type __eof = traits_type::eof();
822 || traits_type::eq_int_type(__sb->
sungetc(), __eof))
828 __throw_exception_again;
838 template<
typename _CharT,
typename _Traits>
846 sentry __cerb(*
this,
true);
864 __throw_exception_again;
874 template<
typename _CharT,
typename _Traits>
875 typename basic_istream<_CharT, _Traits>::pos_type
882 sentry __cerb(*
this,
true);
894 __throw_exception_again;
902 template<
typename _CharT,
typename _Traits>
911 sentry __cerb(*
this,
true);
931 __throw_exception_again;
941 template<
typename _CharT,
typename _Traits>
950 sentry __cerb(*
this,
true);
970 __throw_exception_again;
981 template<
typename _CharT,
typename _Traits>
986 typedef typename __istream_type::int_type __int_type;
988 typename __istream_type::sentry __cerb(__in,
false);
994 const __int_type __cb = __in.
rdbuf()->sbumpc();
995 if (!_Traits::eq_int_type(__cb, _Traits::eof()))
996 __c = _Traits::to_char_type(__cb);
1003 __throw_exception_again;
1013 template<
typename _CharT,
typename _Traits>
1015 __istream_extract(basic_istream<_CharT, _Traits>& __in, _CharT* __s,
1018 typedef basic_istream<_CharT, _Traits> __istream_type;
1019 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
1020 typedef typename _Traits::int_type int_type;
1021 typedef _CharT char_type;
1022 typedef ctype<_CharT> __ctype_type;
1026 typename __istream_type::sentry __cerb(__in,
false);
1033 if (0 < __width && __width < __num)
1036 const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
1038 const int_type __eof = _Traits::eof();
1039 __streambuf_type* __sb = __in.rdbuf();
1040 int_type __c = __sb->sgetc();
1042 while (__extracted < __num - 1
1043 && !_Traits::eq_int_type(__c, __eof)
1044 && !__ct.is(ctype_base::space,
1045 _Traits::to_char_type(__c)))
1047 *__s++ = _Traits::to_char_type(__c);
1049 __c = __sb->snextc();
1052 if (__extracted < __num - 1
1053 && _Traits::eq_int_type(__c, __eof))
1064 __throw_exception_again;
1072 __in.setstate(__err);
1076 template<
typename _CharT,
typename _Traits>
1077 basic_istream<_CharT, _Traits>&
1082 typedef typename __istream_type::int_type __int_type;
1087 typename __istream_type::sentry __cerb(__in,
true);
1093 const __ctype_type& __ct = use_facet<__ctype_type>(__in.
getloc());
1094 const __int_type __eof = _Traits::eof();
1095 __streambuf_type* __sb = __in.
rdbuf();
1096 __int_type __c = __sb->sgetc();
1100 if (_Traits::eq_int_type(__c, __eof))
1105 if (!__ct.is(ctype_base::space, _Traits::to_char_type(__c)))
1107 __c = __sb->snextc();
1113 __throw_exception_again;
1127 #if _GLIBCXX_EXTERN_TEMPLATE 1128 #pragma GCC diagnostic push 1129 #pragma GCC diagnostic ignored "-Wc++11-extensions" // extern template 1130 #pragma GCC diagnostic ignored "-Wlong-long" 1131 extern template class basic_istream<char>;
1137 extern template istream& istream::_M_extract(
unsigned short&);
1138 extern template istream& istream::_M_extract(
unsigned int&);
1139 extern template istream& istream::_M_extract(
long&);
1140 extern template istream& istream::_M_extract(
unsigned long&);
1141 extern template istream& istream::_M_extract(
bool&);
1142 #ifdef _GLIBCXX_USE_LONG_LONG 1143 #pragma GCC diagnostic push 1144 #pragma GCC diagnostic ignored "-Wlong-long" 1145 extern template istream& istream::_M_extract(
long long&);
1146 extern template istream& istream::_M_extract(
unsigned long long&);
1147 #pragma GCC diagnostic pop 1149 extern template istream& istream::_M_extract(
float&);
1150 extern template istream& istream::_M_extract(
double&);
1151 extern template istream& istream::_M_extract(
long double&);
1152 extern template istream& istream::_M_extract(
void*&);
1154 extern template class basic_iostream<char>;
1156 #ifdef _GLIBCXX_USE_WCHAR_T 1157 extern template class basic_istream<wchar_t>;
1162 extern template wistream& wistream::_M_extract(
unsigned short&);
1163 extern template wistream& wistream::_M_extract(
unsigned int&);
1164 extern template wistream& wistream::_M_extract(
long&);
1165 extern template wistream& wistream::_M_extract(
unsigned long&);
1166 extern template wistream& wistream::_M_extract(
bool&);
1167 #ifdef _GLIBCXX_USE_LONG_LONG 1168 extern template wistream& wistream::_M_extract(
long long&);
1169 extern template wistream& wistream::_M_extract(
unsigned long long&);
1171 extern template wistream& wistream::_M_extract(
float&);
1172 extern template wistream& wistream::_M_extract(
double&);
1173 extern template wistream& wistream::_M_extract(
long double&);
1174 extern template wistream& wistream::_M_extract(
void*&);
1176 extern template class basic_iostream<wchar_t>;
1178 #pragma GCC diagnostic pop 1181 _GLIBCXX_END_NAMESPACE_VERSION
1184 #pragma GCC diagnostic pop basic_istream< char > istream
Base class for char input streams.
int_type sputbackc(char_type __c)
Pushing characters back into the input stream.
int_type peek()
Looking ahead in the stream.
fmtflags flags() const
Access to format flags.
void clear(iostate __state=goodbit)
[Re]sets the error state.
static const fmtflags skipws
Skips leading white space before certain input operations.
basic_ostream< _CharT, _Traits > * tie() const
Fetches the current tied stream.
iostate rdstate() const
Returns the error state of the stream buffer.
int_type snextc()
Getting the next character.
int sync()
Synchronizing the stream buffer.
Primary class template num_get.This facet encapsulates the code to parse and return a number from a s...
_Traits::int_type int_type
static const openmode in
Open for input. Default for ifstream and fstream.
__istream_type & operator>>(__istream_type &(*__pf)(__istream_type &))
Interface for manipulators.
int_type sbumpc()
Getting the next character.
__istream_type & unget()
Unextracting the previous character.
iter_type get(iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, bool &__v) const
Numeric parsing.
bool fail() const
Fast error checking.
basic_streambuf< _CharT, _Traits > * rdbuf() const
Accessing the underlying buffer.
__istream_type & putback(char_type __c)
Unextracting a single character.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
sentry(basic_istream< _CharT, _Traits > &__is, bool __noskipws=false)
The constructor performs all the work.
streamsize readsome(char_type *__s, streamsize __n)
Extraction until the buffer is exhausted, but no more.
Template class basic_istream.
Performs setup work for input streams.
void setstate(iostate __state)
Sets additional flags in the error state.
static const seekdir cur
Request a seek relative to the current position within the sequence.
_Traits::pos_type pos_type
Thrown as part of forced unwinding.A magic placeholder class that can be caught by reference to recog...
__istream_type & seekg(pos_type)
Changing the current read position.
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
bool good() const
Fast error checking.
_Ios_Iostate iostate
This is a bitmask type.
basic_istream< wchar_t > wistream
Base class for wchar_t input streams.
static const iostate eofbit
Indicates that an input operation reached the end of an input sequence.
int_type sgetc()
Getting the next character.
ISO C++ entities toplevel namespace is std.
int pubsync()
Calls virtual sync function.
__istream_type & ignore()
Simple extraction.
int_type sungetc()
Moving backwards in the input stream.
locale getloc() const
Locale access.
__istream_type & read(char_type *__s, streamsize __n)
Extraction without delimiters.
pos_type tellg()
Getting the current read position.
The actual work of input and output (interface).
basic_istream< _CharT, _Traits > & ws(basic_istream< _CharT, _Traits > &__is)
Quick and easy way to eat whitespace.
__istream_type & getline(char_type *__s, streamsize __n, char_type __delim)
String extraction.
_Traits::off_type off_type
bool is(mask __m, char_type __c) const
Test char_type classification.
static const iostate goodbit
Indicates all is well.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
int_type get()
Simple extraction.
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.
static const iostate badbit
Indicates a loss of integrity in an input or output sequence (such as an irrecoverable read error fro...