description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: ostrstream Class |
ostrstream Class |
11/04/2016 |
|
|
e2e34679-b266-4728-a8e1-8eda5d400e46 |
Describes an object that controls insertion of elements and encoded objects into a stream buffer of class strstreambuf.
class ostrstream : public ostream
The object stores an object of class strstreambuf
.
Note
This class is deprecated. Consider using ostringstream or wostringstream instead.
Constructor | Description |
---|---|
ostrstream | Constructs an object of type ostrstream . |
Member function | Description |
---|---|
freeze | Causes a stream buffer to be unavailable through stream buffer operations. |
pcount | Returns a count of the number of elements written to the controlled sequence. |
rdbuf | Returns a pointer to the stream's associated strstreambuf object. |
str | Calls freeze, and then returns a pointer to the beginning of the controlled sequence. |
Header: <strstream>
Namespace: std
Causes a stream buffer to be unavailable through stream buffer operations.
void freeze(bool _Freezeit = true);
_Freezeit
A bool
indicating whether you want the stream to be frozen.
The member function calls rdbuf -> freeze(_ Freezeit).
See strstream::freeze for an example that uses freeze
.
Constructs an object of type ostrstream
.
ostrstream();
ostrstream(char* ptr,
streamsize count,
ios_base::openmode _Mode = ios_base::out);
ptr
The buffer.
count
The size of the buffer in bytes.
_Mode
The input and output mode of the buffer. See ios_base::openmode for more information.
Both constructors initialize the base class by calling ostream(sb), where sb
is the stored object of class strstreambuf. The first constructor also initializes sb
by calling strstreambuf
. The second constructor initializes the base class one of two ways:
-
If
_Mode
& ios_base::app== 0, thenptr
must designate the first element of an array ofcount
elements, and the constructor callsstrstreambuf
(ptr
,count
,ptr
). -
Otherwise,
ptr
must designate the first element of an array of count elements that contains a C string whose first element is designated byptr
, and the constructor callsstrstreambuf
(ptr
,count
,ptr
+strlen
(ptr
) ).
Returns a count of the number of elements written to the controlled sequence.
streamsize pcount() const;
The number of elements written to the controlled sequence.
The member function returns rdbuf -> pcount.
See strstream::pcount for a sample that uses pcount
.
Returns a pointer to the stream's associated strstreambuf object.
strstreambuf *rdbuf() const
A pointer to the stream's associated strstreambuf object.
The member function returns the address of the stored stream buffer of type pointer
to strstreambuf.
See strstreambuf::pcount for a sample that uses rdbuf
.
Calls freeze, and then returns a pointer to the beginning of the controlled sequence.
char *str();
A pointer to the beginning of the controlled sequence.
The member function returns rdbuf -> str.
See strstream::str for a sample that uses str
.
ostream
Thread Safety in the C++ Standard Library
iostream Programming
iostreams Conventions