Joedb 9.5.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Network_Connection_Builder.h
Go to the documentation of this file.
1#ifndef joedb_Network_Connection_Builder_declared
2#define joedb_Network_Connection_Builder_declared
3
8
9#include <iostream>
10
11namespace joedb
12{
13 /// @ingroup ui
15 {
16 private:
17 std::unique_ptr<Network_Connector> connector;
18 std::unique_ptr<Robust_Connection> connection;
19
20 public:
21 bool has_sharing_option() const final {return true;}
22 int get_min_parameters() const final {return 2;}
23 int get_max_parameters() const final {return 2;}
24 const char *get_name() const final {return "network";}
25 const char *get_parameters_description() const final
26 {
27 return "<host> <port>";
28 }
29
31 (
32 const int argc,
33 const char * const * const argv,
34 Buffered_File *file
35 ) final
36 {
37 const char * const host = argv[0];
38 const char * const port = argv[1];
39
40 connector = std::make_unique<Network_Connector>(host, port);
41
42 if (file)
43 connection = std::make_unique<Robust_Connection>(*connector, &std::cerr);
44 else
45 connection = std::make_unique<Server_File>(*connector, &std::cerr);
46
47 return *connection;
48 }
49 };
50}
51
52#endif
Connection & build(const int argc, const char *const *const argv, Buffered_File *file) final
const char * get_parameters_description() const final
Definition Blob.h:7