add isl_qpolynomial_as_polynomial_on_domain
[isl.git] / include / isl_arg.h
blob86ff19eaef4c6ad1dac027437c70356cf505552f
1 /*
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
8 */
10 #ifndef ISL_ARG_H
11 #define ISL_ARG_H
13 #include <stddef.h>
14 #include <stdlib.h>
16 #if defined(__cplusplus)
17 extern "C" {
18 #endif
20 struct isl_arg_choice {
21 const char *name;
22 unsigned value;
25 enum isl_arg_type {
26 isl_arg_end,
27 isl_arg_choice,
28 isl_arg_bool,
29 isl_arg_child
32 struct isl_arg {
33 enum isl_arg_type type;
34 char short_name;
35 const char *long_name;
36 size_t offset;
37 union {
38 struct {
39 struct isl_arg_choice *choice;
40 unsigned default_value;
41 } choice;
42 struct {
43 unsigned default_value;
44 } b;
45 struct {
46 struct isl_arg *child;
47 size_t size;
48 } child;
49 } u;
52 #define ISL_ARG_CHOICE(st,f,s,l,c,d) { \
53 .type = isl_arg_choice, \
54 .short_name = s, \
55 .long_name = l, \
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, \
61 .short_name = s, \
62 .long_name = l, \
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, \
68 .long_name = l, \
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,
78 unsigned flags);
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() \
86 { \
87 st *opt = (st *)calloc(1, sizeof(st)); \
88 if (opt) \
89 isl_arg_set_defaults(arg, opt); \
90 return opt; \
91 } \
93 int prefix ## _parse(st *opt, int argc, char **argv, unsigned flags) \
94 { \
95 return isl_arg_parse(arg, argc, argv, opt, flags); \
98 #if defined(__cplusplus)
100 #endif
102 #endif