GNU Info

Info Node: (iostream-295.info)Strings

(iostream-295.info)Strings


Prev: Files Up: Files and Strings
Enter node , (file) or (file)node

Reading and writing in memory
=============================

   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.

 - Constructor:  istrstream::istrstream (const char* STR [, int SIZE])
     Associate the new input string class `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.

 - Constructor:  ostrstream::ostrstream ()
     Create a new stream for output to a dynamically managed string,
     which will grow as needed.

 - Constructor:  ostrstream::ostrstream (char* STR, int SIZE [,int
          MODE])
     A new stream for output to a statically defined string of length
     SIZE, starting at STR.  You may optionally specify one of the
     modes described for `ifstream::ifstream'; if you do not specify
     one, the new stream is simply open for output, with mode
     `ios::out'.

 - Method: int ostrstream::pcount ()
     Report the current length of the string associated with this
     `ostrstream'.

 - Method: char* ostrstream::str ()
     A pointer to the string managed by this `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).

 - Method: void ostrstream::freeze ([int N])
     If N is nonzero (the default), declare that the string associated
     with this `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.

 - Method: int ostrstream::frozen ()
     Test whether `freeze(1)' is in effect for this string.

 - Method: strstreambuf* strstreambase::rdbuf ()
     A pointer to the underlying `strstreambuf'.


automatically generated by info2www version 1.2.2.9