Command line argument parsing class.
More...
#include <ArgParser.h>
|
| ArgParser ()=default |
|
bool | parse (int32_t argc, const char *const *argv) noexcept |
|
const std::map< std::string, std::string > & | getKeyValSet () const noexcept |
|
const std::string & | getValueByKey (const std::string &key, const std::string &default_value) const noexcept |
|
const std::string & | getValueByKey (const std::string &key) const |
|
bool | exist (const std::string &key) const noexcept |
|
const std::string & | getCurrentPath () const |
|
const std::string & | getFileName () const |
|
const std::string & | getFullPath () const |
|
Command line argument parsing class.
◆ Ptr
◆ ArgParser()
sese::ArgParser::ArgParser |
( |
| ) |
|
|
default |
◆ exist()
bool sese::ArgParser::exist |
( |
const std::string & | key | ) |
const |
|
nodiscardnoexcept |
Determine whether the current parameter exists based on the parameter name, applicable for some individual switches that do not need specified values
- Parameters
-
- Returns
- Whether the parameter exists
◆ getCurrentPath()
const std::string & sese::ArgParser::getCurrentPath |
( |
| ) |
const |
|
inlinenodiscard |
Get the program working directory
- Returns
- Working directory string, without a trailing directory separator
References currentPath.
◆ getFileName()
const std::string & sese::ArgParser::getFileName |
( |
| ) |
const |
|
inlinenodiscard |
Get the current program name
- Returns
- Current program name
References fileName.
◆ getFullPath()
const std::string & sese::ArgParser::getFullPath |
( |
| ) |
const |
|
inlinenodiscard |
Get the current absolute path of the program
- Returns
- Program path
References fullPath.
◆ getKeyValSet()
const std::map< std::string, std::string > & sese::ArgParser::getKeyValSet |
( |
| ) |
const |
|
nodiscardnoexcept |
- Returns
- Returns the entire parameter map
References keyValSet.
◆ getValueByKey() [1/2]
const std::string & sese::ArgParser::getValueByKey |
( |
const std::string & | key | ) |
const |
|
nodiscard |
Retrieves the value associated with the given key.
- Parameters
-
key | The name of the parameter. |
- Returns
- The value of the parameter if it exists.
- Exceptions
-
std::out_of_range | If the key does not exist. |
◆ getValueByKey() [2/2]
const std::string & sese::ArgParser::getValueByKey |
( |
const std::string & | key, |
|
|
const std::string & | default_value ) const |
|
nodiscardnoexcept |
Get the parameter value by parameter name
- Parameters
-
key | Parameter name |
default_value | Default parameter value |
- Returns
- Returns the parameter value, or the default value if the parameter does not exist
◆ parse()
bool sese::ArgParser::parse |
( |
int32_t | argc, |
|
|
const char *const * | argv ) |
|
noexcept |
Initialize parser
- Parameters
-
argc | Number of arguments |
argv | Actual arguments |
- Returns
- Whether parsing was successful
◆ currentPath
std::string sese::ArgParser::currentPath |
|
private |
◆ fileName
std::string sese::ArgParser::fileName |
|
private |
◆ fullPath
std::string sese::ArgParser::fullPath |
|
private |
◆ keyValSet
std::map<std::string, std::string> sese::ArgParser::keyValSet |
|
private |
The documentation for this class was generated from the following files: