summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-10-13 11:59:29 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-10-13 17:39:32 +0200
commit03c474c640d63f54d520712693e2f47976d8d531 (patch)
tree5cc255f9ee7a61d18fecb80743787378b6150b74 /include
parentc89f0cd9f6a4b3f77440dd7ea9da08f9cd327711 (diff)
Unify JsonWriter::put and putRaw a bit
In the process, it turned out that there was unnecessary conversion of OStringBuffer to OString and back to OStringBuffer when using putRaw, which is avoided now. Change-Id: I1e3ee685679df0b025bee8f4430624ee5bc9ccb3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123547 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'include')
-rw-r--r--include/tools/json_writer.hxx20
1 files changed, 11 insertions, 9 deletions
diff --git a/include/tools/json_writer.hxx b/include/tools/json_writer.hxx
index fb40e1920314..45df53c61c5f 100644
--- a/include/tools/json_writer.hxx
+++ b/include/tools/json_writer.hxx
@@ -8,13 +8,15 @@
*/
#pragma once
+#include <sal/config.h>
+
#include <tools/toolsdllapi.h>
+#include <rtl/string.hxx>
#include <rtl/ustring.hxx>
+#include <sal/types.h>
-namespace rtl
-{
-class OStringBuffer;
-}
+#include <string>
+#include <string_view>
/** Simple JSON encoder designed specifically for LibreOfficeKit purposes.
*
@@ -49,11 +51,11 @@ public:
[[nodiscard]] ScopedJsonWriterStruct startStruct();
void put(const char* pPropName, const OUString& rPropValue);
- void put(const char* pPropName, const OString& rPropValue);
- void put(const char* pPropName, const char* pPropVal);
- void put(const char* pPropName, const std::string& rPropValue)
+ // Assumes utf-8 property value encoding
+ void put(const char* pPropName, std::string_view rPropValue);
+ void put(const char* pPropName, const char* pPropVal)
{
- put(pPropName, rPropValue.data());
+ put(pPropName, std::string_view(pPropVal));
}
void put(const char* pPropName, sal_uInt16 nPropVal) { put(pPropName, sal_Int64(nPropVal)); }
@@ -67,7 +69,7 @@ public:
void putSimpleValue(const OUString& rPropValue);
/// This assumes that this data belongs at this point in the stream, and is valid, and properly encoded
- void putRaw(const rtl::OStringBuffer&);
+ void putRaw(std::string_view);
/** Hands ownership of the underlying storage buffer to the caller,
* after this no more document modifications may be written. */