#ifndef STREAM_H#define STREAM_H#include <inttypes.h>/* Generic stream classs */class Stream{public: /* Initializes a new instance of the Stream object */ Stream() { } /* Free up any ressources used by this object */ virtual ~Stream() { } /* Reads data from the underlying stream and copy it into [buffer] * @param buffer Pointer where the data is to be copied * @maxLength Maximum amount of data (in bytes) to be copied * @return Amount of bytes read */ virtual uint32_t Read(void *buffer, uint32_t maxLength) { throw 0; } /* Writes data to the underlying stream * @param Buffer Pointer to where the data is * @param length Amount of data (in bytes) to write * @return Number of bytes written */ virtual uint32_t Write(const void* buffer, uint32_t length) { throw 0; } /* Polls for available data * @return Amount of bytes available to read */ virtual uint32_t Poll() const { throw 0; } /* Closes any ressources used in the stream */ virtual void Close() { } /* @return Whether the underlying stream supports reading */ virtual bool CanRead() = 0; /* @return Whether the underlying stream supports writing */ virtual bool CanWrite() = 0; /* @return Wether the underlying stream supports polling (check if data is available) */ virtual bool CanPoll() = 0;};/* Dummy class to nullify something */class NullStream : public Stream{ virtual inline bool CanRead() { return false; } virtual inline bool CanWrite() { return true; } virtual uint32_t Write(const void *buffer, int length) { return length; }};#endif