libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
GblCmdParser Struct Reference

#include <gimbal_cmd_parser.h>

Inheritance diagram for GblCmdParser:
Collaboration diagram for GblCmdParser:

Data Fields

union { 
 
   GblCmdParserClass *   pClass 
 
   GblObject   base 
 
};  
 
GblStringRefpErrorMsg
 
GBL_RESULT parseResult
 
uint8_t allowExtraArgs: 1
 
uint8_t allowUnknownOptions: 1
 
uint8_t firstArgAsExecutable: 1
 
uint8_t enableVersionOption: 1
 
uint8_t enableHelpOption: 1
 
- Data Fields inherited from GblObject
union { 
 
   GblObjectClass *   pClass 
 
   GblBox   base 
 
};  
 
- Data Fields inherited from GblInstance
GblClasspClass
 

Related Symbols

(Note that these are not member symbols.)

Option Groups

Methods for managing GblCmdOptionGroup subobjects

GBL_RESULT GblCmdParser_addOptionGroup (GblCmdParser *pSelf, GblOptionGroup *pGroup)
 
GBL_RESULT GblCmdParser_setOptionGroups (GblCmdParser *pSelf, GblOptionGroup **ppGroups)
 
GblOptionGroupGblCmdParser_optionGroup (const GblCmdParser *pSelf, size_t idx)
 
GblOptionGroupGblCmdParser_findOptionGroup (const GblCmdParser *pSelf, const char *pName)
 
size_t GblCmdParser_optionGroupCount (const GblCmdParser *pSelf)
 
GBL_RESULT GblCmdParser_setMainOptionGroup (GblCmdParser *pSelf, GblOptionGroup *pGroup)
 
GblOptionGroupGblCmdParser_mainOptionGroup (const GblCmdParser *pSelf)
 
Positional Arguments

Methods for managing positional arguments

GBL_RESULT GblCmdParser_addPositionalArg (GblCmdParser *pSelf, const char *pName, const char *pDesc)
 
GBL_RESULT GblCmdParser_setPositionalArgs (GblCmdParser *pSelf, const GblCmdArg *pArgs)
 
GBL_RESULT GblCmdParser_clearPositionalArgs (GblCmdParser *pSelf)
 
size_t GblCmdParser_positionalArgCount (const GblCmdParser *pSelf)
 
const GblCmdArgGblCmdParser_positionalArg (const GblCmdParser *pSelf, size_t index)
 
size_t GblCmdParser_positionalArgValueCount (const GblCmdParser *pSelf)
 
const GblStringListGblCmdParser_positionalArgValues (const GblCmdParser *pSelf)
 
GBL_RESULT GblCmdParser_positionalArgValue (const GblCmdParser *pSelf, size_t index, GblType toType, void *pData)
 

Detailed Description

General-purpose command-line argument parser.

GblCmdParser is a configurable, modular, generalized parser for processing command-line arguments. A parser may contain a single "main" option group and a collection of secondary option groups. This modularity allows each library or framework within an application to add its own individual option group to the main command parser.

See also
GblOptionGroup

Definition at line 76 of file gimbal_cmd_parser.h.

Friends And Related Symbol Documentation

◆ GblCmdParser_addOptionGroup()

GBL_RESULT GblCmdParser_addOptionGroup ( GblCmdParser * pSelf,
GblOptionGroup * pGroup )
related

Adds the GblOptionGroup pGroup to the list of option groups handled by the GblCmdParser.

◆ GblCmdParser_setOptionGroups()

GBL_RESULT GblCmdParser_setOptionGroups ( GblCmdParser * pSelf,
GblOptionGroup ** ppGroups )
related

Sets the internal array of option groups to the list of pointers given by the ppGroups array, NULL-terminated.

◆ GblCmdParser_optionGroup()

GblOptionGroup * GblCmdParser_optionGroup ( const GblCmdParser * pSelf,
size_t idx )
related

Returns a pointer to the GblOptionGroup at the given index.

◆ GblCmdParser_findOptionGroup()

GblOptionGroup * GblCmdParser_findOptionGroup ( const GblCmdParser * pSelf,
const char * pName )
related

Finds a GblOptionGroup from the internal list by its GblObject::name.

◆ GblCmdParser_optionGroupCount()

size_t GblCmdParser_optionGroupCount ( const GblCmdParser * pSelf)
related

Returns the number of option groups held within the internal list of them.

◆ GblCmdParser_setMainOptionGroup()

GBL_RESULT GblCmdParser_setMainOptionGroup ( GblCmdParser * pSelf,
GblOptionGroup * pGroup )
related

Sets the main option group for the parser to the one given by pGroup, returning the result.

◆ GblCmdParser_mainOptionGroup()

GblOptionGroup * GblCmdParser_mainOptionGroup ( const GblCmdParser * pSelf)
related

Returns the GblOptionGroup previously set as the main option group for the GblCmdParser.

◆ GblCmdParser_addPositionalArg()

GBL_RESULT GblCmdParser_addPositionalArg ( GblCmdParser * pSelf,
const char * pName,
const char * pDesc )
related

Dynamically creates a GblCmdArg struct from the given args and adds it to the internal list.

◆ GblCmdParser_setPositionalArgs()

GBL_RESULT GblCmdParser_setPositionalArgs ( GblCmdParser * pSelf,
const GblCmdArg * pArgs )
related

Sets the 0-terminated list of arguments pointed to by pArgs as the new positional argument list.

◆ GblCmdParser_clearPositionalArgs()

GBL_RESULT GblCmdParser_clearPositionalArgs ( GblCmdParser * pSelf)
related

Clears the currently held internal list of GblCmdArg structures, resetting its size to 0.

◆ GblCmdParser_positionalArgCount()

size_t GblCmdParser_positionalArgCount ( const GblCmdParser * pSelf)
related

Returns the size of the internally managed list of GblCmdArg structures represengin command-line arguments.

◆ GblCmdParser_positionalArg()

const GblCmdArg * GblCmdParser_positionalArg ( const GblCmdParser * pSelf,
size_t index )
related

Returns a pointer to the GblCmdArg structure in the internally maintained list at the given index.

◆ GblCmdParser_positionalArgValueCount()

size_t GblCmdParser_positionalArgValueCount ( const GblCmdParser * pSelf)
related

After parsing, this function returns the number of positional arguments extracted.

◆ GblCmdParser_positionalArgValues()

const GblStringList * GblCmdParser_positionalArgValues ( const GblCmdParser * pSelf)
related

After parsing, returns the GblStringList maintained internally, containing the extracted positional argument values.

◆ GblCmdParser_positionalArgValue()

GBL_RESULT GblCmdParser_positionalArgValue ( const GblCmdParser * pSelf,
size_t index,
GblType toType,
void * pData )
related

After parsing, this function converts the value of the argument at the given index to the desired toType, copying its value to pData, and returning the result.

Field Documentation

◆ pClass

GblCmdParserClass* GblCmdParser::pClass

Pointer to class/vtable structure.

Definition at line 76 of file gimbal_cmd_parser.h.

◆ base

GblObject GblCmdParser::base

Inherited base instance structure.

Definition at line 76 of file gimbal_cmd_parser.h.

◆ pErrorMsg

GblStringRef* GblCmdParser::pErrorMsg

Current, pending error message.

Definition at line 77 of file gimbal_cmd_parser.h.

◆ parseResult

GBL_RESULT GblCmdParser::parseResult

Result of last parse operation.

Definition at line 78 of file gimbal_cmd_parser.h.

◆ allowExtraArgs

uint8_t GblCmdParser::allowExtraArgs

Toggle for allowing extra positional arguments beyond the ones added.

Definition at line 79 of file gimbal_cmd_parser.h.

◆ allowUnknownOptions

uint8_t GblCmdParser::allowUnknownOptions

Toggle for allowing unknown options not handled by a GblCmdOptionGroup.

Definition at line 80 of file gimbal_cmd_parser.h.

◆ firstArgAsExecutable

uint8_t GblCmdParser::firstArgAsExecutable

Toggle for determining whether to treat the first argument as the executable name.

Definition at line 81 of file gimbal_cmd_parser.h.

◆ enableVersionOption

uint8_t GblCmdParser::enableVersionOption

Toggle for optionally enabling a version command-line option.

Definition at line 82 of file gimbal_cmd_parser.h.

◆ enableHelpOption

uint8_t GblCmdParser::enableHelpOption

Toggle for optionally enabling an autogenerated help option.

Definition at line 83 of file gimbal_cmd_parser.h.


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