summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2023-05-18 15:00:38 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2023-07-13 12:17:36 +0200
commit6086d896183a529d4a0b83d4862970c8f320b0aa (patch)
treeaea76ff8c6f3d8a1eac48f88a3a495e43852e5cd /tools
parent52d265c0d2f2638c386475e58c3ee489ccd3f06c (diff)
linking: api: use JsonWriter
Change-Id: If5bf1897f1aef8db1672789cbee14b90cb96dc08 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151959 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154378 Tested-by: Jenkins
Diffstat (limited to 'tools')
-rw-r--r--tools/source/misc/json_writer.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/source/misc/json_writer.cxx b/tools/source/misc/json_writer.cxx
index 8303e4c2973e..6e8cd7eafe86 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -225,6 +225,26 @@ void JsonWriter::writeEscapedOUString(const OUString& rPropVal)
validate();
}
+void JsonWriter::put(std::u16string_view pPropName, const OUString& rPropVal)
+{
+ auto nPropNameLength = pPropName.length();
+ // But values can be any UTF-8,
+ // if the string only contains of 0x2028, it will be expanded 6 times (see writeEscapedSequence)
+ auto nWorstCasePropValLength = rPropVal.getLength() * 6;
+ ensureSpace(nPropNameLength + nWorstCasePropValLength + 8);
+
+ addCommaBeforeField();
+
+ writeEscapedOUString(OUString(pPropName));
+
+ memcpy(mPos, ": ", 2);
+ mPos += 2;
+
+ writeEscapedOUString(rPropVal);
+
+ validate();
+}
+
void JsonWriter::put(std::string_view pPropName, const OUString& rPropVal)
{
// Values can be any UTF-8,