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;
40 struct isl_arg_choice *choice;
41 unsigned default_value;
44 unsigned default_value;
47 struct isl_arg *child;
53 #define ISL_ARG_CHOICE(st,f,s,l,c,d,h) { \
54 .type = isl_arg_choice, \
57 .offset = offsetof(st, f), \
59 .u = { .choice = { .choice = c, .default_value = d } } \
61 #define ISL_ARG_BOOL(st,f,s,l,d,h) { \
62 .type = isl_arg_bool, \
65 .offset = offsetof(st, f), \
67 .u = { .b = { .default_value = d } } \
69 #define ISL_ARG_CHILD(st,f,l,c,h) { \
70 .type = isl_arg_child, \
72 .offset = offsetof(st, f), \
74 .u = { .child = { .child = c, .size = sizeof(*((st *)NULL)->f) } }\
76 #define ISL_ARG_END { isl_arg_end }
78 #define ISL_ARG_ALL (1 << 0)
80 void isl_arg_set_defaults(struct isl_arg *arg, void *opt);
81 int isl_arg_parse(struct isl_arg *arg, int argc, char **argv, void *opt,
84 #define ISL_ARG_DECL(prefix,st,arg) \
85 st *prefix ## _new_with_defaults(); \
86 int prefix ## _parse(st *opt, int argc, char **argv, unsigned flags);
88 #define ISL_ARG_DEF(prefix,st,arg) \
89 st *prefix ## _new_with_defaults() \
91 st *opt = (st *)calloc(1, sizeof(st)); \
93 isl_arg_set_defaults(arg, opt); \
97 int prefix ## _parse(st *opt, int argc, char **argv, unsigned flags) \
99 return isl_arg_parse(arg, argc, argv, opt, flags); \
102 #if defined(__cplusplus)