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

  1. /*  iomanip.h -- streams I/O manipulator declarations
  2.  
  3.     Copyright (c) 1990, 1991 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.  
  28. #define SMANIP(typ)     _Paste2(smanip_, typ)
  29. #define SAPP(typ)       _Paste2(sapply_, typ)
  30. #define IMANIP(typ)     _Paste2(imanip_, typ)
  31. #define OMANIP(typ)     _Paste2(omanip_, typ)
  32. #define IOMANIP(typ)    _Paste2(iomanip_, typ)
  33. #define IAPP(typ)       _Paste2(iapply_, typ)
  34. #define OAPP(typ)       _Paste2(oapply_, typ)
  35. #define IOAPP(typ)      _Paste2(ioapply_, typ)
  36.  
  37. #define IOMANIPdeclare(typ)                                             \
  38. class _CLASSTYPE SMANIP(typ) {                                                     \
  39.         ios & (_Cdecl *_fn)(ios &, typ);                                          \
  40.         typ _ag;                                                        \
  41. public:                                                                 \
  42.         _Cdecl SMANIP(typ)(ios & (_Cdecl *_f)(ios &, typ), typ _a) : _fn(_f), _ag(_a) { }\
  43.         friend istream & _Cdecl operator>>(istream & _s, SMANIP(typ) & _f) {       \
  44.                         (*_f._fn)(_s, _f._ag); return _s; }             \
  45.         friend ostream & _Cdecl operator<<(ostream & _s, SMANIP(typ) & _f) {       \
  46.                         (*_f._fn)(_s, _f._ag); return _s; }             \
  47.         };                                                              \
  48. class _CLASSTYPE SAPP(typ) {                                                       \
  49.         ios & (_Cdecl *_fn)(ios &, typ);                                          \
  50. public:                                                                 \
  51.         SAPP(typ)(ios & (_Cdecl *_f)(ios &, typ)) : _fn(_f) { }                   \
  52.         SMANIP(typ) _Cdecl operator()(typ _z) { return SMANIP(typ)(_fn, _z); }  \
  53.         };                                                              \
  54. class _CLASSTYPE IMANIP(typ) {                                                     \
  55.         istream & (_Cdecl *_fn)(istream &, typ);                                  \
  56.         typ _ag;                                                        \
  57. public:                                                                 \
  58.         _Cdecl IMANIP(typ)(istream & (_Cdecl *_f)(istream &, typ), typ _z ) :            \
  59.                 _fn(_f), _ag(_z) { }                                    \
  60.         friend istream & _Cdecl operator>>(istream & _s, IMANIP(typ) & _f) {       \
  61.                 return(*_f._fn)(_s, _f._ag); }                          \
  62.         };                                                              \
  63. class _CLASSTYPE IAPP(typ) {                                                       \
  64.         istream & (_Cdecl *_fn)(istream &, typ);                                  \
  65. public:                                                                 \
  66.         _Cdecl IAPP(typ)(istream & (_Cdecl *_f)(istream &, typ)) : _fn(_f) { }           \
  67.         IMANIP(typ) _Cdecl operator()(typ _z) {                         \
  68.                 return IMANIP(typ)(_fn, _z); }                          \
  69.         };                                                              \
  70. class _CLASSTYPE OMANIP(typ) {                                                     \
  71.         ostream & (_Cdecl *_fn)(ostream &, typ);                                  \
  72.         typ _ag;                                                        \
  73. public:                                                                 \
  74.         _Cdecl OMANIP(typ)(ostream & (_Cdecl *_f)(ostream &, typ), typ _z ) :            \
  75.                 _fn(_f), _ag(_z) { }                                    \
  76.         friend ostream & _Cdecl operator<<(ostream & _s, OMANIP(typ) & _f) {       \
  77.                 return(*_f._fn)(_s, _f._ag); }                          \
  78.         };                                                              \
  79. class _CLASSTYPE OAPP(typ) {                                                       \
  80.         ostream & (_Cdecl *_fn)(ostream &, typ);                                  \
  81. public:                                                                 \
  82.         _Cdecl OAPP(typ)(ostream & (_Cdecl *_f)(ostream &, typ)) : _fn(_f) { }           \
  83.         OMANIP(typ) _Cdecl operator()(typ _z) {                         \
  84.                 return OMANIP(typ)(_fn, _z); }                          \
  85.         };                                                              \
  86. class _CLASSTYPE IOMANIP(typ) {                                                    \
  87.         iostream & (_Cdecl *_fn)(iostream &, typ);                                \
  88.         typ _ag;                                                        \
  89. public:                                                                 \
  90.         _Cdecl IOMANIP(typ)(iostream & (_Cdecl *_f)(iostream &, typ), typ _z ) : \
  91.                 _fn(_f), _ag(_z) { }                                    \
  92.         friend istream & _Cdecl operator>>(iostream & _s, IOMANIP(typ) & _f) {     \
  93.                 return(*_f._fn)(_s, _f._ag); }                          \
  94.         friend ostream & _Cdecl operator<<(iostream & _s, IOMANIP(typ) & _f) {     \
  95.                 return(*_f._fn)(_s, _f._ag); }                          \
  96.         };                                                              \
  97. class _CLASSTYPE IOAPP(typ) {                                                      \
  98.         iostream & (_Cdecl *_fn)(iostream &, typ);                                \
  99. public:                                                                 \
  100.         _Cdecl IOAPP(typ)(iostream & (_Cdecl *_f)(iostream &, typ)) : _fn(_f) { }        \
  101.         IOMANIP(typ) _Cdecl operator()(typ _z) { return IOMANIP(typ)(_fn, _z); }\
  102.         }
  103.  
  104.  
  105.  
  106. IOMANIPdeclare(int);
  107. IOMANIPdeclare(long);
  108.  
  109. // set the conversion base to 0, 8, 10, or 16
  110. smanip_int      _Cdecl setbase(int _b);
  111.  
  112. // clear the flags bitvector according to the bits set in b
  113. smanip_long     _Cdecl resetiosflags(long _b);
  114.  
  115. // set the flags bitvector according to the bits set in b
  116. smanip_long     _Cdecl setiosflags(long _b);
  117.  
  118. // set fill character for padding a field
  119. smanip_int      _Cdecl setfill(int _f);
  120.  
  121. // set the floating-point precision to n digits
  122. smanip_int      _Cdecl setprecision(int _n);
  123.  
  124. // set the field width to n
  125. smanip_int      _Cdecl setw(int _n);
  126.  
  127. #pragma option -Vo.
  128.  
  129. #endif
  130.