2 * Copyright 2008-2009 Katholieke Universiteit Leuven
4 * Use of this software is governed by the GNU LGPLv2.1 license
6 * Written by Sven Verdoolaege, K.U.Leuven, Departement
7 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
16 #if defined(__cplusplus)
20 struct isl_arg_choice
{
33 enum isl_arg_type type
;
35 const char *long_name
;
39 struct isl_arg_choice
*choice
;
40 unsigned default_value
;
43 unsigned default_value
;
46 struct isl_arg
*child
;
52 #define ISL_ARG_CHOICE(st,f,s,l,c,d) { \
53 .type = isl_arg_choice, \
56 .offset = offsetof(st, f), \
57 .u = { .choice = { .choice = c, .default_value = d } } \
59 #define ISL_ARG_BOOL(st,f,s,l,d) { \
60 .type = isl_arg_bool, \
63 .offset = offsetof(st, f), \
64 .u = { .b = { .default_value = d } } \
66 #define ISL_ARG_CHILD(st,f,l,c) { \
67 .type = isl_arg_child, \
69 .offset = offsetof(st, f), \
70 .u = { .child = { .child = c, .size = sizeof(*((st *)NULL)->f) } }\
72 #define ISL_ARG_END { isl_arg_end }
74 #define ISL_ARG_ALL (1 << 0)
76 void isl_arg_set_defaults(struct isl_arg
*arg
, void *opt
);
77 int isl_arg_parse(struct isl_arg
*arg
, int argc
, char **argv
, void *opt
,
80 #define ISL_ARG_DECL(prefix,st,arg) \
81 st *prefix ## _new_with_defaults(); \
82 int prefix ## _parse(st *opt, int argc, char **argv, unsigned flags);
84 #define ISL_ARG_DEF(prefix,st,arg) \
85 st *prefix ## _new_with_defaults() \
87 st *opt = (st *)calloc(1, sizeof(st)); \
89 isl_arg_set_defaults(arg, opt); \
93 int prefix ## _parse(st *opt, int argc, char **argv, unsigned flags) \
95 return isl_arg_parse(arg, argc, argv, opt, flags); \
98 #if defined(__cplusplus)