I have made my own custom stream classes for binary I/O. Now I'm trying to make them compatible with Crypto++ library. I have found a question that deals with custom sink and implemented my own. Now I need to implement a source. I've searched through the documentation and there seems to be a huge inheritance hierarchy so I can't understand it yet.
Can someone provide an example code?
Here's the part of my stream class:
/// \brief Base class for a binary input stream.
/// \details Binary streams are used for low level unformatted I/O. Built on top
/// of standard streams, this system takes care of endianness and provides
/// convenient << and >> overloads. This class is designed to mirror
class BinaryInputStream : public virtual BinaryStreamBase
/// \brief Returns whether last I/O operation has completed successfully.
/// \return True if last I/O operation has completed successfully,
/// false otherwise.
virtual bool IsGood() const = 0;
/// \brief Returns whether end-of-file has been reached.
/// \return True if end-of-file has been reached, false otherwise.
virtual bool IsEOF() const = 0;
/// \brief Returns whether recoverable error has occured.
/// \return True if recoverable error has occured, false otherwise.
virtual bool IsFail() const = 0;
/// \brief Returns whether non-recoverable error has occured.
/// \return True if non-recoverable error has occured, false otherwise.
virtual bool IsBad() const = 0;
/// \brief Reads a sequence of bytes from the stream.
/// \param[in,out] buffer Buffer to write to.
/// \param[in] size Number of bytes to read.
/// \return Reference to this stream.
/// \warning You are responsible for allocating the buffer and ensuring that
/// it contains enough space to hold the data. If number of bytes to read is
/// greater than the size of the buffer, the behavior is undefined.
virtual BinaryInputStream& Read(char* buffer, std::size_t size) = 0;
First, we need to look at the
FileSource class. It inherits from
SourceTemplate<FileStore>. So we need to examine
FileStore class. It inherits from
NotCopyable. We need to create class which also inherits from these classes.
Our store class must have a default constructor and implement the following virtual functions:
StoreInitialize can be private.