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.

646 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. #ifdef __FORCE_INSTANCE
  442. template class _CRTIMP2 basic_istream<char, char_traits<char> >;
  443. template class _CRTIMP2 basic_istream<wchar_t, char_traits<wchar_t> >;
  444. #else // __FORCE_INSTANCE
  445. #pragma warning(disable:4231) /* the extern before template is a non-standard extension */
  446. extern template class _CRTIMP2 basic_istream<char, char_traits<char> >;
  447. extern template class _CRTIMP2 basic_istream<wchar_t, char_traits<wchar_t> >;
  448. #pragma warning(default:4231) /* restore previous warning */
  449. #endif // __FORCE_INSTANCE
  450. #endif // _DLL
  451. // TEMPLATE CLASS basic_iostream
  452. template<class _E, class _Tr /* = char_traits<_E> */ >
  453. class basic_iostream : public basic_istream<_E, _Tr>,
  454. public basic_ostream<_E, _Tr> {
  455. public:
  456. explicit basic_iostream(basic_streambuf<_E, _Tr> *_S)
  457. : basic_istream<_E, _Tr>(_S), basic_ostream<_E, _Tr>(_S, false, false)
  458. {}
  459. virtual ~basic_iostream()
  460. {}
  461. };
  462. #ifdef _DLL
  463. #ifdef __FORCE_INSTANCE
  464. template class _CRTIMP2 basic_iostream<char, char_traits<char> >;
  465. template class _CRTIMP2 basic_iostream<wchar_t, char_traits<wchar_t> >;
  466. #else // __FORCE_INSTANCE
  467. #pragma warning(disable:4231) /* the extern before template is a non-standard extension */
  468. extern template class _CRTIMP2 basic_iostream<char, char_traits<char> >;
  469. extern template class _CRTIMP2 basic_iostream<wchar_t, char_traits<wchar_t> >;
  470. #pragma warning(default:4231) /* restore previous warning */
  471. #endif // __FORCE_INSTANCE
  472. #endif // _DLL
  473. // EXTRACTORS
  474. template<class _E, class _Tr> inline
  475. basic_istream<_E, _Tr>& __cdecl operator>>(
  476. basic_istream<_E, _Tr>& _I, _E *_X)
  477. {typedef basic_istream<_E, _Tr> _Myis;
  478. typedef ctype<_E> _Ctype;
  479. ios_base::iostate _St = ios_base::goodbit;
  480. _E *_S = _X;
  481. const _Myis::sentry _Ok(_I);
  482. if (_Ok)
  483. {const _Ctype& _Fac = _USE(_I.getloc(), _Ctype);
  484. _TRY_IO_BEGIN
  485. int _N = 0 < _I.width() ? _I.width() : INT_MAX;
  486. _Myis::int_type _C = _I.rdbuf()->sgetc();
  487. for (; 0 < --_N; _C = _I.rdbuf()->snextc())
  488. if (_Tr::eq_int_type(_Tr::eof(), _C))
  489. {_St |= ios_base::eofbit;
  490. break; }
  491. else if (_Fac.is(_Ctype::space,
  492. _Tr::to_char_type(_C)))
  493. break;
  494. else
  495. *_S++ = _Tr::to_char_type(_C);
  496. _CATCH_IO_(_I) }
  497. *_S = _E(0);
  498. _I.width(0);
  499. _I.setstate(_S == _X ? _St | ios_base::failbit : _St);
  500. return (_I); }
  501. template<class _E, class _Tr> inline
  502. basic_istream<_E, _Tr>& __cdecl operator>>(
  503. basic_istream<_E, _Tr>& _I, _E& _X)
  504. {typedef basic_istream<_E, _Tr> _Myis;
  505. _Myis::int_type _C;
  506. ios_base::iostate _St = ios_base::goodbit;
  507. const _Myis::sentry _Ok(_I);
  508. if (_Ok)
  509. {_TRY_IO_BEGIN
  510. _C = _I.rdbuf()->sbumpc();
  511. if (_Tr::eq_int_type(_Tr::eof(), _C))
  512. _St |= ios_base::eofbit | ios_base::failbit;
  513. else
  514. _X = _Tr::to_char_type(_C);
  515. _CATCH_IO_(_I) }
  516. _I.setstate(_St);
  517. return (_I); }
  518. template<class _E, class _Tr> inline
  519. basic_istream<_E, _Tr>& __cdecl operator>>(
  520. basic_istream<_E, _Tr>& _I, signed char *_X)
  521. {return (_I >> (char *)_X); }
  522. template<class _E, class _Tr> inline
  523. basic_istream<_E, _Tr>& __cdecl operator>>(
  524. basic_istream<_E, _Tr>& _I, signed char& _C)
  525. {return (_I >> (char&)_C); }
  526. template<class _E, class _Tr> inline
  527. basic_istream<_E, _Tr>& __cdecl operator>>(
  528. basic_istream<_E, _Tr>& _I, unsigned char *_X)
  529. {return (_I >> (char *)_X); }
  530. template<class _E, class _Tr> inline
  531. basic_istream<_E, _Tr>& __cdecl operator>>(
  532. basic_istream<_E, _Tr>& _I, unsigned char& _C)
  533. {return (_I >> (char&)_C); }
  534. template<class _E, class _Tr> inline
  535. basic_istream<_E, _Tr>& __cdecl operator>>(
  536. basic_istream<_E, _Tr>& _I, signed short * _X)
  537. {return (_I >> (wchar_t *)_X); }
  538. // MANIPULATORS
  539. template<class _E, class _Tr> inline
  540. basic_istream<_E, _Tr>& __cdecl ws(basic_istream<_E, _Tr>& _I)
  541. {typedef basic_istream<_E, _Tr> _Myis;
  542. typedef ctype<_E> _Ctype;
  543. ios_base::iostate _St = ios_base::goodbit;
  544. const _Myis::sentry _Ok(_I, true);
  545. if (_Ok)
  546. {const _Ctype& _Fac = _USE(_I.getloc(), _Ctype);
  547. _TRY_IO_BEGIN
  548. for (_Tr::int_type _C = _I.rdbuf()->sgetc(); ;
  549. _C = _I.rdbuf()->snextc())
  550. if (_Tr::eq_int_type(_Tr::eof(), _C))
  551. {_St |= ios_base::eofbit;
  552. break; }
  553. else if (!_Fac.is(_Ctype::space,
  554. _Tr::to_char_type(_C)))
  555. break;
  556. _CATCH_IO_(_I) }
  557. _I.setstate(_St);
  558. return (_I); }
  559. _CRTIMP2 inline basic_istream<char, char_traits<char> >&
  560. __cdecl ws(basic_istream<char, char_traits<char> >& _I)
  561. {typedef char _E;
  562. typedef char_traits<_E> _Tr;
  563. ios_base::iostate _St = ios_base::goodbit;
  564. const basic_istream<_E, _Tr>::sentry _Ok(_I, true);
  565. if (_Ok)
  566. {const ctype<_E>& _Fac = _USE(_I.getloc(), ctype<_E>);
  567. _TRY_IO_BEGIN
  568. for (_Tr::int_type _C = _I.rdbuf()->sgetc(); ;
  569. _C = _I.rdbuf()->snextc())
  570. if (_Tr::eq_int_type(_Tr::eof(), _C))
  571. {_St |= ios_base::eofbit;
  572. break; }
  573. else if (!_Fac.is(ctype<_E>::space,
  574. _Tr::to_char_type(_C)))
  575. break;
  576. _CATCH_IO_(_I) }
  577. _I.setstate(_St);
  578. return (_I); }
  579. _CRTIMP2 inline basic_istream<wchar_t, char_traits<wchar_t> >&
  580. __cdecl ws(basic_istream<wchar_t, char_traits<wchar_t> >& _I)
  581. {typedef wchar_t _E;
  582. typedef char_traits<_E> _Tr;
  583. ios_base::iostate _St = ios_base::goodbit;
  584. const basic_istream<_E, _Tr>::sentry _Ok(_I, true);
  585. if (_Ok)
  586. {const ctype<_E>& _Fac = _USE(_I.getloc(), ctype<_E>);
  587. _TRY_IO_BEGIN
  588. for (_Tr::int_type _C = _I.rdbuf()->sgetc(); ;
  589. _C = _I.rdbuf()->snextc())
  590. if (_Tr::eq_int_type(_Tr::eof(), _C))
  591. {_St |= ios_base::eofbit;
  592. break; }
  593. else if (_Fac.is(ctype<_E>::space,
  594. _Tr::to_char_type(_C)))
  595. break;
  596. _CATCH_IO_(_I) }
  597. _I.setstate(_St);
  598. return (_I); }
  599. #ifdef _DLL
  600. #ifndef CRTDLL2
  601. #pragma warning(disable:4231) /* the extern before template is a non-standard extension */
  602. extern template _CRTIMP2 basic_istream<char, char_traits<char> >& __cdecl operator>>(
  603. basic_istream<char, char_traits<char> >&, char *);
  604. extern template _CRTIMP2 basic_istream<char, char_traits<char> >& __cdecl operator>>(
  605. basic_istream<char, char_traits<char> >&, char&);
  606. extern template _CRTIMP2 basic_istream<char, char_traits<char> >& __cdecl operator>>(
  607. basic_istream<char, char_traits<char> >&, signed char *);
  608. extern template _CRTIMP2 basic_istream<char, char_traits<char> >& __cdecl operator>>(
  609. basic_istream<char, char_traits<char> >&, signed char&);
  610. extern template _CRTIMP2 basic_istream<char, char_traits<char> >& __cdecl operator>>(
  611. basic_istream<char, char_traits<char> >&, unsigned char *);
  612. extern template _CRTIMP2 basic_istream<char, char_traits<char> >& __cdecl operator>>(
  613. basic_istream<char, char_traits<char> >&, unsigned char&);
  614. extern template _CRTIMP2 basic_istream<wchar_t, char_traits<wchar_t> >& __cdecl operator>>(
  615. basic_istream<wchar_t, char_traits<wchar_t> >&, wchar_t *);
  616. extern template _CRTIMP2 basic_istream<wchar_t, char_traits<wchar_t> >& __cdecl operator>>(
  617. basic_istream<wchar_t, char_traits<wchar_t> >&, wchar_t&);
  618. extern template _CRTIMP2 basic_istream<wchar_t, char_traits<wchar_t> >& __cdecl operator>>(
  619. basic_istream<wchar_t, char_traits<wchar_t> >&, signed short *);
  620. #pragma warning(default:4231) /* restore previous warning */
  621. #endif // CRTDLL2
  622. #endif // _DLL
  623. _STD_END
  624. #ifdef _MSC_VER
  625. #pragma pack(pop)
  626. #endif /* _MSC_VER */
  627. #endif /* _ISTREAM_ */
  628. /*
  629. * Copyright (c) 1994 by P.J. Plauger. ALL RIGHTS RESERVED.
  630. * Consult your license regarding permissions and restrictions.
  631. */