[Program Options Library] Does Program Options Library support "sections" in config file?

For example, to connect different databases according to different requests, there are some options stored in a config file, like this: [DB1] server=172.16.21.1 database=dbname1 userid=someone1 password=xxxxxx [DB2] server=172.16.21.2 database=dbname2 userid=someone2 password=oooooo i.e. with same key name in different sectors. In Win32 API, this method is very handy: // to get "server" in "[DB1]" char buf[256]; GetPrivateProfileString (""DB1, "server", "", buf, sizeof(buf), "configfile.ini"); Is there a mechanism in "Program Options Library" to support this config file? Or, does it intend to support? Thanks!

Hi Frank,
For example, to connect different databases according to different requests, there are some options stored in a config file, like this:
[DB1] server=172.16.21.1 database=dbname1 userid=someone1 password=xxxxxx
[DB2] server=172.16.21.2 database=dbname2 userid=someone2 password=oooooo
i.e. with same key name in different sectors.
Yes, you'd just use the syntax above. The library would interpret the above as DB1.server=172.16.21.1 .... DB2.server=172.16.21.1 In other words, it would prepend the name of the section to the name of the option. For your use case, you might want to look at one of the examples: http://zigzag.lvk.cs.msu.su/~ghost/boost/libs/program_options/example/dynami... http://zigzag.lvk.cs.msu.su/~ghost/boost/libs/program_options/example/dynami... which unfortunately is not committed yet. - Volodya
participants (2)
-
Vladimir Prus
-
周方 Frank Chow