mirror of
https://gitlab.com/niansa/llama_nds.git
synced 2025-03-06 20:53:28 +01:00
30 lines
593 B
C++
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
|