emacs
emacs

Reputation: 11

Boost property tree with INI files

I am using Boost property tree classes to read and write MS Ini-files. One of the section name contains a literal dot as part of the string. There is no hierarchy. How can I quote this dot?

[system-no.1]
acq=3

Upvotes: 1

Views: 448

Answers (1)

sehe
sehe

Reputation: 393164

You can only by creating paths with an alternative separator:

Live on Coliru

#include <boost/property_tree/ini_parser.hpp>
#include <iostream>
using boost::property_tree::ptree;

int main() {
    ptree::path_type path("system=no.1#acq", '#');

    ptree pt;
    pt.put(path, 3);

    write_ini(std::cout, pt);
}

Prints

[system=no.1]
acq=3

BONUS

Because the contructor is not explicit you can abbreviate to:

pt.put({"system=no.1#acq", '#'}, 3);

Upvotes: 1

Related Questions