ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::MappedFile Class Reference

a whole file mapped privately in memory, shared by its copies More...

#include <ADS/external/MappedFile.h>

Public member functions

 MappedFile (void)=default
 no file
 MappedFile (const std::filesystem::path &p)
 the file at \( p \), mapped (or read, where it cannot be mapped)
 MappedFile (const MappedFile &o) noexcept
 the same mapping, shared
 MappedFile (MappedFile &&o) noexcept
 the mapping of \( o \), which is left with no file
MappedFile & operator= (const MappedFile &o) noexcept
 the same mapping as \( o \), shared
MappedFile & operator= (MappedFile &&o) noexcept
 the mapping of \( o \), which is left with no file
 ~MappedFile (void)
 the mapping released if this is its last copy
std::span< std::byte > bytes (void) const
 the bytes of the file, which start on a line of the cache (on a page where the file is mapped) and may be written by the process alone
 operator bool (void) const
 whether there is a file
bool mapped (void) const
 whether the file is mapped by the system, rather than read
bool holds (const void *p) const
 whether \( p \) lies in the bytes of the file
void offer (void *p, std::size_t m) const
 the bytes at \( p \), \( m \) of them, offered to the next take() of \( m \) bytes
void * take (std::size_t m) const
 the bytes offered, if \( m \) of them, taken; else null

Friends

bool operator== (const MappedFile &a, const MappedFile &b)
 whether the two are copies of the same mapping

Detailed description

a whole file mapped privately in memory, shared by its copies

Constructor and destructor documentation

◆ MappedFile() [1/4]

ADS::MappedFile::MappedFile ( void )
default

no file

◆ MappedFile() [2/4]

ADS::MappedFile::MappedFile ( const std::filesystem::path & p)
explicit

the file at \( p \), mapped (or read, where it cannot be mapped)

◆ MappedFile() [3/4]

ADS::MappedFile::MappedFile ( const MappedFile & o)
noexcept

the same mapping, shared

◆ MappedFile() [4/4]

ADS::MappedFile::MappedFile ( MappedFile && o)
noexcept

the mapping of \( o \), which is left with no file

◆ ~MappedFile()

ADS::MappedFile::~MappedFile ( void )

the mapping released if this is its last copy

Member function documentation

◆ bytes()

std::span< std::byte > ADS::MappedFile::bytes ( void ) const
nodiscard

the bytes of the file, which start on a line of the cache (on a page where the file is mapped) and may be written by the process alone

◆ holds()

bool ADS::MappedFile::holds ( const void * p) const
nodiscard

whether \( p \) lies in the bytes of the file

◆ mapped()

bool ADS::MappedFile::mapped ( void ) const
nodiscard

whether the file is mapped by the system, rather than read

◆ offer()

void ADS::MappedFile::offer ( void * p,
std::size_t m ) const

the bytes at \( p \), \( m \) of them, offered to the next take() of \( m \) bytes

Precondition
there is a file, which holds \( p \)

◆ operator bool()

ADS::MappedFile::operator bool ( void ) const
inlineexplicitnodiscard

whether there is a file

◆ operator=() [1/2]

MappedFile & ADS::MappedFile::operator= ( const MappedFile & o)
noexcept

the same mapping as \( o \), shared

◆ operator=() [2/2]

MappedFile & ADS::MappedFile::operator= ( MappedFile && o)
noexcept

the mapping of \( o \), which is left with no file

◆ take()

void * ADS::MappedFile::take ( std::size_t m) const
nodiscard

the bytes offered, if \( m \) of them, taken; else null

◆ operator==

bool operator== ( const MappedFile & a,
const MappedFile & b )
friend

whether the two are copies of the same mapping


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