home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c021 / 7.img / INCLUDE.ZIP / IOMANIP.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-04  |  3.7 KB  |  119 lines

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