Standard C++ Library
Copyright 1998, Rogue Wave Software, Inc.
NAME
strstream
- Reads and writes to an array in memory.
SYNOPSIS
#include <strstream>
class strstream
: public basic_iostream<char>
DESCRIPTION
The class strstream reads and writes to an array in memory.
It uses a private strstreambuf object to control the associ-
ated array. It inherits from basic_iostream<char> and there-
fore can use all the formatted and unformatted output and
input functions.
This is a deprecated feature and might not be available in
future versions.
INTERFACE
class strstream
: public basic_iostream<char> {
public:
typedef char_traits<char> traits;
typedef char char_type;
typedef typename traits::int_type int_type;
typedef typename traits::pos_type pos_type;
typedef typename traits::off_type off_type;
strstream();
strstream(char *s, int n,
ios_base::openmode =
ios_base::out | ios_base::in);
void freeze(int freezefl = 1);
int pcount() const;
virtual ~strstream();
strstreambuf *rdbuf() const;
char *str();
};
TYPES
char_type
The type char_type is a synonym of type char.
int_type
The type int_type is a synonym of type traits::in_type.
off_type
The type off_type is a synonym of type traits::off_type.
pos_type
The type pos_type is a synonym of type traits::pos_type.
traits
The type traits is a synonym of type char_traits<char>.
CONSTRUCTORS
strstream();
Constructs an object of class strstream, initializing the
base class basic_iostream<char> with the associated
strstreambuf object. The strstreambuf object is initial-
ized by calling its default constructor strstreambuf().
strstream(char* s, int n, ios_base::openmode
mode = ios_base::out | ios_base::in);
Constructs an object of class strstream, initializing the
base class basic_iostream<char> with the associated
strstreambuf object. The strstreambuf object is initial-
ized by calling one of two constructors:
- If mode & app == 0, calls strstreambuf(s,n,s)
- Otherwise calls strstreambuf(s,n,s +
::strlen(s)).RE
DESTRUCTORS
virtual ~strstream();
Destroys an object of class strstream.
MEMBER FUNCTIONS
void
freeze(int freezefl = 1);
If the mode is dynamic, alters the freeze status of the
dynamic array object as follows:
- If freezefl is false, the function sets the
freeze status to frozen.
- Otherwise, it clears the freeze status..RE
int
pcount() const;
Returns the size of the output sequence.
strstreambuf*
rdbuf() const;
Returns a pointer to the strstreambuf object associated
with the stream.
char*
str();
Returns a pointer to the underlying array object, which
may be null.
EXAMPLES
//
// stdlib/examples/manual/strstream.cpp
//
#include<strstream>
using namespace std;
void main ( )
{
using namespace std;
// create a bi-directional strstream object
strstream inout;
// output characters
inout << "Das ist die rede von einem man" << endl;
inout << "C'est l'histoire d'un home" << endl;
inout << "This is the story of a man" << endl;
char p[100];
// extract the first line
inout.getline(p,100);
// output the first line to stdout
cout << endl << "Deutch :" << endl;
cout << p;
// extract the second line
inout.getline(p,100);
// output the second line to stdout
cout << endl << "Francais :" << endl;
cout << p;
// extract the third line
inout.getline(p,100);
// output the third line to stdout
cout << endl << "English :" << endl;
cout << p;
// output the all content of the
// strstream object to stdout
cout << endl << endl << inout.str();
}
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 Com-
patibility features Section D.6.4
STANDARDS CONFORMANCE
ANSI X3J16/ISO WG21 Joint C++ Committee