Class
Xojo.Core.MutableMemoryBlock
Warning
This item was deprecated in version 2020r2. Please use MemoryBlock as a replacement.
Description
A mutable class for managing and modifying blocks of memory.
Methods
Name |
Parameters |
Returns |
Shared |
---|---|---|---|
bytes() As Byte |
|||
p As Ptr |
|||
size As UInteger |
|||
bytes() As Byte |
|||
other As MemoryBlock |
|||
p As Ptr |
|||
size As UInteger |
|||
offset As UInteger, other As MemoryBlock |
|||
offset As UInteger |
|||
bytes As UInteger |
|||
bytes As UInteger |
|||
Property descriptions
Xojo.Core.MutableMemoryBlock.Data
Data As Ptr
The memory data in the MemoryBlock.
This property is read-only.
This data pointer is invalidated when the MemoryBlock is changed.
Xojo.Core.MutableMemoryBlock.LittleEndian
LittleEndian As Boolean
When True, indicates that the MemoryBlock data is in LittleEndian format. The default is True.
Simple endian usage:
Var mb1 As New Xojo.Core.MemoryBlock(2) ' defaults to Little Endian = True on all platforms
mb1.Int8Value(0) = 1
mb1.Int8Value(1) = 2
Var firstUInt16 As Int16
firstUInt16 = mb1.UInt16Value(0)
' firstUInt16 = (256 * 2) + (1 * 1) = 513
mb1.LittleEndian = False
Var secondUInt16 As Int16
secondUInt16 = mb1.UInt16Value(0)
' secondUInt16 = (256 * 1) + (1 * 2) = 258
Xojo.Core.MutableMemoryBlock.Size
Size As UInteger
The size (in bytes) of the MemoryBlock.
This property is read-only.
If the size is unknown, this returns &hFFFFFFFF (32-bit apps) or &hFFFFFFFFFFFFFFFF (64-bit app).
Method descriptions
Xojo.Core.MutableMemoryBlock.BooleanValue
BooleanValue(offset As UInteger, Assigns value As Boolean)
Sets a Boolean value in the MemoryBlock at the specified offset (in bytes). Any non-zero value is considered True.
Var value As New Xojo.Core.MutableMemoryBlock(1)
value.BooleanValue(0) = True
Xojo.Core.MutableMemoryBlock.Clone
Clone As MemoryBlock
Makes a copy of the MemoryBlock. If its size is known, it copies the content.
Var mb1 As New Xojo.Core.MemoryBlock(64)
Var mb2 As Xojo.Core.MemoryBlock = mb1.Clone
Xojo.Core.MutableMemoryBlock.Comparison
Comparison
MemoryBlocks can be compared with each other using the "=" operator.
MemoryBlocks are considered equal for these conditions: * The MemoryBlocks are the same object * Both MemoryBlocks' data point to the same location * Both MemoryBlocks' size and content are the same There is no concept of one MemoryBlock being greater than or less than another MemoryBlock.
Xojo.Core.MutableMemoryBlock.Constructor
Constructor(bytes() As Byte)
Note
Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.
Creates a MemoryBlock from an existing Byte array.
Xojo.Core.MutableMemoryBlock.Constructor
Constructor(p As Ptr)
Note
Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.
Creates a MemoryBlock from an existing chunk of memory.
Xojo.Core.MutableMemoryBlock.Constructor
Constructor(p As Ptr, size As UInteger)
Note
Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.
Creates a MemoryBlock from an existing block of memory of a specific size.
Xojo.Core.MutableMemoryBlock.Constructor
Constructor(size As UInteger)
Note
Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.
Creates a MemoryBlock with the desired size in bytes.
Xojo.Core.MutableMemoryBlock.Constructor
Constructor(bytes() As Byte)
Note
Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.
Creates a MemoryBlock from an existing Byte array.
Xojo.Core.MutableMemoryBlock.Constructor
Constructor(other As MemoryBlock)
Note
Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.
Creates a new MemoryBlock with the data from an existing MemoryBlock.
Xojo.Core.MutableMemoryBlock.Constructor
Constructor(p As Ptr)
Note
Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.
Creates a MemoryBlock from an existing chunk of memory.
Xojo.Core.MutableMemoryBlock.Constructor
Constructor(p As Ptr, size As UInteger)
Note
Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.
Creates a MemoryBlock from an existing block of memory of a specific size.
Xojo.Core.MutableMemoryBlock.Constructor
Constructor(size As UInteger)
Note
Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.
Creates a MemoryBlock with the desired size in bytes.
Reserve 1K:
Var mb As New Xojo.Core.MemoryBlock(1024) ' Reserve 1K bytes
Xojo.Core.MutableMemoryBlock.CStringValue
CStringValue(offset As UInteger, Assigns value As CString)
Sets a CString value in the MemoryBlock at the specified offset (in bytes).
Xojo.Core.MutableMemoryBlock.CurrencyValue
CurrencyValue(offset As UInteger, Assigns value As Currency)
Sets an 8-byte Currency value in the MemoryBlock at the specified offset (in bytes).
Var c As Currency = 12.34
Var value As New Xojo.Core.MutableMemoryBlock(8)
value.CurrencyValue(0) = c
Xojo.Core.MutableMemoryBlock.DoubleValue
DoubleValue(offset As UInteger, Assigns value As Double)
Sets a Double value in the MemoryBlock at the specified offset (in bytes).
Var d As Double = 12.34
Var value As New Xojo.Core.MutableMemoryBlock(8)
value.DoubleValue(0) = d
Xojo.Core.MutableMemoryBlock.IndexOf
IndexOf(offset As UInteger, other As MemoryBlock) As UInteger
Returns the position of the other MemoryBlock starting at the offset. Returns -1 if other was not found.
Xojo.Core.MutableMemoryBlock.Int16Value
Int16Value(offset As UInteger, Assigns value As Int16)
Sets an Int16 value in the MemoryBlock at the specified offset (in bytes).
Xojo.Core.MutableMemoryBlock.Int32Value
Int32Value(offset As UInteger, Assigns value As Int32)
Sets an Int32 value in the MemoryBlock at the specified offset (in bytes).
Xojo.Core.MutableMemoryBlock.Int64Value
Int64Value(offset As UInteger, Assigns value As Int64)
Sets an Int64 value in the MemoryBlock at the specified offset (in bytes).
Xojo.Core.MutableMemoryBlock.Int8Value
Int8Value(offset As UInteger) As Int8
Gets or sets an Int8 value in the MemoryBlock at the specified offset (in bytes).
Xojo.Core.MutableMemoryBlock.Left
Left(bytes As UInteger) As MemoryBlock
Gets the specified number of bytes at the beginning of the MemoryBlock.
Xojo.Core.MutableMemoryBlock.PtrValue
PtrValue(offset As UInteger, Assigns value As Ptr)
Sets A Ptr value in the MemoryBlock at the specified offset (in bytes).
Xojo.Core.MutableMemoryBlock.Remove
Remove(offset As UInteger, length As UInteger)
Removes length bytes from the MemoryBlock starting at offset, adjusting its size. This potentially invalidates the Data property.
Xojo.Core.MutableMemoryBlock.Right
Right(bytes As UInteger) As MemoryBlock
Gets the bytes from the end of the MemoryBlock.
Get the last two bytes of a MemoryBlock:
Var bytes() As Byte
bytes.Append(&h0a)
bytes.Append(&h0b)
bytes.Append(&h0c)
Var data As New Xojo.Core.MemoryBlock(bytes)
Var mb As Xojo.Core.MemoryBlock = data.Right(2)
Xojo.Core.MutableMemoryBlock.SingleValue
SingleValue(offset As UInteger, Assigns value As Single)
Sets a Single value in the MemoryBlock at the specified offset (in bytes).
Xojo.Core.MutableMemoryBlock.UInt16Value
UInt16Value(offset As UInteger, Assigns value As UInt16)
Sets an UInt16 value in the MemoryBlock at the specified offset (in bytes).
Xojo.Core.MutableMemoryBlock.UInt32Value
UInt32Value(offset As UInteger, Assigns value As UInt32)
Sets an UInt32 value in the MemoryBlock at the specified offset (in bytes).
Xojo.Core.MutableMemoryBlock.UInt64Value
UInt64Value(offset As UInteger, Assigns value As UInt64)
Sets an UInt64 value in the MemoryBlock at the specified offset (in bytes).
Xojo.Core.MutableMemoryBlock.UInt8Value
UInt8Value(offset As UInteger, Assigns value As UInt8)
Sets an UInt8 value in the MemoryBlock at the specified offset (in bytes).
Xojo.Core.MutableMemoryBlock.WStringValue
WStringValue(offset As UInteger, Assigns value As WString)
Sets a WString value in the MemoryBlock at the specified offset (in bytes).
Compatibility
All project types on all supported operating systems.
See also
MemoryBlock parent class; MemoryBlock, MemoryBlock classes