Moai SDK  1.5 revision 1 (MoaiEdition)
MOAIDataBuffer Class Reference

Inherits MOAILuaObject, and MOAILuaObject.

List of all members.

Function List

  base64Decode
  base64Encode
  deflate
  getSize
  getString
  hexDecode
  hexEncode
  inflate
  load
  loadAsync
  save
  saveAsync
  setString
  toCppHeader

Function Documentation

If a string is provided, decodes it as a base64 encoded string. Otherwise, decodes the current data stored in this object as a base64 encoded sequence of characters.


function base64Decode ( [ MOAIDataBuffer self, string data ] )
Parameters:
self ( MOAIDataBuffer ) Optional.
data ( string ) Optional. The string data to decode. You must either provide either a MOAIDataBuffer (via a :base64Decode type call) or string data (via a .base64Decode type call), but not both.
Returns:
output ( string )

If a string is provided, encodes it in base64. Otherwise, encodes the current data stored in this object as a base64 encoded sequence of characters.


function base64Encode ( [ MOAIDataBuffer self, string data ] )
Parameters:
self ( MOAIDataBuffer ) Optional.
data ( string ) Optional. The string data to encode. You must either provide either a MOAIDataBuffer (via a :base64Encode type call) or string data (via a .base64Encode type call), but not both.
Returns:
output ( string )

Compresses the string or the current data stored in this object using the DEFLATE algorithm.


function deflate ( string data [, number level, number windowBits ] )
Parameters:
data ( string ) The string data to deflate.
level ( number ) Optional. The level used in the DEFLATE algorithm.
windowBits ( number ) Optional. The window bits used in the DEFLATE algorithm.
Returns:
output ( string )
Note:

function deflate ( MOAIDataBuffer self [, number level, number windowBits ] )
Parameters:
self ( MOAIDataBuffer )
level ( number ) Optional. The level used in the DEFLATE algorithm.
windowBits ( number ) Optional. The window bits used in the DEFLATE algorithm.
Returns:
output ( string )
Note:

Returns the number of bytes in this data buffer object.


function getSize ( MOAIDataBuffer self )
Parameters:
self ( MOAIDataBuffer )
Returns:
size ( number )

Returns the contents of the data buffer object as a string value.


function getString ( MOAIDataBuffer self )
Parameters:
self ( MOAIDataBuffer )
Returns:
data ( string )

If a string is provided, decodes it as a hex encoded string. Otherwise, decodes the current data stored in this object as a hex encoded sequence of bytes.


function hexDecode ( [ MOAIDataBuffer self, string data ] )
Parameters:
self ( MOAIDataBuffer ) Optional.
data ( string ) Optional. The string data to decode. You must either provide either a MOAIDataBuffer (via a :hexDecode type call) or string data (via a .hexDecode type call), but not both.
Returns:
output ( string )

If a string is provided, encodes it in hex. Otherwise, encodes the current data stored in this object as a hex encoded sequence of characters.


function hexEncode ( [ MOAIDataBuffer self, string data ] )
Parameters:
self ( MOAIDataBuffer ) Optional.
data ( string ) Optional. The string data to encode. You must either provide either a MOAIDataBuffer (via a :hexEncode type call) or string data (via a .hexEncode type call), but not both.
Returns:
output ( string )

Decompresses the string or the current data stored in this object using the DEFLATE algorithm.


function inflate ( string data [, number windowBits ] )
Parameters:
data ( string ) The string data to inflate.
windowBits ( number ) Optional. The window bits used in the DEFLATE algorithm.
Returns:
output ( string )
Note:

function inflate ( MOAIDataBuffer self [, number windowBits ] )
Parameters:
self ( MOAIDataBuffer )
windowBits ( number ) Optional. The window bits used in the DEFLATE algorithm.
Returns:
output ( string )
Note:

Copies the data from the given file into this object. This method is a synchronous operation and will block until the file is loaded.


function load ( MOAIDataBuffer self, string filename [, number detectZip, number windowBits ] )
Parameters:
self ( MOAIDataBuffer )
filename ( string ) The path to the file that the data should be loaded from.
detectZip ( number ) Optional. One of MOAIDataBuffer.NO_UNZIP, MOAIDataBuffer.NO_UNZIP, MOAIDataBuffer.NO_UNZIP
windowBits ( number ) Optional. The window bits used in the DEFLATE algorithm. Pass nil to use the default value.
Returns:
success ( boolean )

Asynchronously copies the data from the given file into this object. This method is an asynchronous operation and will return immediately.


function loadAsync ( MOAIDataBuffer self, string filename, MOAITaskQueue queue [, function callback, number detectZip, boolean inflateAsync, number windowBits ] )
Parameters:
self ( MOAIDataBuffer )
filename ( string ) The path to the file that the data should be loaded from.
queue ( MOAITaskQueue ) The queue to perform the loading operation.
callback ( function ) Optional. The function to be called when the asynchronous operation is complete. The MOAIDataBuffer is passed as the first parameter.
detectZip ( number ) Optional. One of MOAIDataBuffer.NO_INFLATE, MOAIDataBuffer.FORCE_INFLATE, MOAIDataBuffer.INFLATE_ON_EXT
inflateAsync ( boolean ) Optional. 'true' to inflate on task thread. 'false' to inflate on subscriber thread. Default value is 'true.'
windowBits ( number ) Optional. The window bits used in the DEFLATE algorithm. Pass nil to use the default value.
Returns:
task ( MOAIDataIOTask )

Saves the data in this object to the given file. This method is a synchronous operation and will block until the data is saved.


function save ( MOAIDataBuffer self, string filename )
Parameters:
self ( MOAIDataBuffer )
filename ( string ) The path to the file that the data should be saved to.
Returns:
success ( boolean )

Asynchronously saves the data in this object to the given file. This method is an asynchronous operation and will return immediately.


function saveAsync ( MOAIDataBuffer self, string filename, MOAITaskQueue queue [, function callback ] )
Parameters:
self ( MOAIDataBuffer )
filename ( string ) The path to the file that the data should be saved to.
queue ( MOAITaskQueue ) The queue to perform the saving operation.
callback ( function ) Optional. The function to be called when the asynchronous operation is complete. The MOAIDataBuffer is passed as the first parameter.
Returns:
task ( MOAIDataIOTask )

Replaces the contents of this object with the string specified.


function setString ( MOAIDataBuffer self, string data )
Parameters:
self ( MOAIDataBuffer )
data ( string ) The string data to replace the contents of this object with.
Returns:
nil

Convert data to CPP header file.


function toCppHeader ( string data, string name [, number columns ] )
Parameters:
data ( string ) The string data to encode
name ( string )
columns ( number ) Optional. Default value is 12
Returns:
output ( string )
Note:

function toCppHeader ( MOAIDataBuffer data, string name [, number columns ] )
Parameters:
data ( MOAIDataBuffer ) The data buffer to encode
name ( string )
columns ( number ) Optional. Default value is 12
Returns:
output ( string )
Note: