|
@@ -23,10 +23,12 @@ bbdoc: Byte Buffer
|
|
|
End Rem
|
|
|
Module BRL.ByteBuffer
|
|
|
|
|
|
-ModuleInfo "Version: 1.00"
|
|
|
+ModuleInfo "Version: 1.01"
|
|
|
ModuleInfo "License: zlib/libpng"
|
|
|
ModuleInfo "Copyright: 2020 Bruce A Henderson"
|
|
|
|
|
|
+ModuleInfo "History: 1.01"
|
|
|
+ModuleInfo "History: Added GetBytes() and PutBytes()"
|
|
|
ModuleInfo "History: 1.00 Initial Release"
|
|
|
|
|
|
|
|
@@ -271,6 +273,11 @@ Type TByteBuffer Extends TBuffer
|
|
|
End Rem
|
|
|
Method GetDouble:Double() Abstract
|
|
|
|
|
|
+ Rem
|
|
|
+ bbdoc: Copies @length bytes into @dst at the curent position, and increments the position by @length.
|
|
|
+ End Rem
|
|
|
+ Method GetBytes(dst:Byte Ptr, length:UInt) Abstract
|
|
|
+
|
|
|
Rem
|
|
|
bbdoc: Writes the specified #Byte to the current position and increments the position by 1.
|
|
|
End Rem
|
|
@@ -315,6 +322,11 @@ Type TByteBuffer Extends TBuffer
|
|
|
bbdoc: Writes the specified #Double to the current position and increments the position by 8.
|
|
|
End Rem
|
|
|
Method PutDouble:TByteBuffer(value:Double) Abstract
|
|
|
+
|
|
|
+ Rem
|
|
|
+ bbdoc: Writes the specified number of bytes to the current position.
|
|
|
+ End Rem
|
|
|
+ Method PutBytes:TByteBuffer(bytes:Byte Ptr, length:UInt) Abstract
|
|
|
|
|
|
Rem
|
|
|
bbdoc: Returns a sliced #TByteBuffer that shares its content with this one.
|
|
@@ -468,6 +480,18 @@ Type TBytePtrBuffer Extends TByteBuffer
|
|
|
Return Size_T(GetUInt())
|
|
|
?
|
|
|
End Method
|
|
|
+
|
|
|
+ Method GetBytes(dst:Byte Ptr, length:UInt)
|
|
|
+ Local newPosition:Int = _position + length
|
|
|
+ If newPosition > _limit Then
|
|
|
+ Throw New TBufferUnderflowException
|
|
|
+ End If
|
|
|
+
|
|
|
+ Local pos:Int = _position + _offset
|
|
|
+ MemCopy(dst, _data + pos, Size_T(length))
|
|
|
+
|
|
|
+ _position = newPosition
|
|
|
+ End Method
|
|
|
|
|
|
Method Put:TByteBuffer(value:Byte) Override
|
|
|
If _readOnly Then
|
|
@@ -654,6 +678,23 @@ Type TBytePtrBuffer Extends TByteBuffer
|
|
|
Return PutLong(bmx_bytebuffer_doubletolongbits(value))
|
|
|
End Method
|
|
|
|
|
|
+ Method PutBytes:TByteBuffer(bytes:Byte Ptr, length:UInt) Override
|
|
|
+ If _readOnly Then
|
|
|
+ Throw New TReadOnlyBufferException
|
|
|
+ End If
|
|
|
+
|
|
|
+ Local newPosition:Int = _position + length
|
|
|
+ If newPosition > _limit Then
|
|
|
+ Throw New TBufferOverflowException
|
|
|
+ End If
|
|
|
+
|
|
|
+ Local pos:Int = _offset + _position
|
|
|
+ MemCopy(_data + pos, bytes, Size_T(length))
|
|
|
+
|
|
|
+ _position = newPosition
|
|
|
+ Return Self
|
|
|
+ End Method
|
|
|
+
|
|
|
Method Slice:TByteBuffer() Override
|
|
|
Return New TBytePtrBuffer(_data, remaining(), _offset + _position, _readOnly)
|
|
|
End Method
|