Argx 1.2.2-build
Simple yet powerful argument parser made in C++
|
#include <Argx.hpp>
Public Member Functions | |
Argx () | |
Argx (const std::string &id, int argc, char *argv[]) | |
Create Argx with the specific id, argc and argv | |
~Argx () | |
Deconstruct allocated objects. | |
void | add (ARGXOptions option) const |
Add param options. | |
bool | compareArgs (std::vector< ARGXOptions > options, std::vector< std::string > argv) |
Compare if options contains the required id, if the ID does not exist, return false. | |
std::string | createDocs (ARGXStyle style, const std::string &title, const std::string &mainInfo) |
Create documentation for the parameters with the specific style, title and main information. | |
int | findParam (const std::string &id) |
Find parameter and sub-parameter index. | |
int | getArgc () const |
Get the main options from the main() function as argc. | |
int | getArgIDPos (const std::string &arg) |
Get argument using ID. | |
int | getArgPos (const std::string &arg) |
Get argument position with specified arg | |
std::string | getID () const |
Get Argx ID. | |
std::vector< std::string > | getMainArgs () const |
Get main arguments from main() function argv | |
ARGXOptions | getOption (const std::string &id) |
Get Options from specified ID. | |
std::vector< ARGXOptions > | getOptions () const |
Get main set options as ARGXOptions. | |
ARGXParam | getParam (const std::string &id) |
Get the param from id | |
bool | getSubParam (const argx::ARGXParam ¶m, const std::string &id) |
Get the sub-param from id | |
std::vector< std::string > | getSubValue (const std::string &id) |
Get sub-parameter values, starting from the first value found until the first found value that corresponds to a registered parameter. | |
int | getWrongArgs (const std::vector< std::string > &argv) |
Get the incorrect arguments and sub-arguments that were not registered. | |
bool | hasTag (const std::string &id, const std::string &tag) |
Check if the tag exists in option with ID of id | |
bool | paramExists (const std::string &id) |
Get if param exists in the param options. | |
std::string | paramToID (const std::string ¶m) |
Normal parameter or sub-paramter to its corresponding ID. | |
bool | subParamExists (const std::string &id) |
Get if sub-param exists in the param options. |
Static Public Member Functions | |
static int | formatWrongArgs (const int &_int) |
Format to a positive number if number is negative for a correct execution of code. |
Private Attributes | |
std::string | id |
Static Private Attributes | |
static unsigned int | mainArgc |
static std::vector< std::string > * | mainArgs = nullptr |
static std::vector< ARGXOptions > | options |
argx::Argx::Argx | ( | const std::string & | id, |
int | argc, | ||
char * | argv[] ) |
Create Argx with the specific id, argc and argv
id | Set the ID of the Argx |
argc | Set the argc of the main() function |
argv | Set the argv of the main() function |
Definition at line 34 of file Argx.cpp.
References Argx(), id, mainArgc, and mainArgs.
Referenced by Argx().
argx::Argx::~Argx | ( | ) |
void argx::Argx::add | ( | ARGXOptions | option | ) | const |
bool argx::Argx::compareArgs | ( | std::vector< ARGXOptions > | options, |
std::vector< std::string > | argv ) |
Compare if options contains the required id, if the ID does not exist, return false.
options | Return ARGXOptions vector |
id | ID to find |
Definition at line 489 of file Argx.cpp.
References argx::ARGXOptions::hasAnySubParams, argx::ARGXOptions::hasSubParams, options, and argx::ARGXOptions::subParams.
std::string argx::Argx::createDocs | ( | ARGXStyle | style, |
const std::string & | title, | ||
const std::string & | mainInfo ) |
Create documentation for the parameters with the specific style, title and main information.
style | Set the style using ARGXStyle |
title | Title for docs |
Main | information |
Definition at line 293 of file Argx.cpp.
References options, argx::Professional, and argx::Simple.
int argx::Argx::findParam | ( | const std::string & | id | ) |
Find parameter and sub-parameter index.
id | ID to find |
Definition at line 96 of file Argx.cpp.
References mainArgs, and options.
Referenced by getSubParam(), hasTag(), and paramExists().
|
static |
int argx::Argx::getArgc | ( | ) | const |
int argx::Argx::getArgIDPos | ( | const std::string & | arg | ) |
Get argument using ID.
arg | Argument to find |
Definition at line 53 of file Argx.cpp.
References getArgPos(), getOption(), argx::ARGXOptions::param, and argx::ARGXOptions::sparam.
int argx::Argx::getArgPos | ( | const std::string & | arg | ) |
Get argument position with specified arg
arg | Find argument |
Definition at line 79 of file Argx.cpp.
References mainArgs.
Referenced by getArgIDPos(), and getSubValue().
std::string argx::Argx::getID | ( | ) | const |
std::vector< std::string > argx::Argx::getMainArgs | ( | ) | const |
Get main arguments from main() function argv
Definition at line 633 of file Argx.cpp.
References mainArgs.
Referenced by getSubValue().
ARGXOptions argx::Argx::getOption | ( | const std::string & | id | ) |
Get Options from specified ID.
id | ID to find |
ARGXOptions | Option information |
Definition at line 572 of file Argx.cpp.
References options.
Referenced by getArgIDPos(), and getSubValue().
std::vector< ARGXOptions > argx::Argx::getOptions | ( | ) | const |
Get main set options as ARGXOptions.
Definition at line 639 of file Argx.cpp.
References options.
ARGXParam argx::Argx::getParam | ( | const std::string & | id | ) |
Get the param from id
id | The ID to get |
Definition at line 171 of file Argx.cpp.
References argx::ARGXParam::exists, mainArgc, mainArgs, options, and argx::ARGXParam::subExists.
bool argx::Argx::getSubParam | ( | const argx::ARGXParam & | param, |
const std::string & | id ) |
Get the sub-param from id
param | Original param |
id | The ID to get |
Definition at line 290 of file Argx.cpp.
References findParam(), paramExists(), and argx::ARGXParam::subExists.
std::vector< std::string > argx::Argx::getSubValue | ( | const std::string & | id | ) |
Get sub-parameter values, starting from the first value found until the first found value that corresponds to a registered parameter.
id | ID to find to get sub-value |
Definition at line 580 of file Argx.cpp.
References argx::ARGXOptions::defaultValue, getArgPos(), getMainArgs(), getOption(), mainArgs, options, and subParamExists().
int argx::Argx::getWrongArgs | ( | const std::vector< std::string > & | argv | ) |
Get the incorrect arguments and sub-arguments that were not registered.
argv | Main arguments from argv |
Definition at line 395 of file Argx.cpp.
References argx::ARGXOptions::hasAnySubParams, argx::ARGXOptions::hasSubParams, mainArgs, options, and argx::ARGXOptions::subParams.
bool argx::Argx::hasTag | ( | const std::string & | id, |
const std::string & | tag ) |
Check if the tag exists in option with ID of id
id | ID from option |
tag | Tag to find |
Definition at line 159 of file Argx.cpp.
References findParam(), and options.
bool argx::Argx::paramExists | ( | const std::string & | id | ) |
Get if param exists in the param options.
id | ID to get |
Definition at line 142 of file Argx.cpp.
References findParam().
Referenced by getSubParam().
std::string argx::Argx::paramToID | ( | const std::string & | param | ) |
Normal parameter or sub-paramter to its corresponding ID.
param | Parameter value or name |
Definition at line 66 of file Argx.cpp.
bool argx::Argx::subParamExists | ( | const std::string & | id | ) |
Get if sub-param exists in the param options.
id | ID to get |
Definition at line 149 of file Argx.cpp.
References options.
Referenced by getSubValue().
|
private |
Definition at line 20 of file Argx.hpp.
Referenced by Argx(), and paramToID().
|
staticprivate |
Definition at line 25 of file Argx.hpp.
Referenced by Argx(), getArgc(), and getParam().
|
staticprivate |
Definition at line 23 of file Argx.hpp.
Referenced by Argx(), ~Argx(), findParam(), getArgPos(), getMainArgs(), getParam(), getSubValue(), and getWrongArgs().
|
staticprivate |
Definition at line 22 of file Argx.hpp.
Referenced by add(), compareArgs(), createDocs(), findParam(), getOption(), getOptions(), getParam(), getSubValue(), getWrongArgs(), hasTag(), paramToID(), and subParamExists().