Joedb
9.1.4
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
source
tutorial
src
step_by_step_replay.cpp
Go to the documentation of this file.
1
#include "
tutorial/Database.h
"
2
#include "
joedb/journal/File.h
"
3
4
#include <iostream>
5
#include <iomanip>
6
7
namespace
example
8
{
9
////////////////////////////////////////////////////////////////////////////
10
class
My_Database
:
public
tutorial::Database
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
/////////////////////////////////////////////////////////////////////////////
26
int
main
()
27
/////////////////////////////////////////////////////////////////////////////
28
{
29
example::My_Database
db;
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
}
File.h
example::My_Database
Definition
step_by_step_replay.cpp:12
joedb::Readonly_Journal
Definition
Readonly_Journal.h:16
joedb::Readonly_Journal::one_step
void one_step(Writable &writable)
Definition
Readonly_Journal.cpp:213
joedb::Readonly_Journal::at_end_of_file
bool at_end_of_file() const
Definition
Readonly_Journal.cpp:206
tutorial::Database
Store all the tables of the database.
Definition
Database.h:101
tutorial::Database::get_person_table
container_of_person get_person_table() const
Definition
Database.h:908
tutorial::container_of_person::get_size
size_t get_size() const
Definition
Database.h:900
Database.h
joedb::Open_Mode::read_existing
@ read_existing
fails if does not exist
example
Definition
step_by_step_replay.cpp:8
joedb::File
JOEDB_FILE File
Definition
File.h:25
main
int main()
Definition
step_by_step_replay.cpp:26
Generated by
1.9.8