.\" ident @(#)basic_stringstream.3 .\" Standard Template Library .\" $$RW_INSERT_HEADER "slyrs.man" .TH basic_stringstream 3C++ "02 Apr 1998" "Rogue Wave Software" "-" .ce2 Standard C++ Library Copyright 1998, Rogue Wave Software, Inc. .SH NAME \f2basic_stringstream\fP, \f2stringstream\fP \ - Supports writing and reading objects of class basic_string to/from an array in memory. .SH SYNOPSIS .br #include .br template, .RE .RS 8 class Allocator = allocator > .RE .RS 0 class basic_stringstream .br : public basic_iostream .SH DESCRIPTION The template class basic_stringstream reads and writes to an array in memory. It supports writing and reading objects of class basic_string. It uses a \f2basic_stringbuf \fPobject to control the associated storage. It inherits from basic_iostream_and therefore can use all the formatted and unformatted output and input functions. .SH INTERFACE .br template, .RE .RS 8 class Allocator = allocator > .RE .RS 0 class basic_stringstream .br : public basic_iostream { .br public: .RE .RS 1 typedef traits traits_type; .br typedef charT 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 typedef basic_stringbuf sb_type; .br typedef basic_ios ios_type; .br typedef basic_string .RE .RS 9 string_type; .RE .RS 0 .RE .RS 1 explicit basic_stringstream(ios_base::openmode which = .RE .RS 29 ios_base::out | ios_base::in); .RE .RS 0 .RE .RS 1 explicit basic_stringstream(const string_type& str, .RE .RS 29 ios_base::openmode which = .br ios_base::out | ios_base::in); .RE .RS 0 .RE .RS 1 virtual ~basic_stringstream(); .RE .RS 0 .RE .RS 1 basic_stringbuf *rdbuf() const; .br string_type str() const; .br void str(const string_type& str); .RE .RS 0 .br }; .SH TYPES .br char_type .RE .RS 3 The type \f2char_type\fP is a synonym for the template parameter \f2charT\fP. .RE .br int_type .RE .RS 3 The type \f2int_type\fP is a synonym of type \f2traits::in_type\fP. .RE .br ios_type .RE .RS 3 The type\f2 ios_type\fP is an instantiation of class \f2basic_ios \fPon type \f2charT\fP. .RE .br off_type .RE .RS 3 The type\f2 off_type\fP is a synonym of type\f2 traits::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 sb_type .RE .RS 3 The type \f2sb_type\fP is an instantiation of class \f2basic_stringbuf\fP on type \f2charT\fP. .RE .br string_type .RE .RS 3 The type \f2string_type\fP is an instantiation of class \f2basic_string\fP on type \f2charT\fP. .RE .br stringstream .RE .RS 3 The type \f2stringstream\fP is an instantiation of class \f2basic_stringstream\fP on type \f2char\fP: \f2typedef basic_stringstream stringstream;\fP .RE .br traits_type .RE .RS 3 The type \f2traits_type\fP is a synonym for the template parameter \f2traits\fP. .RE .br wstringstream .RE .RS 3 The type \f2wstringstream\fP is an instantiation of class \f2basic_stringstream\fP on type \f2wchar_t:\fP \f2typedef basic_stringstream wstringstream;\fP .RE .SH CONSTRUCTORS .br explicit basic_stringstream(ios_base::openmode which = .RE .RS 18 ios_base::in | ios_base::out); .RE .RS 3 Constructs an object of class \f2basic_stringstream\fP, initializing the base class \f2basic_iostream\fP with the associated string buffer. The string buffer is initialized by calling the \f2basic_stringbuf\fP constructor \f2basic_stringbuf(which).\fP .RE .RE .RS 0 explicit basic_stringstream(const string_type& str, .RE .RS 18 ios_base::openmode which = .br ios_base::in | ios_base::out); .RE .RS 3 Constructs an object of class \f2basic_stringstream\fP, initializing the base class \f2basic_iostream\fP with the associated string buffer. The string buffer is initialized by calling the \f2basic_stringbuf\fP constructor \f2basic_stringbuf(str,which)\fP. .RE .SH DESTRUCTORS .RE .RS 0 virtual ~basic_stringstream(); .RE .RS 3 Destroys an object of class \f2basic_stringstream\fP. .RE .SH MEMBER FUNCTIONS .br basic_stringbuf* .br rdbuf() const; .RE .RS 3 Returns a pointer to the \f2basic_stringbuf\fP associated with the stream. .RE .br string_type .br str() const; .RE .RS 3 Returns a string object of type \f2string_type\fP whose contents is a copy of the underlying buffer contents. .RE .br void .br str(const string_type& str); .RE .RS 3 Clears the string buffer and copies the string object \f2str\fP into it. If the opening mode is \f2in\fP, initializes the input sequence to point to the first character of the buffer. If the opening mode is \f2out\fP, initializes the output sequence to point to the first character of the buffer. If the opening mode is \f2out | app\fP, initializes the output sequence to point to the last character of the buffer. .RE .SH EXAMPLE .br // .br // stdlib/examples/manual/stringstream.cpp .br // .br #include .br #include .br .br void main ( ) .br { .RE .RS 1 using namespace std; .RE .RS 0 .RE .RS 2 // create a bi-directional wstringstream object .RE .RS 1 wstringstream inout; .RE .RS 0 .RE .RS 2 // output characters .RE .RS 1 inout << L"Das ist die rede von einem man" << endl; .br inout << L"C'est l'histoire d'un home" << endl; .br inout << L"This is the story of a man" << endl; .RE .RS 0 .RE .RS 1 wchar_t 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 wcout << endl << L"Deutch :" << endl; .br wcout << 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 wcout << endl << L"Francais :" << endl; .br wcout << 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 wcout << endl << L"English :" << endl; .br wcout << p; .br .RE .RS 2 // output the all content of the .br //wstringstream object to stdout .RE .RS 1 wcout << endl << endl << inout.str(); .RE .RS 0 } .SH SEE ALSO char_traits(3C++), ios_base(3C++), basic_ios(3C++), basic_stringbuf(3C++), basic_string(3C++), basic_istringstream(3C++), basic_ostringstream(3c++) Working Paper for Draft Proposed International Standard for Information Systems--Programming Language C++, Section 27.7.3 .SH STANDARDS CONFORMANCE ANSI X3J16/ISO WG21 Joint C++ Committee