Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>strstream::strstream</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
strstream::strstream

Usage

   #include <sstream.hpp>
   strstreambuf(int = default_allocation);
   strstreambuf(char *memory, int length = 0, char *put_area = 0);
   strstreambuf(void *(*allocator)(size_t),    void
   (*deallocator)(void *), int = default_allocation);

Description

   The first constructor creates an empty strstreambuf in dynamic allocation
   mode. Memory will be allocated as required starting with an allocation of
   the size specified by the argument, defaulted to 32 bytes. Subsequent
   allocations will increase the size of the strstreambuf by a factor of
   3/2. The get and put areas of such a streambuf are contiguous. It will
   not be possible to get characters until some have been put.

   The second constructor creates a strstreambuf to use a user nominated
   area of memory. There will be no dynamic reallocation. If length is
   positive, then the length bytes starting at memory are used. If length is
   zero, then memory is assumed to point at a null terminated string, and

   strlen(memory) bytes will be used. If length is negative, the memory
   region is assumed to be of indefinite length. The put area argument is
   used to divide up the strstreambuf into get and put areas. If put_area is
   zero or less than memory, then attempts to put to the strstreambuf will
   be treated as errors, and the whole of the memory is a get area. If
   put_area is greater than memory, then the area between memory and
   put_area is the get area, and the area pointed at by put_area is the put
   area.

   The third constructor is similar to the first except that the allocator
   and deallocator functions required to manage the dynamic allocation can
   be specified.

Example 

   strstreambuf ssb1;  // dynamic

   char buffer[1024];
   ...;

   strstreambuf ssb2(buffer,1024,buffer+512);
                           // half get, half put

   strstreambuf ssb3(buffer,1024,buffer);
                           // no get area

   strstreambuf ssb4(0, -1);
                           // arbitrary get source

   strstreambuf ssb2("abcdefghijklmnopqrstuvwxyz")
                           // get only, length is strlen() - 26





Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson