Joedb 10.0.1
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
joedb_client.cpp
Go to the documentation of this file.
6
7#include <iostream>
8
9namespace joedb
10{
11 ////////////////////////////////////////////////////////////////////////////
12 static int client(Arguments &arguments)
13 ////////////////////////////////////////////////////////////////////////////
14 {
15 const Open_Mode default_mode = File::lockable
18
19 Client_Parser client_parser
20 (
21 default_mode,
23 arguments
24 );
25
26 if (!client_parser.get())
27 {
28 arguments.print_help(std::cerr) << '\n';
29 client_parser.print_help(std::cerr);
30 return 1;
31 }
32
33 Client &client = *client_parser.get();
34
35 std::unique_ptr<Client_Command_Processor> interpreter;
36
37 Writable_Client *writable_client = dynamic_cast<Writable_Client*>(&client);
38
39 if (writable_client && !client.is_pullonly())
40 interpreter.reset(new Writable_Client_Command_Processor(*writable_client));
41 else
42 interpreter.reset(new Client_Command_Processor(client));
43
44 interpreter->set_prompt(true);
45 interpreter->main_loop(std::cin, std::cout);
46
47 return 0;
48 }
49}
50
51/////////////////////////////////////////////////////////////////////////////
52int main(int argc, char **argv)
53/////////////////////////////////////////////////////////////////////////////
54{
55 joedb::main_wrapper(joedb::client, argc, argv);
56}
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.
Definition Blob.h:7