Lunchbox
1.9.1
|
Helper to map a file to a memory address (mmap). More...
#include <memoryMap.h>
Public Member Functions | |
LUNCHBOX_API | MemoryMap () |
Construct a new memory map. More... | |
LUNCHBOX_API | MemoryMap (const std::string &filename) |
Construct and initialize a new, readonly memory map. More... | |
LUNCHBOX_API | MemoryMap (const std::string &filename, const size_t size) |
Construct and initialize a new, read-write memory map. More... | |
LUNCHBOX_API | ~MemoryMap () |
Destruct the memory map. More... | |
LUNCHBOX_API const void * | map (const std::string &filename) |
Map a file to a memory address. More... | |
LUNCHBOX_API const void * | remap (const std::string &filename) |
Remap a different file for this memory map. More... | |
LUNCHBOX_API void * | create (const std::string &filename, const size_t size) |
Create a writable file to a memory address. More... | |
LUNCHBOX_API void * | recreate (const std::string &filename, const size_t size) |
Recreate a different writable file for this memory map. More... | |
LUNCHBOX_API void | unmap () |
Unmap the file. More... | |
LUNCHBOX_API const void * | getAddress () const |
LUNCHBOX_API void * | getAddress () |
template<class T > | |
const T * | getAddress () const |
template<class T > | |
T * | getAddress () |
LUNCHBOX_API size_t | getSize () const |
Helper to map a file to a memory address (mmap).
Example:
Definition at line 36 of file memoryMap.h.
LUNCHBOX_API lunchbox::MemoryMap::MemoryMap | ( | ) |
Construct a new memory map.
|
explicit |
Construct and initialize a new, readonly memory map.
LUNCHBOX_API lunchbox::MemoryMap::MemoryMap | ( | const std::string & | filename, |
const size_t | size | ||
) |
Construct and initialize a new, read-write memory map.
LUNCHBOX_API lunchbox::MemoryMap::~MemoryMap | ( | ) |
LUNCHBOX_API void* lunchbox::MemoryMap::create | ( | const std::string & | filename, |
const size_t | size | ||
) |
Create a writable file to a memory address.
The file is mapped read-write. An existing file will be overwritten. The file is automatically unmapped when the memory map is deleted.
filename | The filename of the file to map. |
size | this size of the file. |
LUNCHBOX_API const void* lunchbox::MemoryMap::getAddress | ( | ) | const |
Referenced by getAddress().
LUNCHBOX_API void* lunchbox::MemoryMap::getAddress | ( | ) |
|
inline |
Definition at line 116 of file memoryMap.h.
References getAddress().
|
inline |
Definition at line 120 of file memoryMap.h.
References getAddress().
LUNCHBOX_API size_t lunchbox::MemoryMap::getSize | ( | ) | const |
LUNCHBOX_API const void* lunchbox::MemoryMap::map | ( | const std::string & | filename | ) |
Map a file to a memory address.
The file is only mapped read-only. The file is automatically unmapped when the memory map is deleted.
filename | The filename of the file to map. |
LUNCHBOX_API void* lunchbox::MemoryMap::recreate | ( | const std::string & | filename, |
const size_t | size | ||
) |
Recreate a different writable file for this memory map.
The file is only mapped read-write. An existing map is unmapped.
filename | The filename of the file to map. |
size | this size of the file. |
LUNCHBOX_API const void* lunchbox::MemoryMap::remap | ( | const std::string & | filename | ) |
Remap a different file for this memory map.
The file is only mapped read-only. An existing map is unmapped.
filename | The filename of the file to map. |
LUNCHBOX_API void lunchbox::MemoryMap::unmap | ( | ) |
Unmap the file.