.\" ident @(#)strstream.3 .\" Standard Template Library .\" $$RW_INSERT_HEADER "slyrs.man" .TH strstream 3C++ "02 Apr 1998" "Rogue Wave Software" "-" .ce2 Standard C++ Library Copyright 1998, Rogue Wave Software, Inc. .SH NAME \f2strstream\fP \ - Reads and writes to an array in memory. .SH SYNOPSIS .br #include .br class strstream .br : public basic_iostream .SH DESCRIPTION The class strstream reads and writes to an array in memory. It uses a private strstreambuf object to control the associated array. It inherits from basic_iostream and therefore can use all the formatted and unformatted output and input functions. This is a deprecated feature and might not be available in future versions. .SH INTERFACE .br class strstream .br : public basic_iostream { .br .br public: .br .RE .RS 1 typedef char_traits traits; .RE .RS 4 .RE .RS 1 typedef char char_type; .br typedef typename traits::int_type int_type; .br typedef typename traits::pos_type pos_type; .br typedef typename traits::off_type off_type; .RE .RS 0 .RE .RS 1 strstream(); .br strstream(char *s, int n, .RE .RS 11 ios_base::openmode = .br ios_base::out | ios_base::in); .RE .RS 0 .RE .RS 1 void freeze(int freezefl = 1); .br int pcount() const; .RE .RS 0 .RE .RS 1 virtual ~strstream(); .br strstreambuf *rdbuf() const; .RE .RS 0 .RE .RS 1 char *str(); .RE .RS 0 .br }; .SH TYPES .br char_type .RE .RS 3 The type \f2char_type\fP is a synonym of type \f2char\fP. .RE .br int_type .RE .RS 3 The type \f2int_type\fP is a synonym of type\f2 traits::in_type\fP. .RE .br off_type .RE .RS 3 The type \f2off_type\fP is a synonym of type \f2traits::off_type\fP. .RE .br pos_type .RE .RS 3 The type \f2pos_type\fP is a synonym of type \f2traits::pos_type\fP. .RE .br traits .RE .RS 3 The type \f2traits\fP is a synonym of type \f2char_traits\fP. .RE .SH CONSTRUCTORS .br strstream(); .RE .RS 3 Constructs an object of class \f2strstream\fP, initializing the base class \f2basic_iostream\fP with the associated \f2strstreambuf\fP object. The \f2strstreambuf\fP object is initialized by calling its default constructor \f2strstreambuf()\fP. .RE .br strstream(char* s, int n, ios_base::openmode .RE .RS 9 mode = ios_base::out | ios_base::in); .RE .RS 3 Constructs an object of class \f2strstream\fP, initializing the base class \f2basic_iostream\fP with the associated \f2strstreambuf\fP object. The \f2strstreambuf\fP object is initialized by calling one of two constructors: .RS .5i .HP .5i - If \f2mode & app == 0\fP, calls \f2strstreambuf(s,n,s)\fP .HP .5i - Otherwise calls \f2strstreambuf(s,n,s + ::strlen(s))\fP.RE .RE .SH DESTRUCTORS .RE .RS 0 virtual ~strstream(); .RE .RS 3 Destroys an object of class \f2strstream\fP. .RE .SH MEMBER FUNCTIONS .br void .br freeze(int freezefl = 1); .RE .RS 3 If the mode is dynamic, alters the freeze status of the dynamic array object as follows: .RS .5i .HP .5i - If \f2freezefl\fP is \f2false\fP, the function sets the freeze status to \f2frozen\fP. .HP .5i - Otherwise, it clears the freeze status..RE .RE .RE .br int .br pcount() const; .RS 3 Returns the size of the output sequence. .RE .br strstreambuf* .br rdbuf() const; .RE .RS 3 Returns a pointer to the \f2strstreambuf\fP object associated with the stream. .RE .br char* .br str(); .RE .RS 3 Returns a pointer to the underlying array object, which may be null. .RE .SH EXAMPLES .br // .br // stdlib/examples/manual/strstream.cpp .br // .br #include .br using namespace std; .br .br void main ( ) .br { .RE .RS 1 using namespace std; .RE .RS 0 .RE .RS 2 // create a bi-directional strstream object .RE .RS 1 strstream inout; .RE .RS 0 .RE .RS 2 // output characters .RE .RS 1 inout << "Das ist die rede von einem man" << endl; .br inout << "C'est l'histoire d'un home" << endl; .br inout << "This is the story of a man" << endl; .RE .RS 0 .RE .RS 1 char p[100]; .RE .RS 0 .RE .RS 2 // extract the first line .RE .RS 1 inout.getline(p,100); .RE .RS 0 .RE .RS 2 // output the first line to stdout .RE .RS 1 cout << endl << "Deutch :" << endl; .br cout << p; .RE .RS 0 .RE .RS 2 // extract the second line .RE .RS 1 inout.getline(p,100); .RE .RS 0 .RE .RS 2 // output the second line to stdout .RE .RS 1 cout << endl << "Francais :" << endl; .br cout << p; .RE .RS 0 .RE .RS 2 // extract the third line .RE .RS 1 inout.getline(p,100); .RE .RS 0 .RE .RS 2 // output the third line to stdout .RE .RS 1 cout << endl << "English :" << endl; .br cout << p; .br .RE .RS 2 // output the all content of the .br // strstream object to stdout .RE .RS 1 cout << endl << endl << inout.str(); .RE .RS 0 .br } .SH SEE ALSO char_traits(3C++), ios_base(3C++), basic_ios(3C++), strstreambuf(3C++), istrstream(3C++), ostrstream(3c++) Working Paper for Draft Proposed International Standard for Information Systems--Programming Language C++, Annex D Compatibility features Section D.6.4 .SH STANDARDS CONFORMANCE ANSI X3J16/ISO WG21 Joint C++ Committee