home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 7.ddi / MWHC.007 / J < prev    next >
Encoding:
Text File  |  1992-08-26  |  3.6 KB  |  163 lines

  1. /*
  2.  *   iostream.h
  3.  *
  4.  *   C++ IOStreams manipulators.
  5.  *
  6.  *   This file will change drastically once parameterized
  7.  *   types are implemented.
  8.  *
  9.  *           Copyright (c) 1991-1992, MetaWare Incorporated
  10.  */
  11.  
  12. /*   $Id: iomanip.h,v 1.4 1992/02/18 01:38:55 tom Exp $ */
  13.  
  14. #ifndef __IOMANIP_H
  15. #define __IOMANIP_H
  16. #pragma push_align_members(64);
  17.  
  18. #c_include <generic.h>
  19. #c_include <iostream.h>
  20.  
  21. #define SMANIP(TYPE)    name2(smanip_,TYPE)
  22. #define SAPP(TYPE)    name2(sapply_,TYPE)
  23. #define IMANIP(TYPE)    name2(imanip_,TYPE)
  24. #define OMANIP(TYPE)    name2(omanip_,TYPE)
  25. #define IOMANIP(TYPE)    name2(iomanip_,TYPE)
  26. #define IAPP(TYPE)    name2(iapply_,TYPE)
  27. #define OAPP(TYPE)    name2(oapply_,TYPE)
  28. #define IOAPP(TYPE)    name2(ioapply_,TYPE)
  29.  
  30. #define _CLa(TYPE) \
  31.     class SMANIP(TYPE){ \
  32.         ios&(*fcn)(ios&,TYPE); \
  33.         TYPE arg; \
  34.     public: \
  35.         SMANIP(TYPE)(ios&(*f)(ios&,TYPE),TYPE a) { \
  36.             fcn=f; \
  37.             arg=a; \
  38.             } \
  39.         friend istream&operator>>(istream&i,SMANIP(TYPE)&m){ \
  40.             ios *s=&i; \
  41.             (*m.fcn)(*s,m.arg); \
  42.             return i; \
  43.             }\
  44.         friend ostream&operator<<(ostream&o,SMANIP(TYPE)&m){ \
  45.             ios*s=&o; \
  46.             (*m.fcn)(*s,m.arg); \
  47.             return o; \
  48.             } \
  49.     };\
  50.     \
  51.     class SAPP(TYPE){ \
  52.         ios&(*fcn)(ios&,TYPE); \
  53.     public: \
  54.         SAPP(TYPE)(ios&(*f)(ios&,TYPE)) { \
  55.             fcn=f; \
  56.             } \
  57.         SMANIP(TYPE) operator()(TYPE a){ \
  58.             return SMANIP(TYPE)(fcn,a); \
  59.             }\
  60.     };
  61.  
  62.  
  63. #define _CLb(TYPE) \
  64.     class IMANIP(TYPE){ \
  65.         istream&(*fcn)(istream&,TYPE); \
  66.         TYPE arg; \
  67.     public: \
  68.         IMANIP(TYPE)(istream&(*f)(istream&,TYPE),TYPE a){ \
  69.             fcn=f; \
  70.             arg=a; \
  71.             } \
  72.         friend istream& operator>>(istream&s,IMANIP(TYPE)&m){ \
  73.             return(*m.fcn)(s,m.arg); \
  74.             } \
  75.     };\
  76.     \
  77.     class IAPP(TYPE){ \
  78.         istream&(*fcn)(istream&,TYPE); \
  79.     public: \
  80.         IAPP(TYPE)(istream&(*f)(istream&,TYPE)){ \
  81.             fcn=f; \
  82.             } \
  83.         IMANIP(TYPE) operator()(TYPE a){ \
  84.             return IMANIP(TYPE)(fcn,a); \
  85.             } \
  86.     };
  87.  
  88.  
  89. #define _CLc(TYPE) \
  90.     class OMANIP(TYPE){ \
  91.         ostream&(*fcn)(ostream&,TYPE); \
  92.         TYPE arg; \
  93.     public: \
  94.         OMANIP(TYPE)(ostream&(*f)(ostream&,TYPE),TYPE a){ \
  95.             fcn=f; \
  96.             arg=a; \
  97.             } \
  98.         friend ostream&operator<<(ostream&s,OMANIP(TYPE)&m){ \
  99.             return(*m.fcn)(s,m.arg); \
  100.             } \
  101.     };\
  102.     \
  103.     class OAPP(TYPE){ \
  104.         ostream&(*fcn)(ostream&,TYPE); \
  105.     public: \
  106.         OAPP(TYPE)(ostream&(*f)(ostream&,TYPE)){ \
  107.             fcn=f; \
  108.             } \
  109.         OMANIP(TYPE) operator()(TYPE a){ \
  110.             return OMANIP(TYPE)(fcn,a); \
  111.             } \
  112.     };
  113.  
  114. #define _CLd(TYPE)\
  115.     class IOMANIP(TYPE){ \
  116.         iostream&(*fcn)(iostream&,TYPE); \
  117.         TYPE arg; \
  118.     public: \
  119.         IOMANIP(TYPE)(iostream&(*f)(iostream&,TYPE),TYPE a){ \
  120.             fcn=f; \
  121.             arg=a; \
  122.             } \
  123.         friend istream&operator>>(iostream&s,IOMANIP(TYPE)&m){ \
  124.             return(*m.fcn)(s,m.arg); \
  125.             } \
  126.         friend ostream&operator<<(iostream&s,IOMANIP(TYPE)&m){ \
  127.             return(*m.fcn)(s,m.arg); \
  128.             } \
  129.     };\
  130.     \
  131.     class IOAPP(TYPE){ \
  132.         iostream&(*fcn)(iostream&,TYPE); \
  133.     public: \
  134.         IOAPP(TYPE)(iostream&(*f)(iostream&,TYPE)){ \
  135.             fcn=f; \
  136.             } \
  137.         IOMANIP(TYPE) operator()(TYPE a){ \
  138.             return IOMANIP(TYPE)(fcn,a); \
  139.             } \
  140.     };
  141.  
  142. #define IOMANIPdeclare(TYPE) _CLa(TYPE) _CLb(TYPE) _CLc(TYPE) _CLd(TYPE)
  143.  
  144. #pragma on(nodebug)
  145.  
  146. IOMANIPdeclare(int) ;
  147. IOMANIPdeclare(long) ;
  148.  
  149. SMANIP(int)     setbase(int b) ;    // 0, 8, 10, or 16. (NOT ios::hex, etc.)
  150. SMANIP(long)    resetiosflags(long b) ;
  151. SMANIP(long)    setiosflags(long b) ;
  152. SMANIP(int)    setfill(int f);
  153. SMANIP(int)    setprecision(int p);
  154. SMANIP(int)    setw(int w) ;
  155.  
  156. #pragma pop(nodebug)
  157.  
  158. #pragma pop_align_members();
  159. #endif  // __IOMANIP_H
  160.  
  161.  
  162. /**          Copyright (c) 1991-1992, MetaWare Incorporated             **/
  163.