Joedb 10.3.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
joedb_client.cpp
Go to the documentation of this file.
7
8#include <iostream>
9
10namespace joedb
11{
12 ////////////////////////////////////////////////////////////////////////////
13 static int client(Arguments &arguments)
14 ////////////////////////////////////////////////////////////////////////////
15 {
16 Parsed_Logger logger(arguments);
17
18 const Open_Mode default_mode = File::lockable
21
22 Client_Parser client_parser
23 (
24 logger.get(),
25 default_mode,
27 arguments
28 );
29
30 if (!client_parser.get())
31 {
32 arguments.print_help(std::cerr) << '\n';
33 client_parser.print_help(std::cerr);
34 return 1;
35 }
36
37 Client &client = *client_parser.get();
38
39 std::unique_ptr<Client_Command_Processor> interpreter;
40
41 Writable_Client *writable_client = dynamic_cast<Writable_Client*>(&client);
42
43 if (writable_client && !client.is_pullonly())
44 interpreter.reset(new Writable_Client_Command_Processor(*writable_client));
45 else
46 interpreter.reset(new Client_Command_Processor(client));
47
48 interpreter->set_prompt(true);
49 interpreter->main_loop(std::cin, std::cout);
50
51 return 0;
52 }
53}
54
55/////////////////////////////////////////////////////////////////////////////
56int main(int argc, char **argv)
57/////////////////////////////////////////////////////////////////////////////
58{
59 joedb::main_wrapper(joedb::client, argc, argv);
60}
int main()
Open_Mode
Definition Open_Mode.h:8
@ shared_write
like write_existing_or_create_new, but does not lock the file, and does not fail if locked
@ write_existing_or_create_new
either write_existing or create_new depending on whether the file exists. Racy in Posix,...
int main_wrapper(int(*main)(Arguments &), int argc, char **argv)
Process command-line arguments and catch exceptions from main.