HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions | Friends
hi::v1::file_view Class Reference

#include <hikogui/file/file_view.hpp>

Public Member Functions

 file_view (file_view const &other) noexcept=default
 
 file_view (file_view &&other) noexcept=default
 
file_viewoperator= (file_view const &other) noexcept=default
 
file_viewoperator= (file_view &&other) noexcept=default
 
 file_view (file const &file, std::size_t offset=0, std::size_t size=0)
 Create a file-view from a file-mapping.
 
 file_view (std::filesystem::path const &path, access_mode access_mode=access_mode::open_for_read, std::size_t offset=0, std::size_t size=0)
 
std::size_t offset () const noexcept
 
std::size_t size () const noexcept
 
bool unmapped () const noexcept
 Check if this file view is closed.
 
 operator bool () const noexcept
 Check if this file view is open.
 
void unmap () noexcept
 
void_span void_span () const noexcept
 Span to the mapping into memory.
 
const_void_span const_void_span () const noexcept
 
void flush (hi::void_span span) const noexcept
 Flush changes in memory to the open file view.
 

Friends

template<typename T >
std::span< T > as_span (file_view const &view) noexcept
 
std::string_view as_string_view (file_view const &view) noexcept
 
bstring_view as_bstring_view (file_view const &view) noexcept
 

Detailed Description

Map a file into virtual memory.

To map a file into memory there are three objects needed:

Constructor & Destructor Documentation

◆ file_view()

hi::v1::file_view::file_view ( file const & file,
std::size_t offset = 0,
std::size_t size = 0 )
inline

Create a file-view from a file-mapping.

Note
The mapping object will be retained by this file-view.
Parameters
fileAn open file object.
offsetThe offset from the beginning of the file-mapping (a file mapping may have an offset on its own). The offset must also be a multiple of the granularity.
sizeThe size of the mapping, if zero the full file-mapping object is mapped.

Member Function Documentation

◆ const_void_span()

const_void_span hi::v1::file_view::const_void_span ( ) const
inlinenoexcept

Span to the mapping into memory.

◆ flush()

void v1::file_view::flush ( hi::void_span span) const
inlinenoexcept

Flush changes in memory to the open file view.

Parameters
spanThe part of the buffer to flush.

◆ operator bool()

hi::v1::file_view::operator bool ( ) const
inlineexplicitnoexcept

Check if this file view is open.

Postcondition
Resources may be released if the file view is closed.
Returns
true of the file view is open.

◆ unmapped()

bool hi::v1::file_view::unmapped ( ) const
inlinenoexcept

Check if this file view is closed.

Postcondition
Resources may be released if the file view is closed.
Returns
true of the file view is closed.

◆ void_span()

void_span hi::v1::file_view::void_span ( ) const
inlinenoexcept

Span to the mapping into memory.


The documentation for this class was generated from the following files: