Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
DEMO
Loading...
Searching...
No Matches
signet::forge::MmapReader Class Reference

Low-level memory-mapped file handle. More...

#include <mmap_reader.hpp>

Public Member Functions

const uint8_t * data () const
 Pointer to the start of the mapped file.
 
size_t size () const
 Total file size in bytes.
 
const uint8_t * data_at (size_t offset) const
 Pointer to mapped memory at a given offset.
 
void close ()
 Unmap the file and close the file descriptor.
 
 ~MmapReader ()
 Destructor – unmaps file and closes fd.
 
 MmapReader (const MmapReader &)=delete
 Non-copyable.
 
MmapReaderoperator= (const MmapReader &)=delete
 Non-copyable.
 
 MmapReader (MmapReader &&other) noexcept
 Move constructor – transfers ownership of the mapping.
 
MmapReaderoperator= (MmapReader &&other) noexcept
 Move assignment – transfers ownership of the mapping.
 
bool is_open () const
 Returns true if the mapping is currently active.
 
 MmapReader ()=default
 Default constructor — creates a closed/unmapped reader.
 

Static Public Member Functions

static expected< MmapReaderopen (const std::filesystem::path &path)
 Open a file and memory-map it read-only.
 

Detailed Description

Low-level memory-mapped file handle.

RAII wrapper around POSIX mmap(2). Opens a file in read-only mode, maps it entirely into memory, and unmaps on destruction (or explicit close()). Non-copyable, movable.

Note
data_at() returns nullptr for out-of-bounds offsets (C4 hardening).

Definition at line 82 of file mmap_reader.hpp.

Constructor & Destructor Documentation

◆ ~MmapReader()

signet::forge::MmapReader::~MmapReader ( )
inline

Destructor – unmaps file and closes fd.

Definition at line 188 of file mmap_reader.hpp.

◆ MmapReader() [1/3]

signet::forge::MmapReader::MmapReader ( const MmapReader )
delete

Non-copyable.

◆ MmapReader() [2/3]

signet::forge::MmapReader::MmapReader ( MmapReader &&  other)
inlinenoexcept

Move constructor – transfers ownership of the mapping.

Definition at line 198 of file mmap_reader.hpp.

◆ MmapReader() [3/3]

signet::forge::MmapReader::MmapReader ( )
default

Default constructor — creates a closed/unmapped reader.

Member Function Documentation

◆ close()

void signet::forge::MmapReader::close ( )
inline

Unmap the file and close the file descriptor.

Safe to call multiple times; subsequent calls are no-ops.

Definition at line 175 of file mmap_reader.hpp.

◆ data()

const uint8_t * signet::forge::MmapReader::data ( ) const
inline

Pointer to the start of the mapped file.

Definition at line 153 of file mmap_reader.hpp.

◆ data_at()

const uint8_t * signet::forge::MmapReader::data_at ( size_t  offset) const
inline

Pointer to mapped memory at a given offset.

Returns nullptr if offset is out of bounds.

Definition at line 163 of file mmap_reader.hpp.

◆ is_open()

bool signet::forge::MmapReader::is_open ( ) const
inline

Returns true if the mapping is currently active.

Definition at line 223 of file mmap_reader.hpp.

◆ open()

static expected< MmapReader > signet::forge::MmapReader::open ( const std::filesystem::path &  path)
inlinestatic

Open a file and memory-map it read-only.

On success, returns an active MmapReader whose data() points to the mapped file contents. Applies MADV_SEQUENTIAL if available.

Parameters
pathFilesystem path to the file to map.
Returns
An MmapReader on success, or an Error on failure.

Definition at line 91 of file mmap_reader.hpp.

◆ operator=() [1/2]

MmapReader & signet::forge::MmapReader::operator= ( const MmapReader )
delete

Non-copyable.

◆ operator=() [2/2]

MmapReader & signet::forge::MmapReader::operator= ( MmapReader &&  other)
inlinenoexcept

Move assignment – transfers ownership of the mapping.

Definition at line 209 of file mmap_reader.hpp.

◆ size()

size_t signet::forge::MmapReader::size ( ) const
inline

Total file size in bytes.

Definition at line 158 of file mmap_reader.hpp.


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