.\" to invoke 'tbl', 'eqn', 'pic' in the proper order .\" '\" tep .\" .\" @(#)strstream.3 1.7 00/02/18 SMI; .\" .TH STRSTREAM 3CC4 "14 March 1995" .\" .SH NAME strstream \- stream class for ``I/O'' using character arrays .SH SYNOPSIS .LP .nf .ft B #include .sp .5v class ios { public: enum open_mode { in, out, ate, app, trunc, nocreate, noreplace }; // \fIsee \fBios\fR(3CC4)\fI for remainder ...\fB }; .sp .5v #include \fI// includes \fB .sp .5v class strstreambuf : public streambuf { // \fIsee \fBstrstreambuf\fR(3C++)\fI ...\fB }; .sp .5v class strstreambase : virtual public ios { // \fIimplementation detail of the Xstream classes ...\fB }; .sp .5v class istrstream : public strstreambase, public istream { public: istrstream(char* ptr); istrstream(char* ptr, int len); strstreambuf* rdbuf(); }; .sp .5v class ostrstream : public strstreambase, public ostream { public: ostrstream(char* ptr, int len, int mode=ios::out); ostrstream(); strstreambuf* rdbuf(); int pcount(); char* str(); }; .sp .5v class strstream : public strstreambase, public iostream { public: strstream(); strstream(char* ptr, int len, int mode); strstreambuf* rdbuf(); char* str(); }; .ft R .fi .\" .SH DESCRIPTION .LP Classes .BR istrstream ", " ostrstream ", and " strstream are specialization of classes .BR istream ", " ostream ", and " iostream , respectively, for I/O using in-memory character arrays. That is, the associated \fBstreambuf\fR is a \fBstrstreambuf\fR. .LP An auxiliary class \fBstrstreambase\fR is an implementation detail, primarily to provide a set of common functions. It is not further discussed. .\" .SS "istrstream members" .TP .B "istrstream(ptr)" Assumes \fBptr\fR points to a null-terminated array of characters, which will serve as the input source. The null is not part of the input. Seeks, using \fBseekg()\fR, are allowed within the range of the array. .TP .B "istrstream(ptr, len)" Assumes \fBptr\fR points to an array of characters of length \fBlen\fR, which will serve as the input source. Seeks, using \fBseekg()\fR, are allowed within the range of the array. .TP .B "strstreambuf* ssbp = iss.rdbuf()" Returns a pointer to the \fBstrstreambuf\fR associated with \fBiss\fR. This is the same as base class versions of this function, except that the return type is specifically a \fBstrstreambuf*\fR. .\" .SS "ostrstream members" .TP .B "ostrstream()" Creates an empty output stream, which uses a dynamic (expandable) array of characters (see \fBssbuf\fR(3CC4). Seeks are permitted within the current bounds of the array. Presumably this stream will be converted later to a \fBchar*\fR via \fBstr()\fR (see below). .TP .B "ostrstream(ptr, len, mode)" Creates an output stream using the static (non-expandable) array of \fBlen\fR characters starting at \fBptr\fR. If the \fBios::ate\fR or \fBios::app\fR bits are set in \fBmode\fR (see \fBios\fR(3CC4)), the array is assumed to contain a null-terminated string beginning at \fBptr\fR. Characters will be stored beginning at the null character, but will never go beyond \fBlen\fR characters. If those bits are not set in \fBmode\fR, the array is assumed to contain no data, and characters will be stored beginning at \fBptr\fR. Seeks are allowed within the range of the array. .TP .B "strstreambuf* ssbp = oss.rdbuf()" Returns a pointer to the \fBstrstreambuf\fR associated with \fBoss\fR. This is the same as base class versions of this function, except that the return type is specifically a \fBstrstreambuf*\fR. .TP .B "int n = oss.pcount()" Returns the number of characters stored in the array. This is of use particularly when the array contains binary data or is not otherwise null-terminated. .TP .B "char* ptr = oss.str()" Returns a pointer to the start of the underlying array, and freezes (see \fBstrstreambuf\fR(3C++)) the stream. If the array was dynamically allocated, it will not now be automatically deleted or null-terminated, and is no longer expandable (see \fBfreeze()\fR in \fBstrstreambuf\fR). Until \fBstr()\fR is called, a dynamically allocated array would be automatically freed when the streambuf was destroyed. Afterward, the user is responsible for the array and when to free it. .\" .SS "strstream members" .TP .B "strstream()" Creates an empty bidirectional stream, which uses a dynamic (expandable) array of characters (see \fBssbuf\fR(3CC4). Seeks are permitted within the current bounds of the array. .TP .B "strstream(ptr, len, mode)" Creates a bidirectional stream using the static (non-expandable) array of \fBlen\fR characters starting at \fBptr\fR. If the \fBios::ate\fR or \fBios::app\fR bits are set in \fBmode\fR (see \fBios\fR(3CC4)), the array is assumed to contain a null-terminated string beginning at \fBptr\fR. Characters will be stored beginning at the null character, but will never go beyond \fBlen\fR characters. If those bits are not set in \fBmode\fR, the array is assumed to contain no data, and characters will be stored beginning at \fBptr\fR. Seeks are allowed within the range of the array. .TP .B "strstreambuf* ssbp = ss.rdbuf()" Returns a pointer to the \fBstrstreambuf\fR associated with \fBss\fR. This is the same as base class versions of this function, except that the return type is specifically a \fBstrstreambuf*\fR. .TP .B "char* ptr = ss.str()" Returns a pointer to the start of the underlying array, and freezes (see \fBstrstreambuf\fR(3C++)) the stream. If the array was dynamically allocated, it will not now be automatically deleted or null-terminated, and is no longer expandable (see \fBfreeze()\fR in \fBstrstreambuf\fR). Until \fBstr()\fR is called, a dynamically allocated array would be automatically freed when the streambuf was destroyed. Afterward, the user is responsible for the array and when to free it. .\" .SH "SEE ALSO" .LP .na .BR ios.intro (3CC4), .BR ios (3CC4), .BR istream (3CC4), .BR ostream (3CC4), .BR sbufpub (3CC4), .BR ssbuf (3CC4), .TP .I C++ Library Reference .TP Chapter 3, "The Classic \fIiostream\fR Library." .\" .TZ ????