1#ifndef SOURCEMETA_CORE_IO_FILEVIEW_H_
2#define SOURCEMETA_CORE_IO_FILEVIEW_H_
4#ifndef SOURCEMETA_CORE_IO_EXPORT
5#include <sourcemeta/core/io_export.h>
13namespace sourcemeta::core {
44 [[nodiscard]]
auto size() const noexcept -> std::
size_t;
50 [[nodiscard]] auto
as(const std::
size_t offset = 0) const noexcept
52 assert(offset +
sizeof(T) <= this->size_);
54 return reinterpret_cast<const T *
>(this->data_ + offset);
58 const std::uint8_t *data_{
nullptr};
61 void *file_handle_{
nullptr};
62 void *mapping_handle_{
nullptr};
64 int file_descriptor_{-1};
FileView(const std::filesystem::path &path)
Memory-map the file at the given path.
auto as(const std::size_t offset=0) const noexcept -> const T *
Definition io_fileview.h:50
auto size() const noexcept -> std::size_t
The size of the memory-mapped data in bytes.