POCO - 属性文件配置保存方法始终使用 ":" 作为分隔符进行写入
POCO - PropertyFileConfiguration save method always writes using ":" as delimiter
我们目前正在项目中使用POCO库。我正在使用setstring
来设置键和值映射。如果我尝试保存,我希望该文件应该以key= value
格式保存。但POCO将其保存为key: value
格式。
有没有办法用key=value
格式保存文件?
示例:
Poco::AutoPtr<Poco::Util::PropertyFileConfiguration> pConf;
pConf = new poco::Util::PropertyFileConfiguration(file1);
pConf->setString("key1","value1");
pConf->save(file1);
文件1:的输出
key1: value1
但我预计输出应该是:
key1= value1
我不知道。类PropertyFileConfiguration
可以加载格式<key> = <pair>
和<key> : <pair>
,但只能使用<key> : <pair>
格式进行保存。
来自文件:
保存
无效保存(std::ostream&奥斯特)const;
将配置数据写入给定的流。
数据以<键>:<值>用换行符分隔。
如果真的没有其他选项,您可以将自己的saveUsingEqual()
函数添加到PropertyFileConfiguration
中。原始save()
的代码非常简单:
void PropertyFileConfiguration::save(std::ostream& ostr) const
{
MapConfiguration::iterator it = begin();
MapConfiguration::iterator ed = end();
while (it != ed)
{
ostr << it->first << ": " << it->second << "n";
++it;
}
}
所以您只需要将": "
替换为"= "
。
相关文章:
- C++使用分隔符读取文件
- 到达分隔符时跳到文本文件的下一行
- 使用空格分隔符从文本文件将对象读入数组
- 使用任意分隔符从文件流读取
- 使用 C++ 读取具有两个连续分隔符的 csv 文件
- 通过自定义分隔符从文件中读取对象数组
- 使用不同类型的分隔符从.txt文件中读取输入
- 如何在没有分隔符的大文本文件中查找所有字典单词
- 将 OpenCV MAT 保存到 TXT 文件作为不带分隔符的十六进制值
- 如何在C++中正确解析带有多个分隔符的文本文件
- 从没有分隔符 C++ 的文件读取数字出现次数
- 生成文件,缺少分隔符错误
- 生成文件错误:缺少分隔符
- 检测 CSV 文件中的记录/行分隔符
- C++ 使用多个分隔符存储输入文件
- 用指定的分隔符按线解析文本文件
- 如何获取标准 C/C++ 中的文件分隔符符号:/ 或 \
- 在C++中搜索二进制文件分隔符时出现不正确的偏移量
- C++具有混合分隔符和数据类型的文件输入
- 我的生成文件中缺少分隔符