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;
116 this->setstate(__err);
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;
161 this->setstate(__err);
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;
206 this->setstate(__err);
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;
239 this->setstate(__err);
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;
275 this->setstate(__err);
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;
312 this->setstate(__err);
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;
359 this->setstate(__err);
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();
378 int_type __c = __this_sb->
sgetc();
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;
410 this->setstate(__err);
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;
467 this->setstate(__err);
474 template<
typename _CharT,
typename _Traits>
480 sentry __cerb(*
this,
true);
486 const int_type __eof = traits_type::eof();
489 if (traits_type::eq_int_type(__sb->
sbumpc(), __eof))
497 __throw_exception_again;
502 this->setstate(__err);
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;
572 this->setstate(__err);
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();
591 int_type __c = __sb->
sgetc();
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;
649 this->setstate(__err);
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;
679 this->setstate(__err);
684 template<
typename _CharT,
typename _Traits>
690 sentry __cerb(*
this,
true);
696 _M_gcount = this->rdbuf()->sgetn(__s, __n);
703 __throw_exception_again;
708 this->setstate(__err);
713 template<
typename _CharT,
typename _Traits>
719 sentry __cerb(*
this,
true);
726 const streamsize __num = this->rdbuf()->in_avail();
729 else if (__num == -1)
735 __throw_exception_again;
740 this->setstate(__err);
745 template<
typename _CharT,
typename _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;
775 this->setstate(__err);
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;
810 this->setstate(__err);
815 template<
typename _CharT,
typename _Traits>
823 sentry __cerb(*
this,
true);
841 __throw_exception_again;
846 this->setstate(__err);
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;
913 this->setstate(__err);
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;
952 this->setstate(__err);
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;
985 __in.setstate(__err);
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;
1097 __in.setstate(__err);
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