Create common base classes for buffered streams

Most streams are backed by a memory buffer. Create common base classes
for this functionality to avoid code duplication.
This commit is contained in:
Pierre Ossman
2020-05-15 20:20:53 +02:00
committed by Lauri Kasanen
parent 7f90205cf2
commit 92c7695981
19 changed files with 414 additions and 398 deletions

View File

@@ -19,29 +19,23 @@
#ifndef __RDR_HEX_INSTREAM_H__
#define __RDR_HEX_INSTREAM_H__
#include <rdr/InStream.h>
#include <rdr/BufferedInStream.h>
namespace rdr {
class HexInStream : public InStream {
class HexInStream : public BufferedInStream {
public:
HexInStream(InStream& is, size_t bufSize=0);
virtual ~HexInStream();
size_t pos();
static bool readHexAndShift(char c, int* v);
static bool hexStrToBin(const char* s, char** data, size_t* length);
protected:
size_t overrun(size_t itemSize, size_t nItems, bool wait);
private:
virtual bool fillBuffer(size_t maxSize, bool wait);
private:
size_t bufSize;
U8* start;
size_t offset;
InStream& in_stream;
};