MemoryOutputStream Y U NO let me pass buffer?


#1

Unlike MemoryInputStream, MemoryOutputStream does not let me pass my own void const* and a size_t to indicate where to put the data!

Jules!


#2

Well, my reason for that was that the output stream was always designed to keep expanding and not have a fixed size. It’s a good request though, and easy to add, so I’ll sort that out for you…


#3

FWIW, i use a different pattern for this.

For a number of juce datastructures (eg MemoryBlock) i put in my consume' anddonate’ pattern.

For example consume(void* data, int size)' andvoid* donate(int& size)’ work to put memory in and out of data structures so to avoid copies. This is useful when you know the data is really big.


#4

Well the thing is I have a piece of already existing memory and I want to use the streams to do serialization and deserialization in network byte order (i.e. big-endian). So its very nice to use the streams for that.