[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[help-gengetopt] enums for string values
From: |
Gyozo, PAPP (VBuster) |
Subject: |
[help-gengetopt] enums for string values |
Date: |
Mon, 10 Apr 2006 17:16:36 +0200 |
Hi,
from time to time I run into the same situation to lookup string values in
gengetopt generated arrays (you know _values postfixed variables with "/*
Possible values for ...*/" comment) to map user-given parameters into integer
value, that is, the index of the array.
It would be nice if enums were generated beside string arrays (in the same
order) and these enums were also set be cmdline parser.
The corresponding *_given could store the enum value in case of simple (not
multiple) option if enum offsets start from 1 instead of 0. I don't know what
to do with multiple options now. (Of course, a very new tag in the cmdline
structure would be the most convenient solution.)
A little example w/ cmdline.ggo:
option "string-option" s "bla-bla" typestr="LEVEL"
values="off","normal","high" default="normal" no
cmdline.c:
char *cmdline_string_option_values[] = {"off", "normal", "high", 0} ; /*
Possible values for string-option. */
cmdline.h:
enum cmdline_string_options {
/* cmdline_string_option_no_value = 0 -- do we need it? */
cmdline_string_option_off = 1,
cmdline_string_option_normal,
cmdline_string_option_high
};
--
Papp, Győző
VirusBuster Kft
- [help-gengetopt] enums for string values,
Gyozo, PAPP (VBuster) <=