ByteDataReader Offset - setter
I am working on a project where I would need to update the offset position. Something similar to MemoryStream class in C#, Where Stream position can be updated.
I see there is a getter for OffsetInBytes. I think enabling this feature adds more value to this solution.
Not sure what you are trying to do here: could you please give a more detailed example of the use case and what's missing?
Thanks @isoos for the quick reply. Sorry, I missed adding more context. I am using the ByteDataReader to read the bytes, in the stream, every message starts with a particular header and ends with a footer. While reading them, I parse byte by byte till I reach the header byte. The read method in ByteDataReader updates the offset position, Once I find the header byte, I want to reset the offset to offset - 1.
ByteDataReader was designed to parse the input only once, as otherwise it should buffer all or parts of it, which increases the number of extra checks it needs to do for every single read. I'd be cautious of adding such feature in it, maybe as a wrapper class on top of it.
However, your use case suggest that you may be working with headers, and that is not an uncommon parsing problem. Previously I've done this with a combination of a buffer that I write the unfinished header bytes until the boundary condition comes, and then parse+process the header, continuing on the input stream after that.