19 #define PASS_2_OUT(args,s) (args)->output.insert(s)
20 #define COPY_2_OUT(args,s) PASS_2_OUT(args, ARB_strdup(s))
21 #define IN_2_OUT(args,i) PASS_2_OUT(args, args->input.get_smart(i))
22 #define PARAM_2_OUT(args,i) PASS_2_OUT(args, args->get_param_smart(i))
24 #define FORMAT_2_OUT(args,fmt,value) PASS_2_OUT(args, GBS_global_string_copy(fmt, value))
45 #define GBL_BEGIN_PARAMS gbl_param *params = NULp
48 gbl_param *gblp = ARB_calloc<gbl_param>(1);
61 typedef unsigned int nat;
78 inline const char *
gbl_param_String(
const char *param_name,
const char *def,
const char *help_text,
gbl_param **pp, String *vaddr) {
91 #define GBL_PARAM_TYPE(type, var, param_name, def, help_text) type var = gbl_param_##type(param_name, def, help_text, ¶ms, &var)
92 #define GBL_STRUCT_PARAM_TYPE(type, strct, member, param_name, def, help_text) strct.member = gbl_param_##type(param_name, def, help_text, ¶ms, &strct.member)
95 #define PARAM_IF(cond,param) ((cond) ? (param) : NULp)
97 #define GBL_PARAM_INT(var, param_name, def, help_text) GBL_PARAM_TYPE(int, var, param_name, def, help_text)
98 #define GBL_PARAM_CHAR(var, param_name, def, help_text) GBL_PARAM_TYPE(char, var, param_name, def, help_text)
99 #define GBL_PARAM_UINT(var, param_name, def, help_text) GBL_PARAM_TYPE(nat, var, param_name, def, help_text)
100 #define GBL_PARAM_STRING(var, param_name, def, help_text) GBL_PARAM_TYPE(String, var, param_name, def, help_text)
101 #define GBL_PARAM_BIT(var, param_name, def, help_text) GBL_PARAM_TYPE(bit, var, param_name, def, help_text)
103 #define GBL_STRUCT_PARAM_INT(strct, member, param_name, def, help_text) GBL_STRUCT_PARAM_TYPE(int, strct, member, param_name, def, help_text)
104 #define GBL_STRUCT_PARAM_CHAR(strct, member, param_name, def, help_text) GBL_STRUCT_PARAM_TYPE(char, strct, member, param_name, def, help_text)
105 #define GBL_STRUCT_PARAM_UINT(strct, member, param_name, def, help_text) GBL_STRUCT_PARAM_TYPE(nat, strct, member, param_name, def, help_text)
106 #define GBL_STRUCT_PARAM_STRING(strct, member, param_name, def, help_text) GBL_STRUCT_PARAM_TYPE(String, strct, member, param_name, def, help_text)
107 #define GBL_STRUCT_PARAM_BIT(strct, member, param_name, def, help_text) GBL_STRUCT_PARAM_TYPE(bit, strct, member, param_name, def, help_text)
109 #define GBL_TRACE_PARAMS(args) \
111 GB_ERROR def_error = \
112 trace_params((args)->get_param_streams(), params, (args)->get_cmdName()); \
113 gb_assert((args)->set_params_checked()); \
114 if (def_error) { GBL_END_PARAMS; return def_error; } \
117 #define GBL_END_PARAMS \
122 params = params->next; \
127 #define GBL_CHECK_FREE_PARAM(nr, cnt) \
129 if ((nr)+(cnt) >= GBL_MAX_ARGUMENTS) { \
131 return "max. parameters exceeded"; \
174 if (params == fix || params == (fix+opt))
return NULp;
175 if (!opt_expect_all && params >= fix && params <= (fix+opt))
return NULp;
182 if (number >= min && number <= max)
return NULp;
183 return GBS_global_string(
"Illegal %s number '%i' (allowed [%i..%i])", what, number, min, max);
195 #define TRACE_ACI(text) if (GBL_IMPL::traceACI) GBL_IMPL::print_trace(text)
197 #define DO_AND_RETURN_ON_ERROR(cmd) do { \
198 GB_ERROR perr = (cmd); \
199 if (perr) return perr; \
202 #define EXPECT_NO_PARAM(args) DO_AND_RETURN_ON_ERROR(GBL_IMPL::check_no_parameter(args))
203 #define EXPECT_PARAMS_PASSED(args,syntax) DO_AND_RETURN_ON_ERROR(GBL_IMPL::check_has_parameters(args,syntax))
204 #define ACCEPT_ANY_PARAMS(args) gb_assert((args)->set_params_checked())
206 #define EXPECT_PARAMS(args,cnt,help) DO_AND_RETURN_ON_ERROR(GBL_IMPL::check_parameters(args, cnt, help))
207 #define EXPECT_OPTIONAL_PARAMS(args,fixCnt,fixhelp,optCnt,opthelp) DO_AND_RETURN_ON_ERROR(GBL_IMPL::check_optional_parameters(args, fixCnt, fixhelp, optCnt, opthelp, true, true))
208 #define EXPECT_OPTIONAL_PARAMS_CUSTOM(args,fixCnt,fixhelp,optCnt,opthelp,trail,all) DO_AND_RETURN_ON_ERROR(GBL_IMPL::check_optional_parameters(args, fixCnt, fixhelp, optCnt, opthelp, trail, all))
210 #define EXPECT_LEGAL_STREAM_INDEX(args,number) do { \
211 GB_ERROR serr = GBL_IMPL::check_valid_stream_index(args, number); \
212 if (serr) return serr; \
215 #define EXPECT_ITEM_REFERENCED(args) DO_AND_RETURN_ON_ERROR(GBL_IMPL::check_item_referenced(args))
218 #define COMMAND_DROPS_INPUT_STREAMS(args) do { \
219 if (GBL_IMPL::traceACI && args->input.size()>0) { \
220 if (args->input.size()>1 || args->input.get(0)[0]) { \
221 GBL_IMPL::print_trace(GBS_global_string("Warning: Dropped %i input streams\n", args->input.size())); \
228 #error gb_aci_impl.h included twice
229 #endif // GB_ACI_IMPL_H
GB_ERROR check_optional_parameters(GBL_command_arguments *args, int fix, const char *fixParam, int opt, const char *optParam, bool opt_trailing, bool opt_expect_all)
int gbl_param_int(const char *param_name, int def, const char *help_text, gbl_param **pp, int *vaddr)
GB_ERROR check_valid_index(int number, const char *what, int min, int max)
nat gbl_param_nat(const char *param_name, nat def, const char *help_text, gbl_param **pp, nat *vaddr)
const char * get_cmdName() const
const char * GBS_global_string(const char *templat,...)
GB_ERROR check_item_referenced(GBL_command_arguments *args)
GB_ERROR check_no_parameter(GBL_command_arguments *args)
int gbl_param_bit(const char *param_name, int def, const char *help_text, gbl_param **pp, bit *vaddr)
GB_ERROR check_valid_stream_index(GBL_command_arguments *args, int number)
static int diff(int v1, int v2, int v3, int v4, int st, int en)
void print_trace(const char *text)
bool set_params_checked()
GB_ERROR trace_params(const GBL_streams ¶m, gbl_param *ppara, const char *com)
char gbl_param_char(const char *param_name, char def, const char *help_text, gbl_param **pp, char *vaddr)
GBDATA * get_item_ref() const
GB_ERROR check_parameters(GBL_command_arguments *args, int expected, const char *parameterList)
void modify_trace_indent(int diff)
GB_ERROR check_valid_param_index(GBL_command_arguments *args, int number)
void gbl_new_param(gbl_param **pp, GB_TYPES type, void *vaddr, const char *param_name, const char *help_text)
const char * search_matching_parenthesis(const char *source)
const char * gbl_param_String(const char *param_name, const char *def, const char *help_text, gbl_param **pp, String *vaddr)
GB_ERROR check_has_parameters(GBL_command_arguments *args, const char *param_syntax)