|
|
1.1 ! root 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: ! 13: #ifndef _INC_OSTREAM ! 14: #define _INC_OSTREAM ! 15: ! 16: #include <ios.h> ! 17: ! 18: // Force word packing to avoid possible -Zp override ! 19: #pragma pack(4) ! 20: ! 21: #pragma warning(disable:4505) // disable unwanted /W4 warning ! 22: // #pragma warning(default:4505) // use this to reenable, if necessary ! 23: ! 24: typedef long streamoff, streampos; ! 25: ! 26: class ostream : virtual public ios { ! 27: ! 28: public: ! 29: ostream(streambuf*); ! 30: virtual ~ostream(); ! 31: ! 32: ostream& flush(); ! 33: int opfx(); ! 34: void osfx(); ! 35: ! 36: inline ostream& operator<<(ostream& (*f)(ostream&)); ! 37: inline ostream& operator<<(ios& (*f)(ios&)); ! 38: ostream& operator<<(const char *); ! 39: inline ostream& operator<<(const unsigned char *); ! 40: inline ostream& operator<<(const signed char *); ! 41: inline ostream& operator<<(char); ! 42: ostream& operator<<(unsigned char); ! 43: inline ostream& operator<<(signed char); ! 44: ostream& operator<<(short); ! 45: ostream& operator<<(unsigned short); ! 46: ostream& operator<<(int); ! 47: ostream& operator<<(unsigned int); ! 48: ostream& operator<<(long); ! 49: ostream& operator<<(unsigned long); ! 50: inline ostream& operator<<(float); ! 51: ostream& operator<<(double); ! 52: // ostream& operator<<(long double); // UNDONE: ! 53: ostream& operator<<(const void *); ! 54: ostream& operator<<(streambuf*); ! 55: inline ostream& put(char); ! 56: ostream& put(unsigned char); ! 57: inline ostream& put(signed char); ! 58: ostream& write(const char *,int); ! 59: inline ostream& write(const unsigned char *,int); ! 60: inline ostream& write(const signed char *,int); ! 61: ostream& seekp(streampos); ! 62: ostream& seekp(streamoff,ios::seek_dir); ! 63: streampos tellp(); ! 64: ! 65: protected: ! 66: ostream(); ! 67: ostream(const ostream&); // treat as private ! 68: ostream& operator=(streambuf*); // treat as private ! 69: ostream& operator=(const ostream& _os) {return operator=(_os.rdbuf()); } ! 70: int do_opfx(int); // not used ! 71: void do_osfx(); // not used ! 72: ! 73: private: ! 74: ostream(ios&); ! 75: ostream& writepad(const char *, const char *); ! 76: int x_floatused; ! 77: }; ! 78: ! 79: inline ostream& ostream::operator<<(ostream& (*f)(ostream&)) { (*f)(*this); return *this; } ! 80: inline ostream& ostream::operator<<(ios& (*f)(ios& )) { (*f)(*this); return *this; } ! 81: ! 82: inline ostream& ostream::operator<<(char c) { return operator<<((unsigned char) c); } ! 83: inline ostream& ostream::operator<<(signed char c) { return operator<<((unsigned char) c); } ! 84: ! 85: inline ostream& ostream::operator<<(const unsigned char * s) { return operator<<((const char *) s); } ! 86: inline ostream& ostream::operator<<(const signed char * s) { return operator<<((const char *) s); } ! 87: ! 88: inline ostream& ostream::operator<<(float f) { x_floatused = 1; return operator<<((double) f); } ! 89: ! 90: inline ostream& ostream::put(char c) { return put((unsigned char) c); } ! 91: inline ostream& ostream::put(signed char c) { return put((unsigned char) c); } ! 92: ! 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: ! 96: ! 97: class ostream_withassign : public ostream { ! 98: public: ! 99: ostream_withassign(); ! 100: ostream_withassign(streambuf* _is); ! 101: ~ostream_withassign(); ! 102: ostream& operator=(const ostream& _os) { return ostream::operator=(_os.rdbuf()); } ! 103: ostream& operator=(streambuf* _sb) { return ostream::operator=(_sb); } ! 104: }; ! 105: ! 106: #ifndef _WINDLL // Warning! Not available under Windows without QuickWin: ! 107: extern ostream_withassign cout; ! 108: extern ostream_withassign cerr; ! 109: extern ostream_withassign clog; ! 110: #endif ! 111: ! 112: inline ostream& flush(ostream& _outs) { return _outs.flush(); } ! 113: inline ostream& endl(ostream& _outs) { return _outs << '\n' << flush; } ! 114: inline ostream& ends(ostream& _outs) { return _outs << char('\0'); } ! 115: ! 116: ios& dec(ios&); ! 117: ios& hex(ios&); ! 118: ios& oct(ios&); ! 119: ! 120: // Restore default packing ! 121: #pragma pack() ! 122: ! 123: #endif // !_INC_OSTREAM
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.