The Battle for Wesnoth  1.19.7+dev
options.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2020 - 2024
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 "utils/optional_fwd.hpp"
24 
25 #include <boost/program_options/options_description.hpp>
26 #include <map>
27 #include "log.hpp"
28 
29 namespace campaignd {
30 
32 {
33 public:
34  /**
35  * Reads the command line.
36  */
37  command_line(int argc, char** argv);
38 
39  /**
40  * Retrieves the --help text.
41  *
42  * @note This text is only available when --help is used. Otherwise,
43  * an empty string is returned instead.
44  */
45  const std::string& help_text() const
46  {
47  return help_text_;
48  }
49 
50  /** True if --help was passed. */
51  bool help;
52  /** True if --version was passed. */
53  bool version;
54 
55  /** Path to the add-ons server configuration file. */
56  utils::optional<std::string> config_file;
57  /** Path to the add-ons server storage dir. */
58  utils::optional<std::string> server_dir;
59  /** Port number on which the server will listen for incoming connections. */
60  utils::optional<unsigned short> port;
61 
62  /** True if --logdomains was passed. */
64  /** Log domain/severity configuration. */
65  std::map<std::string, lg::severity> log_domain_levels;
66  /** Whether to use higher precision for log timestamps. */
68  /** Whether to report timing information for server requests. */
70 
71 private:
72  std::string argv0_;
73  std::vector<std::string> args_;
74  std::string help_text_;
75 
76  command_line(const std::vector<std::string>& args);
77 
78  void parse_log_domains(const std::string& domains_string, int severity);
79 };
80 
81 } // end namespace campaignd
std::string argv0_
Definition: options.hpp:72
bool report_timings
Whether to report timing information for server requests.
Definition: options.hpp:69
utils::optional< std::string > config_file
Path to the add-ons server configuration file.
Definition: options.hpp:56
const std::string & help_text() const
Retrieves the –help text.
Definition: options.hpp:45
bool version
True if –version was passed.
Definition: options.hpp:53
std::string help_text_
Definition: options.hpp:74
utils::optional< unsigned short > port
Port number on which the server will listen for incoming connections.
Definition: options.hpp:60
void parse_log_domains(const std::string &domains_string, int severity)
utils::optional< std::string > server_dir
Path to the add-ons server storage dir.
Definition: options.hpp:58
command_line(int argc, char **argv)
Reads the command line.
Definition: options.cpp:31
bool help
True if –help was passed.
Definition: options.hpp:51
std::vector< std::string > args_
Definition: options.hpp:73
bool show_log_domains
True if –logdomains was passed.
Definition: options.hpp:63
std::map< std::string, lg::severity > log_domain_levels
Log domain/severity configuration.
Definition: options.hpp:65
bool log_precise_timestamps
Whether to use higher precision for log timestamps.
Definition: options.hpp:67
Standard logging facilities (interface).
severity
Definition: log.hpp:83