BEEP-8 Helper Lib 1.0.0
Loading...
Searching...
No Matches
argparse::ArgumentParser Class Reference

Class for parsing command line arguments. More...

#include <argparse.h>

Public Types

enum  Result {
  OK = 0 , SHOWED_HELP = -128 , UNKNOWN_FLAG , BAD_PARAM ,
  UNKNOWN_VAR
}
 Enumeration of possible results from parsing arguments. More...
 

Public Member Functions

int GetVarInt (std::string name_, int if_not_found_)
 Get the integer value of a variable.
 
std::string GetVarStr (std::string name_, std::string if_not_found_)
 Get the string value of a variable.
 
Result ParseArgs (const std::vector< std::string > &args)
 Parse command line arguments.
 
void ShowHelp ()
 Display help information for all arguments.
 
int AddArgument (std::string name_, std::string short_alias_, std::string help_, Argument::Action action_=Argument::store_true)
 Add an argument to the parser.
 
 ArgumentParser ()
 Constructor for ArgumentParser.
 

Public Attributes

bool _showed_help = false
 Flag indicating whether help was shown.
 

Detailed Description

Class for parsing command line arguments.

Member Enumeration Documentation

◆ Result

Enumeration of possible results from parsing arguments.

Enumerator
OK 

Parsing successful.

SHOWED_HELP 

Help message was shown.

UNKNOWN_FLAG 

Unknown flag encountered.

BAD_PARAM 

Bad parameter provided.

UNKNOWN_VAR 

Unknown variable encountered.

Member Function Documentation

◆ AddArgument()

int ArgumentParser::AddArgument ( std::string name_,
std::string short_alias_,
std::string help_,
Argument::Action action_ = Argument::store_true )

Add an argument to the parser.

Parameters
name_Full name of the argument
short_alias_Short alias of the argument
help_Help description for the argument
action_Action associated with the argument (default is store_true)
Returns
Result of adding the argument

◆ GetVarInt()

int ArgumentParser::GetVarInt ( std::string name_,
int if_not_found_ )

Get the integer value of a variable.

Parameters
name_Name of the variable
if_not_found_Value to return if the variable is not found
Returns
Integer value of the variable or if_not_found_ if not found

◆ GetVarStr()

std::string ArgumentParser::GetVarStr ( std::string name_,
std::string if_not_found_ )

Get the string value of a variable.

Parameters
name_Name of the variable
if_not_found_Value to return if the variable is not found
Returns
String value of the variable or if_not_found_ if not found

◆ ParseArgs()

ArgumentParser::Result ArgumentParser::ParseArgs ( const std::vector< std::string > & args)

Parse command line arguments.

Parameters
argsVector of argument strings
Returns
Result of parsing

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