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);
105 #ifndef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT 109 = use_facet<__num_get_type>(this->_M_ios_locale);
111 __ng.
get(*
this, 0, *
this, __err, __v);
116 __throw_exception_again;
126 template<
typename _CharT,
typename _Traits>
127 basic_istream<_CharT, _Traits>&
133 sentry __cerb(*
this,
false);
140 #ifndef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT 144 = use_facet<__num_get_type>(this->_M_ios_locale);
146 __ng.
get(*
this, 0, *
this, __err, __l);
150 if (__l < __gnu_cxx::__numeric_traits<short>::__min)
153 __n = __gnu_cxx::__numeric_traits<short>::__min;
155 else if (__l > __gnu_cxx::__numeric_traits<short>::__max)
158 __n = __gnu_cxx::__numeric_traits<short>::__max;
166 __throw_exception_again;
176 template<
typename _CharT,
typename _Traits>
183 sentry __cerb(*
this,
false);
190 #ifndef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT 194 = use_facet<__num_get_type>(this->_M_ios_locale);
196 __ng.
get(*
this, 0, *
this, __err, __l);
200 if (__l < __gnu_cxx::__numeric_traits<int>::__min)
203 __n = __gnu_cxx::__numeric_traits<int>::__min;
205 else if (__l > __gnu_cxx::__numeric_traits<int>::__max)
208 __n = __gnu_cxx::__numeric_traits<int>::__max;
216 __throw_exception_again;
226 template<
typename _CharT,
typename _Traits>
232 sentry __cerb(*
this,
false);
233 if (__cerb && __sbout)
238 if (!__copy_streambufs_eof(this->
rdbuf(), __sbout, __ineof))
246 __throw_exception_again;
258 template<
typename _CharT,
typename _Traits>
259 typename basic_istream<_CharT, _Traits>::int_type
263 const int_type __eof = traits_type::eof();
267 sentry __cerb(*
this,
true);
272 __c = this->
rdbuf()->sbumpc();
274 if (!traits_type::eq_int_type(__c, __eof))
282 __throw_exception_again;
294 template<
typename _CharT,
typename _Traits>
301 sentry __cerb(*
this,
true);
308 if (!traits_type::eq_int_type(__cb, traits_type::eof()))
311 __c = traits_type::to_char_type(__cb);
319 __throw_exception_again;
331 template<
typename _CharT,
typename _Traits>
338 sentry __cerb(*
this,
true);
343 const int_type __idelim = traits_type::to_int_type(__delim);
344 const int_type __eof = traits_type::eof();
349 && !traits_type::eq_int_type(__c, __eof)
350 && !traits_type::eq_int_type(__c, __idelim))
352 *__s++ = traits_type::to_char_type(__c);
356 if (traits_type::eq_int_type(__c, __eof))
362 __throw_exception_again;
378 template<
typename _CharT,
typename _Traits>
385 sentry __cerb(*
this,
true);
390 const int_type __idelim = traits_type::to_int_type(__delim);
391 const int_type __eof = traits_type::eof();
394 char_type __c2 = traits_type::to_char_type(__c);
395 unsigned long long __gcount = 0;
397 while (!traits_type::eq_int_type(__c, __eof)
398 && !traits_type::eq_int_type(__c, __idelim)
399 && !traits_type::eq_int_type(__sb.
sputc(__c2), __eof))
402 __c = __this_sb->
snextc();
403 __c2 = traits_type::to_char_type(__c);
405 if (traits_type::eq_int_type(__c, __eof))
409 if (__gcount <= __gnu_cxx::__numeric_traits<streamsize>::__max)
412 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
417 __throw_exception_again;
429 template<
typename _CharT,
typename _Traits>
436 sentry __cerb(*
this,
true);
441 const int_type __idelim = traits_type::to_int_type(__delim);
442 const int_type __eof = traits_type::eof();
447 && !traits_type::eq_int_type(__c, __eof)
448 && !traits_type::eq_int_type(__c, __idelim))
450 *__s++ = traits_type::to_char_type(__c);
454 if (traits_type::eq_int_type(__c, __eof))
458 if (traits_type::eq_int_type(__c, __idelim))
470 __throw_exception_again;
489 template<
typename _CharT,
typename _Traits>
495 sentry __cerb(*
this,
true);
501 const int_type __eof = traits_type::eof();
504 if (traits_type::eq_int_type(__sb->
sbumpc(), __eof))
512 __throw_exception_again;
522 template<
typename _CharT,
typename _Traits>
528 sentry __cerb(*
this,
true);
529 if (__cerb && __n > 0)
534 const int_type __eof = traits_type::eof();
545 bool __large_ignore =
false;
549 && !traits_type::eq_int_type(__c, __eof))
554 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
555 && !traits_type::eq_int_type(__c, __eof))
558 __gnu_cxx::__numeric_traits<streamsize>::__min;
559 __large_ignore =
true;
565 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max)
568 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
570 if (traits_type::eq_int_type(__c, __eof))
575 if (traits_type::eq_int_type(__c, __eof))
582 __throw_exception_again;
592 template<
typename _CharT,
typename _Traits>
598 sentry __cerb(*
this,
true);
599 if (__cerb && __n > 0)
604 const int_type __eof = traits_type::eof();
609 bool __large_ignore =
false;
613 && !traits_type::eq_int_type(__c, __eof)
614 && !traits_type::eq_int_type(__c, __delim))
619 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
620 && !traits_type::eq_int_type(__c, __eof)
621 && !traits_type::eq_int_type(__c, __delim))
624 __gnu_cxx::__numeric_traits<streamsize>::__min;
625 __large_ignore =
true;
631 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max)
634 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
636 if (traits_type::eq_int_type(__c, __eof))
647 if (traits_type::eq_int_type(__c, __eof))
659 __throw_exception_again;
669 template<
typename _CharT,
typename _Traits>
670 typename basic_istream<_CharT, _Traits>::int_type
676 sentry __cerb(*
this,
true);
682 __c = this->
rdbuf()->sgetc();
683 if (traits_type::eq_int_type(__c, traits_type::eof()))
689 __throw_exception_again;
699 template<
typename _CharT,
typename _Traits>
705 sentry __cerb(*
this,
true);
718 __throw_exception_again;
728 template<
typename _CharT,
typename _Traits>
734 sentry __cerb(*
this,
true);
744 else if (__num == -1)
750 __throw_exception_again;
760 template<
typename _CharT,
typename _Traits>
770 sentry __cerb(*
this,
true);
776 const int_type __eof = traits_type::eof();
779 || traits_type::eq_int_type(__sb->
sputbackc(__c), __eof))
785 __throw_exception_again;
795 template<
typename _CharT,
typename _Traits>
805 sentry __cerb(*
this,
true);
811 const int_type __eof = traits_type::eof();
814 || traits_type::eq_int_type(__sb->
sungetc(), __eof))
820 __throw_exception_again;
830 template<
typename _CharT,
typename _Traits>
838 sentry __cerb(*
this,
true);
856 __throw_exception_again;
866 template<
typename _CharT,
typename _Traits>
867 typename basic_istream<_CharT, _Traits>::pos_type
874 sentry __cerb(*
this,
true);
886 __throw_exception_again;
894 template<
typename _CharT,
typename _Traits>
903 sentry __cerb(*
this,
true);
923 __throw_exception_again;
933 template<
typename _CharT,
typename _Traits>
942 sentry __cerb(*
this,
true);
962 __throw_exception_again;
973 template<
typename _CharT,
typename _Traits>
978 typedef typename __istream_type::int_type __int_type;
980 typename __istream_type::sentry __cerb(__in,
false);
986 const __int_type __cb = __in.
rdbuf()->sbumpc();
987 if (!_Traits::eq_int_type(__cb, _Traits::eof()))
988 __c = _Traits::to_char_type(__cb);
995 __throw_exception_again;
1005 template<
typename _CharT,
typename _Traits>
1007 __istream_extract(basic_istream<_CharT, _Traits>& __in, _CharT* __s,
1010 typedef basic_istream<_CharT, _Traits> __istream_type;
1011 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
1012 typedef typename _Traits::int_type int_type;
1013 typedef _CharT char_type;
1014 typedef ctype<_CharT> __ctype_type;
1018 typename __istream_type::sentry __cerb(__in,
false);
1025 if (0 < __width && __width < __num)
1028 const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
1030 const int_type __eof = _Traits::eof();
1031 __streambuf_type* __sb = __in.rdbuf();
1032 int_type __c = __sb->sgetc();
1034 while (__extracted < __num - 1
1035 && !_Traits::eq_int_type(__c, __eof)
1036 && !__ct.is(ctype_base::space,
1037 _Traits::to_char_type(__c)))
1039 *__s++ = _Traits::to_char_type(__c);
1041 __c = __sb->snextc();
1044 if (__extracted < __num - 1
1045 && _Traits::eq_int_type(__c, __eof))
1056 __throw_exception_again;
1064 __in.setstate(__err);
1068 template<
typename _CharT,
typename _Traits>
1069 basic_istream<_CharT, _Traits>&
1074 typedef typename __istream_type::int_type __int_type;
1079 typename __istream_type::sentry __cerb(__in,
true);
1085 const __ctype_type& __ct = use_facet<__ctype_type>(__in.
getloc());
1086 const __int_type __eof = _Traits::eof();
1087 __streambuf_type* __sb = __in.
rdbuf();
1088 __int_type __c = __sb->sgetc();
1092 if (_Traits::eq_int_type(__c, __eof))
1097 if (!__ct.is(ctype_base::space, _Traits::to_char_type(__c)))
1099 __c = __sb->snextc();
1105 __throw_exception_again;
1119 #if _GLIBCXX_EXTERN_TEMPLATE 1120 extern template class basic_istream<char>;
1126 extern template istream& istream::_M_extract(
unsigned short&);
1127 extern template istream& istream::_M_extract(
unsigned int&);
1128 extern template istream& istream::_M_extract(
long&);
1129 extern template istream& istream::_M_extract(
unsigned long&);
1130 extern template istream& istream::_M_extract(
bool&);
1131 #ifdef _GLIBCXX_USE_LONG_LONG 1132 extern template istream& istream::_M_extract(
long long&);
1133 extern template istream& istream::_M_extract(
unsigned long long&);
1135 extern template istream& istream::_M_extract(
float&);
1136 extern template istream& istream::_M_extract(
double&);
1137 extern template istream& istream::_M_extract(
long double&);
1138 extern template istream& istream::_M_extract(
void*&);
1140 extern template class basic_iostream<char>;
1142 #ifdef _GLIBCXX_USE_WCHAR_T 1143 extern template class basic_istream<wchar_t>;
1148 extern template wistream& wistream::_M_extract(
unsigned short&);
1149 extern template wistream& wistream::_M_extract(
unsigned int&);
1150 extern template wistream& wistream::_M_extract(
long&);
1151 extern template wistream& wistream::_M_extract(
unsigned long&);
1152 extern template wistream& wistream::_M_extract(
bool&);
1153 #ifdef _GLIBCXX_USE_LONG_LONG 1154 extern template wistream& wistream::_M_extract(
long long&);
1155 extern template wistream& wistream::_M_extract(
unsigned long long&);
1157 extern template wistream& wistream::_M_extract(
float&);
1158 extern template wistream& wistream::_M_extract(
double&);
1159 extern template wistream& wistream::_M_extract(
long double&);
1160 extern template wistream& wistream::_M_extract(
void*&);
1162 extern template class basic_iostream<wchar_t>;
1166 _GLIBCXX_END_NAMESPACE_VERSION
locale getloc() const
Locale access.
static const seekdir cur
Request a seek relative to the current position within the sequence.
bool good() const
Fast error checking.
Performs setup work for input streams.
bool is(mask __m, char_type __c) const
Test char_type classification.
basic_istream< char > istream
Base class for char input streams.
int_type peek()
Looking ahead in the stream.
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
int_type sputbackc(char_type __c)
Pushing characters back into the input stream.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
basic_ostream< _CharT, _Traits > * tie() const
Fetches the current tied stream.
int_type sbumpc()
Getting the next character.
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...
static const iostate badbit
Indicates a loss of integrity in an input or output sequence (such as an irrecoverable read error fro...
void setstate(iostate __state)
Sets additional flags in the error state.
int_type sungetc()
Moving backwards in the input stream.
basic_streambuf< _CharT, _Traits > * rdbuf() const
Accessing the underlying buffer.
basic_istream< wchar_t > wistream
Base class for wchar_t input streams.
void clear(iostate __state=goodbit)
[Re]sets the error state.
int sync()
Synchronizing the stream buffer.
_Ios_Iostate iostate
This is a bitmask type.
int_type sgetc()
Getting the next character.
static const iostate goodbit
Indicates all is well.
ISO C++ entities toplevel namespace is std.
Primary class template ctype facet.This template class defines classification and conversion function...
Thrown as part of forced unwinding.A magic placeholder class that can be caught by reference to recog...
__istream_type & ignore()
Simple extraction.
int_type snextc()
Getting the next character.
int_type sputc(char_type __c)
Entry point for all single-character output functions.
Template class basic_istream.
_Traits::int_type int_type
_Traits::pos_type pos_type
fmtflags flags() const
Access to format flags.
__istream_type & read(char_type *__s, streamsize __n)
Extraction without delimiters.
__istream_type & unget()
Unextracting the previous character.
static const fmtflags skipws
Skips leading white space before certain input operations.
_Traits::off_type off_type
__istream_type & operator>>(__istream_type &(*__pf)(__istream_type &))
Interface for manipulators.
basic_istream< _CharT, _Traits > & ws(basic_istream< _CharT, _Traits > &__is)
Quick and easy way to eat whitespace.
int_type get()
Simple extraction.
bool fail() const
Fast error checking.
static const openmode in
Open for input. Default for ifstream and fstream.
int pubsync()
Calls virtual sync function.
pos_type tellg()
Getting the current read position.
__istream_type & putback(char_type __c)
Unextracting a single character.
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.
The actual work of input and output (interface).
__istream_type & seekg(pos_type)
Changing the current read position.
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.
iter_type get(iter_type __in, iter_type __end, ios_base &__io, ios_base::iostate &__err, bool &__v) const
Numeric parsing.
iostate rdstate() const
Returns the error state of the stream buffer.