1
0
Fork 0
mirror of https://gitlab.com/niansa/llama_any.git synced 2025-03-06 20:48:27 +01:00
llama_any/Receiver.hpp
2023-04-03 22:06:29 +02:00

30 lines
593 B
C++

#ifndef _RECEIVER_HPP
#define _RECEIVER_HPP
#include "Runtime.hpp"
#include <string>
#include <cstddef>
namespace Receiver {
class Simple {
protected:
int fd;
public:
Simple(int fd) : fd(fd) {}
// Reads the exact amount of bytes given
std::string read(size_t amount);
void read(std::byte *buffer, size_t size);
// Reads at max. the amount of bytes given
std::string readSome(size_t max);
// Reads an object of type T
template<typename T>
auto readObject(T& o) {
return read(reinterpret_cast<std::byte *>(&o), sizeof(o));
}
};
}
#endif