Go to the source code of this file.
Functions | |
void | argxcAddOption (Argxc *argxc, ArgxcOptions option) |
Add a new option to the Argxc instance. | |
void | argxcAddSubOption (ArgxcOptions *parent, ArgxcOptions subOption) |
Add a sub-option to a parent option. | |
bool | argxcCompareArgs (ArgxcOptions *options, size_t optionsCount, char **argv, size_t argvCount) |
Compare if the given argv matches a list of ArgxcOptions. | |
Argxc * | argxcCreate (const char *id, int argc, char *argv[]) |
Create a new Argxc instance with a specified ID and command-line arguments. | |
Argxc * | argxcCreateDefault (void) |
Create a new Argxc instance with default values (empty ID and no arguments). | |
char * | argxcCreateDocs (Argxc *argxc, ArgxcStyle style, const char *title, const char *mainInfo) |
Generate documentation for the defined options. | |
ArgxcError | argxcCreateError (const char *type, const char *error, const char *help, int code) |
Create an ArgxcError object. | |
ArgxcOptions | argxcCreateOption (const char *id, const char *param, const char *sparam, const char *info, bool hasSubParams, bool hasAnySubParams) |
Create a new option. | |
void | argxcDestroy (Argxc *argxc) |
Destroy an Argxc instance and free all associated memory. | |
int | argxcFindParam (Argxc *argxc, const char *id) |
Find the index of a parameter by ID. | |
void | argxcFreeError (ArgxcError *error) |
Free resources associated with an ArgxcError struct. | |
void | argxcFreeOption (ArgxcOptions *option) |
Free resources associated with an ArgxcOptions struct. | |
void | argxcFreeParam (ArgxcParam *param) |
Free resources associated with an ArgxcParam struct. | |
void | argxcFreeStringArray (char **array, size_t count) |
Free a string array returned from Argxc (e.g., argv array). | |
int | argxcGetArgc (Argxc *argxc) |
Get the number of command-line arguments passed. | |
const char * | argxcGetId (Argxc *argxc) |
Get the identifier of the Argxc instance. | |
char ** | argxcGetMainArgs (Argxc *argxc, size_t *count) |
Get the raw command-line arguments passed to Argxc. | |
ArgxcOptions * | argxcGetOptions (Argxc *argxc, size_t *count) |
Get all top-level options defined for the Argxc instance. | |
ArgxcParam | argxcGetParam (Argxc *argxc, const char *id) |
Retrieve a parameter by ID. | |
bool | argxcGetSubParam (Argxc *argxc, const ArgxcParam *param, const char *id) |
Retrieve a sub-parameter from a given parameter by ID. | |
bool | argxcParamExists (Argxc *argxc, const char *id) |
Check if a parameter with the given ID exists. | |
void argxcAddOption | ( | Argxc * | argxc, |
ArgxcOptions | option ) |
Add a new option to the Argxc instance.
argxc | Pointer to the Argxc instance. |
option | The option to add. |
Definition at line 124 of file Argx.c.
References Argxc::options, Argxc::optionsCapacity, and Argxc::optionsCount.
void argxcAddSubOption | ( | ArgxcOptions * | parent, |
ArgxcOptions | subOption ) |
Add a sub-option to a parent option.
parent | Pointer to the parent option. |
subOption | Sub-option to add under the parent. |
Definition at line 138 of file Argx.c.
References ArgxcOptions::subParams, ArgxcOptions::subParamsCapacity, and ArgxcOptions::subParamsCount.
bool argxcCompareArgs | ( | ArgxcOptions * | options, |
size_t | optionsCount, | ||
char ** | argv, | ||
size_t | argvCount ) |
Compare if the given argv matches a list of ArgxcOptions.
options | Array of ArgxcOptions. |
optionsCount | Number of options. |
argv | Array of argument strings. |
argvCount | Number of argument strings. |
Definition at line 499 of file Argx.c.
References ArgxcOptions::hasAnySubParams, ArgxcOptions::hasSubParams, ArgxcOptions::param, ArgxcOptions::sparam, ArgxcOptions::subParams, and ArgxcOptions::subParamsCount.
Argxc * argxcCreate | ( | const char * | id, |
int | argc, | ||
char * | argv[] ) |
Create a new Argxc instance with a specified ID and command-line arguments.
id | Identifier for the parser instance. |
argc | Number of command-line arguments. |
argv | Array of command-line argument strings. |
Definition at line 64 of file Argx.c.
References argxcDestroy(), Argxc::id, Argxc::mainArgc, Argxc::mainArgs, Argxc::mainArgsCount, Argxc::options, Argxc::optionsCapacity, Argxc::optionsCount, and stringDuplicate().
Argxc * argxcCreateDefault | ( | void | ) |
Create a new Argxc instance with default values (empty ID and no arguments).
Definition at line 91 of file Argx.c.
References Argxc::id, Argxc::mainArgc, Argxc::mainArgs, Argxc::mainArgsCount, Argxc::options, Argxc::optionsCapacity, and Argxc::optionsCount.
char * argxcCreateDocs | ( | Argxc * | argxc, |
ArgxcStyle | style, | ||
const char * | title, | ||
const char * | mainInfo ) |
Generate documentation for the defined options.
argxc | Pointer to the Argxc instance. |
style | Documentation output style. |
title | Title of the documentation. |
mainInfo | Additional info to be displayed in the documentation. |
Definition at line 375 of file Argx.c.
References ARGX_STYLE_PROFESSIONAL, ARGX_STYLE_SIMPLE, ArgxcOptions::hasSubParams, ArgxcOptions::id, ArgxcOptions::info, Argxc::options, Argxc::optionsCount, ArgxcOptions::param, ArgxcOptions::sparam, ArgxcOptions::subParams, and ArgxcOptions::subParamsCount.
ArgxcError argxcCreateError | ( | const char * | type, |
const char * | error, | ||
const char * | help, | ||
int | code ) |
Create an ArgxcError object.
type | Type/category of the error. |
error | Error message. |
help | Help message for resolving the error. |
code | Exit code or error code. |
Definition at line 667 of file Argx.c.
References ArgxcError::code, ArgxcError::error, ArgxcError::help, stringDuplicate(), and ArgxcError::type.
ArgxcOptions argxcCreateOption | ( | const char * | id, |
const char * | param, | ||
const char * | sparam, | ||
const char * | info, | ||
bool | hasSubParams, | ||
bool | hasAnySubParams ) |
Create a new option.
id | Option identifier. |
param | Parameter name (e.g., –param). |
sparam | Short form (e.g., -p). |
info | Description of the option. |
hasSubParams | Whether the option has sub-parameters. |
hasAnySubParams | Whether the option accepts any sub-parameters. |
Definition at line 607 of file Argx.c.
References ArgxcOptions::hasAnySubParams, ArgxcOptions::hasSubParams, ArgxcOptions::id, ArgxcOptions::info, ArgxcOptions::param, ArgxcOptions::sparam, stringDuplicate(), ArgxcOptions::subParams, and ArgxcOptions::subParamsCount.
void argxcDestroy | ( | Argxc * | argxc | ) |
Destroy an Argxc instance and free all associated memory.
argxc | Pointer to the Argxc instance to destroy. |
Definition at line 113 of file Argx.c.
References freeOptionsArray(), freeStringArray(), Argxc::id, Argxc::mainArgs, Argxc::mainArgsCount, Argxc::options, and Argxc::optionsCount.
Referenced by argxcCreate().
int argxcFindParam | ( | Argxc * | argxc, |
const char * | id ) |
Find the index of a parameter by ID.
argxc | Pointer to the Argxc instance. |
id | The identifier of the parameter to find. |
Definition at line 155 of file Argx.c.
References ArgxcOptions::id, Argxc::mainArgs, Argxc::mainArgsCount, Argxc::options, Argxc::optionsCount, ArgxcOptions::param, ArgxcOptions::sparam, ArgxcOptions::subParams, and ArgxcOptions::subParamsCount.
Referenced by argxcGetSubParam(), and argxcParamExists().
void argxcFreeError | ( | ArgxcError * | error | ) |
Free resources associated with an ArgxcError struct.
error | Pointer to the error to free. |
Definition at line 679 of file Argx.c.
References ArgxcError::error, ArgxcError::help, and ArgxcError::type.
void argxcFreeOption | ( | ArgxcOptions * | option | ) |
Free resources associated with an ArgxcOptions struct.
option | Pointer to the option to free. |
Definition at line 624 of file Argx.c.
References argxcFreeOption(), ArgxcOptions::id, ArgxcOptions::info, ArgxcOptions::param, ArgxcOptions::sparam, ArgxcOptions::subParams, ArgxcOptions::subParamsCapacity, and ArgxcOptions::subParamsCount.
Referenced by argxcFreeOption(), and freeOptionsArray().
void argxcFreeParam | ( | ArgxcParam * | param | ) |
Free resources associated with an ArgxcParam struct.
param | Pointer to the parameter to free. |
Definition at line 653 of file Argx.c.
References ArgxcParam::subExists.
void argxcFreeStringArray | ( | char ** | array, |
size_t | count ) |
Free a string array returned from Argxc (e.g., argv array).
array | The array to free. |
count | Number of elements in the array. |
Definition at line 661 of file Argx.c.
References freeStringArray().
int argxcGetArgc | ( | Argxc * | argxc | ) |
Get the number of command-line arguments passed.
argxc | Pointer to the Argxc instance. |
Definition at line 588 of file Argx.c.
References Argxc::mainArgc.
const char * argxcGetId | ( | Argxc * | argxc | ) |
char ** argxcGetMainArgs | ( | Argxc * | argxc, |
size_t * | count ) |
Get the raw command-line arguments passed to Argxc.
argxc | Pointer to the Argxc instance. |
count | Output: number of arguments returned. |
Definition at line 570 of file Argx.c.
References Argxc::mainArgs, Argxc::mainArgsCount, and stringDuplicate().
ArgxcOptions * argxcGetOptions | ( | Argxc * | argxc, |
size_t * | count ) |
Get all top-level options defined for the Argxc instance.
argxc | Pointer to the Argxc instance. |
count | Output: number of options returned. |
Definition at line 593 of file Argx.c.
References Argxc::options, and Argxc::optionsCount.
ArgxcParam argxcGetParam | ( | Argxc * | argxc, |
const char * | id ) |
Retrieve a parameter by ID.
argxc | Pointer to the Argxc instance. |
id | The identifier of the parameter to retrieve. |
Definition at line 214 of file Argx.c.
References ArgxcParam::exists, ArgxcOptions::hasAnySubParams, ArgxcOptions::hasSubParams, ArgxcOptions::id, Argxc::mainArgc, Argxc::mainArgs, Argxc::mainArgsCount, Argxc::options, Argxc::optionsCount, ArgxcOptions::param, ArgxcOptions::sparam, ArgxcParam::subExists, ArgxcParam::subExistsCount, ArgxcOptions::subParams, and ArgxcOptions::subParamsCount.
bool argxcGetSubParam | ( | Argxc * | argxc, |
const ArgxcParam * | param, | ||
const char * | id ) |
Retrieve a sub-parameter from a given parameter by ID.
argxc | Pointer to the Argxc instance. |
param | Pointer to the parent parameter. |
id | The identifier of the sub-parameter. |
Definition at line 366 of file Argx.c.
References argxcFindParam(), argxcParamExists(), and ArgxcParam::subExists.
bool argxcParamExists | ( | Argxc * | argxc, |
const char * | id ) |
Check if a parameter with the given ID exists.
argxc | Pointer to the Argxc instance. |
id | The identifier of the parameter. |
Definition at line 209 of file Argx.c.
References argxcFindParam().
Referenced by argxcGetSubParam().