Zycore 1.5.2
Zyan Core Library for C
Loading...
Searching...
No Matches
ArgParse.h
Go to the documentation of this file.
1/***************************************************************************************************
2
3 Zyan Core Library (Zycore-C)
4
5 Original Author : Joel Hoener
6
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24
25***************************************************************************************************/
26
31
32#ifndef ZYCORE_ARGPARSE_H
33#define ZYCORE_ARGPARSE_H
34
35#include <Zycore/Types.h>
36#include <Zycore/Status.h>
37#include <Zycore/Vector.h>
38#include <Zycore/String.h>
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44/* ============================================================================================== */
45/* Structs and other types */
46/* ============================================================================================== */
47
69
100
123
124/* ============================================================================================== */
125/* Exported functions */
126/* ============================================================================================== */
127
128#ifndef ZYAN_NO_LIBC
129
144 const char** error_token);
145
146#endif
147
165 const char** error_token, ZyanAllocator* allocator);
166
167/* ============================================================================================== */
168
169#ifdef __cplusplus
170}
171#endif
172
173#endif /* ZYCORE_ARGPARSE_H */
struct ZyanAllocator_ ZyanAllocator
Defines the ZyanAllocator struct.
ZYCORE_EXPORT ZyanStatus ZyanArgParse(const ZyanArgParseConfig *cfg, ZyanVector *parsed, const char **error_token)
Parse arguments according to a ZyanArgParseConfig definition.
struct ZyanArgParseConfig_ ZyanArgParseConfig
Configuration for argument parsing.
struct ZyanArgParseDefinition_ ZyanArgParseDefinition
Definition of a single argument.
struct ZyanArgParseArg_ ZyanArgParseArg
Information about a parsed argument.
ZYCORE_EXPORT ZyanStatus ZyanArgParseEx(const ZyanArgParseConfig *cfg, ZyanVector *parsed, const char **error_token, ZyanAllocator *allocator)
Parse arguments according to a ZyanArgParseConfig definition.
#define ZYCORE_EXPORT
Symbol is exported in shared library builds.
Definition Defines.h:330
Status code definitions and check macros.
ZyanU32 ZyanStatus
Defines the ZyanStatus data type.
Definition Status.h:48
Implements a string type.
struct ZyanStringView_ ZyanStringView
Defines the ZyanStringView struct.
Includes and defines some default data types.
ZyanU8 ZyanBool
Defines the ZyanBool data-type.
Definition Types.h:296
size_t ZyanUSize
Definition Types.h:224
Implements the vector container class.
struct ZyanVector_ ZyanVector
Defines the ZyanVector struct.
Information about a parsed argument.
Definition ArgParse.h:105
ZyanStringView value
If has_value == true, then the argument value.
Definition ArgParse.h:121
ZyanBool has_value
Whether the argument has a value (is non-boolean).
Definition ArgParse.h:115
const ZyanArgParseDefinition * def
Corresponding argument definition, or ZYAN_NULL for unnamed args.
Definition ArgParse.h:111
Configuration for argument parsing.
Definition ArgParse.h:74
ZyanArgParseDefinition * args
Argument definition array, or ZYAN_NULL.
Definition ArgParse.h:98
ZyanUSize argc
argc argument passed to main by LibC.
Definition ArgParse.h:82
ZyanUSize max_unnamed_args
Maximum # of accepted unnamed / anonymous arguments.
Definition ArgParse.h:90
const char ** argv
argv argument passed to main by LibC.
Definition ArgParse.h:78
ZyanUSize min_unnamed_args
Minimum # of accepted unnamed / anonymous arguments.
Definition ArgParse.h:86
Definition of a single argument.
Definition ArgParse.h:52
ZyanBool boolean
Whether the argument is boolean or expects a value.
Definition ArgParse.h:63
const char * name
The argument name, e.g.
Definition ArgParse.h:59
ZyanBool required
Whether this argument is required (error if missing).
Definition ArgParse.h:67