Joedb 9.1.4
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
step_by_step_replay.cpp
Go to the documentation of this file.
1#include "tutorial/Database.h"
3
4#include <iostream>
5#include <iomanip>
6
7namespace example
8{
9 ////////////////////////////////////////////////////////////////////////////
11 ////////////////////////////////////////////////////////////////////////////
12 {
13 void comment(const std::string &comment) override
14 {
15 std::cout << "Comment: " << comment << '\n';
16 };
17
18 void timestamp(int64_t timestamp) override
19 {
20 std::cout << "Timestamp: " << timestamp << '\n';
21 };
22 };
23}
24
25/////////////////////////////////////////////////////////////////////////////
26int main()
27/////////////////////////////////////////////////////////////////////////////
28{
30 joedb::File file("tutorial.joedb", joedb::Open_Mode::read_existing);
31 joedb::Readonly_Journal journal(file);
32
33 int counter = 0;
34
35 while (!journal.at_end_of_file())
36 {
37 journal.one_step(db);
38 ++counter;
39
40 std::cout << std::setw(3) << counter << ' ';
41 std::cout << "Number of persons: ";
42 std::cout << db.get_person_table().get_size();
43 std::cout << '\n';;
44 }
45
46 return 0;
47}
void one_step(Writable &writable)
Store all the tables of the database.
Definition Database.h:101
container_of_person get_person_table() const
Definition Database.h:908
@ read_existing
fails if does not exist
JOEDB_FILE File
Definition File.h:25
int main()