BRL.Bank: Functions Types Modinfo Source  

Banks

A bank object encapsulates a block of memory you can use to store arbitrary data.

Banks are useful for storing data that is of no fixed type - for example, the contents of a binary file.

To create a bank, use the CreateBank command.

To write data to a bank, use one of the Poke commands. To read data from a bank, use one of the Peek commands.

In addition, banks can be loaded or saved using LoadBank or SaveBank.

Functions

Function BankBuf:Byte Ptr( bank:TBank )
ReturnsA byte pointer to the bank's internal memory buffer.
DescriptionGet bank's memory buffer.
InformationPlease use LockBank and UnlockBank instead of this method.

Function BankCapacity( bank:TBank )
ReturnsThe capacity, in bytes, of the bank's internal memory buffer.
DescriptionGet capacity of bank.
InformationThe capacity of a bank is the size limit before a bank must allocate more memory due to a resize. Bank capacity may be increased due to a call to ResizeBank by either 50% or the requested amount, whichever is greater. Capacity never decreases.

Function BankSize( bank:TBank )
ReturnsThe size, in bytes, of the bank's internal memory buffer.
DescriptionGet size of bank.

Function CopyBank( src_bank:TBank,src_offset,dst_bank:TBank,dst_offset,count )
DescriptionCopy bank contents.
InformationCopyBank copies count bytes from src_offset in src_bank to dst_offset in dst_bank.

Function CreateBank:TBank( size=0 )
ReturnsA bank object with an initial size of size bytes.
DescriptionCreate a bank.
InformationCreateBank creates a Bank allocating a specified amount of memory that can be used for storage of binary data using the various Poke and Peek commands.

Function CreateStaticBank:TBank( buf:Byte Ptr,size )
ReturnsA bank object that references an existing block of memory.
DescriptionCreate a bank with existing data.
InformationThe memory referenced by a static bank is not released when the bank is deleted. A static bank cannot be resized.

Function LoadBank:TBank( url:Object )
ReturnsA bank containing the binary contents of url, or null if url could not be opened.
DescriptionLoad a bank.
InformationLoadBank reads the entire contents of a binary file from a specified url into a newly created bank with a size matching that of the file.

Function LockBank:Byte Ptr( bank:TBank )
ReturnsA byte pointer to the memory block controlled by the bank.
DescriptionLock a bank's memory block.
InformationWhile locked, a bank cannot be resized.

After you have finished with a bank's memory block, you must use Unlock to return it to the bank.

Function PeekByte( bank:TBank,offset )
ReturnsThe byte value at the specified byte offset within the bank.
DescriptionPeek a byte from a bank.
InformationA byte is an unsigned 8 bit value with a range of 0..255.

Function PeekDouble!( bank:TBank,offset )
ReturnsThe double value at the specified byte offset within the bank.
DescriptionPeek a double from a bank.
InformationA double requires 8 bytes of storage.

Function PeekFloat#( bank:TBank,offset )
ReturnsThe float value at the specified byte offset within the bank.
DescriptionPeek a float from a bank.
InformationA float requires 4 bytes of storage.

Function PeekInt( bank:TBank,offset )
ReturnsThe int value at the specified byte offset within the bank.
DescriptionPeek an int from a bank.
InformationAn int is a signed 32 bit value (4 bytes).

Function PeekLong:Long( bank:TBank,offset )
ReturnsThe long integer value at the specified byte offset within the bank.
DescriptionPeek a long integer from a bank.
InformationA long is a 64 bit integer that requires 8 bytes of memory.

Function PeekShort( bank:TBank,offset )
ReturnsThe short value at the specified byte offset within the bank.
DescriptionPeek a short from a bank.
InformationA short is an unsigned 16 bit (2 bytes) value with a range of 0..65535.

Function PokeByte( bank:TBank,offset,value )
DescriptionPoke a byte into a bank.

Function PokeDouble( bank:TBank,offset,value! )
DescriptionPoke a double into a bank.
InformationA double requires 8 bytes of storage.

Function PokeFloat( bank:TBank,offset,value# )
DescriptionPoke a float into a bank.
InformationA float requires 4 bytes of storage.

Function PokeInt( bank:TBank,offset,value )
DescriptionPoke an int into a bank.
InformationAn int is a signed 32 bit value that requires 4 bytes of storage.

Function PokeLong( bank:TBank,offset,value:Long )
DescriptionPoke a long integer int into a bank.
InformationA long is a 64 bit integer that requires 8 bytes of storage.

Function PokeShort( bank:TBank,offset,value )
DescriptionPoke a short into a bank.
InformationAn short is an unsigned 16 bit value that requires 2 bytes of storage.

Function ReadBank( bank:TBank,stream:TStream,offset,count )
ReturnsThe number of bytes successfully read from the Stream.
DescriptionRead bytes from a Stream to a Bank.

Function ResizeBank( bank:TBank,size )
DescriptionResize a bank.
InformationResizeBank modifies the size limit of a bank. This may cause memory to be allocated if the requested size is greater than the bank's current capacity, see BankCapacity for more information.

Function SaveBank( bank:TBank,url:Object )
ReturnsTrue if successful.
DescriptionSave a bank.
InformationSaveBank writes it's entire contents to a url. If the url is a file path a new file is created.

Function UnlockBank( bank:TBank )
DescriptionUnlock a bank's memory block.
InformationAfter you have finished with a bank's memory block, you must use Unlock to return it to the bank.

Function WriteBank( bank:TBank,stream:TStream,offset,count )
ReturnsThe number of bytes successfully written to the Stream.
DescriptionWrite bytes from a Bank to a Stream.

Types

Type TBank Extends TData
DescriptionMemory bank.
Method Buf:Byte Ptr()
ReturnsA byte pointer to the memory block controlled by the bank.
DescriptionGet a bank's memory pointer.
InformationPlease use Lock and Unlock instead of this method.
Method Capacity()
ReturnsThe capacity, in bytes, of the bank's internal memory buffer.
DescriptionGet capacity of bank.
Method Lock:Byte Ptr()
ReturnsA byte pointer to the memory block controlled by the bank.
DescriptionLock a bank's memory block.
InformationWhile locked, a bank cannot be resized.

After you have finished with a bank's memory block, you must use Unlock to return it to the bank.
Method PeekByte( offset )
ReturnsThe byte value at the specified byte offset within the bank.
DescriptionPeek a byte from a bank.
Method PeekDouble!( offset )
ReturnsThe double value at the specified byte offset within the bank.
DescriptionPeek a double from a bank.
Method PeekFloat#( offset )
ReturnsThe float value at the specified byte offset within the bank.
DescriptionPeek a float from a bank.
Method PeekInt( offset )
ReturnsThe int value at the specified byte offset within the bank.
DescriptionPeek an int from a bank.
Method PeekLong:Long( offset )
ReturnsThe long value at the specified byte offset within the bank.
DescriptionPeek a long from a bank.
Method PeekShort( offset )
ReturnsThe short value at the specified byte offset within the bank.
DescriptionPeek a short from a bank.
Method PokeByte( offset,value )
DescriptionPoke a byte into a bank.
Method PokeDouble( offset,value! )
DescriptionPoke a double value into a bank.
Method PokeFloat( offset,value# )
DescriptionPoke a float value into a bank.
Method PokeInt( offset,value )
DescriptionPoke an int into a bank.
Method PokeLong( offset,value:Long )
DescriptionPoke a long value into a bank.
Method PokeShort( offset,value )
DescriptionPoke a short into a bank.
Method Read( stream:TStream,offset,count )
DescriptionRead bytes from a stream into a bank.
Method Resize( size )
DescriptionResize a bank.
Method Save( url:Object )
DescriptionSave a bank to a stream.
InformationReturn True if successful, otherwise False.
Method Size()
ReturnsThe size, in bytes, of the memory block controlled by the bank.
DescriptionGet a bank's size.
Method Unlock()
DescriptionUnlock a bank's memory pointer.
InformationAfter you have finished with a bank's memory block, you must use Unlock to return it to the bank.
Method Write( stream:TStream,offset,count )
DescriptionWrite bytes in a bank to a stream.
Function Create:TBank( size )
ReturnsA new TBank object with an initial size of size.
DescriptionCreate a bank.
Function CreateStatic:TBank( buf:Byte Ptr,size )
DescriptionCreate a bank from an existing block of memory.
Function Load:TBank( url:Object )
ReturnsA new TBank object.
DescriptionLoad a bank from a stream.
InformationReturns a new TBank object if successfull, otherwise Null.

Module Information

Version1.06
AuthorMark Sibly
LicenseBlitz Shared Source Code
CopyrightBlitz Research Ltd
ModserverBRL
History1.06 Release
HistoryAdded Lock/Unlock to replace Buf
History1.05 Release
HistoryFixed Read/Write using ReadBytes/WriteBytes