lean cpp library
A lean C++ library providing efficient utility classes for high-performance C++ applications.
Public Member Functions | Protected Member Functions
lean::io::rmapped_file Class Reference

File class that allows for memory-mapped read access to a given file. More...

#include <mapped_file.h>

Inheritance diagram for lean::io::rmapped_file:
lean::io::mapped_file_base

List of all members.

Public Member Functions

LEAN_MAYBE_EXPORT rmapped_file (const utf8_ntri &name, bool mapWhole=true, open_mode mode=file::open, uint4 hints=file::none, uint4 share=file::share_default)
 Opens the given file according to the given flags. Throws a runtime_exception on error.
LEAN_MAYBE_EXPORT ~rmapped_file ()
 Closes this file.
LEAN_MAYBE_EXPORT const void * map (uint8 offset=0, size_t size=0)
 (Re-)maps the file using the given parameters. A size of 0 maps the entire file starting at the given offset. Throws a runtime_exception on error.
LEAN_MAYBE_EXPORT void unmap ()
 Unmaps the file.
LEAN_INLINE const void * data () const
 Gets a pointer to the file in memory, nullptr if currently unmapped.
LEAN_INLINE bool mapped () const
 Gets whether the file is currently mapped.

Protected Member Functions

LEAN_MAYBE_EXPORT void * map (bool readonly, uint8 offset, size_t size)
 Maps the given view of this file. A size of 0 maps the entire file starting at the given offset. Throws a runtime_exception on error.
LEAN_MAYBE_EXPORT void unmap (void *memory)
 Unmaps the given view of this file.
LEAN_MAYBE_EXPORT void resize (uint8 newSize)
 Resizes the file, either extending or truncating it. Throws a runtime_exception on error. Destroys the mapping, re-mapping is only possible again after this method has returned successfully.

Detailed Description

File class that allows for memory-mapped read access to a given file.


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