T
Time Waster
Java property files are dead simple:
key1=val1
some.key2=val2
For simplicity on the Java side, I'd like to use these files from C
as well (the C program and Java program must cooperate). Anyone have
any bright ideas on handling this sort of thing from C? Is there
any preexisting libraries or calls that would help?
One idea I had was to have a big enumerated type of the key names (which are
known ahead of time):
enum { key1 = 0, key2, key3 , MAXKEY}
char *keys[MAXKEY];
Then as I read the keys from the file, I could somehow fill in
the array:
<read key1=val1>
keys[key1] = val1;
But that led me to the dead end because even if I have stringvar == "key1"
that doesn't get me to the bareword needed to have an enumerated reference.
Of course, I could have another stupid array of structs defined mapping the
key1 enumeration thingy to "key1" as a string, but that seems kind of
ugly. Is there a way to get the enumerated constant key1 from the
string value "key1"?
TIA
key1=val1
some.key2=val2
For simplicity on the Java side, I'd like to use these files from C
as well (the C program and Java program must cooperate). Anyone have
any bright ideas on handling this sort of thing from C? Is there
any preexisting libraries or calls that would help?
One idea I had was to have a big enumerated type of the key names (which are
known ahead of time):
enum { key1 = 0, key2, key3 , MAXKEY}
char *keys[MAXKEY];
Then as I read the keys from the file, I could somehow fill in
the array:
<read key1=val1>
keys[key1] = val1;
But that led me to the dead end because even if I have stringvar == "key1"
that doesn't get me to the bareword needed to have an enumerated reference.
Of course, I could have another stupid array of structs defined mapping the
key1 enumeration thingy to "key1" as a string, but that seems kind of
ugly. Is there a way to get the enumerated constant key1 from the
string value "key1"?
TIA