说,我们有一个名为a.conf的文件
s=which(data==1,arr.ind = T)
data$IncomeX[s[,1]]=s[,2]
data
income1 income2 income3 income4 income5 IncomeX
1 0 1 0 0 0 2
2 1 0 0 0 0 1
3 1 0 0 0 0 1
4 1 0 0 0 0 1
5 1 0 0 0 0 1
6 1 0 0 0 0 1
7 0 1 0 0 0 2
8 1 0 0 0 0 1
9 1 0 0 0 0 1
10 0 0 0 1 0 4
当我尝试使用boost信息解析器以下列方式读取具有上述内容的INFO格式文件时;
key3
{
key4 "value4 with spaces" ;this is a key4
}
并在namespace p = boost::property_tree;
p::ptree pt;
std::ifstream input("a.conf");
pt::info_parser::read_info(input, pt);
/*
....do some stuff (optional)
*/
中回写pt
的内容,删除评论。
a.conf
写回后std::ofstream output("a.conf");
write_info(output, pt);
output.close();
文件的内容;
a.conf
有没有办法在使用boost info解析器读/写时保留这些注释?
答案 0 :(得分:0)
INFO往返除了丢失评论和包含指令外。