FeatherMC/src/network/Buffer.h

30 lines
675 B
C++

#pragma once
#include <vector>
#include <cstdint>
using std::vector;
namespace Feather::Network
{
class Buffer
{
public:
inline void WriteByte(uint8_t byte) { m_data.push_back(byte); }
// Returns the number of bytes written.
int WriteVarInt(int i);
// Write a null terminated string to the buffer.
void WriteString(const char *str);
// Write a string with known size to the buffer
void WriteString(const char *str, size_t length);
inline vector<uint8_t> GetData() { return m_data; }
inline size_t Size() { return m_data.size(); }
private:
vector<uint8_t> m_data;
};
}