Joedb 10.0.1
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Local_Connection_Builder.h
Go to the documentation of this file.
1#ifndef joedb_Local_Connection_Builder_declared
2#define joedb_Local_Connection_Builder_declared
3
8
9#include <iostream>
10
11namespace joedb
12{
13 /// @ingroup ui
15 {
16 private:
17 std::unique_ptr<Local_Connector> connector;
18 std::unique_ptr<Robust_Connection> connection;
19
20 public:
21 bool has_sharing_option() const override {return true;}
22 const char *get_name() const override {return "local";}
23 const char *get_parameters_description() const override
24 {
25 return "<endpoint_path>";
26 }
27
28 Connection *build(Arguments &arguments, Buffered_File *file) override
29 {
30 const std::string_view endpoint_path = arguments.get_next();
31
32 if (arguments.missing())
33 return nullptr;
34
35 connector = std::make_unique<Local_Connector>(endpoint_path.data());
36
37 if (file)
38 connection = std::make_unique<Robust_Connection>(*connector, &std::cerr);
39 else
40 connection = std::make_unique<Server_File>(*connector, &std::cerr);
41
42 return connection.get();
43 }
44 };
45}
46
47#endif
Class for conveniently parsing command-line arguments.
Definition Arguments.h:19
bool missing() const
Definition Arguments.h:124
std::string_view get_next()
const char * get_parameters_description() const override
const char * get_name() const override
Connection * build(Arguments &arguments, Buffered_File *file) override
Definition Blob.h:7