Libosmium
2.20.0
Fast and flexible C++ library for working with OpenStreetMap data
|
#include <memory_mapping.hpp>
Public Member Functions | |
TypedMemoryMapping (std::size_t size) | |
TypedMemoryMapping (std::size_t size, MemoryMapping::mapping_mode mode, int fd, off_t offset=0) | |
TypedMemoryMapping (const TypedMemoryMapping &)=delete | |
You can not copy construct a TypedMemoryMapping. More... | |
TypedMemoryMapping & | operator= (const TypedMemoryMapping &)=delete |
You can not copy a TypedMemoryMapping. More... | |
TypedMemoryMapping (TypedMemoryMapping &&other) noexcept=default | |
TypedMemoryMapping & | operator= (TypedMemoryMapping &&other) noexcept=default |
~TypedMemoryMapping () noexcept=default | |
void | unmap () |
void | resize (std::size_t new_size) |
operator bool () const noexcept | |
std::size_t | size () const noexcept |
int | fd () const noexcept |
bool | writable () const noexcept |
T * | begin () noexcept |
T * | end () noexcept |
const T * | cbegin () const noexcept |
const T * | cend () const noexcept |
const T * | begin () const noexcept |
const T * | end () const noexcept |
Private Attributes | |
MemoryMapping | m_mapping |
A thin wrapper around the MemoryMapping class used when all the data in the mapped memory is of the same type. Instead of thinking about the number of bytes mapped, this counts sizes in the number of objects of that type.
Note that no effort is made to actually initialize the objects in this memory. This has to be done by the caller!
|
inlineexplicit |
Create anonymous typed memory mapping of given size.
size | Number of objects of type T to be mapped |
std::system_error | if the mapping fails |
|
inline |
Create file-backed memory mapping of given size. The file must contain at least sizeof(T) * size
bytes!
size | Number of objects of type T to be mapped |
mode | Mapping mode: readonly, or writable (shared or private) |
fd | Open file descriptor of a file we want to map |
offset | Offset into the file where the mapping should start |
std::system_error | if the mapping fails |
|
delete |
You can not copy construct a TypedMemoryMapping.
|
defaultnoexcept |
Move construct a mapping from another one. The other mapping will be marked as invalid.
|
defaultnoexcept |
|
inlinenoexcept |
Get the address of the beginning of the mapping.
|
inlinenoexcept |
Get the address of the beginning of the mapping.
|
inlinenoexcept |
Get the address of the beginning of the mapping.
|
inlinenoexcept |
Get the address one past the end of the mapping.
|
inlinenoexcept |
Get the address one past the end of the mapping.
|
inlinenoexcept |
Get the address one past the end of the mapping.
|
inlinenoexcept |
The file descriptor this mapping was created from.
|
inlineexplicitnoexcept |
In a boolean context a TypedMemoryMapping is true when it is a valid existing mapping.
|
delete |
You can not copy a TypedMemoryMapping.
|
defaultnoexcept |
Move a mapping. The other mapping will be marked as invalid.
|
inline |
Resize a mapping to the given new size.
On Linux systems this will use the mremap() function. On other systems it will unmap and remap the memory. This can only be done for file-based mappings, not anonymous mappings!
new_size | Number of objects of type T to resize to |
std::system_error | if the remapping fails |
|
inlinenoexcept |
The number of objects of class T mapped. This is the same size you created the mapping with. The actual mapping will probably be larger because the system will round it to the page size.
|
inline |
Unmap a mapping. If the mapping is not valid, it will do nothing.
std::system_error | if the unmapping fails |
|
inlinenoexcept |
Was this mapping created as a writable mapping?
|
private |