The classes istrstream
, ostrstream
, and strstream
provide some additional features for reading and writing strings in memory---both static strings, and dynamically allocated strings. The underlying class strstreambase
provides some features common to all three; strstreambuf
underlies that in turn.
istrstream
with an existing static string starting at str, of size size. If you do not specify size, the string is treated as a NUL
terminated string.
ifstream::ifstream
; if you do not specify one, the new stream is simply open for output, with mode ios::out
.
ostrstream
.
ostrstream
. Implies `ostrstream::freeze()'. Note that if you want the string to be nul-terminated, you must do that yourself (perhaps by writing ends to the stream).
ostrstream
is not to change dynamically; while frozen, it will not be reallocated if it needs more space, and it will not be deallocated when the ostrstream
is destroyed. Use `freeze(1)' if you refer to the string as a pointer after creating it via ostrstream
facilities.
`freeze(0)' cancels this declaration, allowing a dynamically allocated string to be freed when its ostrstream
is destroyed.
If this ostrstream
is already static---that is, if it was created to manage an existing statically allocated string---freeze
is unnecessary, and has no effect.
freeze(1)
is in effect for this string.
strstreambuf
.