Joedb 9.5.0
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 joedb_client(int argc, char **argv)
13 ////////////////////////////////////////////////////////////////////////////
14 {
15 const Open_Mode default_mode = File::lockable
18
19 Client_Parser client_parser(default_mode, Client_Parser::DB_Type::interpreted);
20
21 if (argc <= 1)
22 {
23 std::cerr << "usage: " << argv[0];
24 client_parser.print_help(std::cerr);
25 return 1;
26 }
27
28 Client &client = client_parser.parse(argc - 1, argv + 1);
29
30 std::unique_ptr<Client_Command_Processor> interpreter;
31
32 Writable_Client *writable_client = dynamic_cast<Writable_Client*>(&client);
33
34 if (writable_client && !client.is_pullonly())
35 interpreter.reset(new Writable_Client_Command_Processor(*writable_client));
36 else
37 interpreter.reset(new Client_Command_Processor(client));
38
39 interpreter->set_prompt(true);
40 interpreter->main_loop(std::cin, std::cout);
41
42 return 0;
43 }
44}
45
46/////////////////////////////////////////////////////////////////////////////
47int main(int argc, char **argv)
48/////////////////////////////////////////////////////////////////////////////
49{
50 joedb::main_exception_catcher(joedb::joedb_client, argc, argv);
51}
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_exception_catcher(int(*main)(int, char **), int argc, char **argv)
Catch exception from main.
Definition Blob.h:7