|
|
@@ -49,74 +49,74 @@ class Stream
|
|
|
{
|
|
|
public:
|
|
|
|
|
|
- /// Constructor
|
|
|
+ /// Constructor
|
|
|
Stream(StreamOpenMode mode) : m_open_mode(mode) {}
|
|
|
|
|
|
- /// Destructor
|
|
|
+ /// Destructor
|
|
|
virtual ~Stream() {};
|
|
|
|
|
|
- /// Sets the position indicator of the stream to position.
|
|
|
+ /// Sets the position indicator of the stream to position.
|
|
|
virtual void seek(size_t position) = 0;
|
|
|
|
|
|
- /// Sets the position indicator to the end of the stream
|
|
|
+ /// Sets the position indicator to the end of the stream
|
|
|
virtual void seek_to_end() = 0;
|
|
|
|
|
|
- /// Sets the position indicator to bytes after current position
|
|
|
+ /// Sets the position indicator to bytes after current position
|
|
|
virtual void skip(size_t bytes) = 0;
|
|
|
|
|
|
- /// Reads a byte from the stream starting at current position.
|
|
|
+ /// Reads a byte from the stream starting at current position.
|
|
|
virtual uint8_t read_byte() = 0;
|
|
|
|
|
|
- /// Reads a block of data from the stream.
|
|
|
+ /// Reads a block of data from the stream.
|
|
|
virtual void read(void* buffer, size_t size) = 0;
|
|
|
|
|
|
- /// Writes a byte to the stream starting at current position.
|
|
|
+ /// Writes a byte to the stream starting at current position.
|
|
|
virtual void write_byte(uint8_t val) = 0;
|
|
|
|
|
|
- /// Writes a block of data to the stream.
|
|
|
+ /// Writes a block of data to the stream.
|
|
|
virtual void write(const void* buffer, size_t size) = 0;
|
|
|
|
|
|
- /// Copies a chunk of 'size' bytes of data from this to another stream.
|
|
|
+ /// Copies a chunk of 'size' bytes of data from this to another stream.
|
|
|
virtual bool copy_to(Stream* stream, size_t size = 0) = 0;
|
|
|
|
|
|
- /// Zips a chunk of 'size' bytes of data from this to another stream using compressor.
|
|
|
+ /// Zips a chunk of 'size' bytes of data from this to another stream using compressor.
|
|
|
virtual bool compress_to(Stream* stream, size_t size, size_t& compressed_size, Compressor* compressor);
|
|
|
|
|
|
- /// Unzip a zipped stream of data from this to another stream using compressor.
|
|
|
+ /// Unzip a zipped stream of data from this to another stream using compressor.
|
|
|
virtual bool uncompress_to(Stream* stream, size_t& uncompressed_size, Compressor* compressor);
|
|
|
|
|
|
- /// Forces the previouses write operations to complete.
|
|
|
- /// Generally, when a Stream is attached to a file,
|
|
|
- /// write operations are not performed instantly, the output data
|
|
|
- /// may be stored to a temporary buffer before making its way to
|
|
|
- /// the file. This method forces all the pending output operations
|
|
|
- /// to be written to the stream.
|
|
|
+ /// Forces the previouses write operations to complete.
|
|
|
+ /// Generally, when a Stream is attached to a file,
|
|
|
+ /// write operations are not performed instantly, the output data
|
|
|
+ /// may be stored to a temporary buffer before making its way to
|
|
|
+ /// the file. This method forces all the pending output operations
|
|
|
+ /// to be written to the stream.
|
|
|
virtual void flush() = 0;
|
|
|
|
|
|
- /// Returns whether the stream is valid.
|
|
|
- /// A stream is valid when the buffer where it operates
|
|
|
- /// exists. (i.e. a file descriptor is attached to the stream,
|
|
|
- /// a memory area is attached to the stream etc.)
|
|
|
+ /// Returns whether the stream is valid.
|
|
|
+ /// A stream is valid when the buffer where it operates
|
|
|
+ /// exists. (i.e. a file descriptor is attached to the stream,
|
|
|
+ /// a memory area is attached to the stream etc.)
|
|
|
virtual bool is_valid() const = 0;
|
|
|
|
|
|
- /// Returns whether the position is at end of stream.
|
|
|
+ /// Returns whether the position is at end of stream.
|
|
|
virtual bool end_of_stream() const = 0;
|
|
|
|
|
|
- /// Returns the size of stream in bytes.
|
|
|
+ /// Returns the size of stream in bytes.
|
|
|
virtual size_t size() const = 0;
|
|
|
|
|
|
- /// Returns the current position in stream.
|
|
|
- /// Generally, for binary data, it means the number of bytes
|
|
|
- /// from the beginning of the stream.
|
|
|
+ /// Returns the current position in stream.
|
|
|
+ /// Generally, for binary data, it means the number of bytes
|
|
|
+ /// from the beginning of the stream.
|
|
|
virtual size_t position() const = 0;
|
|
|
|
|
|
- /// Returns whether the stream can be read.
|
|
|
+ /// Returns whether the stream can be read.
|
|
|
virtual bool can_read() const = 0;
|
|
|
|
|
|
- /// Returns whether the stream can be wrote.
|
|
|
+ /// Returns whether the stream can be wrote.
|
|
|
virtual bool can_write() const = 0;
|
|
|
|
|
|
- /// Returns whether the stream can be sought.
|
|
|
+ /// Returns whether the stream can be sought.
|
|
|
virtual bool can_seek() const = 0;
|
|
|
|
|
|
protected:
|