0

if I specify

ip_addresses=monkeys
ip_addresses=baboons

parse_config_file creates multiple strings resulting in a std::vector< std::string> as output.

I want to list multiple strings on a single line.

ip_addresses=monkeys, baboons

The result is a single string in the std::vector< <std::string> >. If it is possible, how does one express the seperator ?

The documentation does not specify if string seperation is allowed in the ini-files. However, multi-valued settings can be seperated when supplied as command line switches.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Hassan Syed
  • 20,075
  • 11
  • 87
  • 171
  • I've edited the question, but it should have been pretty obvious. Especially considering the title of the question. – Hassan Syed Feb 09 '11 at 15:37
  • AFAIK the INI file format does not cater for separated values per property. You'll have to tokenize the key if you want this to work. – Nim Feb 09 '11 at 15:45
  • I feared this answer. I wish boost would pick up libconfig (first google result). although I keep coming to the conclusion that a richer file format doesn't mesh well with the mix of environment variables / command-line settings. – Hassan Syed Feb 09 '11 at 15:48
  • No need to fear. Use the boost tokenizer library. Alternatively the boost string algorithms library has a convenient string splitter. – Ferruccio Feb 09 '11 at 16:09
  • @Ferruccio that is a way of doing it, though, it's quite annoying that the documentation promotes using `std::vector< std::string> >` and the method `vm["setting_name"].count()` to check for multi-valued occurances. It's quite ugly having to resort to an external function to split a string up; considering the fact that the command-line parser can do this. – Hassan Syed Feb 09 '11 at 17:08

0 Answers0