home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 1.ddi / INCLUDE.ZIP / IOMANIP.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  7.1 KB  |  136 lines

  1. /*  iomanip.h -- streams I/O manipulator declarations
  2.  
  3.     Copyright (c) 1990, 1992 by Borland International
  4.     All rights reserved
  5. */
  6.  
  7. #ifndef __cplusplus
  8. #error Must use C++ for the io stream manipulators.
  9. #endif
  10.  
  11. #ifndef __IOMANIP_H
  12. #define __IOMANIP_H
  13.  
  14. #if !defined(___DEFS_H)
  15. #include <_defs.h>
  16. #endif
  17.  
  18. #if !defined(__IOSTREAM_H)
  19. #include <iostream.h>
  20. #endif
  21.  
  22. #if !defined(__GENERIC_H)
  23. #include <generic.h>
  24. #endif
  25.  
  26. #pragma option -Vo-
  27. #if defined(__BCOPT__) && !defined(_RTL_ALLOW_po)
  28. #pragma option -po-
  29. #endif
  30.  
  31. #define SMANIP(typ)     _Paste2(smanip_, typ)
  32. #define SAPP(typ)       _Paste2(sapply_, typ)
  33. #define IMANIP(typ)     _Paste2(imanip_, typ)
  34. #define OMANIP(typ)     _Paste2(omanip_, typ)
  35. #define IOMANIP(typ)    _Paste2(iomanip_, typ)
  36. #define IAPP(typ)       _Paste2(iapply_, typ)
  37. #define OAPP(typ)       _Paste2(oapply_, typ)
  38. #define IOAPP(typ)      _Paste2(ioapply_, typ)
  39.  
  40. #define IOMANIPdeclare(typ)                                             \
  41. class _CLASSTYPE SMANIP(typ) {                                                     \
  42.         ios _FAR & (_Cdecl *_fn)(ios _FAR &, typ);                                          \
  43.         typ _ag;                                                        \
  44. public:                                                                 \
  45.         _Cdecl SMANIP(typ)(ios _FAR & (_Cdecl *_f)(ios _FAR &, typ), typ _a) : _fn(_f), _ag(_a) { }\
  46.         friend istream _FAR & _Cdecl operator>>(istream _FAR & _s, const SMANIP(typ) _FAR & _f) {       \
  47.                         (*_f._fn)(_s, _f._ag); return _s; }             \
  48.         friend ostream _FAR & _Cdecl operator<<(ostream _FAR & _s, const SMANIP(typ) _FAR & _f) {       \
  49.                         (*_f._fn)(_s, _f._ag); return _s; }             \
  50.         };                                                              \
  51. class _CLASSTYPE SAPP(typ) {                                                       \
  52.         ios _FAR & (_Cdecl *_fn)(ios _FAR &, typ);                                          \
  53. public:                                                                 \
  54.         SAPP(typ)(ios _FAR & (_Cdecl *_f)(ios _FAR &, typ)) : _fn(_f) { }                   \
  55.         SMANIP(typ) _Cdecl operator()(typ _z) { return SMANIP(typ)(_fn, _z); }  \
  56.         };                                                              \
  57. class _CLASSTYPE IMANIP(typ) {                                                     \
  58.         istream _FAR & (_Cdecl *_fn)(istream _FAR &, typ);                                  \
  59.         typ _ag;                                                        \
  60. public:                                                                 \
  61.         _Cdecl IMANIP(typ)(istream _FAR & (_Cdecl *_f)(istream _FAR &, typ), typ _z ) :            \
  62.                 _fn(_f), _ag(_z) { }                                    \
  63.         friend istream _FAR & _Cdecl operator>>(istream _FAR & _s, const IMANIP(typ) _FAR & _f) {       \
  64.                 return(*_f._fn)(_s, _f._ag); }                          \
  65.         };                                                              \
  66. class _CLASSTYPE IAPP(typ) {                                                       \
  67.         istream _FAR & (_Cdecl *_fn)(istream _FAR &, typ);                                  \
  68. public:                                                                 \
  69.         _Cdecl IAPP(typ)(istream _FAR & (_Cdecl *_f)(istream _FAR &, typ)) : _fn(_f) { }           \
  70.         IMANIP(typ) _Cdecl operator()(typ _z) {                         \
  71.                 return IMANIP(typ)(_fn, _z); }                          \
  72.         };                                                              \
  73. class _CLASSTYPE OMANIP(typ) {                                                     \
  74.         ostream _FAR & (_Cdecl *_fn)(ostream _FAR &, typ);                                  \
  75.         typ _ag;                                                        \
  76. public:                                                                 \
  77.         _Cdecl OMANIP(typ)(ostream _FAR & (_Cdecl *_f)(ostream _FAR &, typ), typ _z ) :            \
  78.                 _fn(_f), _ag(_z) { }                                    \
  79.         friend ostream _FAR & _Cdecl operator<<(ostream _FAR & _s, const OMANIP(typ) _FAR & _f) {       \
  80.                 return(*_f._fn)(_s, _f._ag); }                          \
  81.         };                                                              \
  82. class _CLASSTYPE OAPP(typ) {                                                       \
  83.         ostream _FAR & (_Cdecl *_fn)(ostream _FAR &, typ);                                  \
  84. public:                                                                 \
  85.         _Cdecl OAPP(typ)(ostream _FAR & (_Cdecl *_f)(ostream _FAR &, typ)) : _fn(_f) { }           \
  86.         OMANIP(typ) _Cdecl operator()(typ _z) {                         \
  87.                 return OMANIP(typ)(_fn, _z); }                          \
  88.         };                                                              \
  89. class _CLASSTYPE IOMANIP(typ) {                                                    \
  90.         iostream _FAR & (_Cdecl *_fn)(iostream _FAR &, typ);                                \
  91.         typ _ag;                                                        \
  92. public:                                                                 \
  93.         _Cdecl IOMANIP(typ)(iostream _FAR & (_Cdecl *_f)(iostream _FAR &, typ), typ _z ) : \
  94.                 _fn(_f), _ag(_z) { }                                    \
  95.         friend istream _FAR & _Cdecl operator>>(iostream _FAR & _s, const IOMANIP(typ) _FAR & _f) {     \
  96.                 return(*_f._fn)(_s, _f._ag); }                          \
  97.         friend ostream _FAR & _Cdecl operator<<(iostream _FAR & _s, const IOMANIP(typ) _FAR & _f) {     \
  98.                 return(*_f._fn)(_s, _f._ag); }                          \
  99.         };                                                              \
  100. class _CLASSTYPE IOAPP(typ) {                                                      \
  101.         iostream _FAR & (_Cdecl *_fn)(iostream _FAR &, typ);                                \
  102. public:                                                                 \
  103.         _Cdecl IOAPP(typ)(iostream _FAR & (_Cdecl *_f)(iostream _FAR &, typ)) : _fn(_f) { }        \
  104.         IOMANIP(typ) _Cdecl operator()(typ _z) { return IOMANIP(typ)(_fn, _z); }\
  105.         }
  106.  
  107.  
  108.  
  109. IOMANIPdeclare(int);
  110. IOMANIPdeclare(long);
  111.  
  112. // set the conversion base to 0, 8, 10, or 16
  113. smanip_int      _Cdecl _FARFUNC setbase(int _b);
  114.  
  115. // clear the flags bitvector according to the bits set in b
  116. smanip_long     _Cdecl _FARFUNC resetiosflags(long _b);
  117.  
  118. // set the flags bitvector according to the bits set in b
  119. smanip_long     _Cdecl _FARFUNC setiosflags(long _b);
  120.  
  121. // set fill character for padding a field
  122. smanip_int      _Cdecl _FARFUNC setfill(int _f);
  123.  
  124. // set the floating-point precision to n digits
  125. smanip_int      _Cdecl _FARFUNC setprecision(int _n);
  126.  
  127. // set the field width to n
  128. smanip_int      _Cdecl _FARFUNC setw(int _n);
  129.  
  130. #pragma option -Vo.
  131. #if defined(__BCOPT__)
  132. #pragma option -po.
  133. #endif
  134.  
  135. #endif
  136.