43#include <ufo/io/file_handler.hpp>
52 : fp_(
std::fopen(file.c_str(),
std::string(modes).c_str()))
57 : fp_(std::exchange(other.fp_,
nullptr))
65 fp_ = std::exchange(other.fp_,
nullptr);
75 fp_ = std::fopen(file.c_str(), std::string(modes).c_str());
90 return std::fgets(buffer_.data(),
static_cast<int>(
buffer_size), fp_);
93FileHandler::operator bool() const noexcept {
return nullptr != fp_; }
RAII wrapper around a C std::FILE* handle.
std::FILE * get() const noexcept
Returns the underlying FILE*.
static constexpr std::size_t buffer_size
Maximum number of characters (including the null terminator) read by readline().
void open(std::filesystem::path const &file, std::string_view modes)
Closes any currently open file, then opens file in modes.
char * readline()
Reads one line from the file into the internal buffer.
void close() noexcept
Closes the managed file handle and resets the pointer to null.
FileHandler()=default
Constructs an empty (closed) file handler.
~FileHandler()
Closes the managed file handle (if open).
All vision-related classes and functions.