I have a program that reads a large number of variables from a configuration file using boost::program_options. The configuration file is working and reading the values, however since there are many options in the file, I would like to document them in place. For example I want the config file to look like:
# Here is a description of flag1
# flag1 = true means blah blah blah
# flag1 = false means ...
flag1=true
# Here is a description of flag 2
.
.
.
The issue is that I can not find documentation anywhere that describes a way to do this. I am fairly certain that I could use something such as a=
for my comment delimiter, and simply assign all the comments to a std::vector<string>
to be thrown away after parsing, however I would like to know if there is a more appropriate way to handle comment lines in a configuration file.
The documentation of program_options
is really bad.
Fact is, it already supports comment lines starting with '#'. It throws these lines out. You don't have to do anything to make that work, it is done implicitely. It does not work with '//', etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With