Joedb 9.6.1
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
tutorial_interpreter.cpp
Go to the documentation of this file.
3#include "tutorial/Readable.h"
10
11#include <iostream>
12#include <joedb/Multiplexer.h>
13
14namespace joedb
15{
16 ////////////////////////////////////////////////////////////////////////////
17 static int tutorial_interpreter(Arguments &arguments)
18 ////////////////////////////////////////////////////////////////////////////
19 {
20 const std::string_view file_name = arguments.get_next("file.joedb");
21
22 if (arguments.missing())
23 {
24 arguments.print_help(std::cerr);
25 return 1;
26 }
27
28 tutorial::File_Client client(file_name.data());
29
30 client.transaction([](tutorial::Writable_Database &db){
31 tutorial::Readable readable(db);
32 tutorial::Multiplexer multiplexer(db);
33
34 Command_Interpreter interpreter;
35
36 Blob_Reader_Command_Processor blob_reader_processor
37 (
39 );
40
41 Data_Manipulation_Command_Processor data_manipulation_processor
42 (
43 readable,
44 multiplexer,
45 0
46 );
47
48 Writable_Command_Processor writable_processor(multiplexer, db);
49
50 interpreter.add_processor(blob_reader_processor);
51 interpreter.add_processor(data_manipulation_processor);
52 interpreter.add_processor(writable_processor);
53
54 interpreter.main_loop(std::cin, std::cout);
55 });
56
57 return 0;
58 }
59}
60
61/////////////////////////////////////////////////////////////////////////////
62int main(int argc, char **argv)
63/////////////////////////////////////////////////////////////////////////////
64{
65 joedb::main_wrapper(joedb::tutorial_interpreter, argc, argv);
66}
const Buffered_File & get_file() const
Shortcut to directly build a Client from a file name.
Definition File_Client.h:39
Write simultaneously to the database and the file (ignore schema changes)
Definition Multiplexer.h:40
Implement the joedb::Readable interface for a compiled database.
Definition Readable.h:27
A writable Database constructed from a writable joedb::Buffered_File.
const joedb::Readonly_Journal & get_journal() const
int main()
int main_wrapper(int(*main)(Arguments &), int argc, char **argv)
Process command-line arguments and catch exceptions from main.
Definition Blob.h:7