Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

strstreambuf(3C++)

ios(3C++)

istream(3C++)

ostream(3C++)






       strstream(3C++)                                      strstream(3C++)


       NAME
             strstream - iostream specialized to arrays

       SYNOPSIS
             #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 strstreambase : public virtual ios {
                    ...
             } ;

             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();
             };


       DESCRIPTION
             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
             strstreambuf(3C++)).


                           Copyright 1994 Novell, Inc.               Page 1













      strstream(3C++)                                      strstream(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*.

         Constructors
            istrstream(cp)
                  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, len)
                  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,n,mode)
                  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,n,mode)
                  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.  Note that, if mode is set to
                  ios::in|ios::out, the original string (if any) stored at
                  cp will not be accessible unless seeks


                          Copyright 1994 Novell, Inc.               Page 2













       strstream(3C++)                                      strstream(3C++)


                   (ostream::seekp()) are used to adjust the put pointer.

          istrstream members
             ssb = iss.rdbuf()
                   Returns the strstreambuf associated with iss.

          ostrstream members
             ssb = oss.rdbuf()
                   Returns the strstreambuf associated with oss.

             cp=oss.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.

             i=oss.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.str() does not point to a null
                   terminated string.

          strstream members
             ssb  = ss.rdbuf()
                   Returns the strstreambuf associated with ss.

             cp=ss.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.

       REFERENCES
             strstreambuf(3C++), ios(3C++), istream(3C++), ostream(3C++)




                           Copyright 1994 Novell, Inc.               Page 3








Typewritten Software • bear@typewritten.org • Edmonds, WA 98026