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.

158 lines
5.0 KiB

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