Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

634 lines
18 KiB

  1. // istream standard header
  2. #ifndef _ISTREAM_
  3. #define _ISTREAM_
  4. #include <ostream>
  5. #ifdef _MSC_VER
  6. #pragma pack(push,8)
  7. #endif /* _MSC_VER */
  8. _STD_BEGIN
  9. // TEMPLATE CLASS basic_istream
  10. template<class _E, class _Tr /* = char_traits<_E> */ >
  11. class basic_istream : virtual public basic_ios<_E, _Tr> {
  12. public:
  13. typedef basic_istream<_E, _Tr> _Myt;
  14. typedef basic_ios<_E, _Tr> _Myios;
  15. typedef basic_streambuf<_E, _Tr> _Mysb;
  16. typedef istreambuf_iterator<_E, _Tr> _Iter;
  17. typedef ctype<_E> _Ctype;
  18. typedef num_get<_E, _Iter> _Nget;
  19. explicit basic_istream(_Mysb *_S, bool _Isstd = false)
  20. : _Chcount(0) {init(_S, _Isstd); }
  21. basic_istream(_Uninitialized)
  22. {_Addstd(); }
  23. virtual ~basic_istream()
  24. {}
  25. class sentry {
  26. public:
  27. explicit sentry(_Myt& _Is, bool _Noskip = false)
  28. : _Ok(_Is.ipfx(_Noskip)) {}
  29. operator bool() const
  30. {return (_Ok); }
  31. private:
  32. bool _Ok;
  33. };
  34. bool ipfx(bool _Noskip = false)
  35. {if (good())
  36. {if (tie() != 0)
  37. tie()->flush();
  38. if (!_Noskip && flags() & skipws)
  39. {const _Ctype& _Fac = _USE(getloc(), _Ctype);
  40. _TRY_IO_BEGIN
  41. int_type _C = rdbuf()->sgetc();
  42. while (!_Tr::eq_int_type(_Tr::eof(), _C)
  43. && _Fac.is(_Ctype::space,
  44. _Tr::to_char_type(_C)))
  45. _C = rdbuf()->snextc();
  46. _CATCH_IO_END }
  47. if (good())
  48. return (true); }
  49. setstate(failbit);
  50. return (false); }
  51. void isfx()
  52. {}
  53. _Myt& operator>>(_Myt& (__cdecl *_F)(_Myt&))
  54. {return ((*_F)(*this)); }
  55. _Myt& operator>>(_Myios& (__cdecl *_F)(_Myios&))
  56. {(*_F)(*(_Myios *)this);
  57. return (*this); }
  58. _Myt& operator>>(ios_base& (__cdecl *_F)(ios_base&))
  59. {(*_F)(*(ios_base *)this);
  60. return (*this); }
  61. _Myt& operator>>(_Bool& _X)
  62. {iostate _St = goodbit;
  63. const sentry _Ok(*this);
  64. if (_Ok)
  65. {const _Nget& _Fac = _USE(getloc(), _Nget);
  66. _TRY_IO_BEGIN
  67. _Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
  68. _CATCH_IO_END }
  69. setstate(_St);
  70. return (*this); }
  71. _Myt& operator>>(short& _X)
  72. {iostate _St = goodbit;
  73. const sentry _Ok(*this);
  74. if (_Ok)
  75. {long _Y;
  76. const _Nget& _Fac = _USE(getloc(), _Nget);
  77. _TRY_IO_BEGIN
  78. _Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _Y);
  79. _CATCH_IO_END
  80. if (_St & failbit || _Y < SHRT_MIN || SHRT_MAX < _Y)
  81. _St |= failbit;
  82. else
  83. _X = (short)_Y; }
  84. setstate(_St);
  85. return (*this); }
  86. _Myt& operator>>(unsigned short& _X)
  87. {iostate _St = goodbit;
  88. const sentry _Ok(*this);
  89. if (_Ok)
  90. {const _Nget& _Fac = _USE(getloc(), _Nget);
  91. _TRY_IO_BEGIN
  92. _Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
  93. _CATCH_IO_END }
  94. setstate(_St);
  95. return (*this); }
  96. _Myt& operator>>(int& _X)
  97. {iostate _St = goodbit;
  98. const sentry _Ok(*this);
  99. if (_Ok)
  100. {long _Y;
  101. const _Nget& _Fac = _USE(getloc(), _Nget);
  102. _TRY_IO_BEGIN
  103. _Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _Y);
  104. _CATCH_IO_END
  105. if (_St & failbit || _Y < INT_MIN || INT_MAX < _Y)
  106. _St |= failbit;
  107. else
  108. _X = _Y; }
  109. setstate(_St);
  110. return (*this); }
  111. _Myt& operator>>(unsigned int& _X)
  112. {iostate _St = goodbit;
  113. const sentry _Ok(*this);
  114. if (_Ok)
  115. {const _Nget& _Fac = _USE(getloc(), _Nget);
  116. _TRY_IO_BEGIN
  117. _Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
  118. _CATCH_IO_END }
  119. setstate(_St);
  120. return (*this); }
  121. _Myt& operator>>(long& _X)
  122. {iostate _St = goodbit;
  123. const sentry _Ok(*this);
  124. if (_Ok)
  125. {const _Nget& _Fac = _USE(getloc(), _Nget);
  126. _TRY_IO_BEGIN
  127. _Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
  128. _CATCH_IO_END }
  129. setstate(_St);
  130. return (*this); }
  131. _Myt& operator>>(unsigned long& _X)
  132. {iostate _St = goodbit;
  133. const sentry _Ok(*this);
  134. if (_Ok)
  135. {const _Nget& _Fac = _USE(getloc(), _Nget);
  136. _TRY_IO_BEGIN
  137. _Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
  138. _CATCH_IO_END }
  139. setstate(_St);
  140. return (*this); }
  141. #ifdef _WIN64
  142. _Myt& operator>>(__int64& _X)
  143. {iostate _St = goodbit;
  144. const sentry _Ok(*this);
  145. if (_Ok)
  146. {const _Nget& _Fac = _USE(getloc(), _Nget);
  147. _TRY_IO_BEGIN
  148. _Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
  149. _CATCH_IO_END }
  150. setstate(_St);
  151. return (*this); }
  152. _Myt& operator>>(unsigned __int64& _X)
  153. {iostate _St = goodbit;
  154. const sentry _Ok(*this);
  155. if (_Ok)
  156. {const _Nget& _Fac = _USE(getloc(), _Nget);
  157. _TRY_IO_BEGIN
  158. _Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
  159. _CATCH_IO_END }
  160. setstate(_St);
  161. return (*this); }
  162. #endif // _WIN64
  163. _Myt& operator>>(float& _X)
  164. {iostate _St = goodbit;
  165. const sentry _Ok(*this);
  166. if (_Ok)
  167. {const _Nget& _Fac = _USE(getloc(), _Nget);
  168. _TRY_IO_BEGIN
  169. _Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
  170. _CATCH_IO_END }
  171. setstate(_St);
  172. return (*this); }
  173. _Myt& operator>>(double& _X)
  174. {iostate _St = goodbit;
  175. const sentry _Ok(*this);
  176. if (_Ok)
  177. {const _Nget& _Fac = _USE(getloc(), _Nget);
  178. _TRY_IO_BEGIN
  179. _Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
  180. _CATCH_IO_END }
  181. setstate(_St);
  182. return (*this); }
  183. _Myt& operator>>(long double& _X)
  184. {iostate _St = goodbit;
  185. const sentry _Ok(*this);
  186. if (_Ok)
  187. {const _Nget& _Fac = _USE(getloc(), _Nget);
  188. _TRY_IO_BEGIN
  189. _Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
  190. _CATCH_IO_END }
  191. setstate(_St);
  192. return (*this); }
  193. _Myt& operator>>(void *& _X)
  194. {iostate _St = goodbit;
  195. const sentry _Ok(*this);
  196. if (_Ok)
  197. {const _Nget& _Fac = _USE(getloc(), _Nget);
  198. _TRY_IO_BEGIN
  199. _Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
  200. _CATCH_IO_END }
  201. setstate(_St);
  202. return (*this); }
  203. _Myt& operator>>(_Mysb *_Pb)
  204. {iostate _St = goodbit;
  205. bool _Copied = false;
  206. const sentry _Ok(*this);
  207. if (_Ok && _Pb != 0)
  208. {_TRY_IO_BEGIN
  209. int_type _C = rdbuf()->sgetc();
  210. for (; ; _C = rdbuf()->snextc())
  211. if (_Tr::eq_int_type(_Tr::eof(), _C))
  212. {_St |= eofbit;
  213. break; }
  214. else
  215. {_TRY_BEGIN
  216. if (_Tr::eq_int_type(_Tr::eof(),
  217. _Pb->sputc(_Tr::to_char_type(_C))))
  218. break;
  219. _CATCH_ALL
  220. break;
  221. _CATCH_END
  222. _Copied = true; }
  223. _CATCH_IO_END }
  224. setstate(!_Copied ? _St | failbit : _St);
  225. return (*this); }
  226. int_type get()
  227. {int_type _C;
  228. iostate _St = goodbit;
  229. _Chcount = 0;
  230. const sentry _Ok(*this, true);
  231. if (!_Ok)
  232. _C = _Tr::eof();
  233. else
  234. {_TRY_IO_BEGIN
  235. _C = rdbuf()->sbumpc();
  236. if (_Tr::eq_int_type(_Tr::eof(), _C))
  237. _St |= eofbit | failbit;
  238. else
  239. ++_Chcount;
  240. _CATCH_IO_END }
  241. setstate(_St);
  242. return (_C); }
  243. _Myt& get(_E *_S, streamsize _N)
  244. {return (get(_S, _N, widen('\n'))); }
  245. _Myt& get(_E *_S, streamsize _N, _E _D)
  246. {iostate _St = goodbit;
  247. _Chcount = 0;
  248. const sentry _Ok(*this, true);
  249. if (_Ok && 0 < _N)
  250. {_TRY_IO_BEGIN
  251. int_type _C = rdbuf()->sgetc();
  252. for (; 0 < --_N; _C = rdbuf()->snextc())
  253. if (_Tr::eq_int_type(_Tr::eof(), _C))
  254. {_St |= eofbit;
  255. break; }
  256. else if (_Tr::to_char_type(_C) == _D)
  257. break;
  258. else
  259. *_S++ = _Tr::to_char_type(_C), ++_Chcount;
  260. _CATCH_IO_END }
  261. setstate(_Chcount == 0 ? _St | failbit : _St);
  262. *_S = _E(0);
  263. return (*this); }
  264. _Myt& get(_E& _X)
  265. {int_type _C = get();
  266. if (!_Tr::eq_int_type(_Tr::eof(), _C))
  267. _X = _Tr::to_char_type(_C);
  268. return (*this); }
  269. _Myt& get(_Mysb& _Sb)
  270. {return (get(_Sb, widen('\n'))); }
  271. _Myt& get(_Mysb& _Sb, _E _D)
  272. {iostate _St = goodbit;
  273. _Chcount = 0;
  274. const sentry _Ok(*this, true);
  275. if (_Ok)
  276. {_TRY_IO_BEGIN
  277. int_type _C = rdbuf()->sgetc();
  278. for (; ; _C = rdbuf()->snextc())
  279. if (_Tr::eq_int_type(_Tr::eof(), _C))
  280. {_St |= eofbit;
  281. break; }
  282. else
  283. {_TRY_BEGIN
  284. _E _Ch = _Tr::to_char_type(_C);
  285. if (_Ch == _D
  286. || _Tr::eq_int_type(_Tr::eof(),
  287. _Sb.sputc(_Ch)))
  288. break;
  289. _CATCH_ALL
  290. break;
  291. _CATCH_END
  292. ++_Chcount; }
  293. _CATCH_IO_END }
  294. if (_Chcount == 0)
  295. _St |= failbit;
  296. setstate(_St);
  297. return (*this); }
  298. _Myt& getline(_E *_S, streamsize _N)
  299. {return (getline(_S, _N, widen('\n'))); }
  300. _Myt& getline(_E *_S, streamsize _N, _E _D)
  301. {iostate _St = goodbit;
  302. _Chcount = 0;
  303. const sentry _Ok(*this, true);
  304. if (_Ok && 0 < _N)
  305. {int_type _Di = _Tr::to_int_type(_D);
  306. _TRY_IO_BEGIN
  307. int_type _C = rdbuf()->sgetc();
  308. for (; ; _C = rdbuf()->snextc())
  309. if (_Tr::eq_int_type(_Tr::eof(), _C))
  310. {_St |= eofbit;
  311. break; }
  312. else if (_C == _Di)
  313. {++_Chcount;
  314. rdbuf()->stossc();
  315. break; }
  316. else if (--_N <= 0)
  317. {_St |= failbit;
  318. break; }
  319. else
  320. {++_Chcount;
  321. *_S++ = _Tr::to_char_type(_C); }
  322. _CATCH_IO_END }
  323. *_S = _E(0);
  324. setstate(_Chcount == 0 ? _St | failbit : _St);
  325. return (*this); }
  326. _Myt& ignore(streamsize _N = 1, int_type _Di = _Tr::eof())
  327. {iostate _St = goodbit;
  328. _Chcount = 0;
  329. const sentry _Ok(*this, true);
  330. if (_Ok && 0 < _N)
  331. {_TRY_IO_BEGIN
  332. for (; ; )
  333. {int_type _C;
  334. if (_N != INT_MAX && --_N < 0)
  335. break;
  336. else if (_Tr::eq_int_type(_Tr::eof(),
  337. _C = rdbuf()->sbumpc()))
  338. {_St |= eofbit;
  339. break; }
  340. else
  341. {++_Chcount;
  342. if (_C == _Di)
  343. break; }}
  344. _CATCH_IO_END }
  345. setstate(_St);
  346. return (*this); }
  347. _Myt& read(_E *_S, streamsize _N)
  348. {iostate _St = goodbit;
  349. _Chcount = 0;
  350. const sentry _Ok(*this, true);
  351. if (_Ok)
  352. {_TRY_IO_BEGIN
  353. const streamsize _M = rdbuf()->sgetn(_S, _N);
  354. _Chcount += _M;
  355. if (_M != _N)
  356. _St |= eofbit | failbit;
  357. _CATCH_IO_END }
  358. setstate(_St);
  359. return (*this); }
  360. streamsize readsome(_E *_S, streamsize _N)
  361. {iostate _St = goodbit;
  362. _Chcount = 0;
  363. int _M;
  364. if (rdbuf() == 0)
  365. _St |= failbit;
  366. else if ((_M = rdbuf()->in_avail()) < 0)
  367. _St |= eofbit;
  368. else if (0 < _M)
  369. read(_S, _M < _N ? _M : _N);
  370. setstate(_St);
  371. return (gcount()); }
  372. int_type peek()
  373. {iostate _St = goodbit;
  374. _Chcount = 0;
  375. int_type _C;
  376. const sentry _Ok(*this, true);
  377. if (!_Ok)
  378. _C = _Tr::eof();
  379. else
  380. {_TRY_IO_BEGIN
  381. if (_Tr::eq_int_type(_Tr::eof(),
  382. _C = rdbuf()->sgetc()))
  383. _St |= eofbit;
  384. _CATCH_IO_END }
  385. setstate(_St);
  386. return (_C); }
  387. _Myt& putback(_E _X)
  388. {iostate _St = goodbit;
  389. _Chcount = 0;
  390. const sentry _Ok(*this, true);
  391. if (_Ok)
  392. {_TRY_IO_BEGIN
  393. if (_Tr::eq_int_type(_Tr::eof(),
  394. rdbuf()->sputbackc(_X)))
  395. _St |= badbit;
  396. _CATCH_IO_END }
  397. setstate(_St);
  398. return (*this); }
  399. _Myt& unget()
  400. {iostate _St = goodbit;
  401. _Chcount = 0;
  402. const sentry _Ok(*this, true);
  403. if (_Ok)
  404. {_TRY_IO_BEGIN
  405. if (_Tr::eq_int_type(_Tr::eof(),
  406. rdbuf()->sungetc()))
  407. _St |= badbit;
  408. _CATCH_IO_END }
  409. setstate(_St);
  410. return (*this); }
  411. streamsize gcount() const
  412. {return (_Chcount); }
  413. int sync()
  414. {iostate _St = goodbit;
  415. int _Ans;
  416. if (rdbuf() == 0)
  417. _Ans = -1;
  418. else if (rdbuf()->pubsync() == -1)
  419. _St |= badbit, _Ans = -1;
  420. else
  421. _Ans = 0;
  422. setstate(_St);
  423. return (_Ans); }
  424. _Myt& seekg(pos_type _P)
  425. {if (!fail())
  426. rdbuf()->pubseekpos(_P, in);
  427. return (*this); }
  428. _Myt& seekg(off_type _O, ios_base::seekdir _W)
  429. {if (!fail())
  430. rdbuf()->pubseekoff(_O, _W, in);
  431. return (*this); }
  432. pos_type tellg()
  433. {if (!fail())
  434. return (rdbuf()->pubseekoff(0, cur, in));
  435. else
  436. return (streampos(_BADOFF)); }
  437. private:
  438. streamsize _Chcount;
  439. };
  440. #ifdef _DLL
  441. #pragma warning(disable:4231) /* the extern before template is a non-standard extension */
  442. extern template class _CRTIMP basic_istream<char, char_traits<char> >;
  443. extern template class _CRTIMP basic_istream<wchar_t, char_traits<wchar_t> >;
  444. #pragma warning(default:4231) /* restore previous warning */
  445. #endif // _DLL
  446. // TEMPLATE CLASS basic_iostream
  447. template<class _E, class _Tr /* = char_traits<_E> */ >
  448. class basic_iostream : public basic_istream<_E, _Tr>,
  449. public basic_ostream<_E, _Tr> {
  450. public:
  451. explicit basic_iostream(basic_streambuf<_E, _Tr> *_S)
  452. : basic_istream<_E, _Tr>(_S), basic_ostream<_E, _Tr>(_S, false, false)
  453. {}
  454. virtual ~basic_iostream()
  455. {}
  456. };
  457. #ifdef _DLL
  458. #pragma warning(disable:4231) /* the extern before template is a non-standard extension */
  459. extern template class _CRTIMP basic_iostream<char, char_traits<char> >;
  460. extern template class _CRTIMP basic_iostream<wchar_t, char_traits<wchar_t> >;
  461. #pragma warning(default:4231) /* restore previous warning */
  462. #endif // _DLL
  463. // EXTRACTORS
  464. template<class _E, class _Tr> inline
  465. basic_istream<_E, _Tr>& __cdecl operator>>(
  466. basic_istream<_E, _Tr>& _I, _E *_X)
  467. {typedef basic_istream<_E, _Tr> _Myis;
  468. typedef ctype<_E> _Ctype;
  469. ios_base::iostate _St = ios_base::goodbit;
  470. _E *_S = _X;
  471. const _Myis::sentry _Ok(_I);
  472. if (_Ok)
  473. {const _Ctype& _Fac = _USE(_I.getloc(), _Ctype);
  474. _TRY_IO_BEGIN
  475. int _N = 0 < _I.width() ? _I.width() : INT_MAX;
  476. _Myis::int_type _C = _I.rdbuf()->sgetc();
  477. for (; 0 < --_N; _C = _I.rdbuf()->snextc())
  478. if (_Tr::eq_int_type(_Tr::eof(), _C))
  479. {_St |= ios_base::eofbit;
  480. break; }
  481. else if (_Fac.is(_Ctype::space,
  482. _Tr::to_char_type(_C)))
  483. break;
  484. else
  485. *_S++ = _Tr::to_char_type(_C);
  486. _CATCH_IO_(_I) }
  487. *_S = _E(0);
  488. _I.width(0);
  489. _I.setstate(_S == _X ? _St | ios_base::failbit : _St);
  490. return (_I); }
  491. template<class _E, class _Tr> inline
  492. basic_istream<_E, _Tr>& __cdecl operator>>(
  493. basic_istream<_E, _Tr>& _I, _E& _X)
  494. {typedef basic_istream<_E, _Tr> _Myis;
  495. _Myis::int_type _C;
  496. ios_base::iostate _St = ios_base::goodbit;
  497. const _Myis::sentry _Ok(_I);
  498. if (_Ok)
  499. {_TRY_IO_BEGIN
  500. _C = _I.rdbuf()->sbumpc();
  501. if (_Tr::eq_int_type(_Tr::eof(), _C))
  502. _St |= ios_base::eofbit | ios_base::failbit;
  503. else
  504. _X = _Tr::to_char_type(_C);
  505. _CATCH_IO_(_I) }
  506. _I.setstate(_St);
  507. return (_I); }
  508. template<class _E, class _Tr> inline
  509. basic_istream<_E, _Tr>& __cdecl operator>>(
  510. basic_istream<_E, _Tr>& _I, signed char *_X)
  511. {return (_I >> (char *)_X); }
  512. template<class _E, class _Tr> inline
  513. basic_istream<_E, _Tr>& __cdecl operator>>(
  514. basic_istream<_E, _Tr>& _I, signed char& _C)
  515. {return (_I >> (char&)_C); }
  516. template<class _E, class _Tr> inline
  517. basic_istream<_E, _Tr>& __cdecl operator>>(
  518. basic_istream<_E, _Tr>& _I, unsigned char *_X)
  519. {return (_I >> (char *)_X); }
  520. template<class _E, class _Tr> inline
  521. basic_istream<_E, _Tr>& __cdecl operator>>(
  522. basic_istream<_E, _Tr>& _I, unsigned char& _C)
  523. {return (_I >> (char&)_C); }
  524. template<class _E, class _Tr> inline
  525. basic_istream<_E, _Tr>& __cdecl operator>>(
  526. basic_istream<_E, _Tr>& _I, signed short * _X)
  527. {return (_I >> (wchar_t *)_X); }
  528. // MANIPULATORS
  529. template<class _E, class _Tr> inline
  530. basic_istream<_E, _Tr>& __cdecl ws(basic_istream<_E, _Tr>& _I)
  531. {typedef basic_istream<_E, _Tr> _Myis;
  532. typedef ctype<_E> _Ctype;
  533. ios_base::iostate _St = ios_base::goodbit;
  534. const _Myis::sentry _Ok(_I, true);
  535. if (_Ok)
  536. {const _Ctype& _Fac = _USE(_I.getloc(), _Ctype);
  537. _TRY_IO_BEGIN
  538. for (_Tr::int_type _C = _I.rdbuf()->sgetc(); ;
  539. _C = _I.rdbuf()->snextc())
  540. if (_Tr::eq_int_type(_Tr::eof(), _C))
  541. {_St |= ios_base::eofbit;
  542. break; }
  543. else if (!_Fac.is(_Ctype::space,
  544. _Tr::to_char_type(_C)))
  545. break;
  546. _CATCH_IO_(_I) }
  547. _I.setstate(_St);
  548. return (_I); }
  549. _CRTIMP inline basic_istream<char, char_traits<char> >&
  550. __cdecl ws(basic_istream<char, char_traits<char> >& _I)
  551. {typedef char _E;
  552. typedef char_traits<_E> _Tr;
  553. ios_base::iostate _St = ios_base::goodbit;
  554. const basic_istream<_E, _Tr>::sentry _Ok(_I, true);
  555. if (_Ok)
  556. {const ctype<_E>& _Fac = _USE(_I.getloc(), ctype<_E>);
  557. _TRY_IO_BEGIN
  558. for (_Tr::int_type _C = _I.rdbuf()->sgetc(); ;
  559. _C = _I.rdbuf()->snextc())
  560. if (_Tr::eq_int_type(_Tr::eof(), _C))
  561. {_St |= ios_base::eofbit;
  562. break; }
  563. else if (!_Fac.is(ctype<_E>::space,
  564. _Tr::to_char_type(_C)))
  565. break;
  566. _CATCH_IO_(_I) }
  567. _I.setstate(_St);
  568. return (_I); }
  569. _CRTIMP inline basic_istream<wchar_t, char_traits<wchar_t> >&
  570. __cdecl ws(basic_istream<wchar_t, char_traits<wchar_t> >& _I)
  571. {typedef wchar_t _E;
  572. typedef char_traits<_E> _Tr;
  573. ios_base::iostate _St = ios_base::goodbit;
  574. const basic_istream<_E, _Tr>::sentry _Ok(_I, true);
  575. if (_Ok)
  576. {const ctype<_E>& _Fac = _USE(_I.getloc(), ctype<_E>);
  577. _TRY_IO_BEGIN
  578. for (_Tr::int_type _C = _I.rdbuf()->sgetc(); ;
  579. _C = _I.rdbuf()->snextc())
  580. if (_Tr::eq_int_type(_Tr::eof(), _C))
  581. {_St |= ios_base::eofbit;
  582. break; }
  583. else if (_Fac.is(ctype<_E>::space,
  584. _Tr::to_char_type(_C)))
  585. break;
  586. _CATCH_IO_(_I) }
  587. _I.setstate(_St);
  588. return (_I); }
  589. #ifdef _DLL
  590. #pragma warning(disable:4231) /* the extern before template is a non-standard extension */
  591. extern template _CRTIMP basic_istream<char, char_traits<char> >& __cdecl operator>>(
  592. basic_istream<char, char_traits<char> >&, char *);
  593. extern template _CRTIMP basic_istream<char, char_traits<char> >& __cdecl operator>>(
  594. basic_istream<char, char_traits<char> >&, char&);
  595. extern template _CRTIMP basic_istream<char, char_traits<char> >& __cdecl operator>>(
  596. basic_istream<char, char_traits<char> >&, signed char *);
  597. extern template _CRTIMP basic_istream<char, char_traits<char> >& __cdecl operator>>(
  598. basic_istream<char, char_traits<char> >&, signed char&);
  599. extern template _CRTIMP basic_istream<char, char_traits<char> >& __cdecl operator>>(
  600. basic_istream<char, char_traits<char> >&, unsigned char *);
  601. extern template _CRTIMP basic_istream<char, char_traits<char> >& __cdecl operator>>(
  602. basic_istream<char, char_traits<char> >&, unsigned char&);
  603. extern template _CRTIMP basic_istream<wchar_t, char_traits<wchar_t> >& __cdecl operator>>(
  604. basic_istream<wchar_t, char_traits<wchar_t> >&, wchar_t *);
  605. extern template _CRTIMP basic_istream<wchar_t, char_traits<wchar_t> >& __cdecl operator>>(
  606. basic_istream<wchar_t, char_traits<wchar_t> >&, wchar_t&);
  607. extern template _CRTIMP basic_istream<wchar_t, char_traits<wchar_t> >& __cdecl operator>>(
  608. basic_istream<wchar_t, char_traits<wchar_t> >&, signed short *);
  609. #pragma warning(default:4231) /* restore previous warning */
  610. #endif // _DLL
  611. _STD_END
  612. #ifdef _MSC_VER
  613. #pragma pack(pop)
  614. #endif /* _MSC_VER */
  615. #endif /* _ISTREAM_ */
  616. /*
  617. * Copyright (c) 1994 by P.J. Plauger. ALL RIGHTS RESERVED.
  618. * Consult your license regarding permissions and restrictions.
  619. */