|
mio 1.1.0
|
#include <mmap.hpp>
Public Types | |
| using | value_type = ByteT |
| using | size_type = size_t |
| using | reference = value_type & |
| using | const_reference = const value_type & |
| using | pointer = value_type * |
| using | const_pointer = const value_type * |
| using | difference_type = std::ptrdiff_t |
| using | iterator = pointer |
| using | const_iterator = const_pointer |
| using | reverse_iterator = std::reverse_iterator< iterator > |
| using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
| using | iterator_category = std::random_access_iterator_tag |
| using | handle_type = file_handle_type |
| using mio::basic_mmap< AccessMode, ByteT >::const_iterator = const_pointer |
| using mio::basic_mmap< AccessMode, ByteT >::const_pointer = const value_type* |
| using mio::basic_mmap< AccessMode, ByteT >::const_reference = const value_type& |
| using mio::basic_mmap< AccessMode, ByteT >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
| using mio::basic_mmap< AccessMode, ByteT >::difference_type = std::ptrdiff_t |
| using mio::basic_mmap< AccessMode, ByteT >::handle_type = file_handle_type |
| using mio::basic_mmap< AccessMode, ByteT >::iterator = pointer |
| using mio::basic_mmap< AccessMode, ByteT >::iterator_category = std::random_access_iterator_tag |
| using mio::basic_mmap< AccessMode, ByteT >::pointer = value_type* |
| using mio::basic_mmap< AccessMode, ByteT >::reference = value_type& |
| using mio::basic_mmap< AccessMode, ByteT >::reverse_iterator = std::reverse_iterator<iterator> |
| using mio::basic_mmap< AccessMode, ByteT >::size_type = size_t |
| using mio::basic_mmap< AccessMode, ByteT >::value_type = ByteT |
|
inline |
The default constructed mmap object is in a non-mapped state, that is, any operation that attempts to access nonexistent underlying data will result in undefined behaviour/segmentation faults.
|
delete |
basic_mmap has single-ownership semantics, so transferring ownership may only be accomplished by moving the object.
| mio::basic_mmap< AccessMode, ByteT >::basic_mmap | ( | basic_mmap< AccessMode, ByteT > && | ) |
| mio::basic_mmap< AccessMode, ByteT >::~basic_mmap | ( | ) |
If this is a read-write mapping, the destructor invokes sync. Regardless of the access mode, unmap is invoked as a final step.
|
inlinenoexcept |
|
inlinenoexcept |
Returns an iterator to the first requested byte, if a valid memory mapping exists, otherwise this function call is undefined behaviour.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Returns a pointer to the first requested byte, or nullptr if no memory mapping exists.
|
inlinenoexcept |
Returns true if no mapping was established, that is, conceptually the same as though the length that was mapped was 0. This function is provided so that this class has Container semantics.
|
inlinenoexcept |
|
inlinenoexcept |
Returns an iterator one past the last requested byte, if a valid memory mapping exists, otherwise this function call is undefined behaviour.
|
inlinenoexcept |
On UNIX systems 'file_handle' and 'mapping_handle' are the same. On Windows, however, a mapped region of a file gets its own handle, which is returned by 'mapping_handle'.
|
noexcept |
Returns true if a mapping was established.
|
inlinenoexcept |
Returns whether a valid memory mapping has been created.
|
inlinenoexcept |
| void mio::basic_mmap< AccessMode, ByteT >::map | ( | const handle_type & | handle, |
| const size_type & | offset, | ||
| const size_type & | length, | ||
| std::error_code & | error | ||
| ) |
Establishes a memory mapping with AccessMode. If the mapping is unsuccesful, the reason is reported via error and the object remains in a state as if this function hadn't been called.
handle, which must be a valid file handle, which is used to memory map the requested region. Upon failure, error is set to indicate the reason and the object remains in an unmapped state.
offset is the number of bytes, relative to the start of the file, where the mapping should begin. When specifying it, there is no need to worry about providing a value that is aligned with the operating system's page allocation granularity. This is adjusted by the implementation such that the first requested byte (as returned by data or begin), so long as offset is valid, will be at offset from the start of the file.
length is the number of bytes to map. It may be map_entire_file, in which case a mapping of the entire file is created.
|
inline |
Establishes a memory mapping with AccessMode. If the mapping is unsuccesful, the reason is reported via error and the object remains in a state as if this function hadn't been called.
handle, which must be a valid file handle, which is used to memory map the requested region. Upon failure, error is set to indicate the reason and the object remains in an unmapped state.
The entire file is mapped.
| void mio::basic_mmap< AccessMode, ByteT >::map | ( | const String & | path, |
| const size_type & | offset, | ||
| const size_type & | length, | ||
| std::error_code & | error | ||
| ) |
Establishes a memory mapping with AccessMode. If the mapping is unsuccesful, the reason is reported via error and the object remains in a state as if this function hadn't been called.
path, which must be a path to an existing file, is used to retrieve a file handle (which is closed when the object destructs or unmap is called), which is then used to memory map the requested region. Upon failure, error is set to indicate the reason and the object remains in an unmapped state.
offset is the number of bytes, relative to the start of the file, where the mapping should begin. When specifying it, there is no need to worry about providing a value that is aligned with the operating system's page allocation granularity. This is adjusted by the implementation such that the first requested byte (as returned by data or begin), so long as offset is valid, will be at offset from the start of the file.
length is the number of bytes to map. It may be map_entire_file, in which case a mapping of the entire file is created.
|
inline |
Establishes a memory mapping with AccessMode. If the mapping is unsuccesful, the reason is reported via error and the object remains in a state as if this function hadn't been called.
path, which must be a path to an existing file, is used to retrieve a file handle (which is closed when the object destructs or unmap is called), which is then used to memory map the requested region. Upon failure, error is set to indicate the reason and the object remains in an unmapped state.
The entire file is mapped.
|
inlinenoexcept |
|
noexcept |
|
inlinenoexcept |
Returns the offset relative to the start of the mapping.
| basic_mmap & mio::basic_mmap< AccessMode, ByteT >::operator= | ( | basic_mmap< AccessMode, ByteT > && | ) |
|
delete |
|
inlinenoexcept |
|
inlinenoexcept |
Returns a reference to the ith byte from the first requested byte (as returned by data). If this is invoked when no valid memory mapping has been created prior to this call, undefined behaviour ensues.
|
inlinenoexcept |
|
inlinenoexcept |
Returns a reverse iterator to the last memory mapped byte, if a valid memory mapping exists, otherwise this function call is undefined behaviour.
|
inlinenoexcept |
|
inlinenoexcept |
Returns a reverse iterator past the first mapped byte, if a valid memory mapping exists, otherwise this function call is undefined behaviour.
|
inlinenoexcept |
size and length both return the logical length, i.e. the number of bytes user requested to be mapped, while mapped_length returns the actual number of bytes that were mapped which is a multiple of the underlying operating system's page allocation granularity.
| void mio::basic_mmap< AccessMode, ByteT >::swap | ( | basic_mmap< AccessMode, ByteT > & | other | ) |
| std::enable_if< A==access_mode::write, void >::type mio::basic_mmap< AccessMode, ByteT >::sync | ( | std::error_code & | error | ) |
Flushes the memory mapped page to disk. Errors are reported via error.
| void mio::basic_mmap< AccessMode, ByteT >::unmap | ( | ) |
If a valid memory mapping has been created prior to this call, this call instructs the kernel to unmap the memory region and disassociate this object from the file.
The file handle associated with the file that is mapped is only closed if the mapping was created using a file path. If, on the other hand, an existing file handle was used to create the mapping, the file handle is not closed.