Joedb 9.1.4
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Network_Connection_Builder.h
Go to the documentation of this file.
4
5#include <iostream>
6
7namespace joedb
8{
9 /// @ingroup ui
11 {
12 private:
13 std::unique_ptr<Network_Channel> channel;
14 std::unique_ptr<Server_Connection> connection;
15
16 public:
17 bool has_sharing_option() const final {return true;}
18 int get_min_parameters() const final {return 2;}
19 int get_max_parameters() const final {return 2;}
20 const char *get_name() const final {return "network";}
21 const char *get_parameters_description() const final
22 {
23 return "<host> <port>";
24 }
25
26 Connection &build(int argc, char **argv, Buffered_File *file) final
27 {
28 const char * const host = argv[0];
29 const char * const port = argv[1];
30
31 channel = std::make_unique<Network_Channel>(host, port);
32
33 if (file)
34 connection = std::make_unique<Server_Connection>(*channel);
35 else
36 connection = std::make_unique<Server_File>(*channel);
37
38 connection->set_log(&std::cerr);
39
40 return *connection;
41 }
42 };
43}
Connection & build(int argc, char **argv, Buffered_File *file) final
const char * get_parameters_description() const final
Definition Blob.h:7