是否有一些escaped_list_separator反向功能

Is there some escaped_list_separator reverse function?

本文关键字:separator 功能 list 是否 escaped      更新时间:2023-10-16

我知道可以使用 boost escaped_list_separator 来拆分字符串并同时删除转义。

有没有类似的(优雅)方法来达到相反的结果?喜欢在添加转义的同时将多个字符串合并为一个?

我知道

你想要一个单行,但找不到任何满足你需求的东西。

使用 string escape(const string &s) 函数,您可以编写自己的单行代码:

#include <algorithm>
string escape(const string &s)
{
    // Do your thing.
    return result;
}
string joinEscaped(const vector<string> &v, const string &delimiter)
{
    std::vector<string> temp(v.size());
    std::transform(v.begin(), v.end(), temp.begin(), escape);
    return boost::algorithm::join(temp, delimiter);
}