Moai SDK  1.5 revision 1 (MoaiEdition)
MOAIStream Class Reference
Inheritance diagram for MOAIStream:
MOAIDataBufferStream MOAIDataBufferStream MOAIFileStream MOAIFileStream MOAIHashWriter MOAIHashWriter MOAIMemStream MOAIMemStream MOAIStreamReader MOAIStreamReader MOAIStreamWriter MOAIStreamWriter

List of all members.

Function List

  flush
  getCursor
  getLength
  read
  read8
  read16
  read32
  readDouble
  readFloat
  readFormat
  readU8
  readU16
  readU32
  seek
  write
  write8
  write16
  write32
  writeDouble
  writeFloat
  writeFormat
  writeStream
  writeU8
  writeU16
  writeU32

Function Documentation

Forces any remaining buffered data into the stream.


function flush ( MOAIStream self )
Parameters:
self ( MOAIStream )
Returns:
nil

Returns the current cursor position in the stream.


function getCursor ( MOAIStream self )
Parameters:
self ( MOAIStream )
Returns:
cursor ( number )

Returns the length of the stream.


function getLength ( MOAIStream self )
Parameters:
self ( MOAIStream )
Returns:
length ( number )

Reads bytes from the stream.


function read ( MOAIStream self [, number byteCount ] )
Parameters:
self ( MOAIStream )
byteCount ( number ) Optional. Number of bytes to read. Default value is the length of the stream.
Returns:
bytes ( string ), actualByteCount ( number )

Reads a signed 16-bit value from the stream.


function read16 ( MOAIStream self )
Parameters:
self ( MOAIStream )
Returns:
value ( number ), size ( number )

Reads a signed 32-bit value from the stream.


function read32 ( MOAIStream self )
Parameters:
self ( MOAIStream )
Returns:
value ( number ), size ( number )

Reads a signed 8-bit value from the stream.


function read8 ( MOAIStream self )
Parameters:
self ( MOAIStream )
Returns:
value ( number ), size ( number )

Reads a 64-bit floating point value from the stream.


function readDouble ( MOAIStream self )
Parameters:
self ( MOAIStream )
Returns:
value ( number ), size ( number )

Reads a 32-bit floating point value from the stream.


function readFloat ( MOAIStream self )
Parameters:
self ( MOAIStream )
Returns:
value ( number ), size ( number )

Reads a series of values from the stream given a format string. Valid tokens for the format string are: u8 u16 u32 f d s8 s16 s32. Tokens may be optionally separated by spaces of commas.


function readFormat ( MOAIStream self, string format )
Parameters:
self ( MOAIStream )
format ( string )
Returns:
..., size ( number )

Reads an unsigned 16-bit value from the stream.


function readU16 ( MOAIStream self )
Parameters:
self ( MOAIStream )
Returns:
value ( number ), size ( number )

Reads an unsigned 32-bit value from the stream.


function readU32 ( MOAIStream self )
Parameters:
self ( MOAIStream )
Returns:
value ( number ), size ( number )

Reads an unsigned 8-bit value from the stream.


function readU8 ( MOAIStream self )
Parameters:
self ( MOAIStream )
Returns:
value ( number ), size ( number )

Repositions the cursor in the stream.


function seek ( MOAIStream self, number offset [, number mode ] )
Parameters:
self ( MOAIStream )
offset ( number ) Value from the stream.
mode ( number ) Optional. One of MOAIStream.SEEK_CUR, MOAIStream.SEEK_END, MOAIStream.SEEK_SET. Default value is MOAIStream.SEEK_SET.
Returns:
nil

Write binary data to the stream.


function write ( MOAIStream self, string bytes [, number size ] )
Parameters:
self ( MOAIStream )
bytes ( string ) Binary data to write.
size ( number ) Optional. Number of bytes to write. Default value is the size of the string.
Returns:
size ( number )

Writes a signed 16-bit value to the stream.


function write16 ( MOAIStream self, number value )
Parameters:
self ( MOAIStream )
value ( number ) Value to write.
Returns:
size ( number )

Writes a signed 32-bit value to the stream.


function write32 ( MOAIStream self, number value )
Parameters:
self ( MOAIStream )
value ( number ) Value to write.
Returns:
size ( number )

Writes a signed 8-bit value to the stream.


function write8 ( MOAIStream self, number value )
Parameters:
self ( MOAIStream )
value ( number ) Value to write.
Returns:
size ( number )

Writes a 64-bit floating point value to the stream.


function writeDouble ( MOAIStream self, number value )
Parameters:
self ( MOAIStream )
value ( number ) Value to write.
Returns:
size ( number )

Writes a 32-bit floating point value to the stream.


function writeFloat ( MOAIStream self, number value )
Parameters:
self ( MOAIStream )
value ( number ) Value to write.
Returns:
size ( number )

Writes a series of values to the stream given a format string. See 'readFormat' for a list of valid format tokens.


function writeFormat ( MOAIStream self, string format, ... )
Parameters:
self ( MOAIStream )
format ( string )
( ... ) values Values to be written to the stream.
Returns:
size ( number )

Reads bytes from the given stream into the calling stream.


function writeStream ( MOAIStream self, MOAIStream stream [, number size ] )
Parameters:
self ( MOAIStream )
stream ( MOAIStream ) Value to write.
size ( number ) Optional. Number of bytes to read/write. Default value is the length of the input stream.
Returns:
size ( number )

Writes an unsigned 16-bit value to the stream.


function writeU16 ( MOAIStream self, number value )
Parameters:
self ( MOAIStream )
value ( number ) Value to write.
Returns:
size ( number )

Writes an unsigned 32-bit value to the stream.


function writeU32 ( MOAIStream self, number value )
Parameters:
self ( MOAIStream )
value ( number ) Value to write.
Returns:
size ( number )

Writes an unsigned 8-bit value to the stream.


function writeU8 ( MOAIStream self, number value )
Parameters:
self ( MOAIStream )
value ( number ) Value to write.
Returns:
size ( number )