Index  |  Related pages  |  Classes  |  Functions  |  Entities  |  Function Sets  |  Groups

ClassStringStream

class StringStream( [buffer] ) from \
    Stream

Memory based stream. more...


Member list

Constructor
init Initializes the StringStream
Methods
closeToString Close the stream and returns its contents.
getString Returns the data currently stored in the stream.

Detailed description

The StringStream class inherits from stream. It can be used to provide functions that are supposed to write to streams with a memory buffer; in example, variables may be serialized on a string stream which can be then written completely on a physical stream, or sent over the network, or written in a database blob field. The reverse is of course possible: a string can be read from any source and then used to construct a StringStream, that can be then fed to function expecting streams as parameters.

Of course, all the methods listed in the Stream class are available also here.

The StringStream is always available for read and write operations, and supports seek operations. Writing past the end of the stream will cause the StringStream to grow.


Class methods

init()

Initializes the StringStream

StringStream.init( [buffer] )
buffer

If the parameter is a numeric value, the constructor preallocates the given size. Writes up to buffer size won't require re-allocation, and the size will be used as a hint to grow the stream buffer sensibly.

If a string is provided, it is used as initial contents of the StringStream; subquesent reads will return the data contained in the string.

closeToString()

Close the stream and returns its contents.

StringStream.closeToString( )
Returns:

The stream contents.

Closes the stream and returns the contents of the stream as a string. The object is internally destroyed, and the whole content is transformed into the returned string. In this way, an extra allocation and copy can be spared.

getString()

Returns the data currently stored in the stream.

StringStream.getString( )
Returns:

A copy of the contents of this stream.

The data currently held in the stream is left untouched, and a new copy of the data is returned.


Index  |  Related pages  |  Classes  |  Functions  |  Entities  |  Function Sets  |  Groups
Made with Faldoc 1.0.0