STRSTREAM(3C++) STRSTREAM(3C++)
strstream - iostream specialized to arrays
#include <strstream.h>
class ios {
public:
enum open_mode { in, out, ate, app, trunc, nocreate, noreplace } ;
// and lots of other stuff, see ios(3C++) ...
} ;
class istrstream : public istream {
public:
istrstream(char*) ;
istrstream(char*, int) ;
strstreambuf*rdbuf() ;
} ;
class ostrstream : public ostream {
public:
ostrstream();
ostrstream(char*, int, int=ios::out) ;
int pcount() ;
strstreambuf*rdbuf() ;
char* str();
};
class strstream : public strstreambase, public iostream {
public:
strstream();
strstream(char*, int, int mode);
strstreambuf*rdbuf() ;
char* str();
};
strstream specializes iostream for ``incore'' operations, that is,
storing and fetching from arrays of bytes. The streambuf associated with
a strstream is a strstreambuf (see ssbuf(3C++)).
In the following descriptions assume:
- ss is a strstream.
- iss is an istrstream.
- oss is an ostrstream.
- cp is a char*.
- mode is an int representing an open_mode.
- i and len are ints.
- ssb is a strstreambuf*.
Page 1
STRSTREAM(3C++) STRSTREAM(3C++)
Constructors [Toc] [Back]
istrstream(cp<b>)
Characters will be fetched from the (null-terminated) string
cp. The terminating null character will not be part of the
sequence. Seeks (istream::seekg()) are allowed within that
space.
istrstream(cp<b>, len<b>)
Characters will be fetched from the array beginning at cp and
extending for len bytes. Seeks (istream::seekg()) are allowed
anywhere within that array.
ostrstream()
Space will be dynamically allocated to hold stored characters.
ostrstream(cp<b>,n<b>,mode<b>)
Characters will be stored into the array starting at cp and
continuing for n bytes. If ios::ate or ios::app is set in
mode, cp is assumed to be a null-terminated string and storing
will begin at the null character. Otherwise storing will begin
at cp. Seeks are allowed anywhere in the array.
strstream()
Space will be dynamically allocated to hold stored characters.
strstream(cp<b>,n<b>,mode<b>)
Characters will be stored into the array starting at cp and
continuing for n bytes. If ios::ate or ios::app is set in
mode, cp is assumed to be a null-terminated string and storing
will begin at the null character. Otherwise storing will begin
at cp. Seeks are allowed anywhere in the array.
istrstream members
ssb <b>= iss<b>.rdbuf()
Returns the strstreambuf associated with iss.
ostrstream members
ssb <b>= oss<b>.rdbuf()
Returns the strstreambuf associated with oss.
cp<b>=oss<b>.str()
Returns a pointer to the array being used and ``freezes'' the
array. Once str has been called the effect of storing more
characters into oss is undefined. If oss was constructed with
an explicit array, cp is just a pointer to the array.
Otherwise, cp points to a dynamically allocated area. Until
str is called, deleting the dynamically allocated area is the
responsibility of oss. After str returns, the array becomes
the responsibility of the user program.
Page 2
STRSTREAM(3C++) STRSTREAM(3C++)
i<b>=oss<b>.pcount()
Returns the number of bytes that have been stored into the
buffer. This is mainly of use when binary data has been stored
and oss<b>.str() does not point to a null terminated string.
strstream members
ssb <b>= ss<b>.rdbuf()
Returns the strstreambuf associated with ss.
cp<b>=ss<b>.str()
Returns a pointer to the array being used and ``freezes'' the
array. Once str has been called the effect of storing more
characters into ss is undefined. If ss was constructed with an
explicit array, cp is just a pointer to the array. Otherwise,
cp points to a dynamically allocated area. Until str is
called, deleting the dynamically allocated area is the
responsibility of ss. After str returns, the array becomes the
responsibility of the user program.
strstreambuf(3C++), ios(3C++) istream(3C++) ostream(3C++)
PPPPaaaaggggeeee 3333 [ Back ]
|