Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost Program_options config file comments

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.

like image 627
Godric Seer Avatar asked Mar 19 '13 13:03

Godric Seer


1 Answers

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.

like image 151
ypnos Avatar answered Sep 18 '22 07:09

ypnos