00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef _ISTREAM_TCC
00037 #define _ISTREAM_TCC 1
00038
00039 #pragma GCC system_header
00040
00041 #include <cxxabi-forced.h>
00042
00043 _GLIBCXX_BEGIN_NAMESPACE(std)
00044
00045 template<typename _CharT, typename _Traits>
00046 basic_istream<_CharT, _Traits>::sentry::
00047 sentry(basic_istream<_CharT, _Traits>& __in, bool __noskip) : _M_ok(false)
00048 {
00049 ios_base::iostate __err = ios_base::goodbit;
00050 if (__in.good())
00051 {
00052 if (__in.tie())
00053 __in.tie()->flush();
00054 if (!__noskip && bool(__in.flags() & ios_base::skipws))
00055 {
00056 const __int_type __eof = traits_type::eof();
00057 __streambuf_type* __sb = __in.rdbuf();
00058 __int_type __c = __sb->sgetc();
00059
00060 const __ctype_type& __ct = __check_facet(__in._M_ctype);
00061 while (!traits_type::eq_int_type(__c, __eof)
00062 && __ct.is(ctype_base::space,
00063 traits_type::to_char_type(__c)))
00064 __c = __sb->snextc();
00065
00066
00067
00068
00069 if (traits_type::eq_int_type(__c, __eof))
00070 __err |= ios_base::eofbit;
00071 }
00072 }
00073
00074 if (__in.good() && __err == ios_base::goodbit)
00075 _M_ok = true;
00076 else
00077 {
00078 __err |= ios_base::failbit;
00079 __in.setstate(__err);
00080 }
00081 }
00082
00083 template<typename _CharT, typename _Traits>
00084 template<typename _ValueT>
00085 basic_istream<_CharT, _Traits>&
00086 basic_istream<_CharT, _Traits>::
00087 _M_extract(_ValueT& __v)
00088 {
00089 sentry __cerb(*this, false);
00090 if (__cerb)
00091 {
00092 ios_base::iostate __err = ios_base::goodbit;
00093 __try
00094 {
00095 const __num_get_type& __ng = __check_facet(this->_M_num_get);
00096 __ng.get(*this, 0, *this, __err, __v);
00097 }
00098 __catch(__cxxabiv1::__forced_unwind&)
00099 {
00100 this->_M_setstate(ios_base::badbit);
00101 __throw_exception_again;
00102 }
00103 __catch(...)
00104 { this->_M_setstate(ios_base::badbit); }
00105 if (__err)
00106 this->setstate(__err);
00107 }
00108 return *this;
00109 }
00110
00111 template<typename _CharT, typename _Traits>
00112 basic_istream<_CharT, _Traits>&
00113 basic_istream<_CharT, _Traits>::
00114 operator>>(short& __n)
00115 {
00116
00117
00118 sentry __cerb(*this, false);
00119 if (__cerb)
00120 {
00121 ios_base::iostate __err = ios_base::goodbit;
00122 __try
00123 {
00124 long __l;
00125 const __num_get_type& __ng = __check_facet(this->_M_num_get);
00126 __ng.get(*this, 0, *this, __err, __l);
00127
00128
00129
00130 if (__l < __gnu_cxx::__numeric_traits<short>::__min)
00131 {
00132 __err |= ios_base::failbit;
00133 __n = __gnu_cxx::__numeric_traits<short>::__min;
00134 }
00135 else if (__l > __gnu_cxx::__numeric_traits<short>::__max)
00136 {
00137 __err |= ios_base::failbit;
00138 __n = __gnu_cxx::__numeric_traits<short>::__max;
00139 }
00140 else
00141 __n = short(__l);
00142 }
00143 __catch(__cxxabiv1::__forced_unwind&)
00144 {
00145 this->_M_setstate(ios_base::badbit);
00146 __throw_exception_again;
00147 }
00148 __catch(...)
00149 { this->_M_setstate(ios_base::badbit); }
00150 if (__err)
00151 this->setstate(__err);
00152 }
00153 return *this;
00154 }
00155
00156 template<typename _CharT, typename _Traits>
00157 basic_istream<_CharT, _Traits>&
00158 basic_istream<_CharT, _Traits>::
00159 operator>>(int& __n)
00160 {
00161
00162
00163 sentry __cerb(*this, false);
00164 if (__cerb)
00165 {
00166 ios_base::iostate __err = ios_base::goodbit;
00167 __try
00168 {
00169 long __l;
00170 const __num_get_type& __ng = __check_facet(this->_M_num_get);
00171 __ng.get(*this, 0, *this, __err, __l);
00172
00173
00174
00175 if (__l < __gnu_cxx::__numeric_traits<int>::__min)
00176 {
00177 __err |= ios_base::failbit;
00178 __n = __gnu_cxx::__numeric_traits<int>::__min;
00179 }
00180 else if (__l > __gnu_cxx::__numeric_traits<int>::__max)
00181 {
00182 __err |= ios_base::failbit;
00183 __n = __gnu_cxx::__numeric_traits<int>::__max;
00184 }
00185 else
00186 __n = int(__l);
00187 }
00188 __catch(__cxxabiv1::__forced_unwind&)
00189 {
00190 this->_M_setstate(ios_base::badbit);
00191 __throw_exception_again;
00192 }
00193 __catch(...)
00194 { this->_M_setstate(ios_base::badbit); }
00195 if (__err)
00196 this->setstate(__err);
00197 }
00198 return *this;
00199 }
00200
00201 template<typename _CharT, typename _Traits>
00202 basic_istream<_CharT, _Traits>&
00203 basic_istream<_CharT, _Traits>::
00204 operator>>(__streambuf_type* __sbout)
00205 {
00206 ios_base::iostate __err = ios_base::goodbit;
00207 sentry __cerb(*this, false);
00208 if (__cerb && __sbout)
00209 {
00210 __try
00211 {
00212 bool __ineof;
00213 if (!__copy_streambufs_eof(this->rdbuf(), __sbout, __ineof))
00214 __err |= ios_base::failbit;
00215 if (__ineof)
00216 __err |= ios_base::eofbit;
00217 }
00218 __catch(__cxxabiv1::__forced_unwind&)
00219 {
00220 this->_M_setstate(ios_base::failbit);
00221 __throw_exception_again;
00222 }
00223 __catch(...)
00224 { this->_M_setstate(ios_base::failbit); }
00225 }
00226 else if (!__sbout)
00227 __err |= ios_base::failbit;
00228 if (__err)
00229 this->setstate(__err);
00230 return *this;
00231 }
00232
00233 template<typename _CharT, typename _Traits>
00234 typename basic_istream<_CharT, _Traits>::int_type
00235 basic_istream<_CharT, _Traits>::
00236 get(void)
00237 {
00238 const int_type __eof = traits_type::eof();
00239 int_type __c = __eof;
00240 _M_gcount = 0;
00241 ios_base::iostate __err = ios_base::goodbit;
00242 sentry __cerb(*this, true);
00243 if (__cerb)
00244 {
00245 __try
00246 {
00247 __c = this->rdbuf()->sbumpc();
00248
00249 if (!traits_type::eq_int_type(__c, __eof))
00250 _M_gcount = 1;
00251 else
00252 __err |= ios_base::eofbit;
00253 }
00254 __catch(__cxxabiv1::__forced_unwind&)
00255 {
00256 this->_M_setstate(ios_base::badbit);
00257 __throw_exception_again;
00258 }
00259 __catch(...)
00260 { this->_M_setstate(ios_base::badbit); }
00261 }
00262 if (!_M_gcount)
00263 __err |= ios_base::failbit;
00264 if (__err)
00265 this->setstate(__err);
00266 return __c;
00267 }
00268
00269 template<typename _CharT, typename _Traits>
00270 basic_istream<_CharT, _Traits>&
00271 basic_istream<_CharT, _Traits>::
00272 get(char_type& __c)
00273 {
00274 _M_gcount = 0;
00275 ios_base::iostate __err = ios_base::goodbit;
00276 sentry __cerb(*this, true);
00277 if (__cerb)
00278 {
00279 __try
00280 {
00281 const int_type __cb = this->rdbuf()->sbumpc();
00282
00283 if (!traits_type::eq_int_type(__cb, traits_type::eof()))
00284 {
00285 _M_gcount = 1;
00286 __c = traits_type::to_char_type(__cb);
00287 }
00288 else
00289 __err |= ios_base::eofbit;
00290 }
00291 __catch(__cxxabiv1::__forced_unwind&)
00292 {
00293 this->_M_setstate(ios_base::badbit);
00294 __throw_exception_again;
00295 }
00296 __catch(...)
00297 { this->_M_setstate(ios_base::badbit); }
00298 }
00299 if (!_M_gcount)
00300 __err |= ios_base::failbit;
00301 if (__err)
00302 this->setstate(__err);
00303 return *this;
00304 }
00305
00306 template<typename _CharT, typename _Traits>
00307 basic_istream<_CharT, _Traits>&
00308 basic_istream<_CharT, _Traits>::
00309 get(char_type* __s, streamsize __n, char_type __delim)
00310 {
00311 _M_gcount = 0;
00312 ios_base::iostate __err = ios_base::goodbit;
00313 sentry __cerb(*this, true);
00314 if (__cerb)
00315 {
00316 __try
00317 {
00318 const int_type __idelim = traits_type::to_int_type(__delim);
00319 const int_type __eof = traits_type::eof();
00320 __streambuf_type* __sb = this->rdbuf();
00321 int_type __c = __sb->sgetc();
00322
00323 while (_M_gcount + 1 < __n
00324 && !traits_type::eq_int_type(__c, __eof)
00325 && !traits_type::eq_int_type(__c, __idelim))
00326 {
00327 *__s++ = traits_type::to_char_type(__c);
00328 ++_M_gcount;
00329 __c = __sb->snextc();
00330 }
00331 if (traits_type::eq_int_type(__c, __eof))
00332 __err |= ios_base::eofbit;
00333 }
00334 __catch(__cxxabiv1::__forced_unwind&)
00335 {
00336 this->_M_setstate(ios_base::badbit);
00337 __throw_exception_again;
00338 }
00339 __catch(...)
00340 { this->_M_setstate(ios_base::badbit); }
00341 }
00342
00343
00344 if (__n > 0)
00345 *__s = char_type();
00346 if (!_M_gcount)
00347 __err |= ios_base::failbit;
00348 if (__err)
00349 this->setstate(__err);
00350 return *this;
00351 }
00352
00353 template<typename _CharT, typename _Traits>
00354 basic_istream<_CharT, _Traits>&
00355 basic_istream<_CharT, _Traits>::
00356 get(__streambuf_type& __sb, char_type __delim)
00357 {
00358 _M_gcount = 0;
00359 ios_base::iostate __err = ios_base::goodbit;
00360 sentry __cerb(*this, true);
00361 if (__cerb)
00362 {
00363 __try
00364 {
00365 const int_type __idelim = traits_type::to_int_type(__delim);
00366 const int_type __eof = traits_type::eof();
00367 __streambuf_type* __this_sb = this->rdbuf();
00368 int_type __c = __this_sb->sgetc();
00369 char_type __c2 = traits_type::to_char_type(__c);
00370
00371 while (!traits_type::eq_int_type(__c, __eof)
00372 && !traits_type::eq_int_type(__c, __idelim)
00373 && !traits_type::eq_int_type(__sb.sputc(__c2), __eof))
00374 {
00375 ++_M_gcount;
00376 __c = __this_sb->snextc();
00377 __c2 = traits_type::to_char_type(__c);
00378 }
00379 if (traits_type::eq_int_type(__c, __eof))
00380 __err |= ios_base::eofbit;
00381 }
00382 __catch(__cxxabiv1::__forced_unwind&)
00383 {
00384 this->_M_setstate(ios_base::badbit);
00385 __throw_exception_again;
00386 }
00387 __catch(...)
00388 { this->_M_setstate(ios_base::badbit); }
00389 }
00390 if (!_M_gcount)
00391 __err |= ios_base::failbit;
00392 if (__err)
00393 this->setstate(__err);
00394 return *this;
00395 }
00396
00397 template<typename _CharT, typename _Traits>
00398 basic_istream<_CharT, _Traits>&
00399 basic_istream<_CharT, _Traits>::
00400 getline(char_type* __s, streamsize __n, char_type __delim)
00401 {
00402 _M_gcount = 0;
00403 ios_base::iostate __err = ios_base::goodbit;
00404 sentry __cerb(*this, true);
00405 if (__cerb)
00406 {
00407 __try
00408 {
00409 const int_type __idelim = traits_type::to_int_type(__delim);
00410 const int_type __eof = traits_type::eof();
00411 __streambuf_type* __sb = this->rdbuf();
00412 int_type __c = __sb->sgetc();
00413
00414 while (_M_gcount + 1 < __n
00415 && !traits_type::eq_int_type(__c, __eof)
00416 && !traits_type::eq_int_type(__c, __idelim))
00417 {
00418 *__s++ = traits_type::to_char_type(__c);
00419 __c = __sb->snextc();
00420 ++_M_gcount;
00421 }
00422 if (traits_type::eq_int_type(__c, __eof))
00423 __err |= ios_base::eofbit;
00424 else
00425 {
00426 if (traits_type::eq_int_type(__c, __idelim))
00427 {
00428 __sb->sbumpc();
00429 ++_M_gcount;
00430 }
00431 else
00432 __err |= ios_base::failbit;
00433 }
00434 }
00435 __catch(__cxxabiv1::__forced_unwind&)
00436 {
00437 this->_M_setstate(ios_base::badbit);
00438 __throw_exception_again;
00439 }
00440 __catch(...)
00441 { this->_M_setstate(ios_base::badbit); }
00442 }
00443
00444
00445 if (__n > 0)
00446 *__s = char_type();
00447 if (!_M_gcount)
00448 __err |= ios_base::failbit;
00449 if (__err)
00450 this->setstate(__err);
00451 return *this;
00452 }
00453
00454
00455
00456
00457 template<typename _CharT, typename _Traits>
00458 basic_istream<_CharT, _Traits>&
00459 basic_istream<_CharT, _Traits>::
00460 ignore(void)
00461 {
00462 _M_gcount = 0;
00463 sentry __cerb(*this, true);
00464 if (__cerb)
00465 {
00466 ios_base::iostate __err = ios_base::goodbit;
00467 __try
00468 {
00469 const int_type __eof = traits_type::eof();
00470 __streambuf_type* __sb = this->rdbuf();
00471
00472 if (traits_type::eq_int_type(__sb->sbumpc(), __eof))
00473 __err |= ios_base::eofbit;
00474 else
00475 _M_gcount = 1;
00476 }
00477 __catch(__cxxabiv1::__forced_unwind&)
00478 {
00479 this->_M_setstate(ios_base::badbit);
00480 __throw_exception_again;
00481 }
00482 __catch(...)
00483 { this->_M_setstate(ios_base::badbit); }
00484 if (__err)
00485 this->setstate(__err);
00486 }
00487 return *this;
00488 }
00489
00490 template<typename _CharT, typename _Traits>
00491 basic_istream<_CharT, _Traits>&
00492 basic_istream<_CharT, _Traits>::
00493 ignore(streamsize __n)
00494 {
00495 _M_gcount = 0;
00496 sentry __cerb(*this, true);
00497 if (__cerb && __n > 0)
00498 {
00499 ios_base::iostate __err = ios_base::goodbit;
00500 __try
00501 {
00502 const int_type __eof = traits_type::eof();
00503 __streambuf_type* __sb = this->rdbuf();
00504 int_type __c = __sb->sgetc();
00505
00506
00507
00508
00509
00510
00511
00512
00513 bool __large_ignore = false;
00514 while (true)
00515 {
00516 while (_M_gcount < __n
00517 && !traits_type::eq_int_type(__c, __eof))
00518 {
00519 ++_M_gcount;
00520 __c = __sb->snextc();
00521 }
00522 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
00523 && !traits_type::eq_int_type(__c, __eof))
00524 {
00525 _M_gcount =
00526 __gnu_cxx::__numeric_traits<streamsize>::__min;
00527 __large_ignore = true;
00528 }
00529 else
00530 break;
00531 }
00532
00533 if (__large_ignore)
00534 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
00535
00536 if (traits_type::eq_int_type(__c, __eof))
00537 __err |= ios_base::eofbit;
00538 }
00539 __catch(__cxxabiv1::__forced_unwind&)
00540 {
00541 this->_M_setstate(ios_base::badbit);
00542 __throw_exception_again;
00543 }
00544 __catch(...)
00545 { this->_M_setstate(ios_base::badbit); }
00546 if (__err)
00547 this->setstate(__err);
00548 }
00549 return *this;
00550 }
00551
00552 template<typename _CharT, typename _Traits>
00553 basic_istream<_CharT, _Traits>&
00554 basic_istream<_CharT, _Traits>::
00555 ignore(streamsize __n, int_type __delim)
00556 {
00557 _M_gcount = 0;
00558 sentry __cerb(*this, true);
00559 if (__cerb && __n > 0)
00560 {
00561 ios_base::iostate __err = ios_base::goodbit;
00562 __try
00563 {
00564 const int_type __eof = traits_type::eof();
00565 __streambuf_type* __sb = this->rdbuf();
00566 int_type __c = __sb->sgetc();
00567
00568
00569 bool __large_ignore = false;
00570 while (true)
00571 {
00572 while (_M_gcount < __n
00573 && !traits_type::eq_int_type(__c, __eof)
00574 && !traits_type::eq_int_type(__c, __delim))
00575 {
00576 ++_M_gcount;
00577 __c = __sb->snextc();
00578 }
00579 if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
00580 && !traits_type::eq_int_type(__c, __eof)
00581 && !traits_type::eq_int_type(__c, __delim))
00582 {
00583 _M_gcount =
00584 __gnu_cxx::__numeric_traits<streamsize>::__min;
00585 __large_ignore = true;
00586 }
00587 else
00588 break;
00589 }
00590
00591 if (__large_ignore)
00592 _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
00593
00594 if (traits_type::eq_int_type(__c, __eof))
00595 __err |= ios_base::eofbit;
00596 else if (traits_type::eq_int_type(__c, __delim))
00597 {
00598 if (_M_gcount
00599 < __gnu_cxx::__numeric_traits<streamsize>::__max)
00600 ++_M_gcount;
00601 __sb->sbumpc();
00602 }
00603 }
00604 __catch(__cxxabiv1::__forced_unwind&)
00605 {
00606 this->_M_setstate(ios_base::badbit);
00607 __throw_exception_again;
00608 }
00609 __catch(...)
00610 { this->_M_setstate(ios_base::badbit); }
00611 if (__err)
00612 this->setstate(__err);
00613 }
00614 return *this;
00615 }
00616
00617 template<typename _CharT, typename _Traits>
00618 typename basic_istream<_CharT, _Traits>::int_type
00619 basic_istream<_CharT, _Traits>::
00620 peek(void)
00621 {
00622 int_type __c = traits_type::eof();
00623 _M_gcount = 0;
00624 sentry __cerb(*this, true);
00625 if (__cerb)
00626 {
00627 ios_base::iostate __err = ios_base::goodbit;
00628 __try
00629 {
00630 __c = this->rdbuf()->sgetc();
00631 if (traits_type::eq_int_type(__c, traits_type::eof()))
00632 __err |= ios_base::eofbit;
00633 }
00634 __catch(__cxxabiv1::__forced_unwind&)
00635 {
00636 this->_M_setstate(ios_base::badbit);
00637 __throw_exception_again;
00638 }
00639 __catch(...)
00640 { this->_M_setstate(ios_base::badbit); }
00641 if (__err)
00642 this->setstate(__err);
00643 }
00644 return __c;
00645 }
00646
00647 template<typename _CharT, typename _Traits>
00648 basic_istream<_CharT, _Traits>&
00649 basic_istream<_CharT, _Traits>::
00650 read(char_type* __s, streamsize __n)
00651 {
00652 _M_gcount = 0;
00653 sentry __cerb(*this, true);
00654 if (__cerb)
00655 {
00656 ios_base::iostate __err = ios_base::goodbit;
00657 __try
00658 {
00659 _M_gcount = this->rdbuf()->sgetn(__s, __n);
00660 if (_M_gcount != __n)
00661 __err |= (ios_base::eofbit | ios_base::failbit);
00662 }
00663 __catch(__cxxabiv1::__forced_unwind&)
00664 {
00665 this->_M_setstate(ios_base::badbit);
00666 __throw_exception_again;
00667 }
00668 __catch(...)
00669 { this->_M_setstate(ios_base::badbit); }
00670 if (__err)
00671 this->setstate(__err);
00672 }
00673 return *this;
00674 }
00675
00676 template<typename _CharT, typename _Traits>
00677 streamsize
00678 basic_istream<_CharT, _Traits>::
00679 readsome(char_type* __s, streamsize __n)
00680 {
00681 _M_gcount = 0;
00682 sentry __cerb(*this, true);
00683 if (__cerb)
00684 {
00685 ios_base::iostate __err = ios_base::goodbit;
00686 __try
00687 {
00688
00689 const streamsize __num = this->rdbuf()->in_avail();
00690 if (__num > 0)
00691 _M_gcount = this->rdbuf()->sgetn(__s, std::min(__num, __n));
00692 else if (__num == -1)
00693 __err |= ios_base::eofbit;
00694 }
00695 __catch(__cxxabiv1::__forced_unwind&)
00696 {
00697 this->_M_setstate(ios_base::badbit);
00698 __throw_exception_again;
00699 }
00700 __catch(...)
00701 { this->_M_setstate(ios_base::badbit); }
00702 if (__err)
00703 this->setstate(__err);
00704 }
00705 return _M_gcount;
00706 }
00707
00708 template<typename _CharT, typename _Traits>
00709 basic_istream<_CharT, _Traits>&
00710 basic_istream<_CharT, _Traits>::
00711 putback(char_type __c)
00712 {
00713
00714
00715 _M_gcount = 0;
00716 sentry __cerb(*this, true);
00717 if (__cerb)
00718 {
00719 ios_base::iostate __err = ios_base::goodbit;
00720 __try
00721 {
00722 const int_type __eof = traits_type::eof();
00723 __streambuf_type* __sb = this->rdbuf();
00724 if (!__sb
00725 || traits_type::eq_int_type(__sb->sputbackc(__c), __eof))
00726 __err |= ios_base::badbit;
00727 }
00728 __catch(__cxxabiv1::__forced_unwind&)
00729 {
00730 this->_M_setstate(ios_base::badbit);
00731 __throw_exception_again;
00732 }
00733 __catch(...)
00734 { this->_M_setstate(ios_base::badbit); }
00735 if (__err)
00736 this->setstate(__err);
00737 }
00738 return *this;
00739 }
00740
00741 template<typename _CharT, typename _Traits>
00742 basic_istream<_CharT, _Traits>&
00743 basic_istream<_CharT, _Traits>::
00744 unget(void)
00745 {
00746
00747
00748 _M_gcount = 0;
00749 sentry __cerb(*this, true);
00750 if (__cerb)
00751 {
00752 ios_base::iostate __err = ios_base::goodbit;
00753 __try
00754 {
00755 const int_type __eof = traits_type::eof();
00756 __streambuf_type* __sb = this->rdbuf();
00757 if (!__sb
00758 || traits_type::eq_int_type(__sb->sungetc(), __eof))
00759 __err |= ios_base::badbit;
00760 }
00761 __catch(__cxxabiv1::__forced_unwind&)
00762 {
00763 this->_M_setstate(ios_base::badbit);
00764 __throw_exception_again;
00765 }
00766 __catch(...)
00767 { this->_M_setstate(ios_base::badbit); }
00768 if (__err)
00769 this->setstate(__err);
00770 }
00771 return *this;
00772 }
00773
00774 template<typename _CharT, typename _Traits>
00775 int
00776 basic_istream<_CharT, _Traits>::
00777 sync(void)
00778 {
00779
00780
00781 int __ret = -1;
00782 sentry __cerb(*this, true);
00783 if (__cerb)
00784 {
00785 ios_base::iostate __err = ios_base::goodbit;
00786 __try
00787 {
00788 __streambuf_type* __sb = this->rdbuf();
00789 if (__sb)
00790 {
00791 if (__sb->pubsync() == -1)
00792 __err |= ios_base::badbit;
00793 else
00794 __ret = 0;
00795 }
00796 }
00797 __catch(__cxxabiv1::__forced_unwind&)
00798 {
00799 this->_M_setstate(ios_base::badbit);
00800 __throw_exception_again;
00801 }
00802 __catch(...)
00803 { this->_M_setstate(ios_base::badbit); }
00804 if (__err)
00805 this->setstate(__err);
00806 }
00807 return __ret;
00808 }
00809
00810 template<typename _CharT, typename _Traits>
00811 typename basic_istream<_CharT, _Traits>::pos_type
00812 basic_istream<_CharT, _Traits>::
00813 tellg(void)
00814 {
00815
00816
00817 pos_type __ret = pos_type(-1);
00818 __try
00819 {
00820 if (!this->fail())
00821 __ret = this->rdbuf()->pubseekoff(0, ios_base::cur,
00822 ios_base::in);
00823 }
00824 __catch(__cxxabiv1::__forced_unwind&)
00825 {
00826 this->_M_setstate(ios_base::badbit);
00827 __throw_exception_again;
00828 }
00829 __catch(...)
00830 { this->_M_setstate(ios_base::badbit); }
00831 return __ret;
00832 }
00833
00834 template<typename _CharT, typename _Traits>
00835 basic_istream<_CharT, _Traits>&
00836 basic_istream<_CharT, _Traits>::
00837 seekg(pos_type __pos)
00838 {
00839
00840
00841 ios_base::iostate __err = ios_base::goodbit;
00842 __try
00843 {
00844 if (!this->fail())
00845 {
00846
00847 const pos_type __p = this->rdbuf()->pubseekpos(__pos,
00848 ios_base::in);
00849
00850
00851 if (__p == pos_type(off_type(-1)))
00852 __err |= ios_base::failbit;
00853 }
00854 }
00855 __catch(__cxxabiv1::__forced_unwind&)
00856 {
00857 this->_M_setstate(ios_base::badbit);
00858 __throw_exception_again;
00859 }
00860 __catch(...)
00861 { this->_M_setstate(ios_base::badbit); }
00862 if (__err)
00863 this->setstate(__err);
00864 return *this;
00865 }
00866
00867 template<typename _CharT, typename _Traits>
00868 basic_istream<_CharT, _Traits>&
00869 basic_istream<_CharT, _Traits>::
00870 seekg(off_type __off, ios_base::seekdir __dir)
00871 {
00872
00873
00874 ios_base::iostate __err = ios_base::goodbit;
00875 __try
00876 {
00877 if (!this->fail())
00878 {
00879
00880 const pos_type __p = this->rdbuf()->pubseekoff(__off, __dir,
00881 ios_base::in);
00882
00883
00884 if (__p == pos_type(off_type(-1)))
00885 __err |= ios_base::failbit;
00886 }
00887 }
00888 __catch(__cxxabiv1::__forced_unwind&)
00889 {
00890 this->_M_setstate(ios_base::badbit);
00891 __throw_exception_again;
00892 }
00893 __catch(...)
00894 { this->_M_setstate(ios_base::badbit); }
00895 if (__err)
00896 this->setstate(__err);
00897 return *this;
00898 }
00899
00900
00901 template<typename _CharT, typename _Traits>
00902 basic_istream<_CharT, _Traits>&
00903 operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
00904 {
00905 typedef basic_istream<_CharT, _Traits> __istream_type;
00906 typedef typename __istream_type::int_type __int_type;
00907
00908 typename __istream_type::sentry __cerb(__in, false);
00909 if (__cerb)
00910 {
00911 ios_base::iostate __err = ios_base::goodbit;
00912 __try
00913 {
00914 const __int_type __cb = __in.rdbuf()->sbumpc();
00915 if (!_Traits::eq_int_type(__cb, _Traits::eof()))
00916 __c = _Traits::to_char_type(__cb);
00917 else
00918 __err |= (ios_base::eofbit | ios_base::failbit);
00919 }
00920 __catch(__cxxabiv1::__forced_unwind&)
00921 {
00922 __in._M_setstate(ios_base::badbit);
00923 __throw_exception_again;
00924 }
00925 __catch(...)
00926 { __in._M_setstate(ios_base::badbit); }
00927 if (__err)
00928 __in.setstate(__err);
00929 }
00930 return __in;
00931 }
00932
00933 template<typename _CharT, typename _Traits>
00934 basic_istream<_CharT, _Traits>&
00935 operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
00936 {
00937 typedef basic_istream<_CharT, _Traits> __istream_type;
00938 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
00939 typedef typename _Traits::int_type int_type;
00940 typedef _CharT char_type;
00941 typedef ctype<_CharT> __ctype_type;
00942
00943 streamsize __extracted = 0;
00944 ios_base::iostate __err = ios_base::goodbit;
00945 typename __istream_type::sentry __cerb(__in, false);
00946 if (__cerb)
00947 {
00948 __try
00949 {
00950
00951 streamsize __num = __in.width();
00952 if (__num <= 0)
00953 __num = __gnu_cxx::__numeric_traits<streamsize>::__max;
00954
00955 const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
00956
00957 const int_type __eof = _Traits::eof();
00958 __streambuf_type* __sb = __in.rdbuf();
00959 int_type __c = __sb->sgetc();
00960
00961 while (__extracted < __num - 1
00962 && !_Traits::eq_int_type(__c, __eof)
00963 && !__ct.is(ctype_base::space,
00964 _Traits::to_char_type(__c)))
00965 {
00966 *__s++ = _Traits::to_char_type(__c);
00967 ++__extracted;
00968 __c = __sb->snextc();
00969 }
00970 if (_Traits::eq_int_type(__c, __eof))
00971 __err |= ios_base::eofbit;
00972
00973
00974
00975 *__s = char_type();
00976 __in.width(0);
00977 }
00978 __catch(__cxxabiv1::__forced_unwind&)
00979 {
00980 __in._M_setstate(ios_base::badbit);
00981 __throw_exception_again;
00982 }
00983 __catch(...)
00984 { __in._M_setstate(ios_base::badbit); }
00985 }
00986 if (!__extracted)
00987 __err |= ios_base::failbit;
00988 if (__err)
00989 __in.setstate(__err);
00990 return __in;
00991 }
00992
00993
00994 template<typename _CharT, typename _Traits>
00995 basic_istream<_CharT, _Traits>&
00996 ws(basic_istream<_CharT, _Traits>& __in)
00997 {
00998 typedef basic_istream<_CharT, _Traits> __istream_type;
00999 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
01000 typedef typename __istream_type::int_type __int_type;
01001 typedef ctype<_CharT> __ctype_type;
01002
01003 const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
01004 const __int_type __eof = _Traits::eof();
01005 __streambuf_type* __sb = __in.rdbuf();
01006 __int_type __c = __sb->sgetc();
01007
01008 while (!_Traits::eq_int_type(__c, __eof)
01009 && __ct.is(ctype_base::space, _Traits::to_char_type(__c)))
01010 __c = __sb->snextc();
01011
01012 if (_Traits::eq_int_type(__c, __eof))
01013 __in.setstate(ios_base::eofbit);
01014 return __in;
01015 }
01016
01017
01018
01019
01020 #if _GLIBCXX_EXTERN_TEMPLATE
01021 extern template class basic_istream<char>;
01022 extern template istream& ws(istream&);
01023 extern template istream& operator>>(istream&, char&);
01024 extern template istream& operator>>(istream&, char*);
01025 extern template istream& operator>>(istream&, unsigned char&);
01026 extern template istream& operator>>(istream&, signed char&);
01027 extern template istream& operator>>(istream&, unsigned char*);
01028 extern template istream& operator>>(istream&, signed char*);
01029
01030 extern template istream& istream::_M_extract(unsigned short&);
01031 extern template istream& istream::_M_extract(unsigned int&);
01032 extern template istream& istream::_M_extract(long&);
01033 extern template istream& istream::_M_extract(unsigned long&);
01034 extern template istream& istream::_M_extract(bool&);
01035 #ifdef _GLIBCXX_USE_LONG_LONG
01036 extern template istream& istream::_M_extract(long long&);
01037 extern template istream& istream::_M_extract(unsigned long long&);
01038 #endif
01039 extern template istream& istream::_M_extract(float&);
01040 extern template istream& istream::_M_extract(double&);
01041 extern template istream& istream::_M_extract(long double&);
01042 extern template istream& istream::_M_extract(void*&);
01043
01044 extern template class basic_iostream<char>;
01045
01046 #ifdef _GLIBCXX_USE_WCHAR_T
01047 extern template class basic_istream<wchar_t>;
01048 extern template wistream& ws(wistream&);
01049 extern template wistream& operator>>(wistream&, wchar_t&);
01050 extern template wistream& operator>>(wistream&, wchar_t*);
01051
01052 extern template wistream& wistream::_M_extract(unsigned short&);
01053 extern template wistream& wistream::_M_extract(unsigned int&);
01054 extern template wistream& wistream::_M_extract(long&);
01055 extern template wistream& wistream::_M_extract(unsigned long&);
01056 extern template wistream& wistream::_M_extract(bool&);
01057 #ifdef _GLIBCXX_USE_LONG_LONG
01058 extern template wistream& wistream::_M_extract(long long&);
01059 extern template wistream& wistream::_M_extract(unsigned long long&);
01060 #endif
01061 extern template wistream& wistream::_M_extract(float&);
01062 extern template wistream& wistream::_M_extract(double&);
01063 extern template wistream& wistream::_M_extract(long double&);
01064 extern template wistream& wistream::_M_extract(void*&);
01065
01066 extern template class basic_iostream<wchar_t>;
01067 #endif
01068 #endif
01069
01070 _GLIBCXX_END_NAMESPACE
01071
01072 #endif