|
|
1.1 ! root 1: /*** ! 2: *istream.h - definitions/declarations for the istream class ! 3: * ! 4: * Copyright (c) 1990-1992, Microsoft Corporation. All rights reserved. ! 5: * ! 6: *Purpose: ! 7: * This file defines the classes, values, macros, and functions ! 8: * used by the istream class. ! 9: * [AT&T C++] ! 10: * ! 11: ****/ ! 12: ! 13: #ifndef _INC_ISTREAM ! 14: #define _INC_ISTREAM ! 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: ! 25: typedef long streamoff, streampos; ! 26: ! 27: class istream : virtual public ios { ! 28: ! 29: public: ! 30: istream(streambuf*); ! 31: virtual ~istream(); ! 32: ! 33: int ipfx(int =0); ! 34: void isfx() { unlockbuf(); unlock(); } ! 35: ! 36: inline istream& operator>>(istream& (*_f)(istream&)); ! 37: inline istream& operator>>(ios& (*_f)(ios&)); ! 38: istream& operator>>(char *); ! 39: inline istream& operator>>(unsigned char *); ! 40: inline istream& operator>>(signed char *); ! 41: istream& operator>>(char &); ! 42: inline istream& operator>>(unsigned char &); ! 43: inline istream& operator>>(signed char &); ! 44: istream& operator>>(short &); ! 45: istream& operator>>(unsigned short &); ! 46: istream& operator>>(int &); ! 47: istream& operator>>(unsigned int &); ! 48: istream& operator>>(long &); ! 49: istream& operator>>(unsigned long &); ! 50: istream& operator>>(float &); ! 51: istream& operator>>(double &); ! 52: // istream& operator>>(long double &); // UNDONE: ! 53: istream& operator>>(streambuf*); ! 54: ! 55: int get(); ! 56: istream& get(char *,int,char ='\n'); ! 57: inline istream& get(unsigned char *,int,char ='\n'); ! 58: inline istream& get(signed char *,int,char ='\n'); ! 59: istream& get(char &); ! 60: inline istream& get(unsigned char &); ! 61: inline istream& get(signed char &); ! 62: istream& get(streambuf&,char ='\n'); ! 63: inline istream& getline(char *,int,char ='\n'); ! 64: inline istream& getline(unsigned char *,int,char ='\n'); ! 65: inline istream& getline(signed char *,int,char ='\n'); ! 66: ! 67: inline istream& ignore(int =1,int =EOF); ! 68: istream& read(char *,int); ! 69: inline istream& read(unsigned char *,int); ! 70: inline istream& read(signed char *,int); ! 71: ! 72: int gcount() const { return x_gcount; } ! 73: int peek(); ! 74: istream& putback(char); ! 75: int sync(); ! 76: ! 77: istream& seekg(streampos); ! 78: istream& seekg(streamoff,ios::seek_dir); ! 79: streampos tellg(); ! 80: ! 81: void eatwhite(); // consider: protect and friend with manipulator ws ! 82: protected: ! 83: istream(); ! 84: istream(const istream&); // treat as private ! 85: istream& operator=(streambuf* _isb); // treat as private ! 86: istream& operator=(const istream& _is) { return operator=(_is.rdbuf()); } ! 87: int do_ipfx(int); ! 88: ! 89: private: ! 90: istream(ios&); ! 91: int getint(char *); ! 92: int getdouble(char *, int); ! 93: int _fGline; ! 94: int x_gcount; ! 95: }; ! 96: ! 97: inline istream& istream::operator>>(istream& (*_f)(istream&)) { (*_f)(*this); return *this; } ! 98: inline istream& istream::operator>>(ios& (*_f)(ios&)) { (*_f)(*this); return *this; } ! 99: ! 100: inline istream& istream::operator>>(unsigned char * _s) { return operator>>((char *)_s); } ! 101: inline istream& istream::operator>>(signed char * _s) { return operator>>((char *)_s); } ! 102: ! 103: inline istream& istream::operator>>(unsigned char & _c) { return operator>>((char &) _c); } ! 104: inline istream& istream::operator>>(signed char & _c) { return operator>>((char &) _c); } ! 105: ! 106: inline istream& istream::get(unsigned char * b, int lim ,char delim) { return get((char *)b, lim, delim); } ! 107: inline istream& istream::get(signed char * b, int lim, char delim) { return get((char *)b, lim, delim); } ! 108: ! 109: inline istream& istream::get(unsigned char & _c) { return get((char &)_c); } ! 110: inline istream& istream::get(signed char & _c) { return get((char &)_c); } ! 111: ! 112: inline istream& istream::getline(char * _b,int _lim,char _delim) { lock(); _fGline++; get(_b, _lim, _delim); unlock(); return *this; } ! 113: inline istream& istream::getline(unsigned char * _b,int _lim,char _delim) { lock(); _fGline++; get((char *)_b, _lim, _delim); unlock(); return *this; } ! 114: inline istream& istream::getline(signed char * _b,int _lim,char _delim) { lock(); _fGline++; get((char *)_b, _lim, _delim); unlock(); return *this; } ! 115: ! 116: inline istream& istream::ignore(int _n,int delim) { lock(); _fGline++; return get((char *)0, _n+1, (char)delim); unlock(); return *this; } ! 117: ! 118: inline istream& istream::read(unsigned char * _ptr, int _n) { return read((char *) _ptr, _n); } ! 119: inline istream& istream::read(signed char * _ptr, int _n) { return read((char *) _ptr, _n); } ! 120: ! 121: class istream_withassign : public istream { ! 122: public: ! 123: istream_withassign(); ! 124: istream_withassign(streambuf*); ! 125: ~istream_withassign(); ! 126: istream& operator=(const istream& _is) { return istream::operator=(_is); } ! 127: istream& operator=(streambuf* _isb) { return istream::operator=(_isb); } ! 128: }; ! 129: ! 130: #ifndef _WINDLL // Warning! Not available under Windows without QuickWin: ! 131: extern istream_withassign cin; ! 132: #endif ! 133: ! 134: inline istream& ws(istream& _ins) { _ins.eatwhite(); return _ins; } ! 135: ! 136: ios& dec(ios&); ! 137: ios& hex(ios&); ! 138: ios& oct(ios&); ! 139: ! 140: // Restore default packing ! 141: #pragma pack() ! 142: ! 143: #endif // !_INC_ISTREAM
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.