libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_cmd_parser.h File Reference

Go to the source code of this file.

Data Structures

struct  GblCmdArg
 
struct  GblCmdParserClass
 
struct  GblCmdParser
 

Macros

Type System

Type UUID and cast operators

#define GBL_CMD_PARSER_TYPE
 
#define GBL_CMD_PARSER(self)
 
#define GBL_CMD_PARSER_CLASS(klass)
 
#define GBL_CMD_PARSER_GET_CLASS(self)
 

Functions

GblType GblCmdParser_type (void)
 
Lifetime Management

Methods for controlling lifetime of a GblCmdParser

GblCmdParserGblCmdParser_create (void)
 
GblRefCount GblCmdParser_unref (GblCmdParser *pSelf)
 
Parsing

Methods for parsing arguments or managing parsed values

GblStringRefGblCmdParser_executable (const GblCmdParser *pSelf)
 
const GblStringListGblCmdParser_unknownOptions (const GblCmdParser *pSelf)
 
GBL_RESULT GblCmdParser_parse (GblCmdParser *pSelf, GblStringList *pArgs)
 

Detailed Description

Modular command-line argument parser.

Todo
More descriptive errors, help and version options, use virtual methods for customization points, implement signals for events (probably), process(..) top-level method for handling exiting upon failure, version, or help.
Author
2023 Falco Girgis

Definition in file gimbal_cmd_parser.h.

Macro Definition Documentation

◆ GBL_CMD_PARSER_TYPE

#define GBL_CMD_PARSER_TYPE

Type UUID of GblCmdParser.

Definition at line 23 of file gimbal_cmd_parser.h.

◆ GBL_CMD_PARSER

#define GBL_CMD_PARSER ( self)

Function-style GblInstance cast.

Definition at line 24 of file gimbal_cmd_parser.h.

◆ GBL_CMD_PARSER_CLASS

#define GBL_CMD_PARSER_CLASS ( klass)

Function-style GblClass cast.

Definition at line 25 of file gimbal_cmd_parser.h.

◆ GBL_CMD_PARSER_GET_CLASS

#define GBL_CMD_PARSER_GET_CLASS ( self)

Get a GblCmdParserClass from GblInstance.

Definition at line 26 of file gimbal_cmd_parser.h.

Function Documentation

◆ GblCmdParser_type()

GblType GblCmdParser_type ( void )

Returns the GblType UUID associated with GblCmdParser.

◆ GblCmdParser_create()

GblCmdParser * GblCmdParser_create ( void )

Creates a GblCmdParser object, initializes it, and returns a pointer to it.

◆ GblCmdParser_unref()

GblRefCount GblCmdParser_unref ( GblCmdParser * pSelf)

Unreferences a GblCmdParser, destroying it if it's the last one, returning the remaining reference count.

◆ GblCmdParser_executable()

GblStringRef * GblCmdParser_executable ( const GblCmdParser * pSelf)

After parsing, returns a GblStringRef to the name of the current executable (first positional argument)

◆ GblCmdParser_unknownOptions()

const GblStringList * GblCmdParser_unknownOptions ( const GblCmdParser * pSelf)

After parsing, retuns a GblStringList to the internally maintained list of unknown command-line options.

◆ GblCmdParser_parse()

GBL_RESULT GblCmdParser_parse ( GblCmdParser * pSelf,
GblStringList * pArgs )

Parses the list of arguments given by pArgs, populating internal structures, and returning the result.