I need to write reader class for a program config file, and I'm trying to determine the best way to approach this.
I have some experience with boost::spirit (actually, just enough to know that I am terrible at writing grammars), and a good bit of experience with regular-expressions.
Other than that, I can't think of much. So my options seem to be:
- boost::spirit
- std or boost regex
- ol' fashion string parsing
I am looking for suggestions or advice on how to proceed - or even pseudo-code should anyone feel inclined.
I realize this is a bit of an opinion-based question, but I'm really struggling with writers-block here. I'm worried I'll start down a path, and waste a lot of time before realizing it was a poor choice.
The config file format is already defined, and looks like this:
Group1 {
Scalar1 = 500
Scalar2 = 45.5
Scalar3 = My Value
List1 {
LS1 = 123
LS2 = hello world
}
List2 {
LS1 = 456
LS2 = goodbye world
}
Array1 [
300
200
25
]
Array2 [
true
false
true
false
]
};
- The config will always have at least one
Group. - A
Groupwill contain 0..nScalar,List, and/orArrayentries - A
scalaris:label = value - A
Listis a labeled container ofScalars - An
Arrayis a labeled container of values
The labels shown (eg. Scalar1, Scalar2, ...) are just examples. They can be called anything: maxrate = 500, avg_val = 45.5, would have been just as valid.