#include <InputParser.hpp>
Parses command line inputs
Definition at line 11 of file InputParser.hpp.
◆ InputParser()
InputParser::InputParser |
( |
const int & | argc, |
|
|
char ** | argv ) |
|
inline |
Constructs a new InputParser object
- Parameters
-
[in] | argc | Number of input arguments |
[in] | argv | Input arguments |
Definition at line 21 of file InputParser.hpp.
22 {
23 for (int i = 1; i < argc; ++i)
24 {
26 }
27 }
◆ cmdOptionExists()
bool InputParser::cmdOptionExists |
( |
const std::string & | option | ) |
const |
|
inlinenodiscard |
Checks whether provided command line option exists.
- Parameters
-
[in] | option | Option to check |
- Returns
- true If the provided option is found
-
false If the provided option is not found
Definition at line 77 of file InputParser.hpp.
◆ getCmdOption()
const std::string & InputParser::getCmdOption |
( |
const std::string & | option | ) |
const |
|
inlinenodiscard |
Gets single command line input
- Parameters
-
[in] | option | Option to check |
- Returns
- const std::string& Found command line input. Empty string if not found
Definition at line 34 of file InputParser.hpp.
35 {
36 std::vector<std::string>::const_iterator itr;
39 {
40 return *itr;
41 }
42 static const std::string empty_string;
43 return empty_string;
44 }
◆ getCmdOptions()
std::vector< std::pair< std::string, std::string > > InputParser::getCmdOptions |
( |
| ) |
const |
|
inlinenodiscard |
Gets all command line options
- Returns
- std::vector<std::pair<std::string, std::string>> All command line options
Definition at line 50 of file InputParser.hpp.
51 {
52 std::vector<std::pair<std::string, std::string>> options;
54 {
55 if (!itr->empty() && itr->at(0) == '-')
56 {
57 auto nextItr = std::next(itr);
58 if (nextItr !=
_tokens.end() && !nextItr->empty() && nextItr->at(0) !=
'-')
59 {
60 options.emplace_back(*itr, *(nextItr));
61 }
62 else
63 {
64 options.emplace_back(*itr, "");
65 }
66 }
67 }
68 return options;
69 }
◆ _tokens
std::vector<std::string> InputParser::_tokens |
|
private |
The documentation for this class was generated from the following file: