2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef GIMBAL_OPTION_GROUP_H
15#define GIMBAL_OPTION_GROUP_H
17#include "../meta/instances/gimbal_object.h"
18#include "../meta/signals/gimbal_signal.h"
19#include "../strings/gimbal_string_list.h"
23
24
25
26#define GBL_OPTION_GROUP_TYPE (GBL_TYPEID(GblOptionGroup))
27#define GBL_OPTION_GROUP(self) (GBL_CAST(GblOptionGroup, self))
29#define GBL_OPTION_GROUP_GET_CLASS(self) (GBL_CLASSOF(GblOptionGroup, self))
32#define GBL_SELF_TYPE GblOptionGroup
40typedef GBL_RESULT (*GblOptionCallbackFn)(GblOptionGroup* pGroup,
41 const GblOption* pOption,
46
47
56
57
77 GblOptionCallbackFn
pFn;
92
93
94
95
96
97
98
99
100
101
106 GBL_RESULT (*pFnTry) (
GBL_SELF, GblStringView key, GblStringView value, size_t *pUsed);
110
111
112
113
114
115
116
117
118
119
120
121
144 (parsePrePass, (GBL_INSTANCE_TYPE, pReceiver), (GBL_POINTER_TYPE, pStringList)),
145 (parsePostPass, (GBL_INSTANCE_TYPE, pReceiver), (GBL_POINTER_TYPE, pStringList)),
146 (parseError, (GBL_INSTANCE_TYPE, pReceiver), (GBL_ENUM_TYPE, errorCode))
166#define GblOptionGroup_parse(...)
167 GblOptionGroup_parseDefault_
(__VA_ARGS__, GBL_FALSE)
168#define GblOptionGroup_parseDefault_(self, list, prefix, ...)
169 (GblOptionGroup_parse
)(self, list, prefix)
#define GBL_CLASS_CAST(cType, klass)
#define GBL_FORWARD_DECLARE_STRUCT(S)
#define GBL_TYPEID(instanceStruct)
#define GBL_INSTANCE_DERIVE(derivedInstance, baseInstance)
#define GBL_DECLARE_ENUM(E)
#define GBL_CLASS_DERIVE(...)
#define GBL_DECLARE_FLAGS(F)
#define GBL_CLASSOF(cType, self)
#define GBL_CAST(cType, self)
GBL_RESULT GblOptionGroup_parse(GblOptionGroup *pSelf, GblStringList *pList, GblBool prefixOnly)
Processes the given string list, optionally requiring prefixes on all options.
GBL_OPTION_TYPE
Represents the list of every supported type of GblOption value.
@ GBL_OPTION_TYPE_UINT16
uint16_t
@ GBL_OPTION_TYPE_CALLBACK
GblOptionCallbackFn.
@ GBL_OPTION_TYPE_INT16
int16_t
@ GBL_OPTION_TYPE_UINT32
uint32_t
@ GBL_OPTION_TYPE_INT64
int64_t
@ GBL_OPTION_TYPE_BOOL
GblBool.
@ GBL_OPTION_TYPE_CHAR
char
@ GBL_OPTION_TYPE_UINT64
uint64_t
@ GBL_OPTION_TYPE_FLOAT
float
@ GBL_OPTION_TYPE_INT32
int32_t
@ GBL_OPTION_TYPE_DOUBLE
double
@ GBL_OPTION_TYPE_UINT8
uint8_t
@ GBL_OPTION_TYPE_STRING
const char*
GBL_OPTION_FLAGS
GblOption flags for controlling special option behaviors.
@ GBL_OPTION_FLAG_NONE
None.
@ GBL_OPTION_FLAG_BOOL_INVERTED
Underlying boolean value is swapped from user input.
@ GBL_OPTION_FLAG_HIDDEN
Hidden (doesn't display in the –help text)
@ GBL_OPTION_FLAG_BOOL_NO_VALUE
Bool option is enabled just by being present, without value.
GblType GblOptionGroup_type(void)
Returns the GblType UUID associated with GblOptionGroup.
GblOptionGroup * GblOptionGroup_create(const char *pName, const char *pPrefix, const GblOption *pOptions)
Creates a GblOptionGroup with an option name, prefix, and NULL-terminated option list.
GblRefCount GblOptionGroup_unref(GblOptionGroup *pSelf)
Decrements the reference counter of the given GblOptionGroup by 1, destructing when it hits 0.
#define GBL_STRING_TYPE
Builtin ID for string GblVariant type.
#define GBL_UINT32_TYPE
Builtin ID for uint32_t GblVariant type.
#define GBL_PROPERTIES(object,...)
Declares a list of properties for the given object/instance structure.
#define GBL_SIGNALS(instanceStruct,...)
uint32_t GblFlags
Standard-sized flags type, 32-bits across platforms.
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)
uint16_t GblRefCount
Type able to hold a reference counter across the codebase.
GblRingList GblStringList
List of strings with array-like API.
const char GblStringRef
Reference-counted, const char*-compatible string type.
uint32_t GblVersion
32-bit unsigned integer representing a packed version in the form (MAJOR.MINOR.PATCH)
Grouping of command-line options.
GblStringList * pParsedArgs
List of all options/values which have been extracted and parsed.
GblVersion version
Version number for the module/unit represented by this group.
GblOption * pOptions
Array of GblOption entries.
size_t optionCount
Number of options within pOptions.
GblStringRef * pSummary
Summary of the module/unit represented by the option group.
GBL_RESULT parseResult
Result of GblOptionGroup_parse()
GblStringRef * pPrefix
Prefix for all options within this group.
GblStringRef * pDescription
Longer description of the module/unit represented by the option group.
Describes a single command-line option along with handler info.
GblFlags flags
Additional flags for the option.
char shortName
Shorthanded, single-character name of option (optional)
const char * pLongName
Long, hyphenated name of option.
const char * pDescription
Help description of option.
GblOptionPtr pOutput
Union for either data or callback pointer.
const char * pValueName
Name of the value associated with the option.
GBL_OPTION_TYPE type
Data type of the option handler.
Union for SAFELY storing either a data or callback pointer.
void * pData
Data pointer of union.
GblOptionCallbackFn pFn
Callback pointer of union.