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