#include "input.h" #include #include #include #include #include std::string ReadFile(const std::string &filepath) { std::ifstream file(filepath, std::ios::binary | std::ios::ate); std::streamsize size = file.tellg(); file.seekg(0, std::ios::beg); std::string buffer(size, '\0'); file.read(buffer.data(), size); return buffer; } std::optional Lines::Next() { if (text_.empty()) { return std::nullopt; } for (size_t i = 0; i < text_.size(); ++i) { if (text_[i] == '\n') { std::string_view result(text_.data(), i); if (text_.size() > i + 1) { text_ = std::string_view(text_.data() + i + 1, text_.size() - i - 1); } else { text_ = std::string_view(); } return result; } } std::string_view last_result = text_; text_ = std::string_view(); return last_result; }