diff options
Diffstat (limited to 'gentoobrowse-api/domain/converters.impl.h')
-rw-r--r-- | gentoobrowse-api/domain/converters.impl.h | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/gentoobrowse-api/domain/converters.impl.h b/gentoobrowse-api/domain/converters.impl.h index ebff336..1d79e56 100644 --- a/gentoobrowse-api/domain/converters.impl.h +++ b/gentoobrowse-api/domain/converters.impl.h @@ -18,15 +18,6 @@ namespace Slicer { std::vector<T> & list; }; - std::string - escapePqChar(char c) - { - if (c == '"') { - return std::string("\\\"", 2); - } - return std::string(1, c); - } - template<typename T> void packPqVar(std::ostream & s, const T & l) @@ -35,9 +26,14 @@ namespace Slicer { s << l; } else { - s << "\""; - std::transform(l.begin(), l.end(), std::ostream_iterator<std::string>(s), escapePqChar); - s << "\""; + s << '\"'; + std::transform(l.begin(), l.end(), std::ostream_iterator<std::string_view>(s), [](const char & c) { + if (c == '"') { + return std::string_view(R"(\")"); + } + return std::string_view(&c, 1); + }); + s << '\"'; } } |