I want to discard my home-grown “Pipe” classes in exchange for using InputStream and variants. But there’s a problem… readInt(), for example, returns zero if the stream is exhausted part way. There is no meaningful way to perform error checking. In my case I am putting external data into input streams and trying to read them (for example, ID3 tags, or binary database records). Its a requirement that any code which accesses external data needs to do validation on the input. What do I do? This would be nice:
Result InputStream::readInt (int32& value);
Also, I think MemoryInputStream should provide a way to get the current location and remaining bytes (yeah this can be done with getTotalLength() - getCurrentPosition()). For example, I have a block consisting of several struct fields followed by compressed preprocessed data. I would like to read the struct fields as structured data using the memory input stream, and then decode the compressed data with my own routines using the pointer provided by some function like MemoryInputStream::getCurrentPositionPointer() + MemoryInputStream::getBytesRemaining().