[GRASS-dev] [GRASS-SVN] r60703 - in grass/trunk: display/d.vect general/g.gisenv gui/wxpython/animation lib/python/temporal raster/r.colors raster/r.external raster/r.in.bin raster/r.mapcalc raster/r.neighbors raster/r.out.bin raster/r.quant raster/r.resamp.filter raster/r.series raster/r.series.accumulate raster/r.series.interp raster/r.stats.quantile vector/v.colors vector/v.external.out
Huidae Cho
grass4u at gmail.com
Wed Jun 18 06:56:47 PDT 2014
I think we need two more functions:
// at most one option from a set
void G_option_exclusive(void *first, ...);
// at least one option from a set
void G_option_required(void *first, ...);
// if the first option is present, at least one of the other
// options must also be present
void G_option_requires(void *first, ...);
// if the first option is present, all the other options must also
be present.
// same as multiple G_option_requires(first, opt)...
void G_option_requires_all(void *first, ...);
// G_option_requires_all() doesn't make the second/third... option
require all the other options.
// if any option is present, all the other options must also be
present.
// all or nothing from a set
void G_option_inclusive(void *first, ...);
On Wed, Jun 11, 2014 at 10:12 AM, Huidae Cho <grass4u at gmail.com> wrote:
> Right, G_option_exclusive(void *first, ...) should work.
>
>
> On Wed, Jun 11, 2014 at 6:43 AM, Glynn Clements <glynn at gclements.plus.com>
> wrote:
>
>>
>> Huidae Cho wrote:
>>
>> > Maybe, we can use variadic macros in C99 to remove the first name
>> argument.
>>
>> GRASS doesn't require C99. In general, we try to keep the hard
>> dependencies to a bare minimium, particularly in core functionality
>> such as libgis.
>>
>> In any case, the <stdarg.h> requirement for an explicit first argument
>> isn't a significant problem. The functions would never be called with
>> less than two arguments.
>>
>> In the worst case, it complicates the implementation slightly, as we
>> can't simply iterate over all of the arguments using va_arg(), but
>> have to treat the explicit argument separately. That can be handled
>> like:
>>
>> void G_option_exclusive(void *first, ...)
>> {
>> void *opt = first;
>> va_start(ap, first);
>> for (;;) {
>> process(opt); // search for opt in options/flags
>> opt = va_arg(ap, void*);
>> if (!opt) // NULL terminator
>> break;
>> }
>> va_end(ap);
>> }
>>
>> --
>> Glynn Clements <glynn at gclements.plus.com>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20140618/29e97b67/attachment-0001.html>
More information about the grass-dev
mailing list