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.

129 lines
4.2 KiB

  1. /***
  2. *ostream.h - definitions/declarations for the ostream class
  3. *
  4. * Copyright (c) 1991-1992, 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. #include <ios.h>
  15. // Force word packing to avoid possible -Zp override
  16. #pragma pack(2)
  17. #pragma warning(disable:4505) // disable unwanted /W4 warning
  18. // #pragma warning(default:4505) // use this to reenable, if necessary
  19. #ifdef M_I86HM
  20. #define _HFAR_ __far
  21. #else
  22. #define _HFAR_
  23. #endif
  24. typedef long streamoff, streampos;
  25. class ostream : virtual public ios {
  26. public:
  27. ostream(streambuf*);
  28. virtual ~ostream();
  29. ostream& flush();
  30. int opfx();
  31. void osfx();
  32. inline ostream& operator<<(ostream& (*f)(ostream&));
  33. inline ostream& operator<<(ios& (*f)(ios&));
  34. ostream& operator<<(const char _HFAR_ *);
  35. inline ostream& operator<<(const unsigned char _HFAR_ *);
  36. inline ostream& operator<<(const signed char _HFAR_ *);
  37. inline ostream& operator<<(char);
  38. ostream& operator<<(unsigned char);
  39. inline ostream& operator<<(signed char);
  40. ostream& operator<<(short);
  41. ostream& operator<<(unsigned short);
  42. ostream& operator<<(int);
  43. ostream& operator<<(unsigned int);
  44. ostream& operator<<(long);
  45. ostream& operator<<(unsigned long);
  46. inline ostream& operator<<(float);
  47. ostream& operator<<(double);
  48. ostream& operator<<(long double);
  49. ostream& operator<<(const void _HFAR_ *);
  50. ostream& operator<<(streambuf*);
  51. inline ostream& put(char);
  52. ostream& put(unsigned char);
  53. inline ostream& put(signed char);
  54. ostream& write(const char _HFAR_ *,int);
  55. inline ostream& write(const unsigned char _HFAR_ *,int);
  56. inline ostream& write(const signed char _HFAR_ *,int);
  57. ostream& seekp(streampos);
  58. ostream& seekp(streamoff,ios::seek_dir);
  59. streampos tellp();
  60. protected:
  61. ostream();
  62. ostream(const ostream&); // treat as private
  63. ostream& operator=(streambuf*); // treat as private
  64. ostream& operator=(const ostream& _os) {return operator=(_os.rdbuf()); }
  65. int do_opfx(int); // not used
  66. void do_osfx(); // not used
  67. private:
  68. ostream(ios&);
  69. ostream& writepad(const char _HFAR_ *, const char _HFAR_ *);
  70. int x_floatused;
  71. };
  72. inline ostream& ostream::operator<<(ostream& (*f)(ostream&)) { (*f)(*this); return *this; }
  73. inline ostream& ostream::operator<<(ios& (*f)(ios& )) { (*f)(*this); return *this; }
  74. inline ostream& ostream::operator<<(char c) { return operator<<((unsigned char) c); }
  75. inline ostream& ostream::operator<<(signed char c) { return operator<<((unsigned char) c); }
  76. inline ostream& ostream::operator<<(const unsigned char _HFAR_ * s) { return operator<<((const char _HFAR_ *) s); }
  77. inline ostream& ostream::operator<<(const signed char _HFAR_ * s) { return operator<<((const char _HFAR_ *) s); }
  78. inline ostream& ostream::operator<<(float f) { x_floatused = 1; return operator<<((double) f); }
  79. inline ostream& ostream::put(char c) { return put((unsigned char) c); }
  80. inline ostream& ostream::put(signed char c) { return put((unsigned char) c); }
  81. inline ostream& ostream::write(const unsigned char _HFAR_ * s, int n) { return write((char _HFAR_ *) s, n); }
  82. inline ostream& ostream::write(const signed char _HFAR_ * s, int n) { return write((char _HFAR_ *) s, n); }
  83. class ostream_withassign : public ostream {
  84. public:
  85. ostream_withassign();
  86. ostream_withassign(streambuf* _is);
  87. ~ostream_withassign();
  88. ostream& operator=(const ostream& _os) { return ostream::operator=(_os.rdbuf()); }
  89. ostream& operator=(streambuf* _sb) { return ostream::operator=(_sb); }
  90. };
  91. #ifndef _WINDLL
  92. extern ostream_withassign cout;
  93. extern ostream_withassign cerr;
  94. extern ostream_withassign clog;
  95. #endif
  96. inline ostream& flush(ostream& _outs) { return _outs.flush(); }
  97. inline ostream& endl(ostream& _outs) { return _outs << '\n' << flush; }
  98. inline ostream& ends(ostream& _outs) { return _outs << char('\0'); }
  99. ios& dec(ios&);
  100. ios& hex(ios&);
  101. ios& oct(ios&);
  102. // Restore default packing
  103. #pragma pack()
  104. #endif