Joedb 10.2.1
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Memory_File.h
Go to the documentation of this file.
1#ifndef joedb_Memory_File_declared
2#define joedb_Memory_File_declared
3
5
6#include <string>
7
8namespace joedb
9{
10 /// @ingroup journal
12 {
13 protected:
14 std::string data;
15
16 public:
21
22 void resize(size_t size) {data.resize(size);}
23 std::string &get_data() {return data;}
24 const std::string &get_data() const {return data;}
25 std::string move_data() const {return std::move(data);}
26
27 int64_t get_size() const override {return int64_t(data.size());}
28 size_t pread(char *buffer, size_t size, int64_t offset) const override;
29 void pwrite(const char *buffer, size_t size, int64_t offset) override;
30 };
31}
32
33#endif
const std::string & get_data() const
Definition Memory_File.h:24
void pwrite(const char *buffer, size_t size, int64_t offset) override
Write a range of bytes. Extend file size if necessary.
std::string & get_data()
Definition Memory_File.h:23
size_t pread(char *buffer, size_t size, int64_t offset) const override
Read a range of bytes.
void resize(size_t size)
Definition Memory_File.h:22
std::string move_data() const
Definition Memory_File.h:25
std::string data
Definition Memory_File.h:14
Memory_File(Open_Mode mode=Open_Mode::create_new)
Definition Memory_File.h:17
int64_t get_size() const override
Get the size of the file, or -1 if it is unknown.
Definition Memory_File.h:27
Open_Mode
Definition Open_Mode.h:8
@ create_new
fails if already exists, locks the file for writing