replaced boost by manual xml writing, to improve serialization perfs

This commit is contained in:
emeric
2025-09-19 00:34:37 +02:00
parent 2b85de7939
commit c65b7b3e0b
8 changed files with 335 additions and 141 deletions
+21 -1
View File
@@ -44,10 +44,20 @@ namespace lms::core::stringUtils
constexpr std::pair<char, std::string_view> jsonEscapeChars[]{
{ '\\', "\\\\" },
{ '"', "\\\"" },
{ '\b', "\\b" },
{ '\f', "\\f" },
{ '\n', "\\n" },
{ '\r', "\\r" },
{ '\t', "\\t" },
{ '"', "\\\"" },
};
constexpr std::pair<char, std::string_view> xmlEscapeChars[]{
{ '&', "&amp;" },
{ '<', "&lt;" },
{ '>', "&gt;" },
{ '\'', "&apos;" },
{ '"', "&quot;" },
};
template<std::size_t N>
@@ -442,6 +452,16 @@ namespace lms::core::stringUtils
details::writeEscapedString(os, str, details::jsonEscapeChars);
}
std::string xmlEscape(std::string_view str)
{
return details::escape(str, details::xmlEscapeChars);
}
void writeXmlEscapedString(std::ostream& os, std::string_view str)
{
details::writeEscapedString(os, str, details::xmlEscapeChars);
}
std::string escapeString(std::string_view str, std::string_view charsToEscape, char escapeChar)
{
std::string res;