DataStream

Monkey Forums/Monkey Bug Reports/DataStream

Pharmhaus(Posted 2014) [#1]
The New Methods of the DataStream contain some spelling mistakes.



Should be



Also, would it be possible to upgrade the datastream so it can dynamically grow like the ringbuffer? Or add a ringbufferstream? The ringbuffer itself is a bit clumsy....


ImmutableOctet(SKNG)(Posted 2014) [#2]
You have three options, either you write your own data-stream implementation (Or Mark decides to write these features into Monkey), use an existing one (Like my implementation; see below), or you write your own 'RingBuffer' based 'Stream' class. If I were you, I'd go with writing my own class. In fact, if I were writing a class today (Compared to my original attempt), I'd probably do what you were thinking of, and just wrap a 'RingBuffer'. If you don't want to do that, then modules like mine are for you.

And though it's an intermediate-module for my other projects (Thus, all of the constructors in my classes), you could try out my 'publicdatastream' module. My 'PublicDataStream' class is basically 'DataStream', only with some added features.

Most notably, it supports endian conversions (My 'byteorder' module is required; this was added for standard networking compliance), resizing the internal buffer when writing (Currently a bit basic, I might take another look at it later), as well as delegation of the internal 'DataBuffer' (Not sure if Mark added this to the main implementation yet).

There are some things to note about this module, however. The 'ResizeBuffer' (Used internally for resizing with the 'PublicDataStream' class) command is basically a carbon copy of my 'util' module's implementation. The only difference is that this implementation won't be updated as I update my 'util' module. This was because of how I managed my 'regalnet' module. So, don't expect that command to be updated very often.

EDIT: I should also mention that one of the reasons this isn't a feature in Monkey is because Mark's 'DataStream' class was generally meant for writing to a 'DataBuffer', not for writing to memory as much as the user wants (Thus, the lack of resizing). My class (On the other hand) is meant for packet writing.