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.

756 lines
20 KiB

  1. // ostream standard header
  2. #pragma once
  3. #ifndef _OSTREAM_
  4. #define _OSTREAM_
  5. #include <ios>
  6. #pragma pack(push,8)
  7. #pragma warning(push,3)
  8. _STD_BEGIN
  9. // I/O EXCEPTION MACROS
  10. #if _HAS_EXCEPTIONS
  11. #define _TRY_IO_BEGIN _TRY_BEGIN /* begin try block */
  12. #define _CATCH_IO_END _CATCH_ALL /* catch block for _Myios */ \
  13. _Myios::setstate(ios_base::badbit, true); /* set badbit and rethrow */ \
  14. _CATCH_END
  15. #define _CATCH_IO_(x) _CATCH_ALL /* catch block for basic_ios x */ \
  16. (x).setstate(ios_base::badbit, true); /* set badbit and rethrow */ \
  17. _CATCH_END
  18. #else
  19. #define _TRY_IO_BEGIN { /* begin try block */
  20. #define _CATCH_IO_END } /* catch block for _Myios */
  21. #define _CATCH_IO_(x) } /* catch block for basic_ios x */
  22. #endif
  23. // TEMPLATE CLASS basic_ostream
  24. template<class _Elem, class _Traits>
  25. class basic_ostream
  26. : virtual public basic_ios<_Elem, _Traits>
  27. { // control insertions into a stream buffer
  28. public:
  29. typedef basic_ostream<_Elem, _Traits> _Myt;
  30. typedef basic_ios<_Elem, _Traits> _Myios;
  31. typedef basic_streambuf<_Elem, _Traits> _Mysb;
  32. typedef ostreambuf_iterator<_Elem, _Traits> _Iter;
  33. typedef num_put<_Elem, _Iter> _Nput;
  34. explicit basic_ostream(basic_streambuf<_Elem, _Traits> *_Strbuf,
  35. bool _Isstd = false)
  36. { // construct from a stream buffer pointer
  37. _Myios::init(_Strbuf, _Isstd);
  38. }
  39. basic_ostream(_Uninitialized)
  40. { // construct uninitialized
  41. ios_base::_Addstd();
  42. }
  43. virtual ~basic_ostream()
  44. { // destroy the object
  45. }
  46. typedef typename _Traits::int_type int_type;
  47. typedef typename _Traits::pos_type pos_type;
  48. typedef typename _Traits::off_type off_type;
  49. class _Sentry_base
  50. { // stores thread lock and reference to output stream
  51. public:
  52. _Sentry_base(_Myt& _Ostr)
  53. : _Myostr(_Ostr)
  54. { // lock the stream buffer, if there
  55. if (_Myostr.rdbuf() != 0)
  56. _Myostr.rdbuf()->_Lock();
  57. }
  58. ~_Sentry_base()
  59. { // destroy after unlocking
  60. if (_Myostr.rdbuf() != 0)
  61. _Myostr.rdbuf()->_Unlock();
  62. }
  63. _Myt& _Myostr; // the output stream, for _Unlock call at destruction
  64. };
  65. class sentry
  66. : public _Sentry_base
  67. { // stores thread lock and state of stream
  68. public:
  69. explicit sentry(_Myt& _Ostr)
  70. : _Sentry_base(_Ostr)
  71. { // construct locking and testing stream
  72. if (_Ostr.good() && _Ostr.tie() != 0)
  73. _Ostr.tie()->flush();
  74. _Ok = _Ostr.good(); // store test only after flushing tie
  75. }
  76. ~sentry()
  77. { // destroy the object
  78. #if _HAS_EXCEPTIONS
  79. if (!uncaught_exception())
  80. _Myostr._Osfx();
  81. }
  82. #else
  83. _Myostr._Osfx();
  84. }
  85. #endif
  86. operator bool() const
  87. { // test if stream state okay
  88. return (_Ok);
  89. }
  90. private:
  91. sentry(const sentry&); // not defined
  92. sentry& operator=(const sentry&); // not defined
  93. bool _Ok; // true if stream state okay at construction
  94. };
  95. bool opfx()
  96. { // test stream state and flush tie stream as needed (retained)
  97. if (ios_base::good() && _Myios::tie() != 0)
  98. _Myios::tie()->flush();
  99. return (ios_base::good());
  100. }
  101. void osfx()
  102. { // perform any wrapup (retained)
  103. _Osfx();
  104. }
  105. void _Osfx()
  106. { // perform any wrapup
  107. if (ios_base::flags() & ios_base::unitbuf)
  108. flush(); // flush stream as needed
  109. }
  110. _Myt& operator<<(_Myt& (__cdecl *_Pfn)(_Myt&))
  111. { // call basic_ostream manipulator
  112. return ((*_Pfn)(*this));
  113. }
  114. _Myt& operator<<(_Myios& (__cdecl *_Pfn)(_Myios&))
  115. { // call basic_ios manipulator
  116. (*_Pfn)(*(_Myios *)this);
  117. return (*this);
  118. }
  119. _Myt& operator<<(ios_base& (__cdecl *_Pfn)(ios_base&))
  120. { // call ios_base manipulator
  121. (*_Pfn)(*(ios_base *)this);
  122. return (*this);
  123. }
  124. _Myt& operator<<(_Bool _Val)
  125. { // insert a boolean
  126. ios_base::iostate _State = ios_base::goodbit;
  127. const sentry _Ok(*this);
  128. if (_Ok)
  129. { // state okay, use facet to insert
  130. const _Nput& _Fac = _USE(ios_base::getloc(), _Nput);
  131. _TRY_IO_BEGIN
  132. if (_Fac.put(_Iter(_Myios::rdbuf()), *this,
  133. _Myios::fill(), _Val).failed())
  134. _State |= ios_base::badbit;
  135. _CATCH_IO_END
  136. }
  137. _Myios::setstate(_State);
  138. return (*this);
  139. }
  140. _Myt& operator<<(short _Val)
  141. { // insert a short
  142. ios_base::iostate _State = ios_base::goodbit;
  143. const sentry _Ok(*this);
  144. if (_Ok)
  145. { // state okay, use facet to insert
  146. const _Nput& _Fac = _USE(ios_base::getloc(), _Nput);
  147. ios_base::fmtflags _Bfl =
  148. ios_base::flags() & ios_base::basefield;
  149. long _Tmp = (_Bfl == ios_base::oct
  150. || _Bfl == ios_base::hex)
  151. ? (long)(unsigned short)_Val : (long)_Val;
  152. _TRY_IO_BEGIN
  153. if (_Fac.put(_Iter(_Myios::rdbuf()), *this,
  154. _Myios::fill(), _Tmp).failed())
  155. _State |= ios_base::badbit;
  156. _CATCH_IO_END
  157. }
  158. _Myios::setstate(_State);
  159. return (*this);
  160. }
  161. _Myt& operator<<(unsigned short _Val)
  162. { // insert an unsigned short
  163. ios_base::iostate _State = ios_base::goodbit;
  164. const sentry _Ok(*this);
  165. if (_Ok)
  166. { // state okay, use facet to insert
  167. const _Nput& _Fac = _USE(ios_base::getloc(), _Nput);
  168. _TRY_IO_BEGIN
  169. if (_Fac.put(_Iter(_Myios::rdbuf()), *this,
  170. _Myios::fill(), (unsigned long)_Val).failed())
  171. _State |= ios_base::badbit;
  172. _CATCH_IO_END
  173. }
  174. _Myios::setstate(_State);
  175. return (*this);
  176. }
  177. _Myt& operator<<(int _Val)
  178. { // insert an int
  179. ios_base::iostate _State = ios_base::goodbit;
  180. const sentry _Ok(*this);
  181. if (_Ok)
  182. { // state okay, use facet to insert
  183. const _Nput& _Fac = _USE(ios_base::getloc(), _Nput);
  184. ios_base::fmtflags _Bfl =
  185. ios_base::flags() & ios_base::basefield;
  186. long _Tmp = (_Bfl == ios_base::oct
  187. || _Bfl == ios_base::hex)
  188. ? (long)(unsigned int)_Val : (long)_Val;
  189. _TRY_IO_BEGIN
  190. if (_Fac.put(_Iter(_Myios::rdbuf()), *this,
  191. _Myios::fill(), _Tmp).failed())
  192. _State |= ios_base::badbit;
  193. _CATCH_IO_END
  194. }
  195. _Myios::setstate(_State);
  196. return (*this);
  197. }
  198. _Myt& operator<<(unsigned int _Val)
  199. { // insert an unsigned int
  200. ios_base::iostate _State = ios_base::goodbit;
  201. const sentry _Ok(*this);
  202. if (_Ok)
  203. { // state okay, use facet to insert
  204. const _Nput& _Fac = _USE(ios_base::getloc(), _Nput);
  205. _TRY_IO_BEGIN
  206. if (_Fac.put(_Iter(_Myios::rdbuf()), *this,
  207. _Myios::fill(), (unsigned long)_Val).failed())
  208. _State |= ios_base::badbit;
  209. _CATCH_IO_END
  210. }
  211. _Myios::setstate(_State);
  212. return (*this);
  213. }
  214. _Myt& operator<<(long _Val)
  215. { // insert a long
  216. ios_base::iostate _State = ios_base::goodbit;
  217. const sentry _Ok(*this);
  218. if (_Ok)
  219. { // state okay, use facet to insert
  220. const _Nput& _Fac = _USE(ios_base::getloc(), _Nput);
  221. _TRY_IO_BEGIN
  222. if (_Fac.put(_Iter(_Myios::rdbuf()), *this,
  223. _Myios::fill(), _Val).failed())
  224. _State |= ios_base::badbit;
  225. _CATCH_IO_END
  226. }
  227. _Myios::setstate(_State);
  228. return (*this);
  229. }
  230. _Myt& operator<<(unsigned long _Val)
  231. { // insert an unsigned long
  232. ios_base::iostate _State = ios_base::goodbit;
  233. const sentry _Ok(*this);
  234. if (_Ok)
  235. { // state okay, use facet to insert
  236. const _Nput& _Fac = _USE(ios_base::getloc(), _Nput);
  237. _TRY_IO_BEGIN
  238. if (_Fac.put(_Iter(_Myios::rdbuf()), *this,
  239. _Myios::fill(), _Val).failed())
  240. _State |= ios_base::badbit;
  241. _CATCH_IO_END
  242. }
  243. _Myios::setstate(_State);
  244. return (*this);
  245. }
  246. #ifdef _LONGLONG
  247. _Myt& operator<<(_LONGLONG _Val)
  248. { // insert a long long
  249. ios_base::iostate _State = ios_base::goodbit;
  250. const sentry _Ok(*this);
  251. if (_Ok)
  252. { // state okay, use facet to insert
  253. const _Nput& _Fac = _USE(ios_base::getloc(), _Nput);
  254. _TRY_IO_BEGIN
  255. if (_Fac.put(_Iter(_Myios::rdbuf()), *this,
  256. _Myios::fill(), _Val).failed())
  257. _State |= ios_base::badbit;
  258. _CATCH_IO_END
  259. }
  260. _Myios::setstate(_State);
  261. return (*this);
  262. }
  263. _Myt& operator<<(_ULONGLONG _Val)
  264. { // insert an unsigned long long
  265. ios_base::iostate _State = ios_base::goodbit;
  266. const sentry _Ok(*this);
  267. if (_Ok)
  268. { // state okay, use facet to insert
  269. const _Nput& _Fac = _USE(ios_base::getloc(), _Nput);
  270. _TRY_IO_BEGIN
  271. if (_Fac.put(_Iter(_Myios::rdbuf()), *this,
  272. _Myios::fill(), _Val).failed())
  273. _State |= ios_base::badbit;
  274. _CATCH_IO_END
  275. }
  276. _Myios::setstate(_State);
  277. return (*this);
  278. }
  279. #endif /* _LONGLONG */
  280. _Myt& operator<<(float _Val)
  281. { // insert a float
  282. ios_base::iostate _State = ios_base::goodbit;
  283. const sentry _Ok(*this);
  284. if (_Ok)
  285. { // state okay, use facet to insert
  286. const _Nput& _Fac = _USE(ios_base::getloc(), _Nput);
  287. _TRY_IO_BEGIN
  288. if (_Fac.put(_Iter(_Myios::rdbuf()), *this,
  289. _Myios::fill(), (double)_Val).failed())
  290. _State |= ios_base::badbit;
  291. _CATCH_IO_END
  292. }
  293. _Myios::setstate(_State);
  294. return (*this);
  295. }
  296. _Myt& operator<<(double _Val)
  297. { // insert a double
  298. ios_base::iostate _State = ios_base::goodbit;
  299. const sentry _Ok(*this);
  300. if (_Ok)
  301. { // state okay, use facet to insert
  302. const _Nput& _Fac = _USE(ios_base::getloc(), _Nput);
  303. _TRY_IO_BEGIN
  304. if (_Fac.put(_Iter(_Myios::rdbuf()), *this,
  305. _Myios::fill(), _Val).failed())
  306. _State |= ios_base::badbit;
  307. _CATCH_IO_END
  308. }
  309. _Myios::setstate(_State);
  310. return (*this);
  311. }
  312. _Myt& operator<<(long double _Val)
  313. { // insert a long double
  314. ios_base::iostate _State = ios_base::goodbit;
  315. const sentry _Ok(*this);
  316. if (_Ok)
  317. { // state okay, use facet to insert
  318. const _Nput& _Fac = _USE(ios_base::getloc(), _Nput);
  319. _TRY_IO_BEGIN
  320. if (_Fac.put(_Iter(_Myios::rdbuf()), *this,
  321. _Myios::fill(), _Val).failed())
  322. _State |= ios_base::badbit;
  323. _CATCH_IO_END
  324. }
  325. _Myios::setstate(_State);
  326. return (*this);
  327. }
  328. _Myt& operator<<(const void *_Val)
  329. { // insert a void pointer
  330. ios_base::iostate _State = ios_base::goodbit;
  331. const sentry _Ok(*this);
  332. if (_Ok)
  333. { // state okay, use facet to insert
  334. const _Nput& _Fac = _USE(ios_base::getloc(), _Nput);
  335. _TRY_IO_BEGIN
  336. if (_Fac.put(_Iter(_Myios::rdbuf()), *this,
  337. _Myios::fill(), _Val).failed())
  338. _State |= ios_base::badbit;
  339. _CATCH_IO_END
  340. }
  341. _Myios::setstate(_State);
  342. return (*this);
  343. }
  344. _Myt& operator<<(_Mysb *_Strbuf)
  345. { // insert until end-of-file from a stream buffer
  346. ios_base::iostate _State = ios_base::goodbit;
  347. bool _Copied = false;
  348. const sentry _Ok(*this);
  349. if (_Ok && _Strbuf != 0)
  350. for (int_type _Meta = _Traits::eof(); ; _Copied = true)
  351. { // extract another character from stream buffer
  352. _TRY_BEGIN
  353. _Meta = _Traits::eq_int_type(_Traits::eof(), _Meta)
  354. ? _Strbuf->sgetc() : _Strbuf->snextc();
  355. _CATCH_ALL
  356. _Myios::setstate(ios_base::failbit);
  357. _RERAISE;
  358. _CATCH_END
  359. if (_Traits::eq_int_type(_Traits::eof(), _Meta))
  360. break; // end of file, quit
  361. _TRY_IO_BEGIN
  362. if (_Traits::eq_int_type(_Traits::eof(),
  363. _Myios::rdbuf()->sputc(
  364. _Traits::to_char_type(_Meta))))
  365. { // insertion failed, quit
  366. _State |= ios_base::badbit;
  367. break;
  368. }
  369. _CATCH_IO_END
  370. }
  371. ios_base::width(0);
  372. _Myios::setstate(!_Copied ? _State | ios_base::failbit : _State);
  373. return (*this);
  374. }
  375. _Myt& put(_Elem _Ch)
  376. { // insert a character
  377. ios_base::iostate _State = ios_base::goodbit;
  378. const sentry _Ok(*this);
  379. if (!_Ok)
  380. _State |= ios_base::badbit;
  381. else
  382. { // state okay, insert character
  383. _TRY_IO_BEGIN
  384. if (_Traits::eq_int_type(_Traits::eof(),
  385. _Myios::rdbuf()->sputc(_Ch)))
  386. _State |= ios_base::badbit;
  387. _CATCH_IO_END
  388. }
  389. _Myios::setstate(_State);
  390. return (*this);
  391. }
  392. _Myt& write(const _Elem *_Str, streamsize _Count)
  393. { // insert _Count characters from array _Str
  394. ios_base::iostate _State = ios_base::goodbit;
  395. const sentry _Ok(*this);
  396. if (!_Ok)
  397. _State |= ios_base::badbit;
  398. else
  399. { // state okay, insert characters
  400. _TRY_IO_BEGIN
  401. if (_Myios::rdbuf()->sputn(_Str, _Count) != _Count)
  402. _State |= ios_base::badbit;
  403. _CATCH_IO_END
  404. }
  405. _Myios::setstate(_State);
  406. return (*this);
  407. }
  408. _Myt& flush()
  409. { // flush output stream
  410. ios_base::iostate _State = ios_base::goodbit;
  411. if (!ios_base::fail() && _Myios::rdbuf()->pubsync() == -1)
  412. _State |= ios_base::badbit; // sync failed
  413. _Myios::setstate(_State);
  414. return (*this);
  415. }
  416. _Myt& seekp(pos_type _Pos)
  417. { // set output stream position to _Pos
  418. if (!ios_base::fail()
  419. && (off_type)_Myios::rdbuf()->pubseekpos(_Pos,
  420. ios_base::out) == _BADOFF)
  421. _Myios::setstate(ios_base::failbit);
  422. return (*this);
  423. }
  424. _Myt& seekp(off_type _Off, ios_base::seekdir _Way)
  425. { // change output stream position by _Off, according to _Way
  426. if (!ios_base::fail()
  427. && (off_type)_Myios::rdbuf()->pubseekoff(_Off, _Way,
  428. ios_base::out) == _BADOFF)
  429. _Myios::setstate(ios_base::failbit);
  430. return (*this);
  431. }
  432. pos_type tellp()
  433. { // return output stream position
  434. if (!ios_base::fail())
  435. return (_Myios::rdbuf()->pubseekoff(0,
  436. ios_base::cur, ios_base::out));
  437. else
  438. return (pos_type(_BADOFF));
  439. }
  440. };
  441. #ifdef _DLL_CPPLIB
  442. template class _CRTIMP2 basic_ostream<char, char_traits<char> >;
  443. template class _CRTIMP2 basic_ostream<wchar_t, char_traits<wchar_t> >;
  444. #endif // _DLL_CPPLIB
  445. // INSERTERS
  446. template<class _Elem, class _Traits> inline
  447. basic_ostream<_Elem, _Traits>& __cdecl operator<<(
  448. basic_ostream<_Elem, _Traits>& _Ostr, const _Elem *_Val)
  449. { // insert NTCS
  450. typedef basic_ostream<_Elem, _Traits> _Myos;
  451. ios_base::iostate _State = ios_base::goodbit;
  452. streamsize _Count = (streamsize)_Traits::length(_Val); // may overflow
  453. streamsize _Pad = _Ostr.width() <= 0 || _Ostr.width() <= _Count
  454. ? 0 : _Ostr.width() - _Count;
  455. const typename _Myos::sentry _Ok(_Ostr);
  456. if (!_Ok)
  457. _State |= ios_base::badbit;
  458. else
  459. { // state okay, insert
  460. _TRY_IO_BEGIN
  461. if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left)
  462. for (; 0 < _Pad; --_Pad) // pad on left
  463. if (_Traits::eq_int_type(_Traits::eof(),
  464. _Ostr.rdbuf()->sputc(_Ostr.fill())))
  465. { // insertion failed, quit
  466. _State |= ios_base::badbit;
  467. break;
  468. }
  469. if (_State == ios_base::goodbit
  470. && _Ostr.rdbuf()->sputn(_Val, _Count) != _Count)
  471. _State |= ios_base::badbit;
  472. if (_State == ios_base::goodbit)
  473. for (; 0 < _Pad; --_Pad) // pad on right
  474. if (_Traits::eq_int_type(_Traits::eof(),
  475. _Ostr.rdbuf()->sputc(_Ostr.fill())))
  476. { // insertion failed, quit
  477. _State |= ios_base::badbit;
  478. break;
  479. }
  480. _Ostr.width(0);
  481. _CATCH_IO_(_Ostr)
  482. }
  483. _Ostr.setstate(_State);
  484. return (_Ostr);
  485. }
  486. template<class _Elem, class _Traits> inline
  487. basic_ostream<_Elem, _Traits>& __cdecl operator<<(
  488. basic_ostream<_Elem, _Traits>& _Ostr, _Elem _Ch)
  489. { // insert a character
  490. typedef basic_ostream<_Elem, _Traits> _Myos;
  491. ios_base::iostate _State = ios_base::goodbit;
  492. const typename _Myos::sentry _Ok(_Ostr);
  493. if (_Ok)
  494. { // state okay, insert
  495. streamsize _Pad = _Ostr.width() <= 1 ? 0 : _Ostr.width() - 1;
  496. _TRY_IO_BEGIN
  497. if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left)
  498. for (; _State == ios_base::goodbit && 0 < _Pad;
  499. --_Pad) // pad on left
  500. if (_Traits::eq_int_type(_Traits::eof(),
  501. _Ostr.rdbuf()->sputc(_Ostr.fill())))
  502. _State |= ios_base::badbit;
  503. if (_State == ios_base::goodbit
  504. && _Traits::eq_int_type(_Traits::eof(),
  505. _Ostr.rdbuf()->sputc(_Ch)))
  506. _State |= ios_base::badbit;
  507. for (; _State == ios_base::goodbit && 0 < _Pad;
  508. --_Pad) // pad on right
  509. if (_Traits::eq_int_type(_Traits::eof(),
  510. _Ostr.rdbuf()->sputc(_Ostr.fill())))
  511. _State |= ios_base::badbit;
  512. _CATCH_IO_(_Ostr)
  513. }
  514. _Ostr.width(0);
  515. _Ostr.setstate(_State);
  516. return (_Ostr);
  517. }
  518. template<class _Traits> inline
  519. basic_ostream<char, _Traits>& __cdecl operator<<(
  520. basic_ostream<char, _Traits>& _Ostr, const signed char *_Val)
  521. { // insert a signed char NTBS
  522. return (_Ostr << (const char *)_Val);
  523. }
  524. template<class _Traits> inline
  525. basic_ostream<char, _Traits>& __cdecl operator<<(
  526. basic_ostream<char, _Traits>& _Ostr, signed char _Ch)
  527. { // insert a signed char
  528. return (_Ostr << (char)_Ch);
  529. }
  530. template<class _Traits> inline
  531. basic_ostream<char, _Traits>& __cdecl operator<<(
  532. basic_ostream<char, _Traits>& _Ostr, const unsigned char *_Val)
  533. { // insert an unsigned char NTBS
  534. return (_Ostr << (const char *)_Val);
  535. }
  536. template<class _Traits> inline
  537. basic_ostream<char, _Traits>& __cdecl operator<<(
  538. basic_ostream<char, _Traits>& _Ostr, unsigned char _Ch)
  539. { // insert an unsigned char
  540. return (_Ostr << (char)_Ch);
  541. }
  542. // MANIPULATORS
  543. template<class _Elem, class _Traits> inline
  544. basic_ostream<_Elem, _Traits>&
  545. __cdecl endl(basic_ostream<_Elem, _Traits>& _Ostr)
  546. { // insert newline and flush stream
  547. _Ostr.put(_Ostr.widen('\n'));
  548. _Ostr.flush();
  549. return (_Ostr);
  550. }
  551. template<class _Elem, class _Traits> inline
  552. basic_ostream<_Elem, _Traits>&
  553. __cdecl ends(basic_ostream<_Elem, _Traits>& _Ostr)
  554. { // insert null character
  555. _Ostr.put(_Elem());
  556. return (_Ostr);
  557. }
  558. template<class _Elem, class _Traits> inline
  559. basic_ostream<_Elem, _Traits>&
  560. __cdecl flush(basic_ostream<_Elem, _Traits>& _Ostr)
  561. { // flush stream
  562. _Ostr.flush();
  563. return (_Ostr);
  564. }
  565. _CRTIMP2 inline basic_ostream<char, char_traits<char> >&
  566. __cdecl endl(basic_ostream<char, char_traits<char> >& _Ostr)
  567. { // insert newline and flush byte stream
  568. _Ostr.put('\n');
  569. _Ostr.flush();
  570. return (_Ostr);
  571. }
  572. _CRTIMP2 inline basic_ostream<wchar_t, char_traits<wchar_t> >&
  573. __cdecl endl(basic_ostream<wchar_t,
  574. char_traits<wchar_t> >& _Ostr)
  575. { // insert newline and flush wide stream
  576. _Ostr.put('\n');
  577. _Ostr.flush();
  578. return (_Ostr);
  579. }
  580. _CRTIMP2 inline basic_ostream<char, char_traits<char> >&
  581. __cdecl ends(basic_ostream<char, char_traits<char> >& _Ostr)
  582. { // insert null character into byte stream
  583. _Ostr.put('\0');
  584. return (_Ostr);
  585. }
  586. _CRTIMP2 inline basic_ostream<wchar_t, char_traits<wchar_t> >&
  587. __cdecl ends(basic_ostream<wchar_t,
  588. char_traits<wchar_t> >& _Ostr)
  589. { // insert null character into wide stream
  590. _Ostr.put('\0');
  591. return (_Ostr);
  592. }
  593. _CRTIMP2 inline basic_ostream<char, char_traits<char> >&
  594. __cdecl flush(basic_ostream<char, char_traits<char> >& _Ostr)
  595. { // flush byte stream
  596. _Ostr.flush();
  597. return (_Ostr);
  598. }
  599. _CRTIMP2 inline basic_ostream<wchar_t, char_traits<wchar_t> >&
  600. __cdecl flush(basic_ostream<wchar_t,
  601. char_traits<wchar_t> >& _Ostr)
  602. { // flush wide stream
  603. _Ostr.flush();
  604. return (_Ostr);
  605. }
  606. #ifdef _DLL_CPPLIB
  607. template _CRTIMP2 basic_ostream<char, char_traits<char> >& __cdecl
  608. operator<<(basic_ostream<char, char_traits<char> >&,
  609. const char *);
  610. template _CRTIMP2 basic_ostream<char, char_traits<char> >& __cdecl
  611. operator<<(basic_ostream<char, char_traits<char> >&, char);
  612. template _CRTIMP2 basic_ostream<char, char_traits<char> >& __cdecl
  613. operator<<(basic_ostream<char, char_traits<char> >&,
  614. const signed char *);
  615. template _CRTIMP2 basic_ostream<char, char_traits<char> >& __cdecl
  616. operator<<(basic_ostream<char, char_traits<char> >&, signed char);
  617. template _CRTIMP2 basic_ostream<char, char_traits<char> >& __cdecl
  618. operator<<(basic_ostream<char, char_traits<char> >&,
  619. const unsigned char *);
  620. template _CRTIMP2 basic_ostream<char, char_traits<char> >& __cdecl
  621. operator<<(basic_ostream<char, char_traits<char> >&, unsigned char);
  622. template _CRTIMP2 basic_ostream<wchar_t, char_traits<wchar_t> >& __cdecl
  623. operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&,
  624. const wchar_t *);
  625. template _CRTIMP2 basic_ostream<wchar_t, char_traits<wchar_t> >& __cdecl
  626. operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, wchar_t);
  627. #endif // _DLL_CPPLIB
  628. _STD_END
  629. #pragma warning(pop)
  630. #pragma pack(pop)
  631. #endif /* _OSTREAM_ */
  632. /*
  633. * Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED.
  634. * Consult your license regarding permissions and restrictions.
  635. V3.10:0009 */