Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
arg_parser Class Reference

A class to parse command line arguments. More...

Public Member Functions

 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.
 

Private Attributes

std::vector< std::string_view > args
 A vector containing string views of the command line arguments.
 

Detailed Description

A class to parse command line arguments.

Constructor & Destructor Documentation

◆ 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
argcThe number of arguments.
argvAn 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

Member Function Documentation

◆ 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
argThe 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
indexThe index to access.
Returns
The argument.
2372 {
2373 return args[index];
2374 }
index

◆ size()

size_t arg_parser::size ( ) const
inline

Get the number of command line arguments.

Returns
The number of arguments.
2382 {
2383 return args.size();
2384 }

The documentation for this class was generated from the following file: