BRL.Bank: Types Functions Source  


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 'Poke' style commands, such as PokeByte.

To read data from a bank, use one of the 'Peek' style commands, such as PeekByte.

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

Types

TBankMemory bank

Functions

CreateBankCreate a bank
CreateStaticBankCreate a bank with existing data
LoadBankLoad a bank
SaveBankSave a bank
BankBufGet bank's memory buffer
LockBankLock a bank's memory block
UnlockBankUnlock a bank's memory block
BankSizeGet size of bank
BankCapacityGet capacity of bank
ResizeBankResize a bank
CopyBankCopy bank contents
PeekBytePeek a byte from a bank
PokeBytePoke a byte into a bank
PeekShortPeek a short from a bank
PokeShortPoke a short into a bank
PeekIntPeek an int from a bank
PokeIntPoke an int into a bank
PeekLongPeek a long integer from a bank
PokeLongPoke a long integer int into a bank
PeekFloatPeek a float from a bank
PokeFloatPoke a float into a bank
PeekDoublePeek a double from a bank
PokeDoublePoke a double into a bank
ReadBankRead bytes from a Stream to a Bank
WriteBankWrite bytes from a Bank to a Stream

Function reference

Function CreateBank:TBank( size=0 )
ReturnsA bank object with an initial size of size bytes
DescriptionCreate a bank
Information CreateBank 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
Information The 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
Information LoadBank 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 SaveBank( bank:TBank,url:Object )
ReturnsTrue if successful.
DescriptionSave a bank
Information SaveBank writes it's entire contents to a url. If the url is a file path a new file is created.

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

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

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

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

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

Function BankCapacity( bank:TBank )
ReturnsThe capacity, in bytes, of the bank's internal memory buffer
DescriptionGet capacity of bank
Information The 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 ResizeBank( bank:TBank,size )
DescriptionResize a bank
Information ResizeBank 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 CopyBank( src_bank:TBank,src_offset,dst_bank:TBank,dst_offset,count )
DescriptionCopy bank contents
Information CopyBank copies count bytes from src_offset in src_bank to dst_offset in dst_bank.

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

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

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

Function PokeShort( bank:TBank,offset,value )
DescriptionPoke a short into a bank
Information An short is an unsigned 16 bit value that requires 2 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
Information An int is a signed 32 bit value (4 bytes).

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

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
Information A long is a 64 bit integer that requires 8 bytes of memory.

Function PokeLong( bank:TBank,offset,value:Long )
DescriptionPoke a long integer int into a bank
Information A long is a 64 bit integer that 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
Information A float requires 4 bytes of storage

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

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

Function PokeDouble( bank:TBank,offset,value! )
DescriptionPoke a double into a bank
Information A double requires 8 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 WriteBank( bank:TBank,stream:TStream,offset,count )
ReturnsThe number of bytes successfully written to the Stream
DescriptionWrite bytes from a Bank to a Stream