mavtables  0.2.1
MAVLink router and firewall.
Options.hpp
Go to the documentation of this file.
1 // MAVLink router and firewall.
2 // Copyright (C) 2018 Michael R. Shannon <mrshannon.aerospace@gmail.com>
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 
18 #ifndef OPTIONS_HPP_
19 #define OPTIONS_HPP_
20 
21 
22 #include <iostream>
23 #include <optional>
24 #include <ostream>
25 #include <string>
26 
27 #include "Filesystem.hpp"
28 
29 
30 /** An options class which is used to parse the command line arguments.
31  *
32  * This class is what provides the command line help for mavtables.
33  * ```
34  * usage: mavtables:
35  * -h [ --help ] print this message
36  * --config arg specify configuration file
37  * --ast print AST of configuration file (do not run)
38  * --version print version and license information
39  * --loglevel arg level of logging, between 0 and 3
40  * ```
41  */
42 class Options
43 {
44  public:
45  Options(
46  int argc, const char *argv[],
47  const Filesystem &filesystem = Filesystem());
48  bool ast();
49  unsigned int loglevel();
50  std::string config_file();
51  bool run();
52  explicit operator bool() const;
53 
54  private:
55  bool continue_;
56  unsigned int loglevel_;
57  std::string config_file_;
58  bool print_ast_;
59  bool run_firewall_;
60 };
61 
62 
63 std::optional<std::string> find_config(
64  const Filesystem &filesystem = Filesystem());
65 
66 
67 #endif // OPTIONS_HPP_
bool run()
Definition: Options.cpp:167
bool ast()
Definition: Options.cpp:135
unsigned int loglevel()
Definition: Options.cpp:156
std::optional< std::string > find_config(const Filesystem &filesystem)
Definition: Options.cpp:199
Options(int argc, const char *argv[], const Filesystem &filesystem=Filesystem())
Definition: Options.cpp:46
std::string config_file()
Definition: Options.cpp:146