home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / MS_VC.50 / VC / INCLUDE / XIOSBASE < prev    next >
Encoding:
Text File  |  1997-01-08  |  6.6 KB  |  182 lines

  1. // xiosbase internal header (from <ios>)
  2. #ifndef _XIOSBASE_
  3. #define _XIOSBASE_
  4. #include <xlocale>
  5.  
  6. #ifdef  _MSC_VER
  7. #pragma pack(push,8)
  8. #endif  /* _MSC_VER */
  9. _STD_BEGIN
  10.                 // CLASS ios_base
  11. class _CRTIMP ios_base {
  12. public:
  13.                         // CLASS failure
  14.         class failure : public runtime_error {
  15.         public:
  16.                 explicit failure(const string &_S)
  17.                         : runtime_error(_S) {}
  18.                 virtual ~failure()
  19.                         {}
  20.         protected:
  21.                 virtual void _Doraise() const
  22.                         {_RAISE(*this); }
  23.         };
  24.         enum _Fmtflags {skipws = 0x0001, unitbuf = 0x0002,
  25.                 uppercase = 0x0004, showbase = 0x0008,
  26.                 showpoint = 0x0010, showpos = 0x0020,
  27.                 left = 0x0040, right = 0x0080, internal = 0x0100,
  28.                 dec = 0x0200, oct = 0x0400, hex = 0x0800,
  29.                 scientific = 0x1000, fixed = 0x2000, boolalpha = 0x4000,
  30.                 adjustfield = 0x01c0, basefield = 0x0e00,
  31.                 floatfield = 0x3000, _Fmtmask = 0x7fff, _Fmtzero = 0};
  32.         enum _Iostate {goodbit = 0x0, eofbit = 0x1,
  33.                 failbit = 0x2, badbit = 0x4, _Statmask = 0x7};
  34.         enum _Openmode {in = 0x01, out = 0x02, ate = 0x04,
  35.                 app = 0x08, trunc = 0x10, binary = 0x20};
  36.         enum seekdir {beg = 0, cur = 1, end = 2};
  37.         enum event {erase_event, imbue_event, copyfmt_event};
  38.         typedef void (__cdecl *event_callback)(event, ios_base&, int);
  39.         _BITMASK(_Fmtflags, fmtflags);
  40.         _BITMASK(_Iostate, iostate);
  41.         _BITMASK(_Openmode, openmode);
  42.         typedef short io_state, open_mode, seek_dir;
  43.                         // CLASS Init
  44.         class _CRTIMP Init {
  45.         public:
  46.                 Init();
  47.                 ~Init();
  48.         private:
  49.                 static int _Init_cnt;
  50.                 };
  51.         ios_base& operator=(const ios_base& _R)
  52.                 {if (this != &_R)
  53.                         {_State = _R._State;
  54.                         copyfmt(_R); }
  55.                 return (*this); }
  56.         operator void *() const
  57.                 {return (fail() ? 0 : (void *)this); }
  58.         bool operator!() const
  59.                 {return (fail()); }
  60.         void clear(iostate = goodbit, bool = false);
  61.         void clear(io_state _St)
  62.                 {clear((iostate)_St); }
  63.         iostate rdstate() const
  64.                 {return (_State); }
  65.         void setstate(iostate _St, bool _Ex = false)
  66.                 {if (_St != goodbit)
  67.                         clear((iostate)((int)rdstate() | (int)_St), _Ex); }
  68.         void setstate(io_state _St)
  69.                 {setstate((iostate)_St); }
  70.         bool good() const
  71.                 {return (rdstate() == goodbit); }
  72.         bool eof() const
  73.                 {return ((int)rdstate() & (int)eofbit); }
  74.         bool fail() const
  75.                 {return (((int)rdstate() & ((int)badbit | (int)failbit)) != 0); }
  76.         bool bad() const
  77.                 {return (((int)rdstate() & (int)badbit) != 0); }
  78.         iostate exceptions() const
  79.                 {return (_Except); }
  80.         void exceptions(iostate _Ne)
  81.                 {_Except = _Ne & _Statmask;
  82.                 clear(_State); }
  83.         void exceptions(io_state _St)
  84.                 {exceptions((iostate)_St); }
  85.         fmtflags flags() const
  86.                 {return (_Fmtfl); }
  87.         fmtflags flags(fmtflags _Nf)
  88.                 {fmtflags _Of = _Fmtfl;
  89.                 _Fmtfl = _Nf & _Fmtmask;
  90.                 return (_Of); }
  91.         fmtflags setf(fmtflags _Nf)
  92.                 {ios_base::fmtflags _Of = _Fmtfl;
  93.                 _Fmtfl |= _Nf & _Fmtmask;
  94.                 return (_Of); }
  95.         fmtflags setf(fmtflags _Nf, fmtflags _M)
  96.                 {ios_base::fmtflags _Of = _Fmtfl;
  97.                 _Fmtfl = (_Fmtfl & ~_M) | (_Nf & _M & _Fmtmask);
  98.                 return (_Of); }
  99.         void unsetf(fmtflags _M)
  100.                 {_Fmtfl &= ~_M; }
  101.         streamsize precision() const
  102.                 {return (_Prec); }
  103.         streamsize precision(int _Np)
  104.                 {streamsize _Op = _Prec;
  105.                 _Prec = _Np;
  106.                 return (_Op); }
  107.         streamsize width() const
  108.                 {return (_Wide); }
  109.         streamsize width(streamsize _Nw)
  110.                 {streamsize _Ow = _Wide;
  111.                 _Wide = _Nw;
  112.                 return (_Ow); }
  113.         locale getloc() const
  114.                 {return (_Loc); }
  115.         locale imbue(const locale&);
  116.         static int __cdecl xalloc()
  117.                 {_Lockit _Lk;
  118.                 return (_Index++); }
  119.         long& iword(int _Idx)
  120.                 {return (_Findarr(_Idx)._Lo); }
  121.         void *& pword(int _Idx)
  122.                 {return (_Findarr(_Idx)._Vp); }
  123.         void register_callback(event_callback, int);
  124.         ios_base& copyfmt(const ios_base&);
  125.         virtual ~ios_base();
  126.         static bool __cdecl sync_with_stdio(bool _Sfl = true)
  127.                 {_Lockit _Lk;
  128.                 const bool _Osfl = _Sync;
  129.                 _Sync = _Sfl;
  130.                 return (_Osfl); }
  131. protected:
  132.         ios_base()
  133.                 : _Loc(_Noinit), _Stdstr(0) {}
  134.         void _Addstd();
  135.         void _Init();
  136. private:
  137.                         // STRUCT _Iosarray
  138.         struct _Iosarray {
  139.         public:
  140.                 _Iosarray(int _Idx, _Iosarray *_Link)
  141.                         : _Next(_Link), _Index(_Idx), _Lo(0), _Vp(0) {}
  142.                 _Iosarray *_Next;
  143.                 int _Index;
  144.                 long _Lo;
  145.                 void *_Vp;
  146.                 };
  147.                         // STRUCT _Fnarray
  148.         struct _Fnarray {
  149.                 _Fnarray(int _Idx, event_callback _P, _Fnarray *_Link)
  150.                         : _Next(_Link), _Index(_Idx), _Pfn(_P) {}
  151.                 _Fnarray *_Next;
  152.                 int _Index;
  153.                 event_callback _Pfn;
  154.                 };
  155.         void _Callfns(event);
  156.         _Iosarray& _Findarr(int);
  157.         void _Tidy();
  158.         iostate _State, _Except;
  159.         fmtflags _Fmtfl;
  160.         int _Prec, _Wide;
  161.         _Iosarray *_Arr;
  162.         _Fnarray *_Calls;
  163.         locale _Loc;
  164.         size_t _Stdstr;
  165.         static int _Index;
  166.         static bool _Sync;
  167.         };
  168. _BITMASK_OPS(ios_base::_Fmtflags)
  169. _BITMASK_OPS(ios_base::_Iostate)
  170. _BITMASK_OPS(ios_base::_Openmode)
  171. _STD_END
  172. #ifdef  _MSC_VER
  173. #pragma pack(pop)
  174. #endif  /* _MSC_VER */
  175.  
  176. #endif /* _XIOSBASE_ */
  177.  
  178. /*
  179.  * Copyright (c) 1995 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  180.  * Consult your license regarding permissions and restrictions.
  181.  */
  182.