Smallcase folders part 1
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
namespace network
|
||||
{
|
||||
class Buffer
|
||||
{
|
||||
public:
|
||||
explicit Buffer(std::vector<uint8_t> &buf) : buffer(buf), pos(0) {}
|
||||
explicit Buffer(size_t reserve = 0) : buffer(reserve), pos(0) {}
|
||||
|
||||
// --- Writing ---
|
||||
void writeUint8(uint8_t v);
|
||||
void writeUint32(uint32_t v);
|
||||
void writeFloat(float f);
|
||||
void writeBytes(const uint8_t *data, size_t len);
|
||||
void writeString(const std::string &s);
|
||||
// --- Reading ---
|
||||
uint8_t readUint8();
|
||||
uint32_t readUint32();
|
||||
float readFloat();
|
||||
std::string readString();
|
||||
|
||||
size_t remaining() const;
|
||||
std::vector<uint8_t> &data();
|
||||
|
||||
private:
|
||||
void checkRemaining(size_t n);
|
||||
|
||||
std::vector<uint8_t> buffer;
|
||||
size_t pos;
|
||||
};
|
||||
} // namespace network
|
||||
Reference in New Issue
Block a user