home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / borhead.zip / IOMANIP.H < prev    next >
C/C++ Source or Header  |  1994-11-09  |  5KB  |  155 lines

  1. /*  iomanip.h -- streams I/O manipulator declarations
  2.  
  3. */
  4.  
  5. /*
  6.  *      C/C++ Run Time Library - Version 1.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. #endif
  33.  
  34. #pragma option -Vo-
  35.  
  36. #if defined(__STDC__)
  37. #pragma warn -nak
  38. #endif
  39.  
  40. #endif  /* !RC_INVOKED */
  41.  
  42.  
  43. template<class typ> class _EXPCLASS smanip {
  44.         ios _FAR & (_RTLENTRY *_fn)(ios _FAR &, typ);
  45.         typ _ag;
  46. public:
  47.         _RTLENTRY smanip(ios _FAR & (_RTLENTRY *_f)(ios _FAR &, typ), typ _a) :
  48.                 _fn(_f), _ag(_a) { }
  49.         friend istream _FAR & _RTLENTRY operator>>(istream _FAR & _s, smanip<typ> _FAR & _f) {
  50.                         (*_f._fn)(_s, _f._ag); return _s; }
  51.         friend ostream _FAR & _RTLENTRY operator<<(ostream _FAR & _s, smanip<typ> _FAR & _f) {
  52.                         (*_f._fn)(_s, _f._ag); return _s; }
  53.         };
  54.  
  55. template<class typ> class _EXPCLASS sapp {
  56.         ios _FAR & (_RTLENTRY *_fn)(ios _FAR &, typ);
  57. public:
  58.         sapp(ios _FAR & (_RTLENTRY *_f)(ios _FAR &, typ)) : _fn(_f) { }
  59.         smanip<typ> _RTLENTRY operator()(typ _z)
  60.                 { return smanip<typ>(_fn, _z); }
  61.         };
  62.  
  63. template<class typ> class _EXPCLASS imanip {
  64.         istream _FAR & (_RTLENTRY *_fn)(istream _FAR &, typ);
  65.         typ _ag;
  66. public:
  67.         _RTLENTRY imanip(istream _FAR & (_RTLENTRY *_f)(istream _FAR &, typ), typ _z ) :
  68.                 _fn(_f), _ag(_z) { }
  69.         friend istream _FAR & _RTLENTRY operator>>(istream _FAR & _s, imanip<typ> _FAR & _f) {
  70.                 return(*_f._fn)(_s, _f._ag); }
  71.         };
  72.  
  73. template<class typ> class _EXPCLASS iapply {
  74.         istream _FAR & (_RTLENTRY *_fn)(istream _FAR &, typ);
  75. public:
  76.         _RTLENTRY iapply(istream _FAR & (_RTLENTRY *_f)(istream _FAR &, typ)) :
  77.                 _fn(_f) { }
  78.         imanip<typ> _RTLENTRY operator()(typ _z) {
  79.                 return IMANIP(typ)(_fn, _z); }
  80.         };
  81.  
  82. template<class typ> class _EXPCLASS omanip {
  83.         ostream _FAR & (_RTLENTRY *_fn)(ostream _FAR &, typ);
  84.         typ _ag;
  85. public:
  86.         _RTLENTRY omanip(ostream _FAR & (_RTLENTRY *_f)(ostream _FAR &, typ), typ _z ) :
  87.                 _fn(_f), _ag(_z) { }
  88.         friend ostream _FAR & _RTLENTRY operator<<(ostream _FAR & _s, omanip<typ> _FAR & _f) {
  89.                 return(*_f._fn)(_s, _f._ag); }
  90.         };
  91.  
  92. template<class typ> class _EXPCLASS oapp {
  93.         ostream _FAR & (_RTLENTRY *_fn)(ostream _FAR &, typ);
  94. public:
  95.         _RTLENTRY oapp(ostream _FAR & (_RTLENTRY *_f)(ostream _FAR &, typ)) :
  96.                 _fn(_f) { }
  97.         omanip<typ> _RTLENTRY operator()(typ _z) {
  98.                 return omanip<typ>(_fn, _z); }
  99.         };
  100.  
  101. template<class typ> class _EXPCLASS iomanip {
  102.         iostream _FAR & (_RTLENTRY *_fn)(iostream _FAR &, typ);
  103.         typ _ag;
  104. public:
  105.         _RTLENTRY iomanip(iostream _FAR & (_RTLENTRY *_f)(iostream _FAR &, typ), typ _z ) :
  106.                 _fn(_f), _ag(_z) { }
  107.         friend istream _FAR & _RTLENTRY operator>>(iostream _FAR & _s, iomanip<typ> _FAR & _f) {
  108.                 return(*_f._fn)(_s, _f._ag); }
  109.         friend ostream _FAR & _RTLENTRY operator<<(iostream _FAR & _s, iomanip<typ> _FAR & _f) {
  110.                 return(*_f._fn)(_s, _f._ag); }
  111.         };
  112.  
  113. template<class typ> class _EXPCLASS ioapp {
  114.         iostream _FAR & (_RTLENTRY *_fn)(iostream _FAR &, typ);
  115. public:
  116.         _RTLENTRY ioapp(iostream _FAR & (_RTLENTRY *_f)(iostream _FAR &, typ)) : _fn(_f) { }
  117.         iomanip<typ> _RTLENTRY operator()(typ _z) {
  118.                 return iomanip<typ>(_fn, _z); }
  119.         };
  120.  
  121. // set the conversion base to 0, 8, 10, or 16
  122. smanip<int>     _RTLENTRY _EXPFUNC setbase(int _b);
  123.  
  124. // clear the flags bitvector according to the bits set in b
  125. smanip<long>    _RTLENTRY _EXPFUNC resetiosflags(long _b);
  126.  
  127. // set the flags bitvector according to the bits set in b
  128. smanip<long>    _RTLENTRY _EXPFUNC setiosflags(long _b);
  129.  
  130. // set fill character for padding a field
  131. smanip<int>     _RTLENTRY _EXPFUNC setfill(int _f);
  132.  
  133. // set the floating-point precision to n digits
  134. smanip<int>     _RTLENTRY _EXPFUNC setprecision(int _n);
  135.  
  136. // set the field width to n
  137. smanip<int>     _RTLENTRY _EXPFUNC setw(int _n);
  138.  
  139.  
  140. #if !defined(RC_INVOKED)
  141.  
  142. #if defined(__STDC__)
  143. #pragma warn .nak
  144. #endif
  145.  
  146. #pragma option -Vo.
  147.  
  148. #if defined(__BCOPT__)
  149. #endif
  150.  
  151. #endif  /* !RC_INVOKED */
  152.  
  153.  
  154. #endif  /* __IOMANIP_H */
  155.