class StringStream

extends Stream

Provides a way to access a string as if it were a stream

Description

This class inherits from the Stream class, so it supports all the basic Stream methods such as readln(), println(), etc. and it also supports many of the same methods that the FileStream class has such as seek(), eos(), truncate(), etc. It does not have the getDescriptor() method however, so you cannot include a StringStream object in a Select array (it wouldn't make any sense to do so anyway).

class attributes [NB. Highlighted attributes are static members]
function StringStream() - The constructor for the StringStream class
function eos() - Find out if the stream pointer is at the end of the string
function truncate() - Truncates the string to the specified length
function seek() - Sets the stream pointer to the specified position in the string
function length() - Returns the length of the string
function pos() - Returns the current stream pointer value
function toString() - Returns the string stored within the StringStream object as an ordinary string

Functions

function StringStream Click to go up to the list
The constructor for the StringStream class
Declaration:
    function StringStream(string s)
Description:
This function is the constructor for the StringStream class. You should supply it with the string you want to use for the Stream data. If you want to create an empty StringStream, you can supply it with an empty string (ie. "").
Parameters:
    Parameter #1: string s - The string to use for the stream data

function eos Click to go up to the list
Find out if the stream pointer is at the end of the string
Declaration:
    function eos()
Returns:
    True if the pointer is at the end of the string, false if not

function truncate Click to go up to the list
Truncates the string to the specified length
Declaration:
    function truncate(number length)
Returns:
    True on success or false on error

function seek Click to go up to the list
Sets the stream pointer to the specified position in the string
Declaration:
    function seek(number offset, number whence)
Description:
This function sets the stream pointer to the specified position in the stream. The whence parameter specifies where the offset is relative to. It can be one of: Sys.SEEK_SET (relative to the start of the string), Sys.SEEK_CUR (relative to the current stream position), or Sys.SEEK_END (relative to the end of the stream). seek() does not extend the string if the resulting stream position would be greater than the length of the string.
Parameters:
    Parameter #1: number offset - The amount to offset the pointer by
    Parameter #2: number whence - Where to offset the pointer relative to
Returns:
    True on success or false on error

function length Click to go up to the list
Returns the length of the string
Declaration:
    function length()
Returns:
    The length of the string

function pos Click to go up to the list
Returns the current stream pointer value
Declaration:
    function pos()
Returns:
    The position of the stream pointer within the string

function toString Click to go up to the list
Returns the string stored within the StringStream object as an ordinary string
Declaration:
    function toString()
Returns:
    The string from within the StringStream object.

Automatically generated at 8:45pm, Wednesday 08 January 2003 by feritedoc.