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.

157 lines
4.6 KiB

  1. /***
  2. *ostream.h - definitions/declarations for the ostream class
  3. *
  4. * Copyright (c) 1991-1995, 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. * [Public]
  12. *
  13. ****/
  14. #ifdef __cplusplus
  15. #ifndef _INC_OSTREAM
  16. #define _INC_OSTREAM
  17. #if !defined(_WIN32) && !defined(_MAC)
  18. #error ERROR: Only Mac or Win32 targets supported!
  19. #endif
  20. #ifdef _MSC_VER
  21. // Currently, all MS C compilers for Win32 platforms default to 8 byte
  22. // alignment.
  23. #pragma pack(push,8)
  24. #endif // _MSC_VER
  25. /* Define _CRTIMP */
  26. #ifndef _CRTIMP
  27. #ifdef _NTSDK
  28. /* definition compatible with NT SDK */
  29. #define _CRTIMP
  30. #else /* ndef _NTSDK */
  31. /* current definition */
  32. #ifdef _DLL
  33. #define _CRTIMP __declspec(dllimport)
  34. #else /* ndef _DLL */
  35. #define _CRTIMP
  36. #endif /* _DLL */
  37. #endif /* _NTSDK */
  38. #endif /* _CRTIMP */
  39. #include <ios.h>
  40. #ifdef _MSC_VER
  41. // C4514: "unreferenced inline function has been removed"
  42. #pragma warning(disable:4514) // disable C4514 warning
  43. // #pragma warning(default:4514) // use this to reenable, if desired
  44. #endif // _MSC_VER
  45. typedef long streamoff, streampos;
  46. class _CRTIMP ostream : virtual public ios {
  47. public:
  48. ostream(streambuf*);
  49. virtual ~ostream();
  50. ostream& flush();
  51. int opfx();
  52. void osfx();
  53. inline ostream& operator<<(ostream& (__cdecl * _f)(ostream&));
  54. inline ostream& operator<<(ios& (__cdecl * _f)(ios&));
  55. ostream& operator<<(const char *);
  56. inline ostream& operator<<(const unsigned char *);
  57. inline ostream& operator<<(const signed char *);
  58. inline ostream& operator<<(char);
  59. ostream& operator<<(unsigned char);
  60. inline ostream& operator<<(signed char);
  61. ostream& operator<<(short);
  62. ostream& operator<<(unsigned short);
  63. ostream& operator<<(int);
  64. ostream& operator<<(unsigned int);
  65. ostream& operator<<(long);
  66. ostream& operator<<(unsigned long);
  67. inline ostream& operator<<(float);
  68. ostream& operator<<(double);
  69. ostream& operator<<(long double);
  70. ostream& operator<<(const void *);
  71. ostream& operator<<(streambuf*);
  72. inline ostream& put(char);
  73. ostream& put(unsigned char);
  74. inline ostream& put(signed char);
  75. ostream& write(const char *,int);
  76. inline ostream& write(const unsigned char *,int);
  77. inline ostream& write(const signed char *,int);
  78. ostream& seekp(streampos);
  79. ostream& seekp(streamoff,ios::seek_dir);
  80. streampos tellp();
  81. protected:
  82. ostream();
  83. ostream(const ostream&); // treat as private
  84. ostream& operator=(streambuf*); // treat as private
  85. ostream& operator=(const ostream& _os) {return operator=(_os.rdbuf()); }
  86. int do_opfx(int); // not used
  87. void do_osfx(); // not used
  88. private:
  89. ostream(ios&);
  90. ostream& writepad(const char *, const char *);
  91. int x_floatused;
  92. };
  93. inline ostream& ostream::operator<<(ostream& (__cdecl * _f)(ostream&)) { (*_f)(*this); return *this; }
  94. inline ostream& ostream::operator<<(ios& (__cdecl * _f)(ios& )) { (*_f)(*this); return *this; }
  95. inline ostream& ostream::operator<<(char _c) { return operator<<((unsigned char) _c); }
  96. inline ostream& ostream::operator<<(signed char _c) { return operator<<((unsigned char) _c); }
  97. inline ostream& ostream::operator<<(const unsigned char * _s) { return operator<<((const char *) _s); }
  98. inline ostream& ostream::operator<<(const signed char * _s) { return operator<<((const char *) _s); }
  99. inline ostream& ostream::operator<<(float _f) { x_floatused = 1; return operator<<((double) _f); }
  100. inline ostream& ostream::put(char _c) { return put((unsigned char) _c); }
  101. inline ostream& ostream::put(signed char _c) { return put((unsigned char) _c); }
  102. inline ostream& ostream::write(const unsigned char * _s, int _n) { return write((char *) _s, _n); }
  103. inline ostream& ostream::write(const signed char * _s, int _n) { return write((char *) _s, _n); }
  104. class _CRTIMP ostream_withassign : public ostream {
  105. public:
  106. ostream_withassign();
  107. ostream_withassign(streambuf* _is);
  108. ~ostream_withassign();
  109. ostream& operator=(const ostream& _os) { return ostream::operator=(_os.rdbuf()); }
  110. ostream& operator=(streambuf* _sb) { return ostream::operator=(_sb); }
  111. };
  112. extern ostream_withassign _CRTIMP cout;
  113. extern ostream_withassign _CRTIMP cerr;
  114. extern ostream_withassign _CRTIMP clog;
  115. inline _CRTIMP ostream& __cdecl flush(ostream& _outs) { return _outs.flush(); }
  116. inline _CRTIMP ostream& __cdecl endl(ostream& _outs) { return _outs << '\n' << flush; }
  117. inline _CRTIMP ostream& __cdecl ends(ostream& _outs) { return _outs << char('\0'); }
  118. _CRTIMP ios& __cdecl dec(ios&);
  119. _CRTIMP ios& __cdecl hex(ios&);
  120. _CRTIMP ios& __cdecl oct(ios&);
  121. #ifdef _MSC_VER
  122. // Restore default packing
  123. #pragma pack(pop)
  124. #endif // _MSC_VER
  125. #endif // _INC_OSTREAM
  126. #endif /* __cplusplus */