home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / INC.PAK / IOMANIP.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  5KB  |  161 lines

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