61 const char*
data() const noexcept {
return static_cast<const char*
>(data_); }
64 std::size_t
size() const noexcept {
return size_; }
67 bool empty() const noexcept {
return size_ == 0; }
70 void* data_ =
nullptr;
71 std::size_t size_ = 0;
74 void* file_ =
nullptr;
75 void* mapping_ =
nullptr;
96 static char empty = 0;
97 begin_ = size == 0 ? &empty :
const_cast<char*
>(data);
99 setg(begin_, begin_, end_);
103 std::streampos seekoff(std::streamoff off, std::ios_base::seekdir way,
104 std::ios_base::openmode which)
override;
105 std::streampos seekpos(std::streampos sp, std::ios_base::openmode which)
override;
108 char* begin_ =
nullptr;
109 char* end_ =
nullptr;
Read-only memory mapping of a file.
Definition mapped_file.hh:43
bool empty() const noexcept
Returns whether the file is empty.
Definition mapped_file.hh:67
MappedFile(const std::string &path)
Opens and maps the file at path.
std::size_t size() const noexcept
Returns the size of the mapping in bytes.
Definition mapped_file.hh:64
const char * data() const noexcept
Returns a pointer to the first mapped byte (nullptr for an empty file).
Definition mapped_file.hh:61
~MappedFile()
Unmaps the file and releases all handles.
Streambuf over a read-only memory region.
Definition mapped_file.hh:87
mapped_istreambuf(const char *data, std::size_t size)
Definition mapped_file.hh:93
Visibility/export macro for the shared library.
#define LIBKEEPASS_API
Marks a class, function or variable as part of the public ABI.
Definition export.hh:43