diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2023-05-18 15:00:38 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2023-05-23 09:07:48 +0200 |
commit | 9a8c2106aede982007e15bdb1d0f2764a5610dde (patch) | |
tree | 8b534eddce7281b5e6c237605c149304e165f638 /tools | |
parent | 805c4cddd82d08e803fb921728f3f0b6a1b30ee9 (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>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/misc/json_writer.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/source/misc/json_writer.cxx b/tools/source/misc/json_writer.cxx index aea89a15d421..5bc718608d6a 100644 --- a/tools/source/misc/json_writer.cxx +++ b/tools/source/misc/json_writer.cxx @@ -231,6 +231,32 @@ void JsonWriter::writeEscapedOUString(const OUString& rPropVal) validate(); } +void JsonWriter::put(const OUString& pPropName, const OUString& rPropVal) +{ + auto nPropNameLength = pPropName.getLength(); + // 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(); + + *mPos = '"'; + ++mPos; + + writeEscapedOUString(pPropName); + + memcpy(mPos, "\": \"", 4); + mPos += 4; + + writeEscapedOUString(rPropVal); + + *mPos = '"'; + ++mPos; + + validate(); +} + void JsonWriter::put(const char* pPropName, const OUString& rPropVal) { auto nPropNameLength = strlen(pPropName); |