Hi all,
I've browsed the net trying to find a paradigm to describe what I'm looking for but haven't been successful. So I'll try to explain it as succinctly as I can.
Right now, for my PhD research, I've set out a few applications that take input files that have paramater/value pairs. When I want to execute a specific case, I generate a new text file with the input parameters I want to pass to the application and execute the application using these parameters.
Within the application, I read in the input file, strip and trim all unncessary stuff, like comment lines, whitespaces etc., and then I tokenize the contents and store the data on a line-by-line basis in a vector of strings. Then, for each tokenized line, I walk through a huge list of if-statements, to determine which parameter it is, and to subsequently set the value of the parameter in a struct, which I then use in the rest of my application.
Initially, this was a quick and dirty way to do this, and worked well, but it's turning out to be quite unwieldy now with all the if-statements. I'm sure there must be more intelligent ways of doing this.
What I'm basically looking for is a way to set up some sort of dictionary, that I can search through to match parameters from the input file, and then set the values given in the struct. Also, it would be handy if I can specify in the definition of the parameter in such a dictionary, what type of parameter/value combination it is, e.g., defining the data type and whether it's scalar/vector/list data.
From what I understand XML is appropriate for defining some of this, but I'm not very familiar with that, and before I take the plunge to look into something in further depth, I thought I'd ask here to see if someone can point me in the direction of any literature online that tackles input file parsing of parameter/value pairs.
Thanks in advance for your advice!
Regards,
Kartik