1#ifndef CODEX_PACKET_READER_PACKET_READER_HPP
2#define CODEX_PACKET_READER_PACKET_READER_HPP
40 static constexpr std::size_t
N = 32;
42 std::span<char, N>
data() {
return this->
buf; }
57 std::array<char, N>
buf = {};
64 const auto ni = this->
i +
sizeof(
T);
65 assert(ni < this->
buf.size());
71 assert(this->
i +
sizeof(
T) <= this->
buf.size());
73 std::memcpy(&ret, this->
buf.data() + this->i,
sizeof(
T));
#define T(f, T, C)
Definition bench.cpp:136
Wrapper for a raw byte buffer with methods to extract data from it.
Definition packet_reader.hpp:37
size_t i
Current offset into buf.
Definition packet_reader.hpp:59
std::span< char, N > data()
Provides direct access to the underlying buffer.
Definition packet_reader.hpp:42
std::array< char, N > buf
Raw byte buffer.
Definition packet_reader.hpp:57
void advance()
Advances i after reading a type T.
T read()
Reads a sngle value of type T from the buffer.
Definition packet_reader.hpp:70
ReadResult read(T *p)
Checks that the buffer contains a value of type T and reads it.
auto get(Readable auto *...ps)
Extracts typed data from the underlying raw byte buffer.
Definition packet_reader.hpp:44
Identifies whether a C++ type can be read from a buffer.
Definition packet_reader.hpp:22
constexpr Type type_to_enum< float >
Definition packet_reader.hpp:19
Type
Data types that can be read from a buffer.
Definition packet_reader.hpp:14
constexpr Type type_to_enum
Mapping from Type to C++ types.
Definition packet_reader.hpp:17
bool ReadResult
Arbitrary return type which could be replaced with a more detailed type.
Definition packet_reader.hpp:25
constexpr Type type_to_enum< int >
Definition packet_reader.hpp:18
codex::refl::field_tuple_t< E > T
Definition soa.cpp:9
#define p()
Definition std2.c:11