RAII memory-mapped read-only file view.
More...
#include <MappedFile.hpp>
RAII memory-mapped read-only file view.
The constructor opens the file and maps its entire contents into virtual memory. The destructor unmaps and closes all handles. Move-only.
Usage:
const char*
data = mf.data();
size_t len = mf.size();
MappedFile(const std::string &path, bool enforce_size_limit=true)
Opens and memory-maps a file for reading.
Definition MappedFile.hpp:63
const char * data() const noexcept
Pointer to the start of the mapped file contents.
Definition MappedFile.hpp:181
◆ MappedFile() [1/3]
| correlation::core::MappedFile::MappedFile |
( |
const std::string & | path, |
|
|
bool | enforce_size_limit = true ) |
|
inlineexplicit |
Opens and memory-maps a file for reading.
- Parameters
-
| path | File system path. |
| enforce_size_limit | If true, throws when file exceeds 4 GiB. |
- Exceptions
-
| std::runtime_error | on I/O or mapping errors, or if the file exceeds the 4 GiB limit while enforce_size_limit is true. |
◆ ~MappedFile()
| correlation::core::MappedFile::~MappedFile |
( |
| ) |
|
|
inline |
◆ MappedFile() [2/3]
| correlation::core::MappedFile::MappedFile |
( |
MappedFile && | other | ) |
|
|
inlinenoexcept |
◆ MappedFile() [3/3]
| correlation::core::MappedFile::MappedFile |
( |
const MappedFile & | | ) |
|
|
delete |
◆ data()
| const char * correlation::core::MappedFile::data |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
Pointer to the start of the mapped file contents.
◆ end()
| const char * correlation::core::MappedFile::end |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
Convenience: pointer past the end.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ release()
| void correlation::core::MappedFile::release |
( |
| ) |
|
|
inlineprivatenoexcept |
◆ size()
| std::size_t correlation::core::MappedFile::size |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
Size of the mapped region in bytes.
◆ data_
| void* correlation::core::MappedFile::data_ {nullptr} |
|
private |
◆ fd_
| int correlation::core::MappedFile::fd_ {-1} |
|
private |
◆ size_
| std::size_t correlation::core::MappedFile::size_ {0} |
|
private |
The documentation for this class was generated from the following file: