Go to the documentation of this file.
4 #ifndef LEXY_INPUT_FILE_HPP_INCLUDED
5 #define LEXY_INPUT_FILE_HPP_INCLUDED
12 #ifdef LEXY_DISABLE_FILE
13 # error "lexy::read_file() and lexy::read_stdin() have been disabled"
48 template <
typename Encoding = default_encoding,
typename MemoryResource =
void>
55 explicit operator bool() const noexcept
94 template <
typename Encoding, encoding_endianness Endian,
typename MemoryResource>
104 return [](
void* _user_data,
const char* memory, std::size_t
size) {
108 = lexy::make_buffer_from_raw<Encoding, Endian>(memory,
size, user_data->resource);
114 template <
typename Encoding = default_encoding,
117 MemoryResource* resource = _detail::get_memory_resource<MemoryResource>())
126 template <
typename Encoding = default_encoding,
128 auto read_stdin(MemoryResource* resource = _detail::get_memory_resource<MemoryResource>())
137 #endif // LEXY_INPUT_FILE_HPP_INCLUDED
file_error read_stdin(file_callback cb, void *user_data)
constexpr auto size(const C &c) -> decltype(c.size())
encoding_endianness
The endianness used by an encoding.
MemoryResource * resource
string_view::value_type char_type
@ permission_denied
The file cannot be opened.
auto read_file(const char *path, MemoryResource *resource=_detail::get_memory_resource< MemoryResource >()) -> read_file_result< Encoding, MemoryResource >
Reads the file at the specified path into a buffer.
lexy::buffer< Encoding, MemoryResource > && buffer() &&noexcept
auto read_stdin(MemoryResource *resource=_detail::get_memory_resource< MemoryResource >()) -> read_file_result< Encoding, MemoryResource >
Reads stdin into a buffer.
lexy::buffer< Encoding, MemoryResource > buffer
#define LEXY_PRECONDITION(Expr)
read_file_result(file_error ec, lexy::buffer< Encoding, MemoryResource > &&buffer) noexcept
_read_file_user_data(MemoryResource *resource)
typename encoding::char_type char_type
file_error error() const noexcept
file_error
Errors that might occur while reading the file.
@ os_error
An internal OS error, such as failure to read from the file.
read_file_result(file_error ec, MemoryResource *resource) noexcept
void(*)(void *user_data, const char *memory, std::size_t size) file_callback
lexy::buffer< Encoding, MemoryResource > _buffer
const lexy::buffer< Encoding, MemoryResource > & buffer() const &noexcept
@ file_not_found
The file was not found.
file_error read_file(const char *path, file_callback cb, void *user_data)