The Battle for Wesnoth  1.15.9+dev
options.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2020 by Iris Morelle <shadowm@wesnoth.org>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /**
16  * @file
17  * campaignd command line options parsing.
18  */
19 
20 #pragma once
21 
22 #include <optional>
23 
24 #include <boost/program_options/options_description.hpp>
25 #include <map>
26 
27 namespace campaignd {
28 
30 {
31 public:
32  /**
33  * Reads the command line.
34  */
35  command_line(int argc, char** argv);
36 
37  /**
38  * Retrieves the --help text.
39  *
40  * @note This text is only available when --help is used. Otherwise,
41  * an empty string is returned instead.
42  */
43  const std::string& help_text() const
44  {
45  return help_text_;
46  }
47 
48  /** True if --help was passed. */
49  bool help;
50  /** True if --version was passed. */
51  bool version;
52 
53  /** Path to the add-ons server configuration file. */
54  std::optional<std::string> config_file;
55  /** Path to the add-ons server storage dir. */
56  std::optional<std::string> server_dir;
57  /** Port number on which the server will listen for incoming connections. */
58  std::optional<unsigned short> port;
59 
60  /** True if --logdomains was passed. */
62  /** Log domain/severity configuration. */
63  std::map<std::string, int> log_domain_levels;
64  /** Whether to use higher precision for log timestamps. */
66  /** Whether to report timing information for server requests. */
68 
69 private:
70  std::string argv0_;
71  std::vector<std::string> args_;
72  std::string help_text_;
73 
74  command_line(const std::vector<std::string>& args);
75 
76  void parse_log_domains(const std::string& domains_string, int severity);
77 };
78 
79 } // end namespace campaignd
void parse_log_domains(const std::string &domains_string, int severity)
bool report_timings
Whether to report timing information for server requests.
Definition: options.hpp:67
std::optional< std::string > server_dir
Path to the add-ons server storage dir.
Definition: options.hpp:56
std::string argv0_
Definition: options.hpp:70
std::vector< std::string > args_
Definition: options.hpp:71
std::optional< std::string > config_file
Path to the add-ons server configuration file.
Definition: options.hpp:54
const std::string & help_text() const
Retrieves the –help text.
Definition: options.hpp:43
std::optional< unsigned short > port
Port number on which the server will listen for incoming connections.
Definition: options.hpp:58
bool version
True if –version was passed.
Definition: options.hpp:51
std::string help_text_
Definition: options.hpp:72
bool log_precise_timestamps
Whether to use higher precision for log timestamps.
Definition: options.hpp:65
bool help
True if –help was passed.
Definition: options.hpp:49
command_line(int argc, char **argv)
Reads the command line.
Definition: options.cpp:30
bool show_log_domains
True if –logdomains was passed.
Definition: options.hpp:61
std::map< std::string, int > log_domain_levels
Log domain/severity configuration.
Definition: options.hpp:63