home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / INCLUDE / ISTREAM.H_ / ISTREAM.H
Encoding:
C/C++ Source or Header  |  1993-02-08  |  5.4 KB  |  150 lines

  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(2)
  20.  
  21. #pragma warning(disable:4505)       // disable unwanted /W4 warning
  22. // #pragma warning(default:4505)    // use this to reenable, if necessary
  23.  
  24.  
  25. #ifdef M_I86HM
  26. #define _HFAR_ __far
  27. #else 
  28. #define _HFAR_
  29. #endif 
  30.  
  31. typedef long streamoff, streampos;
  32.  
  33. class istream : virtual public ios {
  34.  
  35. public:
  36.     istream(streambuf*);
  37.     virtual ~istream();
  38.  
  39.     int  ipfx(int =0);
  40.     void isfx() { }
  41.  
  42.     inline istream& operator>>(istream& (*_f)(istream&));
  43.     inline istream& operator>>(ios& (*_f)(ios&));
  44.     istream& operator>>(char _HFAR_ *);
  45.     inline istream& operator>>(unsigned char _HFAR_ *);
  46.     inline istream& operator>>(signed char _HFAR_ *);
  47.     istream& operator>>(char _HFAR_ &);
  48.     inline istream& operator>>(unsigned char _HFAR_ &);
  49.     inline istream& operator>>(signed char _HFAR_ &);
  50.     istream& operator>>(short _HFAR_ &);
  51.     istream& operator>>(unsigned short _HFAR_ &);
  52.     istream& operator>>(int _HFAR_ &);
  53.     istream& operator>>(unsigned int _HFAR_ &);
  54.     istream& operator>>(long _HFAR_ &);
  55.     istream& operator>>(unsigned long _HFAR_ &);
  56.     istream& operator>>(float _HFAR_ &);
  57.     istream& operator>>(double _HFAR_ &);
  58.     istream& operator>>(long double _HFAR_ &);
  59.     istream& operator>>(streambuf*);
  60.  
  61.     int get();
  62.     istream& get(char _HFAR_ *,int,char ='\n');
  63.     inline istream& get(unsigned char _HFAR_ *,int,char ='\n');
  64.     inline istream& get(signed char _HFAR_ *,int,char ='\n');
  65.     istream& get(char _HFAR_ &);
  66.     inline istream& get(unsigned char _HFAR_ &);
  67.     inline istream& get(signed char _HFAR_ &);
  68.     istream& get(streambuf&,char ='\n');
  69.     inline istream& getline(char _HFAR_ *,int,char ='\n');
  70.     inline istream& getline(unsigned char _HFAR_ *,int,char ='\n');
  71.     inline istream& getline(signed char _HFAR_ *,int,char ='\n');
  72.  
  73.     inline istream& ignore(int =1,int =EOF);
  74.     istream& read(char _HFAR_ *,int);
  75.     inline istream& read(unsigned char _HFAR_ *,int);
  76.     inline istream& read(signed char _HFAR_ *,int);
  77.  
  78.     int gcount() const { return x_gcount; }
  79.     int peek();
  80.     istream& putback(char);
  81.     int sync();
  82.  
  83.     istream& seekg(streampos);
  84.     istream& seekg(streamoff,ios::seek_dir);
  85.     streampos tellg();
  86.  
  87.     void eatwhite();    // consider: protect and friend with manipulator ws
  88. protected:
  89.     istream();
  90.     istream(const istream&);    // treat as private
  91.     istream& operator=(streambuf* _isb); // treat as private
  92.     istream& operator=(const istream& _is) { return operator=(_is.rdbuf()); }
  93.     int do_ipfx(int);
  94.  
  95. private:
  96.     istream(ios&);
  97.     int getint(char _HFAR_ *);
  98.     int getdouble(char _HFAR_ *, int);
  99.     int _fGline;
  100.     int x_gcount;
  101. };
  102.  
  103.     inline istream& istream::operator>>(istream& (*_f)(istream&)) { (*_f)(*this); return *this; }
  104.     inline istream& istream::operator>>(ios& (*_f)(ios&)) { (*_f)(*this); return *this; }
  105.  
  106.     inline istream& istream::operator>>(unsigned char _HFAR_ * _s) { return operator>>((char _HFAR_ *)_s); }
  107.     inline istream& istream::operator>>(signed char _HFAR_ * _s) { return operator>>((char _HFAR_ *)_s); }
  108.  
  109.     inline istream& istream::operator>>(unsigned char _HFAR_ & _c) { return operator>>((char _HFAR_ &) _c); }
  110.     inline istream& istream::operator>>(signed char _HFAR_ & _c) { return operator>>((char _HFAR_ &) _c); }
  111.  
  112.     inline istream& istream::get(unsigned char _HFAR_ * b, int lim ,char delim) { return get((char _HFAR_ *)b, lim, delim); }
  113.     inline istream& istream::get(signed char _HFAR_ * b, int lim, char delim) { return get((char _HFAR_ *)b, lim, delim); }
  114.  
  115.     inline istream& istream::get(unsigned char _HFAR_ & _c) { return get((char _HFAR_ &)_c); }
  116.     inline istream& istream::get(signed char _HFAR_ & _c) { return get((char _HFAR_ &)_c); }
  117.  
  118.     inline istream& istream::getline(char _HFAR_ * _b,int _lim,char _delim) { _fGline++; return get(_b, _lim, _delim); }
  119.     inline istream& istream::getline(unsigned char _HFAR_ * _b,int _lim,char _delim) { _fGline++; return get((char _HFAR_ *)_b, _lim, _delim); }
  120.     inline istream& istream::getline(signed char _HFAR_ * _b,int _lim,char _delim) { _fGline++; return get((char _HFAR_ *)_b, _lim, _delim); }
  121.  
  122.     inline istream& istream::ignore(int _n,int delim) { _fGline++; return get((char _HFAR_ *)0, _n+1, (char)delim); }
  123.  
  124.     inline istream& istream::read(unsigned char _HFAR_ * _ptr, int _n) { return read((char _HFAR_ *) _ptr, _n); }
  125.     inline istream& istream::read(signed char _HFAR_ * _ptr, int _n) { return read((char _HFAR_ *) _ptr, _n); }
  126.  
  127. class istream_withassign : public istream {
  128.     public:
  129.         istream_withassign();
  130.         istream_withassign(streambuf*);
  131.         ~istream_withassign();
  132.     istream& operator=(const istream& _is) { return istream::operator=(_is); }
  133.     istream& operator=(streambuf* _isb) { return istream::operator=(_isb); }
  134. };
  135.  
  136. #ifndef _WINDLL
  137. extern istream_withassign cin;
  138. #endif 
  139.  
  140. inline istream& ws(istream& _ins) { _ins.eatwhite(); return _ins; }
  141.  
  142. ios&        dec(ios&);
  143. ios&        hex(ios&);
  144. ios&        oct(ios&);
  145.  
  146. // Restore default packing
  147. #pragma pack()
  148.  
  149. #endif 
  150.