A class to parse command line arguments.
More...
|
| | arg_parser (int argc, char *argv[]) |
| | Convert the command line arguments passed to the main() function into an std::vector.
|
| |
| bool | exists (const std::string_view arg) const |
| | Check if a specific command line argument has been passed to the program.
|
| |
| const std::string_view | operator[] (const size_t index) const |
| | Access a command line argument at a specific index.
|
| |
| size_t | size () const |
| | Get the number of command line arguments.
|
| |
|
|
std::vector< std::string_view > | args |
| | A vector containing string views of the command line arguments.
|
| |
A class to parse command line arguments.
◆ arg_parser()
| arg_parser::arg_parser |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
|
inline |
Convert the command line arguments passed to the main() function into an std::vector.
- Parameters
-
| argc | The number of arguments. |
| argv | An array containing the arguments. |
2347:
args(argv, argv + argc){};
std::vector< std::string_view > args
A vector containing string views of the command line arguments.
Definition BS_thread_pool_test.cpp:2390
◆ exists()
| bool arg_parser::exists |
( |
const std::string_view |
arg | ) |
const |
|
inline |
Check if a specific command line argument has been passed to the program.
- Parameters
-
| arg | The argument to check for. |
- Returns
true if the argument exists, false otherwise.
2356 {
2357 for (
const std::string_view str :
args)
2358 {
2359 if (str == arg)
2360 return true;
2361 }
2362 return false;
2363 }
◆ operator[]()
| const std::string_view arg_parser::operator[] |
( |
const size_t |
index | ) |
const |
|
inline |
Access a command line argument at a specific index.
- Parameters
-
| index | The index to access. |
- Returns
- The argument.
◆ size()
| size_t arg_parser::size |
( |
| ) |
const |
|
inline |
Get the number of command line arguments.
- Returns
- The number of arguments.
The documentation for this class was generated from the following file: