MarlinMT  0.1.0
CmdLineParser.h
Go to the documentation of this file.
1 #pragma once
2 
3 // -- std headers
4 #include <map>
5 #include <string>
6 #include <vector>
7 
8 namespace marlinmt {
9 
14  class CmdLineParser {
15  public:
16  using AdditionalArgs = std::map<std::string, std::string> ;
17 
19  struct ParseResult {
21  std::string _programName {} ;
23  std::vector<std::string> _arguments {} ;
27  std::optional<std::string> _config {} ;
29  unsigned int _nthreads {1} ;
31  bool _dumpExample {false} ;
32  };
33 
34  public:
36  CmdLineParser() = default ;
38  ~CmdLineParser() = default ;
39 
45  void setOptionalArgs( bool opt = true ) ;
46 
50  std::vector<std::string> getStandardOptions() const ;
51 
58  [[nodiscard]] ParseResult parse( int argc, char**argv ) ;
59 
60  private:
62  bool _optionalArgs {false} ;
63  };
64 
65 }
std::vector< std::string > _arguments
All command line arguments except the program name (argv[0])
Definition: CmdLineParser.h:23
AdditionalArgs _additionalArgs
Additional command line arguments.
Definition: CmdLineParser.h:25
std::string _programName
The program name.
Definition: CmdLineParser.h:21
ParseResult parse(int argc, char **argv)
Parse the command line.
CmdLineParser()=default
Default constructor.
~CmdLineParser()=default
Default destructor.
unsigned int _nthreads
The number of threads.
Definition: CmdLineParser.h:29
void setOptionalArgs(bool opt=true)
Set all cmd line arguments to optional during parsing.
std::map< std::string, std::string > AdditionalArgs
Definition: CmdLineParser.h:16
std::vector< std::string > getStandardOptions() const
Get all possible command options (short and long options)
bool _dumpExample
Whether to dump an example configuration and exit.
Definition: CmdLineParser.h:31
std::optional< std::string > _config
The config argument.
Definition: CmdLineParser.h:27
ParseResult struct. The result of the command line parsing.
Definition: CmdLineParser.h:19
bool _optionalArgs
Whether all arguments are optional.
Definition: CmdLineParser.h:62
CmdLineParser class Does the main command line parsing for MarlinMT.
Definition: CmdLineParser.h:14