Zycore  1.2.0.0
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 
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 
52 {
59  const char* name;
69 
73 typedef struct ZyanArgParseConfig_
74 {
78  const char** argv;
82  ZyanUSize argc;
86  ZyanUSize min_unnamed_args;
90  ZyanUSize max_unnamed_args;
100 
104 typedef struct ZyanArgParseArg_
105 {
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 */
ZYCORE_EXPORT ZyanStatus ZyanArgParse(const ZyanArgParseConfig *cfg, ZyanVector *parsed, const char **error_token)
struct ZyanArgParseConfig_ ZyanArgParseConfig
struct ZyanArgParseDefinition_ ZyanArgParseDefinition
struct ZyanArgParseArg_ ZyanArgParseArg
ZYCORE_EXPORT ZyanStatus ZyanArgParseEx(const ZyanArgParseConfig *cfg, ZyanVector *parsed, const char **error_token, ZyanAllocator *allocator)
#define ZYCORE_EXPORT
Definition: Defines.h:221
ZyanU32 ZyanStatus
Definition: Status.h:48
ZyanU8 ZyanBool
Definition: Types.h:192
Definition: Allocator.h:89
Definition: ArgParse.h:105
ZyanStringView value
Definition: ArgParse.h:121
ZyanBool has_value
Definition: ArgParse.h:115
const ZyanArgParseDefinition * def
Definition: ArgParse.h:111
Definition: ArgParse.h:74
ZyanUSize max_unnamed_args
Definition: ArgParse.h:90
ZyanUSize argc
Definition: ArgParse.h:82
ZyanArgParseDefinition * args
Definition: ArgParse.h:98
const char ** argv
Definition: ArgParse.h:78
ZyanUSize min_unnamed_args
Definition: ArgParse.h:86
Definition: ArgParse.h:52
ZyanBool boolean
Definition: ArgParse.h:63
const char * name
Definition: ArgParse.h:59
ZyanBool required
Definition: ArgParse.h:67
Definition: String.h:132
Definition: Vector.h:76