Class StringStream

Memory based stream.

class StringStream( [buffer] ) \ from Stream

more...

Summary

closeToString()Close the stream and returns its contents.
getString()Returns the data currently stored in the stream.

Inherited properties

encoding from Stream Name of the set encoding, if given, for text operations
eolMode from Stream Mode of EOL conversion in text operations.

Inherited methods

clone from Stream Clone the stream handle.
close from Stream Closes the stream.
eof from Stream Checks if the last read operation hit the end of the file.
errorDescription from Stream Returns a system specific textual description of the last error.
flush from Stream Flushes a stream.
getBuffering from Stream Returns the size of I/O buffering active on this stream.
grab from Stream Grabs binary data from the stream.
grabLine from Stream Grabs a line of text encoded data.
grabText from Stream Grabs text encoded data from the stream.
isOpen from Stream Checks if the stream is currently open.
lastError from Stream Return the last system error.
lastMoved from Stream Return the amount of data moved by the last operation.
read from Stream Reads binary data from the stream.
readAvailable from Stream Checks if data can be read, or wait for available data.
readLine from Stream Reads a line of text encoded data.
readText from Stream Reads text encoded data from the stream.
seek from Stream Moves the file pointer on seekable streams.
seekCur from Stream Moves the file pointer on seekable streams relative to current position.
seekEnd from Stream Moves the file pointer on seekable streams relative to end of file.
setBuffering from Stream Set the buffering state of this stream.
setEncoding from Stream Set the text encoding and EOL mode for text-based operations.
tell from Stream Return the current position in a stream.
truncate from Stream Resizes a file.
write from Stream Write binary data to a stream.
writeAvailable from Stream Checks if data can be written, or wait until it's possible to write.
writeText from Stream Write text data to a stream.

Detailed description

class StringStream( [buffer] ) \ from Stream

bufferThe buffer that will be used as stream

Memory based stream.

The StringStream class inherits from stream. It can be used to provide functions that are supposed to write to streams with a memory buffer; for 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.

If the parameter buffer 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; subsequent reads will return the data contained in the string.

Methods

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.


Made with faldoc 2.2.0