Zycore
1.5.1.0
Toggle main menu visibility
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
41
extern
"C"
{
42
#endif
43
44
/* ============================================================================================== */
45
/* Structs and other types */
46
/* ============================================================================================== */
47
51
typedef
struct
ZyanArgParseDefinition_
52
{
59
const
char
*
name
;
63
ZyanBool
boolean
;
67
ZyanBool
required
;
68
}
ZyanArgParseDefinition
;
69
73
typedef
struct
ZyanArgParseConfig_
74
{
78
const
char
**
argv
;
82
ZyanUSize
argc
;
86
ZyanUSize
min_unnamed_args
;
90
ZyanUSize
max_unnamed_args
;
98
ZyanArgParseDefinition
*
args
;
99
}
ZyanArgParseConfig
;
100
104
typedef
struct
ZyanArgParseArg_
105
{
111
const
ZyanArgParseDefinition
*
def
;
115
ZyanBool
has_value
;
121
ZyanStringView
value
;
122
}
ZyanArgParseArg
;
123
124
/* ============================================================================================== */
125
/* Exported functions */
126
/* ============================================================================================== */
127
128
#ifndef ZYAN_NO_LIBC
129
143
ZYCORE_EXPORT
ZyanStatus
ZyanArgParse
(
const
ZyanArgParseConfig
*cfg,
ZyanVector
* parsed,
144
const
char
** error_token);
145
146
#endif
147
164
ZYCORE_EXPORT
ZyanStatus
ZyanArgParseEx
(
const
ZyanArgParseConfig
*cfg,
ZyanVector
* parsed,
165
const
char
** error_token,
ZyanAllocator
* allocator);
166
167
/* ============================================================================================== */
168
169
#ifdef __cplusplus
170
}
171
#endif
172
173
#endif
/* ZYCORE_ARGPARSE_H */
ZyanAllocator
struct ZyanAllocator_ ZyanAllocator
ZyanArgParse
ZYCORE_EXPORT ZyanStatus ZyanArgParse(const ZyanArgParseConfig *cfg, ZyanVector *parsed, const char **error_token)
ZyanArgParseConfig
struct ZyanArgParseConfig_ ZyanArgParseConfig
ZyanArgParseDefinition
struct ZyanArgParseDefinition_ ZyanArgParseDefinition
ZyanArgParseArg
struct ZyanArgParseArg_ ZyanArgParseArg
ZyanArgParseEx
ZYCORE_EXPORT ZyanStatus ZyanArgParseEx(const ZyanArgParseConfig *cfg, ZyanVector *parsed, const char **error_token, ZyanAllocator *allocator)
ZYCORE_EXPORT
#define ZYCORE_EXPORT
Definition
Defines.h:235
Status.h
ZyanStatus
ZyanU32 ZyanStatus
Definition
Status.h:48
String.h
ZyanStringView
struct ZyanStringView_ ZyanStringView
Types.h
ZyanBool
ZyanU8 ZyanBool
Definition
Types.h:296
Vector.h
ZyanVector
struct ZyanVector_ ZyanVector
ZyanArgParseArg_
Definition
ArgParse.h:105
ZyanArgParseArg_::value
ZyanStringView value
Definition
ArgParse.h:121
ZyanArgParseArg_::has_value
ZyanBool has_value
Definition
ArgParse.h:115
ZyanArgParseArg_::def
const ZyanArgParseDefinition * def
Definition
ArgParse.h:111
ZyanArgParseConfig_
Definition
ArgParse.h:74
ZyanArgParseConfig_::max_unnamed_args
ZyanUSize max_unnamed_args
Definition
ArgParse.h:90
ZyanArgParseConfig_::argc
ZyanUSize argc
Definition
ArgParse.h:82
ZyanArgParseConfig_::args
ZyanArgParseDefinition * args
Definition
ArgParse.h:98
ZyanArgParseConfig_::argv
const char ** argv
Definition
ArgParse.h:78
ZyanArgParseConfig_::min_unnamed_args
ZyanUSize min_unnamed_args
Definition
ArgParse.h:86
ZyanArgParseDefinition_
Definition
ArgParse.h:52
ZyanArgParseDefinition_::boolean
ZyanBool boolean
Definition
ArgParse.h:63
ZyanArgParseDefinition_::name
const char * name
Definition
ArgParse.h:59
ZyanArgParseDefinition_::required
ZyanBool required
Definition
ArgParse.h:67
include
Zycore
ArgParse.h
Generated by
1.17.0