This is a nice to have request. For example, if you have a 1024 byte array (used as buffer/temp array), but you've only read 32 bytes into it say from an SPIFFS file. The file contained 32 bytes was originally serialized from an array of objects. You then want to convert the 32 bytes back to an object array, the way to do that now is something like this:
Would be nice to have a version of ConvertBytesToArray, say ConvertBytesToArray2 that you can pass in the number of bytes to read to perform the conversion:
ConvertBytesToArray2 (Bytes() As Byte, readsize as UInt, ObjectsBuffer() As Object) As Object()
B4X:
Private fs As ESP8266FileSystem
Public ser As B4RSerializator
Public bc As ByteConverter
Dim b(1024) As Byte 'buffer array
dim filename as string = "/info"
fs.OpenRead(filename)
Dim size As ULong = fs.CurrentFile.Size
Dim readsize As Int = fs.Stream.ReadBytes(b, 0, size)
'the data that's read into byte array b is 32 bytes in length, it was a previously serialized object array
'to convert back to object array properly
Dim buf(3) As Object
Dim obj_a() As Object
obj_a = ser.ConvertBytesToArray(bc.SubString2(b,0,readsize),buf) '<-convert back to object array
Would be nice to have a version of ConvertBytesToArray, say ConvertBytesToArray2 that you can pass in the number of bytes to read to perform the conversion:
ConvertBytesToArray2 (Bytes() As Byte, readsize as UInt, ObjectsBuffer() As Object) As Object()
B4X:
obj_a = ser.ConvertBytesToArray2(b,readsize, buf)