4 #include "ArraySegment.hpp"
5 #include "Platform.hpp"
12 byte* buffer =
nullptr;
16 explicit NetworkReader(
byte* _buffer) : buffer(_buffer) { position = 0; }
33 inline void reset() { position = 0; }
42 T value = *(T*)(buffer + position);
43 position +=
sizeof(T);
52 byte* array =
new byte[count];
53 std::copy(buffer + position, buffer + position + count, array);
63 auto length = read<short>();
65 std::string str((
char*)array, length);
std::string readString()
Read a string from the buffer.
Definition: NetworkReader.hpp:62
T * toArray() const
Get the array.
Definition: ArraySegment.hpp:40
Definition: NetworkReader.hpp:10
byte * readBytes(int count)
Read a byte array from the buffer.
Definition: NetworkReader.hpp:51
T read()
Read a value from the buffer.
Definition: NetworkReader.hpp:41
void reset()
Reset the position to 0.
Definition: NetworkReader.hpp:33
Definition: ArraySegment.hpp:9