16 |
optTypeFlag, // 1 |
optTypeFlag, // 1 |
17 |
optTypeBool, // 2 |
optTypeBool, // 2 |
18 |
optTypeInt, // 3 |
optTypeInt, // 3 |
19 |
optTypeReal, // 4 |
optTypeUInt, // 4 |
20 |
optTypeReal2, // 5 |
optTypeReal, // 5 |
21 |
optTypeReal3, // 6 |
optTypeReal2, // 6 |
22 |
optTypeReal4, // 7 |
optTypeReal3, // 7 |
23 |
optTypeString // 8 |
optTypeReal4, // 8 |
24 |
|
optTypeString // 9 |
25 |
} opt_type_t; |
} opt_type_t; |
26 |
|
|
27 |
/*! The struct containing the definition of *one* option, and storage |
/*! The struct containing the definition of *one* option, and storage |
35 |
int b; //!< storage for boolean-valued options |
int b; //!< storage for boolean-valued options |
36 |
double r[4]; //!< storage for real-valued options |
double r[4]; //!< storage for real-valued options |
37 |
int64_t i[4]; //!< storage for integer-valued options |
int64_t i[4]; //!< storage for integer-valued options |
38 |
|
uint64_t u[1]; //!< storage for unsigned integer-valued options |
39 |
char *s; //!< storage for string-valued options |
char *s; //!< storage for string-valued options |
40 |
} hval; |
} hval; |
41 |
void *valp; //!< pointer to Diderot global variable being set |
void *valp; //!< pointer to Diderot global variable being set |
278 |
hasDflt ? buf : NULL, desc); |
hasDflt ? buf : NULL, desc); |
279 |
} |
} |
280 |
|
|
281 |
|
/*! \brief add an unsigned integer option to the list of options. |
282 |
|
* \param dopts the list of options |
283 |
|
* \param name the name of the option |
284 |
|
* \param desc a short description string |
285 |
|
* \param v a pointer to the location where the value gets stored |
286 |
|
* \param hasDflt true if there is an initial value |
287 |
|
*/ |
288 |
|
void Diderot_OptAddUInt ( |
289 |
|
Diderot_Options_t *dopts, |
290 |
|
const char *name, const char *desc, Diderot_uint_t *v, bool hasDflt) |
291 |
|
{ |
292 |
|
char buf[AIR_STRLEN_HUGE] = ""; |
293 |
|
if (hasDflt) { |
294 |
|
snprintf(buf, sizeof(buf), "%ld", (unsigned long)*v); |
295 |
|
} |
296 |
|
opt_def_t *odf = OptAdd(dopts, name, desc, (void*)v, optTypeUInt); |
297 |
|
hestOptAdd ( |
298 |
|
&dopts->hopt, name, "int", airTypeULongInt, 1, 1, odf->hval.u, |
299 |
|
hasDflt ? buf : NULL, desc); |
300 |
|
} |
301 |
|
|
302 |
/*! \brief add a real-valued option to the list of options. |
/*! \brief add a real-valued option to the list of options. |
303 |
* \param dopts the list of options |
* \param dopts the list of options |
304 |
* \param name the name of the option |
* \param name the name of the option |
438 |
case optTypeInt: |
case optTypeInt: |
439 |
*(Diderot_int_t *)(odf->valp) = (Diderot_int_t)(odf->hval.i[0]); |
*(Diderot_int_t *)(odf->valp) = (Diderot_int_t)(odf->hval.i[0]); |
440 |
break; |
break; |
441 |
|
case optTypeUInt: |
442 |
|
*(Diderot_uint_t *)(odf->valp) = (Diderot_uint_t)(odf->hval.u[0]); |
443 |
|
break; |
444 |
case optTypeReal: |
case optTypeReal: |
445 |
*(Diderot_real_t *)(odf->valp) = (Diderot_real_t)(odf->hval.r[0]); |
*(Diderot_real_t *)(odf->valp) = (Diderot_real_t)(odf->hval.r[0]); |
446 |
break; |
break; |