blob: 6a82c7a32ad59b82c471809036cd544f7e41c4ab [file] [log] [blame]
#pragma once
#include <array>
#include <functional>
#include <span>
#include <stdplus/fd/intf.hpp>
#include <string>
namespace stdplus
{
namespace fd
{
class LineReader
{
public:
static constexpr size_t buf_size = 4096;
LineReader(stdplus::Fd& fd);
LineReader(const LineReader&) = delete;
LineReader(LineReader&&) = default;
LineReader& operator=(const LineReader&) = delete;
LineReader& operator=(LineReader&&) = default;
const std::string* readLine();
private:
std::reference_wrapper<stdplus::Fd> fd;
std::array<char, buf_size> buf;
std::span<char> buf_data;
std::string line;
bool line_complete = false, hit_eof = false;
};
} // namespace fd
} // namespace stdplus