I have a space separated file which contains some key->value pairs. These are to be loaded to a structure of the type given below:
#define FV_PARAM1 "A"
#define FV_PARAM2 "B"
parameter_t & parameterFeatureVector (
parameter_t & param,
int param1,
int param2,
) {
param.addParam(FV_PARAM1, param1);
param.addParam(FV_PARAM2, param2);
return param;
}
So to the above, I can pass the following values:
parameterFeatureVector( 10, 20 );
And I would expect the same to get loaded to ‘param’ structure. The above values are taken from the file. How would I go about implementing the same. If the above is not clear, do feel free to get back on it.
I take it you are asking how to translate a name “A” to a specific structure field? If So, C++ has no built-in way of doing that – you have to write a function:
However, I would suggest not doing that, and instead use a map:
you can then say things like: