"Daniel P. Berrange" <berrange(a)redhat.com> wrote:
There are quite a few places in our code where we have to convert
from
a string to an int enumeration, and vica-verca. This is tedious code to
write, and I'm about to introduce a tonne more enumerations in the new
generic domain XML parser / generator. So I reckon its time for some
helper APIs
...
Very nice. That's been annoying me for some time.
ACK
diff -r bc1615919490 src/util.c
--- a/src/util.c Fri Jun 13 15:43:20 2008 +0100
+++ b/src/util.c Fri Jun 13 18:52:39 2008 +0100
@@ -798,3 +798,24 @@
return idx;
}
+int virEnumFromString(const char *const*types,
+ int ntypes,
If using an unsigned type (size_t or unsigned int) doesn't cause too
much disruption among the callers, that'd be nice, since negative
"ntypes" is not useful.
+ const char *type)
+{
+ int i;
matching type here, too.
ACK, either way.