home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / progs / CB / DATA.Z / IOMANIP.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-25  |  4.9 KB  |  156 lines

  1. /*  iomanip.h -- streams I/O manipulator declarations
  2.  
  3. */
  4.  
  5. /* $Copyright: 1990$ */
  6. /* $Revision:   8.2  $ */
  7.  
  8. #ifndef __cplusplus
  9. #error Must use C++ for the io stream manipulators.
  10. #endif
  11.  
  12. #ifndef __IOMANIP_H
  13. #define __IOMANIP_H
  14.  
  15. #if !defined(___DEFS_H)
  16. #include <_defs.h>
  17. #endif
  18.  
  19. #if !defined(__IOSTREAM_H)
  20. #include <iostream.h>
  21. #endif
  22.  
  23.  
  24. #if !defined(RC_INVOKED)
  25.  
  26. #if defined(__BCOPT__)
  27. #if !defined(_RTL_ALLOW_po) && !defined(__FLAT__)
  28. #pragma option -po-     // disable Object data calling convention
  29. #endif
  30. #endif
  31.  
  32. #pragma option -Vo-
  33.  
  34. #if defined(__STDC__)
  35. #pragma warn -nak
  36. #endif
  37.  
  38. #endif  /* !RC_INVOKED */
  39.  
  40.  
  41. template<class _typ> class _EXPCLASS smanip {
  42.         ios _FAR & (_RTLENTRY *_fn)(ios _FAR &, _typ);
  43.         _typ _ag;
  44. public:
  45.         _RTLENTRY smanip(ios _FAR & (_RTLENTRY *_f)(ios _FAR &, _typ), _typ _a) :
  46.                 _fn(_f), _ag(_a) { }
  47.         friend istream _FAR & _RTLENTRY operator>>(istream _FAR & _s, const smanip<_typ> _FAR & _f) {
  48.                         (*_f._fn)(_s, _f._ag); return _s; }
  49.         friend ostream _FAR & _RTLENTRY operator<<(ostream _FAR & _s, const smanip<_typ> _FAR & _f) {
  50.                         (*_f._fn)(_s, _f._ag); return _s; }
  51.         };
  52.  
  53. template<class _typ> class _EXPCLASS sapp {
  54.         ios _FAR & (_RTLENTRY *_fn)(ios _FAR &, _typ);
  55. public:
  56.         sapp(ios _FAR & (_RTLENTRY *_f)(ios _FAR &, _typ)) : _fn(_f) { }
  57.         smanip<_typ> _RTLENTRY operator()(_typ _z)
  58.                 { return smanip<_typ>(_fn, _z); }
  59.         };
  60.  
  61. template<class _typ> class _EXPCLASS imanip {
  62.         istream _FAR & (_RTLENTRY *_fn)(istream _FAR &, _typ);
  63.         _typ _ag;
  64. public:
  65.         _RTLENTRY imanip(istream _FAR & (_RTLENTRY *_f)(istream _FAR &, _typ), _typ _z ) :
  66.                 _fn(_f), _ag(_z) { }
  67.         friend istream _FAR & _RTLENTRY operator>>(istream _FAR & _s, const imanip<_typ> _FAR & _f) {
  68.                 return(*_f._fn)(_s, _f._ag); }
  69.         };
  70.  
  71. template<class _typ> class _EXPCLASS iapply {
  72.         istream _FAR & (_RTLENTRY *_fn)(istream _FAR &, _typ);
  73. public:
  74.         _RTLENTRY iapply(istream _FAR & (_RTLENTRY *_f)(istream _FAR &, _typ)) :
  75.                 _fn(_f) { }
  76.         imanip<_typ> _RTLENTRY operator()(_typ _z) {
  77.                 return IMANIP(_typ)(_fn, _z); }
  78.         };
  79.  
  80. template<class _typ> class _EXPCLASS omanip {
  81.         ostream _FAR & (_RTLENTRY *_fn)(ostream _FAR &, _typ);
  82.         _typ _ag;
  83. public:
  84.         _RTLENTRY omanip(ostream _FAR & (_RTLENTRY *_f)(ostream _FAR &, _typ), _typ _z ) :
  85.                 _fn(_f), _ag(_z) { }
  86.         friend ostream _FAR & _RTLENTRY operator<<(ostream _FAR & _s, const omanip<_typ> _FAR & _f) {
  87.                 return(*_f._fn)(_s, _f._ag); }
  88.         };
  89.  
  90. template<class _typ> class _EXPCLASS oapp {
  91.         ostream _FAR & (_RTLENTRY *_fn)(ostream _FAR &, _typ);
  92. public:
  93.         _RTLENTRY oapp(ostream _FAR & (_RTLENTRY *_f)(ostream _FAR &, _typ)) :
  94.                 _fn(_f) { }
  95.         omanip<_typ> _RTLENTRY operator()(_typ _z) {
  96.                 return omanip<_typ>(_fn, _z); }
  97.         };
  98.  
  99. template<class _typ> class _EXPCLASS iomanip {
  100.         iostream _FAR & (_RTLENTRY *_fn)(iostream _FAR &, _typ);
  101.         _typ _ag;
  102. public:
  103.         _RTLENTRY iomanip(iostream _FAR & (_RTLENTRY *_f)(iostream _FAR &, _typ), _typ _z ) :
  104.                 _fn(_f), _ag(_z) { }
  105.         friend istream _FAR & _RTLENTRY operator>>(iostream _FAR & _s, const iomanip<_typ> _FAR & _f) {
  106.                 return(*_f._fn)(_s, _f._ag); }
  107.         friend ostream _FAR & _RTLENTRY operator<<(iostream _FAR & _s, const iomanip<_typ> _FAR & _f) {
  108.                 return(*_f._fn)(_s, _f._ag); }
  109.         };
  110.  
  111. template<class _typ> class _EXPCLASS ioapp {
  112.         iostream _FAR & (_RTLENTRY *_fn)(iostream _FAR &, _typ);
  113. public:
  114.         _RTLENTRY ioapp(iostream _FAR & (_RTLENTRY *_f)(iostream _FAR &, _typ)) : _fn(_f) { }
  115.         iomanip<_typ> _RTLENTRY operator()(_typ _z) {
  116.                 return iomanip<_typ>(_fn, _z); }
  117.         };
  118.  
  119. // set the conversion base to 0, 8, 10, or 16
  120. smanip<int>     _RTLENTRY _EXPFUNC setbase(int _b);
  121.  
  122. // clear the flags bitvector according to the bits set in b
  123. smanip<long>    _RTLENTRY _EXPFUNC resetiosflags(long _b);
  124.  
  125. // set the flags bitvector according to the bits set in b
  126. smanip<long>    _RTLENTRY _EXPFUNC setiosflags(long _b);
  127.  
  128. // set fill character for padding a field
  129. smanip<int>     _RTLENTRY _EXPFUNC setfill(int _f);
  130.  
  131. // set the floating-point precision to n digits
  132. smanip<int>     _RTLENTRY _EXPFUNC setprecision(int _n);
  133.  
  134. // set the field width to n
  135. smanip<int>     _RTLENTRY _EXPFUNC setw(int _n);
  136.  
  137.  
  138. #if !defined(RC_INVOKED)
  139.  
  140. #if defined(__STDC__)
  141. #pragma warn .nak
  142. #endif
  143.  
  144. #pragma option -Vo.
  145.  
  146. #if defined(__BCOPT__)
  147. #if !defined(_RTL_ALLOW_po) && !defined(__FLAT__)
  148. #pragma option -po.     // restore Object data calling convention
  149. #endif
  150. #endif
  151.  
  152. #endif  /* !RC_INVOKED */
  153.  
  154.  
  155. #endif  /* __IOMANIP_H */
  156.