blob: 735730d5d2e7bbc597e58289733f40609e186643 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#ifndef SHARED_INIT_HH_
#define SHARED_INIT_HH_
#include <string>
#include <vector>
#include <boost/lexical_cast.hpp>
namespace shared {
constexpr auto DEFAULT_ADDRESS = "0.0.0.0";
constexpr auto SINGLEPLAYER_ADDRESS = "localhost";
constexpr auto DEFAULT_PORT = "8191";
void init();
using main_func_t = void (*)(const std::string_view, const std::string_view);
void try_main(const main_func_t& func, const std::string_view address,
const std::string_view port);
// We use our own arg struct to parse args.
struct arg {
const char* name; // "address"
const char* desc; // "change the address"
const char* val; // "a:"
};
using args_t = std::vector<arg>;
const args_t& get_options();
using args_callback_t = bool (*)(const int& c, const char* const arg);
bool parse_arg(const int& c, const char* const arg);
using args_callbacks_t = std::vector<args_callback_t>;
void parse_args(const int argc, char* const argv[], const args_t& args,
const args_callbacks_t& callback);
} // namespace shared
#endif
|