|
|
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 IOS.OUT 3I+ "C++ Stream Library" " "
8: .SH NAME
9: ostream \- formatted and unformatted output
10: .SH SYNOPSIS
11: .ft B
12: .ta1i 2i
13: .nf
14: #include <iostream.h>
15:
16: typedef long streamoff, streampos;
17: class ios {
18: public:
19: enum seek_dir { beg, cur, end };
20: enum open_mode { in, out, ate, app } ;
21: // \fIand lots of other stuff ... \fP
22: } ;
23:
24: class ostream : ios {
25: public:
26: ostream& flush();
27: int opfx();
28: ostream& put(char c);
29: ostream& seekp(streampos pos);
30: ostream& seekp(streamoff off, seek_dir d);
31: streampos tellp();
32: ostream& write(const char* ptr,int n);
33: ostream& write(const unsigned char* ptr, int n);
34: ostream& operator<<(const char*);
35: ostream& operator<<(char);
36: ostream& operator<<(short);
37: ostream& operator<<(int a);
38: ostream& operator<<(long);
39: ostream& operator<<(double);
40: ostream& operator<<(unsigned char);
41: ostream& operator<<(unsigned short);
42: ostream& operator<<(unsigned int);
43: ostream& operator<<(unsigned long);
44: ostream& operator<<(void*);
45: ostream& operator<<(const streambuf&);
46: ostream& operator<<(ostream& (*)(ostream&));
47: };
48:
49: class ostream_withassign {
50: ostream_withassign();
51: istream& operator=(istream&);
52: istream& operator=(streambuf*);
53: };
54:
55: extern ostream_withassign cout;
56: extern ostream_withassign cerr;
57: extern ostream_withassign clog;
58:
59:
60: ostream& endl(ostream& i) ;
61: ostream& ends(ostream& i) ;
62: ostream& flush(ostream& i) ;
63: .fi
64: .ft R
65: .SH DESCRIPTION
66: \f(CWistream\fRs support
67: insertion (storing) into an \f(CWstreambuf\fR.
68: These are commonly refered to as output operations.
69: .PP
70: Assume:
71: .br
72: \(em \fBouts\fR is an \f(CWostream\fR.
73: .br
74: \(em \fBoutswa\fR is an \f(CWostream_withassign\fR.
75: .br
76: \(em \fBoutsp\fR is an \f(CWostream*\fR.
77: .br
78: \(em \fBc\fR is a \f(CWchar\fR.
79: .br
80: \(em \fBptr\fR is a \f(CWchar*\fR or \f(CWunsigned char*\fR.
81: .br
82: \(em \fBsb\fR is a \f(CWstreambuf*\fR
83: .br
84: \(em \fBi\fR and \fBn\fR are \f(CWint\fR.
85: .br
86: \(em \fBpos\fR is a \f(CWstreampos\fR.
87: .br
88: \(em \fBoff\fR is a \f(CWstreamoff\fR.
89: .br
90: \(em \fBdir\fR is a \f(CWseek_dir\fR.
91: .br
92: \(em \fBmanip\fR is a function with type \f(CWostream& (*)(ostream&)\fR.
93: .PP
94: .PP
95: Constructors and assignment:
96: .TP
97: \fBostream(sb)\fR
98: Initializes \fBios\fR state variables and associates stream with
99: buffer \fBsb\fR.
100: \fBostream_withassign()\fR
101: Does no initialization. This allows a file static
102: variable of this type
103: (\fBcout\fR for example) to be used before it is constructed provided
104: it is assigned to first.
105: .TP
106: \fBoutswa=sb\fR
107: Associates \fBsb\fR with \fBswa\fR and initializes the entire
108: state of \fBoutswa\fR.
109: .TP
110: \fBinswa=ins\fR
111: Associates \fBins->rdbuf()\fR with \fBswa\fR and initializes the entire
112: state of \fBoutswa\fR.
113: The inserters:
114: .TP
115: \fBouts<<x\fR
116: First call \fBouts.opfx()\fR. If that returns 0 do nothing.
117: Otherwise insert a sequence of characters
118: representing \fBx\fR into \fBouts.rdbuf()\fR.
119: Errors are indicated by setting
120: the error state of \fBouts\fR.
121: \fBouts\fR is always returned.
122: .RS
123: .PP
124: \fBx\fR is converted into a sequence of characters
125: (its representation) according
126: to rules that depend on \fBx\fR's type and
127: \fBouts\fR's format state variables (see \fIios\fR(3C++)):
128: .TP
129: \f(CWchar*\fR
130: The representation is the sequence of characters up to
131: (but not including)
132: the terminating null of the string \fBx\fR points at.
133: .TP
134: \fIany integral type\fR
135: If \fBx\fR is positive
136: the representation contains a sequence of
137: decimal, octal, or hexadecimal digits with no leading zeros
138: according to whether
139: \fBouts.convbase()\fR is 10, 8, or 16 respectively.
140: If \fBx\fR is zero the representation is a single
141: zero character(\f(CW0\fR).
142: If \fBx\fR is negative, decimal conversion converts is to a minus
143: sign (\f(CW-\fR) followed by decimal digits.
144: The other conversions treat all values as unsigned.
145: A value of 0 for \fBouts.convbase()\fR
146: also causes decimal conversion.
147: The effect of other values of \fBouts.convbase()\fR is undefined.
148: If \fBouts.showbase()\fR
149: is non-zero the hex representation contains
150: \f(CW0x\fR before the hex digits.
151: If \fBouts.showbase()\fR is non-zero the octal representation contains
152: a leading 0.
153: .TP
154: \f(CWvoid*\fR
155: Pointers are cast to integral values and then converted
156: to hexadecimal numbers as if \fBouts.showbase()\fR were set.
157: .TP
158: \f(CWfloat\fR, \f(CWdouble\fR
159: The arguments are converted according to the current values
160: of \fBouts.precision()\fR, \fBouts.floatfmt()\fR, and \fBouts.width()\fR
161: using the printf formatting conventions for
162: \f(CW"%\fBfloatfmt\f(CW"\fR.
163: The default values for \fBouts.floatfmt()\fR and \fBouts.precision()\fR
164: are \f(CWg\fR and 6 respectively.
165: .PP
166: After the representation is determined, padding occurs.
167: If \fBouts.width()\fR
168: is greater than 0
169: and the representation contains less than \fBouts.width()\fR
170: characters, then enough \fBouts.fill()\fR characters are added
171: to bring the total number of characters to \fBios.width()\fR.
172: If \fBios.ladjust()\fR is non-zero the sequence is left adjusted.
173: That is, characters are added after the characters determined above.
174: Otherwise the padding is added before the characters determined
175: above. \fBios.width()\fR is reset to 0, but all other format
176: state variables are unchanged. The resulting sequence (padding
177: plus representation) is inserted into \fBouts.rdbuf()\fR.
178: .RE
179: .TP
180: \fBouts<<sb\fR
181: If \fBouts.opfx()\fR returns non-zero
182: the sequence of characters that can be fetched from \fBsb\fR
183: are inserted into \fBouts.rdbuf\fR. Insertion stops when
184: no more characters can be fetcheded from \fBsb\fR. No padding
185: is performed. Always return \fBouts\fR.
186: .PP
187: Other members:
188: .TP
189: \fBi=outs.opfx()\fR
190: If \fBouts\fR's error state is nonzero returns immediately.
191: If \fBouts.tie()\fR is non-null flush it.
192: Returns non-zero except when \fBouts\fR'es error state is nonzero.
193: .TP
194: \fBoutsp=&outs.flush()\fR
195: storing characters into a streambuf does not always
196: cause them to be consumed (e.g., written to the external file)
197: immediately.
198: \fBflush\fR
199: causes any characters that may have been stored but not yet consumed
200: to be consumed by calling \fBouts.rdbuf()->sync\fR.
201: .TP
202: \fBouts<<manip\fR
203: Equivalent to \fBmanip(outs)\fR.
204: Syntactically this looks like an insertion
205: operation, but semantically it does an arbitrary operations
206: rather than converting \fBmanip\fR to a sequence of characters as
207: do the insertion operators.
208: .PP
209: Unformatted output functions:
210: .TP
211: \fBoutsp=&outs.put(c)\fR
212: Inserts \fBc\fR into \fBouts.rdbuf()\fR. Sets the error state if
213: the insertion fails.
214: .TP
215: \fBoutsp=&outs.write(s,n)\fR
216: Inserts the
217: \fBn\fR
218: characters starting at \fBs\fR into \fBouts.rdbuf()\fR.
219: These characters may include zeros (i.e., \fBs\fR need not be
220: a null terminated string).
221: .PP
222: Positioning functions:
223: .TP
224: \fBoutsp=&ins.seekp(off,dir)\fR
225: Repositions \fBouts.rdbuf()\fR's put pointer.
226: See \fIsbuf.pub\fR(3C++)\fR for a discussion of positioning.
227: .TP
228: \fBoutsp=&outs.seekp(pos)\fR
229: Repositions \fBouts.rdbuf()\fR's put pointer.
230: See \fIsbuf.pub\fR(3C++)\fR for a discussion of positioning.
231: .TP
232: \fBpos=outs.tellp()\fR
233: The current position of \fBouts.rdbuf()\fR's put pointer.
234: See \fIsbuf.pub\fR(3C++)\fR for a discussion of positioning.
235: .PP
236: Manipulators:
237: .TP
238: \fBouts<<endl\fR
239: Ends a line by inserting a newline character and flushing.
240: .TP
241: \fBouts<<ends\fR
242: Ends a string by inserting a null(0) character.
243: .TP
244: \fBouts<<flush\fR
245: Flushes \fBouts\fR
246: .SH SEE ALSO
247: ios(3C++)
248: sbuf.pub(3C++)
249: manip(3C++)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.