11#include "file_intf.hpp"
12#include "file_view_win32_impl.hpp"
13#include "access_mode.hpp"
14#include "../container/container.hpp"
15#include "../char_maps/char_maps.hpp"
16#include "../utility/utility.hpp"
17#include "../macros.hpp"
22hi_export_module(hikogui.file.file_view);
27hi_warning_ignore_msvc(26490);
29hi_export
namespace hi {
inline namespace v1 {
57 _pimpl(
std::make_shared<detail::file_view_impl>(
file.pimpl(), offset, size))
62 std::filesystem::path
const& path,
72 hi_assert_not_null(_pimpl);
73 return _pimpl->offset();
78 hi_assert_not_null(_pimpl);
79 return _pimpl->size();
90 if (_pimpl->unmapped()) {
106 explicit operator bool() const noexcept
111 void unmap() noexcept
113 if (
auto pimpl = std::exchange(_pimpl,
nullptr)) {
122 hi_assert_not_null(_pimpl);
123 return _pimpl->void_span();
130 hi_assert_not_null(_pimpl);
131 return _pimpl->const_void_span();
138 void flush(hi::void_span span)
const noexcept
140 hi_assert_not_null(_pimpl);
141 return _pimpl->flush(span);
145 [[nodiscard]]
friend std::span<T> as_span(
file_view const& view)
noexcept
147 if constexpr (std::is_const_v<T>) {
148 return as_span<T>(view.const_void_span());
150 return as_span<T>(view.void_span());
154 [[nodiscard]]
friend std::string_view as_string_view(file_view
const& view)
noexcept
156 hi_assert(view.offset() == 0);
157 return as_string_view(view.const_void_span());
160 [[nodiscard]]
friend bstring_view as_bstring_view(file_view
const& view)
noexcept
162 hi_assert(view.offset() == 0);
163 return as_bstring_view(view.const_void_span());
access_mode
The mode in which way to open a file.
Definition access_mode.hpp:17
@ open_for_read
Default open a file for reading.
@ other
The gui_event does not have associated data.
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
A File object.
Definition file_intf.hpp:33
Map a file into virtual memory.
Definition file_view.hpp:39
void_span void_span() const noexcept
Span to the mapping into memory.
Definition file_view.hpp:120
const_void_span const_void_span() const noexcept
Definition file_view.hpp:128
void flush(hi::void_span span) const noexcept
Flush changes in memory to the open file view.
Definition file_view.hpp:138
file_view(file const &file, std::size_t offset=0, std::size_t size=0)
Create a file-view from a file-mapping.
Definition file_view.hpp:56
bool unmapped() const noexcept
Check if this file view is closed.
Definition file_view.hpp:87