Aztec® Programming Language
Version 1.1 Alpha 2

Copyright © 2010-2017, Aztec Development Group, All Rights Reserved

Download Aztec

Search        Contact Us

It's before my time... but I've been told.

He never came back from Copperhead Road.

- Steve Earl

 

aztec.io.FilterStream

public class FilterStream from<StreamIO>

Base

StreamIO

FilterStream

The FilterStream class provides a base framework for filtering data streams and for adding other functionality to streams. A filter stream does not have its own data source like FileStream or SocketStream. A filter stream requires the use of another stream (called the "associated stream").

 

All I/O operations which are performed on the filter stream are actually performed on the associated stream. This class overrides all pertinent methods from the StreamIO base class, and redirects the same request over to the associated stream instead. Any class which is derived from FilterStream can override any or all of the I/O methods, or it can add new methods to provided added functionality to a stream.

 

Keep in mind that a filter stream can be used with any type of "associated stream" (file, memory, socket). It doesn't care what type of stream it's dealing with.

FilterStream Methods

FilterStream() Constructor for the FilterStream class using an "associated stream" object
BytesAvailable() Virtual method to return the number of bytes available to read before end of buffer
Pos() Virtual method to return the current position within the associated stream
SetPos() Virtual method to set the current position within the associated stream
DirectAccess() Virtual method to return true or false for DirectAccess mode based on associated stream
EndOfStream() Virtual method to return true if currently at end of associated stream
Read() Virtual method to read a single 8 byte integer from the associated stream
Read() Virtual method to read a single "small" integer from the associated stream (1, 2 or 4 bytes)
Read() Virtual method to read a single float from the associated stream (4 or 8 bytes)
Read() Virtual method to read a text string from the associated stream (default length or specific length)
Read() Virtual method to read a boolean from the associated stream
Read() Virtual method to read a binary buffer (stream) from the associated stream
Write() Virtual method to write a single 8 byte integer to the associated stream
Write() Virtual method to write a single "small" integer to the associated stream (1, 2 or 4 bytes)
Write() Virtual method to write a single float to the associated stream (4 or 8 bytes)
Write() Virtual method to write a single text string (default or specific length)
Write() Virtual method to write a single boolean to the associated stream
Write() Virtual method to write a binary buffer (stream) to the associated stream

Derived Classes

See Also

 


FilterStream()

public method FilterStream(StreamIO AssociatedStream)

Parameters

AssociatedStream

Stream object associated with this filter stream

Return Value

None

Description

Constructor for the FilterStream class. The "associated stream" is specified as the only argument. The I/O type (ReadOnly, WriteOnly or ReadWrite) is determined from the associated stream and is passed into the constructor for 'StreamIO'.

 

All I/O operations performed on a filter stream (any class derived from FilterStream) are actually performed on the associated stream behind the scenes.

 

FilterStream Class


BytesAvailable()

public virtual method<int> BytesAvailable()

Parameters

None

Return Value

Number of bytes available to read

Description

Returns the number of bytes available to read from the associated stream. It is based on the current pointer position and the total size of the buffer.

 

FilterStream Class


Pos()

public virtual method<int> Pos()

Parameters

None

Return Value

Current read/write pointer position

Description

Virtual method to return the current pointer position within the associated stream (one based). The next read or write operation takes place at this position.

 

FilterStream Class


SetPos()

public virtual method<bool> SetPos(int PointerPosition)

Parameters

PointerPosition

One based position in stream to read/write

Return Value

true if successul

Description

Virtual method to set the current read/write pointer position with the associated stream (one based), if applicable (based on "direct access"). The next read or write operation will take place at this position.

 

FilterStream Class


DirectAccess()

public virtual method<bool> DirectAccess()

Parameters

None

Return Value

Returns value of "direct access" flag

Description

Virtual method to return the direct access mode of the associated stream.

 

FilterStream Class


EndOfStream()

public virtual method<bool> EndOfStream()

Parameters

None

Return Value

Returns true if at end of stream

Description

Virtual method to return the value of the "end of stream" flag. If there are no bytes available in the associated stream to read, this method returns true and false if there are one or more bytes available to read.

 

FilterStream Class


Read()

public virtual method Read(int ref IntBucket, bool PeekOnly = false)

Parameters

IntBucket

Integer reference to receive the value

PeekOnly

If true, peek without reading/removing

Return Value

None

Description

Virtual method to read a single binary 8 byte integer value from the associated stream and copy the value into the IntBucket..

 

If the stream is specified as "WriteMode", this method will fire a StreamException.

 

FilterStream Class


Read()

public virtual method Read(int ref IntBucket, SmallInt IntSizeEnum, bool IsSigned = true, bool PeekOnly = false)

Parameters

IntBucket

Integer reference to receive the value

IntSizeEnum

Enumeration to indicate 1, 2 or 4 byte integer

IsSigned

Treat as signed integer If true, and unsigned if false (default is false)

PeekOnly

Peek without reading/removing if true (default is false)

Return Value

None

Description

Virtual method to read a single "small" binary integer value from the associated stream and copy the value into the IntBucket. The size of the integer read operation is specified by IntSizeEnum, and represents 1, 2 or 4 bytes. The "IsSigned" flag is also used to affect how the binary integer buffer is interpreted, signed or unsiged.

 

If the stream is specified as "WriteMode", this method will fire a StreamException.

 

FilterStream Class


Read()

public virtual method Read(float ref FloatBucket, bool Read32BitFloat = false, bool PeekOnly = false)

Parameters

FloatBucket

Float reference to receive the value

Read32BitFloat

Read 32 bit (4 byte) float if true (default is false)

PeekOnly

If true, read without advancing pointer

Return Value

None

Description

Virtual method to read a single binary floating point value from the associated stream and copy the value into the FloatBucket. The default size of the float read operation is 8 bytes, but can be changed to 4 bytes by setting the "Read32BitFloat" flag. If the "PeekOnly" flag is true, the value is read but the pointer position is not advanced, so the next read operation will read the same data.

 

If the stream is specified as "WriteMode", this method will fire a StreamException.

 

FilterStream Class


Read()

public virtual method Read(string ref StringBucket, bool ExtractLength = true, int ReadSize = 0, bool PeekOnly = false)

Parameters

StringBucket

String reference to receive the value

ExtractLength

Read the string length from the stream if true

ReadSize

Size of the read operation if ExtractLength is false

PeekOnly

If true, read without advancing pointer

Return Value

None

Description

Virtual method to read a single string from the associated stream and copy the value into the StringBucket. This supports reading a variable length string, and there are two ways of handling this. If the "ExtractLength" flag is true, the size of the string is actually read from the stream (as a 4 byte integer) and then the string read operation is dictacted by that size. If the "ExtractLength" flag is false, the "ReadSize" value is then used to dictate the length of the string to be read.

 

If the "PeekOnly" flag is true, the value is read but the pointer position is not advanced, so the next read operation will read the same data.

 

If the stream is specified as "WriteMode", this method will fire a StreamException.

 

FilterStream Class


Read()

public virtual method Read(bool ref BoolBucket, bool PeekOnly = false)

Parameters

BoolBucket

Boolean reference to receive the value

PeekOnly

If true, read without advancing pointer

Return Value

None

Description

Virtual method to read a single binary boolean value from the associated stream and copy the value into the BoolBucket. It is read as a one byte value. If the "PeekOnly" flag is true, the value is read but the pointer position is not advanced, so the next read operation will read the same data.

 

If the stream is specified as "WriteMode", this method will fire a StreamException.

 

FilterStream Class


Read()

public virtual method Read(StreamIO StreamBucket, int ReadSize = 0, bool PeekOnly = false)

Parameters

StreamBucket

Stream reference to receive the data

ReadSize

Size of the binary read operation

PeekOnly

If true, read without advancing pointer

Return Value

None

Description

Virtual method to read a binary block of data from the associated stream and write it into the target stream (StreamBucket). The size of the read operation is specified. If the target stream supports "random access", the data is written at the current pointer position within that target stream. If the "PeekOnly" flag is true, the value is read but the pointer position is not advanced, so the next read operation will read the same data.

 

If the ReadSize is specified as zero, the read operation goes all the way to the end of the associated stream.

 

If the stream is specified as "WriteMode", this method will fire a StreamException.

 

FilterStream Class


Write()

public virtual method Write(int Value)

Parameters

Value

Integer value to be written

Return Value

None

Description

Virtual method to write a single 8 byte binary integer value to the associated stream.

 

If the stream is specified as "ReadMode", this method will fire a StreamException.

 

FilterStream Class


Write()

public virtual method Write(int Value, SmallInt IntSizeEnum)

Parameters

Value

Integer value to be written

IntSizeEnum

Enumeration to indicate 1, 2 or 4 byte integer

Return Value

None

Description

Virtual method to write a single "small" binary integer value to the associated stream. The size of the integer write operation is specified by IntSizeEnum, and represents 1, 2 or 4 bytes. The integer value must fit within one of the two valid ranges for the integer size that was specified. For each integer size, there is a valid "signed" range and a separate value "unsigned" range. Refer to the 'int' class documention for more details.

 

If the stream is specified as "ReadMode", this method will fire a StreamException.

 

FilterStream Class


Write()

public virtual method Write(float Value, bool Write32BitFloat = false)

Parameters

Value

Float value to be written

Write32BitFloat

Write 32 bit (4 byte) float if true (default is false)

Return Value

None

Description

Virtual method to write a single binary floating point value to the associated stream. The default size of the float write operation is 8 bytes, but can be changed to 4 bytes by setting the "Write32BitFloat" flag. If the "Write32BitFlag" is set, the floating point value must fit within the valid range for a 4 byte float. Refer to the 'float' class documention for more details.

 

If the stream is specified as "ReadMode", this method will fire a StreamException.

 

FilterStream Class


Write()

public virtual method Write(string Value, bool EmbedLength = true, int OverrideLength = 0)

Parameters

Value

String value to be written to stream

EmbedLength

If true, embed string length into stream before the string

OverrideLength

Override length for string to be written

Return Value

None

Description

Virtual method to write a single string to the associated stream. If the "EmbedLength" flag is true, the length of the string is embedded in the stream before the text string itself (as a 4 byte integer). By default, the entire string is written to the stream, but if "OverrideLength" is greater than zero, then the override length will be used instead.

 

If the stream is specified as "ReadMode", this method will fire a StreamException.

 

FilterStream Class


Write()

public virtual method Write(bool Value)

Parameters

Value

Boolean value to be written

Return Value

None

Description

Virtual method to write a single binary boolean value to the associated stream. It is written as a one byte integer value repesenting the enumeration index.

 

If the stream is specified as "ReadMode", this method will fire a StreamException.

 

FilterStream Class


Write()

public virtual method Write(StreamIO SourceStream, int WriteSize = 0)

Parameters

SourceStream

Source stream reference

WriteSize

Size of the binary write operation

Return Value

None

Description

Virtual method to read a binary block of data from the source stream and write it into this associated stream. The size of the read and write operation is specified by "WriteSize". If the source stream supports "random access", the data is read from the current pointer position within that source stream and then written into this associated stream (at current pointer position). If the WriteSize is specified as zero, the read operation from the source stream goes all the way to the end of that stream.

 

If the stream is specified as "ReadMode", this method will fire a StreamException.

 

FilterStream Class

 

Copyright © 2010-2017

Aztec Development Group

All Rights Reserved

Download Aztec