Joedb 9.1.4
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::pull()
9 ////////////////////////////////////////////////////////////////////////////
10 {
12 journal.pull();
13
15 {
17 stream << '\n';
18 Interpreter_Writable writable(stream, db);
19 Multiplexer multiplexer{writable, db};
21 journal.play_until_checkpoint(multiplexer);
22 stream.flush();
23 }
24 }
25
26 ////////////////////////////////////////////////////////////////////////////
27 void Interpreted_Stream_File::pwrite
28 ////////////////////////////////////////////////////////////////////////////
29 (
30 const char *buffer,
31 size_t size,
32 int64_t offset
33 )
34 {
35 Memory_File::pwrite(buffer, size, offset);
37 pull();
38 }
39
40 ////////////////////////////////////////////////////////////////////////////
42 ////////////////////////////////////////////////////////////////////////////
43 Readonly_Interpreted_File(stream, false),
44 stream(stream)
45 {
46 stream.clear(); // clears eof flag after reading, get ready to write
47 }
48
49 ////////////////////////////////////////////////////////////////////////////
51 ////////////////////////////////////////////////////////////////////////////
52 {
53 constexpr auto in = std::ios::binary | std::ios::in;
54 file_stream.open(file_name, in | std::ios::out);
55 if (!file_stream)
56 file_stream.open(file_name, in | std::ios::out | std::ios::trunc);
57 }
58
59 ////////////////////////////////////////////////////////////////////////////
61 ////////////////////////////////////////////////////////////////////////////
62
63 ////////////////////////////////////////////////////////////////////////////
64 Interpreted_File::Interpreted_File(const char *file_name):
65 ////////////////////////////////////////////////////////////////////////////
66 Interpreted_File_Data(file_name),
67 Interpreted_Stream_File(file_stream)
68 {
69 }
70}
Interpreted_File_Data(const char *file_name)
Interpreted_File(const char *file_name)
Interpreted_Stream_File(std::iostream &stream)
void pwrite(const char *buffer, size_t size, int64_t offset) override
static constexpr bool is_second_checkpoint_copy(int64_t offset)
void set_position(int64_t position)
int64_t get_checkpoint_position() const
void play_until_checkpoint(Writable &writable)
static constexpr int64_t header_size
Definition Blob.h:7