Joedb 10.0.1
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Interpreted_File.cpp
Go to the documentation of this file.
2#include "joedb/Multiplexer.h"
4
5namespace joedb
6{
7 ////////////////////////////////////////////////////////////////////////////
8 void Interpreted_Stream_File::pwrite
9 ////////////////////////////////////////////////////////////////////////////
10 (
11 const char *buffer,
12 size_t size,
13 int64_t offset
14 )
15 {
16 Memory_File::pwrite(buffer, size, offset);
17
18 if (offset < Header::ssize && journal.pull())
19 {
20 Interpreter_Writable writable(stream, db);
21 Multiplexer multiplexer{writable, db};
22 journal.play_until_checkpoint(multiplexer);
23 stream.flush();
24 }
25 }
26
27 ////////////////////////////////////////////////////////////////////////////
29 ////////////////////////////////////////////////////////////////////////////
30 Readonly_Interpreted_File(stream, false),
31 stream(stream)
32 {
33 stream.clear(); // clears eof flag after reading, get ready to write
34 }
35
36 ////////////////////////////////////////////////////////////////////////////
37 detail::Interpreted_File_Data::Interpreted_File_Data(const char *file_name)
38 ////////////////////////////////////////////////////////////////////////////
39 {
40 constexpr auto in = std::ios::binary | std::ios::in;
41 file_stream.open(file_name, in | std::ios::out);
42 if (!file_stream)
43 file_stream.open(file_name, in | std::ios::out | std::ios::trunc);
44 }
45
46 ////////////////////////////////////////////////////////////////////////////
47 detail::Interpreted_File_Data::~Interpreted_File_Data() = default;
48 ////////////////////////////////////////////////////////////////////////////
49
50 ////////////////////////////////////////////////////////////////////////////
51 Interpreted_File::Interpreted_File(const char *file_name):
52 ////////////////////////////////////////////////////////////////////////////
53 Interpreted_File_Data(file_name),
54 Interpreted_Stream_File(file_stream)
55 {
56 }
57}
Interpreted_File(const char *file_name)
Interpreted_Stream_File(std::iostream &stream)
void pwrite(const char *buffer, size_t size, int64_t offset) override
Write a range of bytes. Extend file size if necessary.
Definition Blob.h:7
static constexpr int64_t ssize
Definition Header.h:18