Joedb 9.5.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
SSH_Connection_Builder.h
Go to the documentation of this file.
1#ifndef joedb_SSH_Connection_Builder
2#define joedb_SSH_Connection_Builder
3
7
8#include <iostream>
9
10namespace joedb
11{
12 /// @ingroup ui
14 {
15 private:
16 std::unique_ptr<ssh::Connector> connector;
17 std::unique_ptr<Connection> connection;
18
19 public:
20 bool has_sharing_option() const final {return true;}
21 int get_min_parameters() const final {return 3;}
22 int get_max_parameters() const final {return 5;}
23 const char *get_name() const final {return "ssh";}
24 const char *get_parameters_description() const final
25 {
26 return "<user> <host> <endpoint_path> [<ssh_port> [<ssh_log_level>]]";
27 }
28
30 (
31 const int argc,
32 const char * const * const argv,
33 Buffered_File *file
34 ) final
35 {
36 const char * const user = argv[0];
37 const char * const host = argv[1];
38 const char * const remote_path = argv[2];
39 const unsigned ssh_port = argc > 3 ? std::atoi(argv[3]) : 22;
40 const int ssh_log_level = argc > 4 ? std::atoi(argv[4]) : 0;
41
42 connector = std::make_unique<ssh::Connector>
43 (
44 user,
45 host,
46 ssh_port,
47 ssh_log_level,
48 nullptr,
49 nullptr,
50 remote_path
51 );
52
53 if (file)
54 connection = std::make_unique<Robust_Connection>(*connector, &std::cerr);
55 else
56 connection = std::make_unique<Server_File>(*connector, &std::cerr);
57
58 return *connection;
59 }
60 };
61}
62
63#endif
Connection & build(const int argc, const char *const *const argv, Buffered_File *file) final
const char * get_name() const final
const char * get_parameters_description() const final
Definition Blob.h:7