#pragma once

#include "BitStream.h"

#include <vector>
#include <iterator>

class BufferBitStream : public BitStream
{
public:
    const std::vector<unsigned char>& getBuffer() const;

    bool isFinished() const override;

    std::vector<unsigned char> peekNextNBytes(unsigned n) const override;

    std::optional<unsigned char> readNextByte() override;

    void reset() override;

    void setBuffer(const std::vector<unsigned char>& data);

    void writeByte(unsigned char data, bool checkOverflow = true) override;

    void writeBytes(const std::vector<unsigned char> data) override;

private:
    std::vector<unsigned char> mBuffer;
};
