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.

798 lines
21 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. #ifdef __FORCE_INSTANCE
  443. template class _CRTIMP2 basic_ostream<char, char_traits<char> >;
  444. template class _CRTIMP2 basic_ostream<wchar_t, char_traits<wchar_t> >;
  445. #ifdef _CRTBLD_NATIVE_WCHAR_T
  446. template class _CRTIMP2 basic_ostream<unsigned short, char_traits<unsigned short> >;
  447. #endif
  448. #endif // __FORCE_INSTANCE
  449. #endif // _DLL_CPPLIB
  450. // INSERTERS
  451. template<class _Elem, class _Traits> inline
  452. basic_ostream<_Elem, _Traits>& __cdecl operator<<(
  453. basic_ostream<_Elem, _Traits>& _Ostr, const _Elem *_Val)
  454. { // insert NTCS
  455. typedef basic_ostream<_Elem, _Traits> _Myos;
  456. ios_base::iostate _State = ios_base::goodbit;
  457. streamsize _Count = (streamsize)_Traits::length(_Val); // may overflow
  458. streamsize _Pad = _Ostr.width() <= 0 || _Ostr.width() <= _Count
  459. ? 0 : _Ostr.width() - _Count;
  460. const typename _Myos::sentry _Ok(_Ostr);
  461. if (!_Ok)
  462. _State |= ios_base::badbit;
  463. else
  464. { // state okay, insert
  465. _TRY_IO_BEGIN
  466. if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left)
  467. for (; 0 < _Pad; --_Pad) // pad on left
  468. if (_Traits::eq_int_type(_Traits::eof(),
  469. _Ostr.rdbuf()->sputc(_Ostr.fill())))
  470. { // insertion failed, quit
  471. _State |= ios_base::badbit;
  472. break;
  473. }
  474. if (_State == ios_base::goodbit
  475. && _Ostr.rdbuf()->sputn(_Val, _Count) != _Count)
  476. _State |= ios_base::badbit;
  477. if (_State == ios_base::goodbit)
  478. for (; 0 < _Pad; --_Pad) // pad on right
  479. if (_Traits::eq_int_type(_Traits::eof(),
  480. _Ostr.rdbuf()->sputc(_Ostr.fill())))
  481. { // insertion failed, quit
  482. _State |= ios_base::badbit;
  483. break;
  484. }
  485. _Ostr.width(0);
  486. _CATCH_IO_(_Ostr)
  487. }
  488. _Ostr.setstate(_State);
  489. return (_Ostr);
  490. }
  491. template<class _Elem, class _Traits> inline
  492. basic_ostream<_Elem, _Traits>& __cdecl operator<<(
  493. basic_ostream<_Elem, _Traits>& _Ostr, _Elem _Ch)
  494. { // insert a character
  495. typedef basic_ostream<_Elem, _Traits> _Myos;
  496. ios_base::iostate _State = ios_base::goodbit;
  497. const typename _Myos::sentry _Ok(_Ostr);
  498. if (_Ok)
  499. { // state okay, insert
  500. streamsize _Pad = _Ostr.width() <= 1 ? 0 : _Ostr.width() - 1;
  501. _TRY_IO_BEGIN
  502. if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left)
  503. for (; _State == ios_base::goodbit && 0 < _Pad;
  504. --_Pad) // pad on left
  505. if (_Traits::eq_int_type(_Traits::eof(),
  506. _Ostr.rdbuf()->sputc(_Ostr.fill())))
  507. _State |= ios_base::badbit;
  508. if (_State == ios_base::goodbit
  509. && _Traits::eq_int_type(_Traits::eof(),
  510. _Ostr.rdbuf()->sputc(_Ch)))
  511. _State |= ios_base::badbit;
  512. for (; _State == ios_base::goodbit && 0 < _Pad;
  513. --_Pad) // pad on right
  514. if (_Traits::eq_int_type(_Traits::eof(),
  515. _Ostr.rdbuf()->sputc(_Ostr.fill())))
  516. _State |= ios_base::badbit;
  517. _CATCH_IO_(_Ostr)
  518. }
  519. _Ostr.width(0);
  520. _Ostr.setstate(_State);
  521. return (_Ostr);
  522. }
  523. template<class _Traits> inline
  524. basic_ostream<char, _Traits>& __cdecl operator<<(
  525. basic_ostream<char, _Traits>& _Ostr, const signed char *_Val)
  526. { // insert a signed char NTBS
  527. return (_Ostr << (const char *)_Val);
  528. }
  529. template<class _Traits> inline
  530. basic_ostream<char, _Traits>& __cdecl operator<<(
  531. basic_ostream<char, _Traits>& _Ostr, signed char _Ch)
  532. { // insert a signed char
  533. return (_Ostr << (char)_Ch);
  534. }
  535. template<class _Traits> inline
  536. basic_ostream<char, _Traits>& __cdecl operator<<(
  537. basic_ostream<char, _Traits>& _Ostr, const unsigned char *_Val)
  538. { // insert an unsigned char NTBS
  539. return (_Ostr << (const char *)_Val);
  540. }
  541. template<class _Traits> inline
  542. basic_ostream<char, _Traits>& __cdecl operator<<(
  543. basic_ostream<char, _Traits>& _Ostr, unsigned char _Ch)
  544. { // insert an unsigned char
  545. return (_Ostr << (char)_Ch);
  546. }
  547. // MANIPULATORS
  548. template<class _Elem, class _Traits> inline
  549. basic_ostream<_Elem, _Traits>&
  550. __cdecl endl(basic_ostream<_Elem, _Traits>& _Ostr)
  551. { // insert newline and flush stream
  552. _Ostr.put(_Ostr.widen('\n'));
  553. _Ostr.flush();
  554. return (_Ostr);
  555. }
  556. template<class _Elem, class _Traits> inline
  557. basic_ostream<_Elem, _Traits>&
  558. __cdecl ends(basic_ostream<_Elem, _Traits>& _Ostr)
  559. { // insert null character
  560. _Ostr.put(_Elem());
  561. return (_Ostr);
  562. }
  563. template<class _Elem, class _Traits> inline
  564. basic_ostream<_Elem, _Traits>&
  565. __cdecl flush(basic_ostream<_Elem, _Traits>& _Ostr)
  566. { // flush stream
  567. _Ostr.flush();
  568. return (_Ostr);
  569. }
  570. _CRTIMP2 inline basic_ostream<char, char_traits<char> >&
  571. __cdecl endl(basic_ostream<char, char_traits<char> >& _Ostr)
  572. { // insert newline and flush byte stream
  573. _Ostr.put('\n');
  574. _Ostr.flush();
  575. return (_Ostr);
  576. }
  577. _CRTIMP2 inline basic_ostream<wchar_t, char_traits<wchar_t> >&
  578. __cdecl endl(basic_ostream<wchar_t,
  579. char_traits<wchar_t> >& _Ostr)
  580. { // insert newline and flush wide stream
  581. _Ostr.put('\n');
  582. _Ostr.flush();
  583. return (_Ostr);
  584. }
  585. #ifdef _CRTBLD_NATIVE_WCHAR_T
  586. _CRTIMP2 inline basic_ostream<unsigned short, char_traits<unsigned short> >&
  587. __cdecl endl(basic_ostream<unsigned short,
  588. char_traits<unsigned short> >& _Ostr)
  589. { // insert newline and flush wide stream
  590. _Ostr.put('\n');
  591. _Ostr.flush();
  592. return (_Ostr);
  593. }
  594. #endif
  595. _CRTIMP2 inline basic_ostream<char, char_traits<char> >&
  596. __cdecl ends(basic_ostream<char, char_traits<char> >& _Ostr)
  597. { // insert null character into byte stream
  598. _Ostr.put('\0');
  599. return (_Ostr);
  600. }
  601. _CRTIMP2 inline basic_ostream<wchar_t, char_traits<wchar_t> >&
  602. __cdecl ends(basic_ostream<wchar_t,
  603. char_traits<wchar_t> >& _Ostr)
  604. { // insert null character into wide stream
  605. _Ostr.put('\0');
  606. return (_Ostr);
  607. }
  608. #ifdef _CRTBLD_NATIVE_WCHAR_T
  609. _CRTIMP2 inline basic_ostream<unsigned short, char_traits<unsigned short> >&
  610. __cdecl ends(basic_ostream<unsigned short,
  611. char_traits<unsigned short> >& _Ostr)
  612. { // insert null character into wide stream
  613. _Ostr.put('\0');
  614. return (_Ostr);
  615. }
  616. #endif
  617. _CRTIMP2 inline basic_ostream<char, char_traits<char> >&
  618. __cdecl flush(basic_ostream<char, char_traits<char> >& _Ostr)
  619. { // flush byte stream
  620. _Ostr.flush();
  621. return (_Ostr);
  622. }
  623. _CRTIMP2 inline basic_ostream<wchar_t, char_traits<wchar_t> >&
  624. __cdecl flush(basic_ostream<wchar_t,
  625. char_traits<wchar_t> >& _Ostr)
  626. { // flush wide stream
  627. _Ostr.flush();
  628. return (_Ostr);
  629. }
  630. #ifdef _CRTBLD_NATIVE_WCHAR_T
  631. _CRTIMP2 inline basic_ostream<unsigned short, char_traits<unsigned short> >&
  632. __cdecl flush(basic_ostream<unsigned short,
  633. char_traits<unsigned short> >& _Ostr)
  634. { // flush wide stream
  635. _Ostr.flush();
  636. return (_Ostr);
  637. }
  638. #endif
  639. #ifdef _DLL_CPPLIB
  640. #ifndef CRTDLL2
  641. template _CRTIMP2 basic_ostream<char, char_traits<char> >& __cdecl
  642. operator<<(basic_ostream<char, char_traits<char> >&,
  643. const char *);
  644. template _CRTIMP2 basic_ostream<char, char_traits<char> >& __cdecl
  645. operator<<(basic_ostream<char, char_traits<char> >&, char);
  646. template _CRTIMP2 basic_ostream<char, char_traits<char> >& __cdecl
  647. operator<<(basic_ostream<char, char_traits<char> >&,
  648. const signed char *);
  649. template _CRTIMP2 basic_ostream<char, char_traits<char> >& __cdecl
  650. operator<<(basic_ostream<char, char_traits<char> >&, signed char);
  651. template _CRTIMP2 basic_ostream<char, char_traits<char> >& __cdecl
  652. operator<<(basic_ostream<char, char_traits<char> >&,
  653. const unsigned char *);
  654. template _CRTIMP2 basic_ostream<char, char_traits<char> >& __cdecl
  655. operator<<(basic_ostream<char, char_traits<char> >&, unsigned char);
  656. template _CRTIMP2 basic_ostream<wchar_t, char_traits<wchar_t> >& __cdecl
  657. operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&,
  658. const wchar_t *);
  659. template _CRTIMP2 basic_ostream<wchar_t, char_traits<wchar_t> >& __cdecl
  660. operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, wchar_t);
  661. #ifdef _CRTBLD_NATIVE_WCHAR_T
  662. template _CRTIMP2 basic_ostream<unsigned short, char_traits<unsigned short> >& __cdecl
  663. operator<<(basic_ostream<unsigned short, char_traits<unsigned short> >&,
  664. const unsigned short *);
  665. template _CRTIMP2 basic_ostream<unsigned short, char_traits<unsigned short> >& __cdecl
  666. operator<<(basic_ostream<unsigned short, char_traits<unsigned short> >&, unsigned short);
  667. #endif
  668. #endif // CRTDLL2
  669. #endif // _DLL_CPPLIB
  670. _STD_END
  671. #pragma warning(pop)
  672. #pragma pack(pop)
  673. #endif /* _OSTREAM_ */
  674. /*
  675. * Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED.
  676. * Consult your license regarding permissions and restrictions.
  677. V3.10:0009 */