home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c081_11 / 2.ddi / INCLUDE.ZIP / IOMANIP.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-13  |  6.4 KB  |  129 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.  
  8. #ifndef __cplusplus
  9. #error Must use C++ for the io stream manipulators.
  10. #endif
  11.  
  12. #ifndef __IOMANIP_H
  13. #define __IOMANIP_H
  14.  
  15. #if !defined( __IOSTREAM_H )
  16. #include <iostream.h>
  17. #endif
  18.  
  19. #if !defined( __GENERIC_H )
  20. #include <generic.h>
  21. #endif
  22.  
  23. #if __STDC__
  24. #define _Cdecl
  25. #else
  26. #define _Cdecl  cdecl
  27. #endif
  28.  
  29. #define SMANIP(typ)     _Paste2(smanip_, typ)
  30. #define SAPP(typ)       _Paste2(sapply_, typ)
  31. #define IMANIP(typ)     _Paste2(imanip_, typ)
  32. #define OMANIP(typ)     _Paste2(omanip_, typ)
  33. #define IOMANIP(typ)    _Paste2(iomanip_, typ)
  34. #define IAPP(typ)       _Paste2(iapply_, typ)
  35. #define OAPP(typ)       _Paste2(oapply_, typ)
  36. #define IOAPP(typ)      _Paste2(ioapply_, typ)
  37.  
  38. #define IOMANIPdeclare(typ)                                             \
  39. class SMANIP(typ) {                                                     \
  40.         ios& _Cdecl (*_fn)(ios&, typ);                                          \
  41.         typ _ag;                                                        \
  42. public:                                                                 \
  43.         _Cdecl SMANIP(typ)(ios& (*_f)(ios&, typ), typ _a) : _fn(_f), _ag(_a) { }\
  44.         friend istream& _Cdecl operator>>(istream& _s, SMANIP(typ)& _f) {       \
  45.                         (*_f._fn)(_s, _f._ag); return _s; }             \
  46.         friend ostream& _Cdecl operator<<(ostream& _s, SMANIP(typ)& _f) {       \
  47.                         (*_f._fn)(_s, _f._ag); return _s; }             \
  48.         };                                                              \
  49. class SAPP(typ) {                                                       \
  50.         ios& _Cdecl (*_fn)(ios&, typ);                                          \
  51. public:                                                                 \
  52.         SAPP(typ)(ios& _Cdecl (*_f)(ios&, typ)) : _fn(_f) { }                   \
  53.         SMANIP(typ) _Cdecl operator()(typ _z) { return SMANIP(typ)(_fn, _z); }  \
  54.         };                                                              \
  55. class IMANIP(typ) {                                                     \
  56.         istream& _Cdecl (*_fn)(istream&, typ);                                  \
  57.         typ _ag;                                                        \
  58. public:                                                                 \
  59.         _Cdecl IMANIP(typ)(istream& (*_f)(istream&, typ), typ _z ) :            \
  60.                 _fn(_f), _ag(_z) { }                                    \
  61.         friend istream& _Cdecl operator>>(istream& _s, IMANIP(typ)& _f) {       \
  62.                 return(*_f._fn)(_s, _f._ag); }                          \
  63.         };                                                              \
  64. class IAPP(typ) {                                                       \
  65.         istream& _Cdecl (*_fn)(istream&, typ);                                  \
  66. public:                                                                 \
  67.         _Cdecl IAPP(typ)(istream& (*_f)(istream&, typ)) : _fn(_f) { }           \
  68.         IMANIP(typ) _Cdecl operator()(typ _z) {                         \
  69.                 return IMANIP(typ)(_fn, _z); }                          \
  70.         };                                                              \
  71. class OMANIP(typ) {                                                     \
  72.         ostream& _Cdecl (*_fn)(ostream&, typ);                                  \
  73.         typ _ag;                                                        \
  74. public:                                                                 \
  75.         _Cdecl OMANIP(typ)(ostream& (*_f)(ostream&, typ), typ _z ) :            \
  76.                 _fn(_f), _ag(_z) { }                                    \
  77.         friend ostream& _Cdecl operator<<(ostream& _s, OMANIP(typ)& _f) {       \
  78.                 return(*_f._fn)(_s, _f._ag); }                          \
  79.         };                                                              \
  80. class OAPP(typ) {                                                       \
  81.         ostream& _Cdecl (*_fn)(ostream&, typ);                                  \
  82. public:                                                                 \
  83.         _Cdecl OAPP(typ)(ostream& (*_f)(ostream&, typ)) : _fn(_f) { }           \
  84.         OMANIP(typ) _Cdecl operator()(typ _z) {                         \
  85.                 return OMANIP(typ)(_fn, _z); }                          \
  86.         };                                                              \
  87. class IOMANIP(typ) {                                                    \
  88.         iostream& _Cdecl (*_fn)(iostream&, typ);                                \
  89.         typ _ag;                                                        \
  90. public:                                                                 \
  91.         _Cdecl IOMANIP(typ)(iostream& (*_f)(iostream&, typ), typ _z ) : \
  92.                 _fn(_f), _ag(_z) { }                                    \
  93.         friend istream& _Cdecl operator>>(iostream& _s, IOMANIP(typ)& _f) {     \
  94.                 return(*_f._fn)(_s, _f._ag); }                          \
  95.         friend ostream& _Cdecl operator<<(iostream& _s, IOMANIP(typ)& _f) {     \
  96.                 return(*_f._fn)(_s, _f._ag); }                          \
  97.         };                                                              \
  98. class IOAPP(typ) {                                                      \
  99.         iostream& _Cdecl (*_fn)(iostream&, typ);                                \
  100. public:                                                                 \
  101.         _Cdecl IOAPP(typ)(iostream& (*_f)(iostream&, typ)) : _fn(_f) { }        \
  102.         IOMANIP(typ) _Cdecl operator()(typ _z) { return IOMANIP(typ)(_fn, _z); }\
  103.         }
  104.  
  105.  
  106.  
  107. IOMANIPdeclare(int);
  108. IOMANIPdeclare(long);
  109.  
  110. // set the conversion base to 0, 8, 10, or 16
  111. smanip_int      _Cdecl setbase(int _b);
  112.  
  113. // clear the flags bitvector according to the bits set in b
  114. smanip_long     _Cdecl resetiosflags(long _b);
  115.  
  116. // set the flags bitvector according to the bits set in b
  117. smanip_long     _Cdecl setiosflags(long _b);
  118.  
  119. // set fill character for padding a field
  120. smanip_int      _Cdecl setfill(int _f);
  121.  
  122. // set the floating-point precision to n digits
  123. smanip_int      _Cdecl setprecision(int _n);
  124.  
  125. // set the field width to n
  126. smanip_int      _Cdecl setw(int _n);
  127.  
  128. #endif
  129.