home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 14.ddi / GENINC.PAK / IOMANIP.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  4.5 KB  |  135 lines

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