|
|
1.1 root 1: . \"ident "%W%"
2: . \"Copyright (c) 1984 AT&T
3: . \"All Rights Reserved
4: . \"THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
5: . \"The copyright notice above does not evidence any
6: . \"actual or intended publication of such source code.
7: .TH MANIP 3I+ "C++ Stream Library" " "
8: .SH NAME
9: manipulators \- iostream out of band manipulations
10: .SH SYNOPSIS
11: .ft B
12: .ta1i 2i
13: .nf
14: #include <iostream.h>
15: #include <iomanip.h>
16:
17: IOMANIPdeclare(T) ;
18:
19: class SMANIP(T) {
20: SMANIP(T)( ios& (*)(ios&,T), T);
21: };
22:
23: class SAPP(T) {
24: SAPP(T)( ios& (*)(ios&,T));
25: SMANIP(T) operator()(T);
26: };
27:
28: ios& SMANIP(T)::operator<<(ios&);
29: ios& SMANIP(T)::operator>>(ios&);
30: istream& SMANIP(T)::operator>>(istream&);
31: ostream& SMANIP(T)::operator<<(ostream&);
32: iostream& SMANIP(T)::operator<<(iostream&);
33: iostream& SMANIP(T)::operator>>(iostream&);
34:
35: class IMANIP(T) {
36: IMANIP(T)( istream& (*)(istream&,T), T);
37: };
38:
39: class IAPP(T) {
40: IAPP(T)( istream& (*)(istream&,T));
41: IMANIP(T) operator()(T);
42: };
43:
44: istream& operator>>(IMANIP(T), istream&);
45:
46: class OMANIP(T) {
47: OMANIP(T)( ostream& (*)(ostream&,T), T);
48: };
49:
50: class OAPP(T) {
51: OAPP(T)( ostream& (*)(ostream&,T));
52: OMANIP(T) operator()(T);
53: };
54:
55: ostream& operator<<(OMANIP(T), ostream&);
56:
57: class IOMANIP(T) {
58: IOMANIP(T)( ios& (*)(ios&,T), T);
59: };
60:
61: class IOAPP(T) {
62: IOAPP(T)( ios& (*)(ios&,T));
63: IOMANIP(T) operator()(T);
64: };
65:
66: iostream& operator<<(SMANIP(T), iostream&);
67: iostream& operator>>(SMANIP(T), iostream&);
68:
69:
70: IOMANIPdeclare(int) ;
71:
72: IOMANIP(int) setbase(int b) ;
73: IOMANIP(int) setw(int w) ;
74: .fi
75: .ft R
76: .SH DESCRIPTION
77: Manipulators are values that may be "inserted into" or
78: "extracted from" streams in order to achieve some effect
79: (other than to insert a representation of their value).
80: Ideally the types relating to manipulators would be parameterized
81: as "templates".
82: The macros defined in \f(CWiomanip.h\fR are used to simulate a templates.
83: \BIOMANIP(T)\fR declares
84: the various classes and operators. (All code is declared as inlines
85: so that no separate definitions are required.) Each of the other
86: \fBT\fR is used to construct the real names and therefore
87: must be a single
88: identifer. Each of the other macros also requires an identifier
89: and expands to a name.
90: .br
91: \(em \fBt\fR is a \fBT\fR.
92: .br
93: \(em \fBs\fR is an \f(CWios\fR.
94: .br
95: \(em \fBi\fR is an \f(CWistream\fR.
96: .br
97: \(em \fBo\fR is an \f(CWostream\fR.
98: .br
99: \(em \fBio\fR is an \f(CWiostream\fR.
100: .br
101: \(em \fBf\fR is an \f(CWios& (*)(ios&)\fR.
102: .br
103: \(em \fBif\fR is an \f(CWistream& (*)(istream&)\fR.
104: .br
105: \(em \fBof\fR is an \f(CWostream& (*)(ostream&)\fR.
106: .br
107: \(em \fBiof\fR is an \f(CWiostream& (*)(iostream&)\fR.
108: .TP
109: \fBs<<SMANIP(T)(f,t)\fR
110: .nf
111: .in -.5i
112: \fBs<<SMANIP(T)(f,t)\fR
113: \fBs>>SMANIP(T)(f,t)\fR
114: \fBs<<SAPP(T)(f)(t)\fR
115: \fBs>>SAPP(T)(f)(t)\fR
116: \fBi>>SMANIP(T)(if,t)\fR
117: \fBi>>SAPP(T)(if)(t)\fR
118: \fBo<<SMANIP(T)(of,t)\fR
119: \fBo<<SAPP(T)(of)(t)\fR
120: \fBio<<SMANIP(T)(iof,t)\fR
121: \fBio>>SMANIP(T)(iof,t)\fR
122: \fBio<<SAPP(T)(iof)(t)\fR
123: \fBio>>SAPP(T)(iof)(t)\fR
124: .in
125: .fi
126: Returns \fBfct(s,t)\fR, where \fBs\fR is the left operand of
127: the insertion or extractor operator and \fBfct\fR is \fBf\fR,
128: \fBif\R, \fBof\fR or \fBiof\fR.
129: .sp
130: .nf
131: .in -.5i
132: \fBi>>IMANIP(T)(if,t)\fR
133: \fBi>>IAPP(T)(if)(t)\fR
134: .in
135: .fi
136: Return \fBif(i,t)\fR.
137: .sp
138: .nf
139: .in -.5i
140: \fBo<<OMANIP(T)(of,t)\fR
141: \fBo<<OAPP(T)(of)(t)\fR
142: .in
143: .fi
144: Return \fBof(i,t)\fR.
145: .sp
146: .nf
147: .in -.5i
148: \fBio<<IOMANIP(T)(iof,t)\fR
149: \fBio>>IOMANIP(T)(iof,t)\fR
150: \fBio<<IOAPP(T)(iof)(t)\fR
151: \fBio>>IOAPP(T)(iof)(t)\fR
152: .in
153: .fi
154: Return \fBiof(s,t)\fR.
155: .PP
156: \f(CWiomanip.h\fR contains a declaration, \f(CWIOMANIPdeclare(int)\fR
157: and some functions:
158: .sp
159: .nf
160: .in -.5i
161: \fBo<<setbase(n)\fR
162: \fBi>>setbase(n)\fR
163: \fBio<<setbase(n)\fR
164: \fBio>>setbase(n)\fR
165: .in
166: .fi
167: Sets the conversion base of the stream (left hand operand) to \fBn\fR.
168: .sp
169: .nf
170: .in -.5i
171: \fBo<<setw(n)\fR
172: \fBi>>setw(n)\fR
173: \fBio<<setw(n)\fR
174: \fBio>>setw(n)\fR
175: .in
176: .fi
177: Sets the \f(CWwidth\fR format state variable
178: the stream (left hand operand) to \fBn\fR.
179: .SH CAVEATS
180: Syntax errors will be reported if
181: \fBIOMANIP(T)\fR occurs more than once in a file with the
182: same \fBT\fR.
183: .SH SEE ALSO
184: ios(3C++)
185: istream(3C++)
186: ostream(3C++)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.