2016-08-02 05:14:09 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <vector>
|
|
|
|
|
2016-08-11 02:17:38 +08:00
|
|
|
#include "utils/types/byte.hpp"
|
|
|
|
|
2016-08-02 05:14:09 +08:00
|
|
|
namespace bolt
|
|
|
|
{
|
|
|
|
|
|
|
|
class Buffer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void write(const byte* data, size_t len);
|
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
size_t size() const
|
|
|
|
{
|
|
|
|
return buffer.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
byte operator[](size_t idx) const
|
|
|
|
{
|
|
|
|
return buffer[idx];
|
|
|
|
}
|
|
|
|
|
|
|
|
const byte* data() const
|
|
|
|
{
|
|
|
|
return buffer.data();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<byte> buffer;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|