Source code of Windows XP (NT5)
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.

146 lines
4.4 KiB

  1. /***
  2. *ostream.h - definitions/declarations for the ostream class
  3. *
  4. * Copyright (c) 1991-1994, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * This file defines the classes, values, macros, and functions
  8. * used by the ostream class.
  9. * [AT&T C++]
  10. *
  11. ****/
  12. #ifndef _INC_OSTREAM
  13. #define _INC_OSTREAM
  14. /* Define _CRTIMP */
  15. #ifndef _CRTIMP
  16. #ifdef _NTSDK
  17. /* definition compatible with NT SDK */
  18. #define _CRTIMP
  19. #else /* ndef _NTSDK */
  20. /* current definition */
  21. #ifdef _DLL
  22. #define _CRTIMP __declspec(dllimport)
  23. #else /* ndef _DLL */
  24. #define _CRTIMP
  25. #endif /* _DLL */
  26. #endif /* _NTSDK */
  27. #endif /* _CRTIMP */
  28. #include <ios.h>
  29. #ifdef _MSC_VER
  30. // C4505: "unreferenced local function has been removed"
  31. #pragma warning(disable:4505) // disable C4505 warning
  32. // #pragma warning(default:4505) // use this to reenable, if desired
  33. // Force word packing to avoid possible -Zp override
  34. #pragma pack(push,4)
  35. #endif // _MSC_VER
  36. typedef long streamoff, streampos;
  37. class _CRTIMP ostream : virtual public ios {
  38. public:
  39. ostream(streambuf*);
  40. virtual ~ostream();
  41. ostream& flush();
  42. int opfx();
  43. void osfx();
  44. inline ostream& operator<<(ostream& (__cdecl * _f)(ostream&));
  45. inline ostream& operator<<(ios& (__cdecl * _f)(ios&));
  46. ostream& operator<<(const char *);
  47. inline ostream& operator<<(const unsigned char *);
  48. inline ostream& operator<<(const signed char *);
  49. inline ostream& operator<<(char);
  50. ostream& operator<<(unsigned char);
  51. inline ostream& operator<<(signed char);
  52. ostream& operator<<(short);
  53. ostream& operator<<(unsigned short);
  54. ostream& operator<<(int);
  55. ostream& operator<<(unsigned int);
  56. ostream& operator<<(long);
  57. ostream& operator<<(unsigned long);
  58. inline ostream& operator<<(float);
  59. ostream& operator<<(double);
  60. ostream& operator<<(long double);
  61. ostream& operator<<(const void *);
  62. ostream& operator<<(streambuf*);
  63. inline ostream& put(char);
  64. ostream& put(unsigned char);
  65. inline ostream& put(signed char);
  66. ostream& write(const char *,int);
  67. inline ostream& write(const unsigned char *,int);
  68. inline ostream& write(const signed char *,int);
  69. ostream& seekp(streampos);
  70. ostream& seekp(streamoff,ios::seek_dir);
  71. streampos tellp();
  72. protected:
  73. ostream();
  74. ostream(const ostream&); // treat as private
  75. ostream& operator=(streambuf*); // treat as private
  76. ostream& operator=(const ostream& _os) {return operator=(_os.rdbuf()); }
  77. int do_opfx(int); // not used
  78. void do_osfx(); // not used
  79. private:
  80. ostream(ios&);
  81. ostream& writepad(const char *, const char *);
  82. int x_floatused;
  83. };
  84. inline ostream& ostream::operator<<(ostream& (__cdecl * _f)(ostream&)) { (*_f)(*this); return *this; }
  85. inline ostream& ostream::operator<<(ios& (__cdecl * _f)(ios& )) { (*_f)(*this); return *this; }
  86. inline ostream& ostream::operator<<(char _c) { return operator<<((unsigned char) _c); }
  87. inline ostream& ostream::operator<<(signed char _c) { return operator<<((unsigned char) _c); }
  88. inline ostream& ostream::operator<<(const unsigned char * _s) { return operator<<((const char *) _s); }
  89. inline ostream& ostream::operator<<(const signed char * _s) { return operator<<((const char *) _s); }
  90. inline ostream& ostream::operator<<(float _f) { x_floatused = 1; return operator<<((double) _f); }
  91. inline ostream& ostream::put(char _c) { return put((unsigned char) _c); }
  92. inline ostream& ostream::put(signed char _c) { return put((unsigned char) _c); }
  93. inline ostream& ostream::write(const unsigned char * _s, int _n) { return write((char *) _s, _n); }
  94. inline ostream& ostream::write(const signed char * _s, int _n) { return write((char *) _s, _n); }
  95. class _CRTIMP ostream_withassign : public ostream {
  96. public:
  97. ostream_withassign();
  98. ostream_withassign(streambuf* _is);
  99. ~ostream_withassign();
  100. ostream& operator=(const ostream& _os) { return ostream::operator=(_os.rdbuf()); }
  101. ostream& operator=(streambuf* _sb) { return ostream::operator=(_sb); }
  102. };
  103. #ifndef _WINDLL // Warning! Not available under Windows without QuickWin:
  104. extern ostream_withassign _CRTIMP cout;
  105. extern ostream_withassign _CRTIMP cerr;
  106. extern ostream_withassign _CRTIMP clog;
  107. #endif
  108. inline _CRTIMP ostream& __cdecl flush(ostream& _outs) { return _outs.flush(); }
  109. inline _CRTIMP ostream& __cdecl endl(ostream& _outs) { return _outs << '\n' << flush; }
  110. inline _CRTIMP ostream& __cdecl ends(ostream& _outs) { return _outs << char('\0'); }
  111. _CRTIMP ios& __cdecl dec(ios&);
  112. _CRTIMP ios& __cdecl hex(ios&);
  113. _CRTIMP ios& __cdecl oct(ios&);
  114. #ifdef _MSC_VER
  115. // Restore default packing
  116. #pragma pack(pop)
  117. #endif // _MSC_VER
  118. #endif // !_INC_OSTREAM