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