Aztec® Programming Language
Version 1.1 Alpha 2

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

Download Aztec

Search        Contact Us

And the beards have all grown longer overnight.

- Pete Townshend

 

aztec.io.StreamIO

public class StreamIO from<Base>

Base

StreamIO

The StreamIO class is an abstract class which provides a general purpose framework for binary input/output using streams such as files, sockets and memory buffers. A stream object can perform read and write operations, and the type of operations supported are specified by the IOType in the constructor (ReadMode, WriteMode or ReadWriteMode).

 

A critical error which occurs during stream I/O operations will cause a StreamException object to be fired.

StreamIO Methods

StreamIO() Constructor for the StreamIO class
IOMode() Method to return the I/O mode for this stream (Read, Write, ReadWrite)
BytesAvailable() Abstract method to return the number of bytes available to read
Pos() Virtual method to return the current position within the stream
SetPos() Virtual method to set the current position within the stream
DirectAccess() Virtual method to return true if Direct Access I/O is available and false if not (false by default)
EndOfStream() Abstract method to return true if currently at end of stream
Read() Abstract method to read a single 8 byte integer from the stream
Read() Abstract method to read a single "small" integer from the stream (1, 2 or 4 bytes)
Read() Abstract method to read a single float from the stream (4 or 8 bytes)
Read() Abstract method to read a text string from the stream (default length or specific length)
Read() Abstract method to read a boolean from the stream
Read() Abstract method to read a binary buffer (stream) from the stream
Write() Abstract method to write a single 8 byte integer to the stream
Write() Abstract method to write a single "small" integer to the stream (1, 2 or 4 bytes)
Write() Abstract method to write a single float to the stream (4 or 8 bytes)
Write() Abstract method to write a single text string (default or specific length)
Write() Abstract method to write a single boolean to the stream
Write() Abstract method to write a binary buffer (stream) to the stream

StreamIO Constants

Constant Data Item Data Type Value
StreamIO.ReadMode int 1
StreamIO.WriteMode int 2
StreamIO.ReadWriteMode int 3

Derived Classes

See Also

 


StreamIO()

public method StreamIO(int IOMode = StreamIO.ReadMode)

Parameters

IOMode

Indicates type of I/O which is valid

Return Value

None

Description

Constructor for the abstract StreamIO class. The I/O mode (ReadMode, WriteMode or ReadWriteMode) is specified.

 

StreamIO Class


IOMode()

public virtual method<int> IOMode()

Parameters

None

Return Value

I/O Mode - Read, ReadWrite, Write

Description

Returns the I/O Mode that the stream I/O object was created with, either StreamIO.ReadMode, StreamIO.ReadWriteMode or StreamIO.WriteMode.

 

StreamIO Class


BytesAvailable()

public abstract method<int> BytesAvailable()

Parameters

None

Return Value

Number of bytes available to read

Description

Returns the number of bytes available to read.

 

StreamIO Class


Pos()

public virtual method<int> Pos()

Parameters

None

Return Value

Current read/write pointer position (or zero if N/A)

Description

Virtual method to return the current pointer position within the stream (one based). The next read or write operation will take place at this position (if direct access is supported). If direct access is not supported, this method has no meaning and returns zero.

 

StreamIO Class


SetPos()

public virtual method<bool> SetPos(int PointerPosition)

Parameters

PointerPosition

One based position in stream to read/write

Return Value

true if successful

Description

Virtual method to set the current read/write pointer position with the stream (one based). This only applies to stream classes which have direct access turned on. This base class implementation does nothing with the value and it returns a value of false, so it must be overidden by the derived class if it supports direct access.

 

StreamIO Class


DirectAccess()

public virtual method<bool> DirectAccess()

Parameters

None

Return Value

Returns true if direct access is supported

Description

Virtual method to return the direct access mode. If true, direct access is supported and if false, direct access is not supported. Direct access means that the Pos() and SetPos() can be used to adjust the next read or write operation.

 

This implementation of the method always returns false (direct access is not supported). In order to support direct access, a derived class should override this method and return true, as well as the SetPos() method.

 

StreamIO Class


EndOfStream()

public abstract method<bool> EndOfStream()

Parameters

None

Return Value

Returns true if at end of stream

Description

Abstract method to return the value of the "end of stream" flag. If there are no bytes available to read, this method returns true and false if there are one or more bytes available to read. Each derived class must override this method and handle it individually.

 

StreamIO Class


Read()

public abstract 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

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

 

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

 

StreamIO Class


Read()

public abstract 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

Abstract method to read a single "small" binary integer value from the 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.

 

StreamIO Class


Read()

public abstract 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, peek without reading/removing

Return Value

None

Description

Abstract method to read a single binary floating point value from the 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 stream is specified as "WriteMode", this method will fire a StreamException.

 

StreamIO Class


Read()

public abstract 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, peek without reading/removing

Return Value

None

Description

Abstract method to read a single string from the 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 stream is specified as "WriteMode", this method will fire a StreamException.

 

StreamIO Class


Read()

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

Parameters

BoolBucket

Boolean reference to receive the value

PeekOnly

If true, peek without reading/removing

Return Value

None

Description

Abstract method to read a single binary boolean value from the stream and copy the value into the BoolBucket. It is read as a one byte value.

 

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

 

StreamIO Class


Read()

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

Parameters

StreamBucket

Stream reference to receive the value

ReadSize

Size of the binary read operation

PeekOnly

If true, peek without reading/removing

Return Value

None

Description

Abstract method to read a binary block of data from the 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 ReadSize is specified as zero, the read operation goes all the way to the end of this stream.

 

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

 

StreamIO Class


Write()

public abstract method Write(int Value)

Parameters

Value

Integer value to be written

Return Value

None

Description

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

 

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

 

StreamIO Class


Write()

public abstract 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

Abstract method to write a single "small" binary integer value to the 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.

 

StreamIO Class


Write()

public abstract 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

Abstract method to write a single binary floating point value to the 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.

 

StreamIO Class


Write()

public abstract 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

Abstract method to write a single string to the 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.

 

StreamIO Class


Write()

public abstract method Write(bool Value)

Parameters

Value

Boolean value to be written

Return Value

None

Description

Abstract method to write a single binary boolean value to the stream. It is written as a one byte value.

 

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

 

StreamIO Class


Write()

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

Parameters

SourceStream

Source stream reference

WriteSize

Size of the binary write operation

Return Value

None

Description

Abstract method to read a binary block of data from the source stream and write it into this 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 stream (also at current pointer position if applicable). 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.

 

StreamIO Class

 

Copyright © 2010-2017

Aztec Development Group

All Rights Reserved

Download Aztec