#pragma once #include #include #include #include #include #include #include "detail/Errors.hpp" namespace ovdl::detail { template class BasicBufferHandler { public: OVDL_OPTIONAL_CONSTEXPR bool is_valid() const { return _buffer.size() != 0; } OVDL_OPTIONAL_CONSTEXPR std::optional load_buffer_size(const char* data, std::size_t size) { _buffer = lexy::buffer(data, size); return std::nullopt; } OVDL_OPTIONAL_CONSTEXPR std::optional load_buffer(const char* start, const char* end) { _buffer = lexy::buffer(start, end); return std::nullopt; } std::optional load_file(const char* path) { auto file = lexy::read_file(path); if (!file) { return ovdl::errors::make_no_file_error(path); } _buffer = file.buffer(); return std::nullopt; } protected: lexy::buffer _buffer; }; }