Add conversion from rtl::OStringNumber to std::string_view

...and revert the relevant part of 2f5f45921b
"support O(U)String::number() for fast string concatenation", as discussed in
the comments of that Gerrit change, now that
89bb0b0dcd "Deduplicate O(U)StringNumber
definitions; add toAsciiUpperCase" paved the way.

For consistency, also add conversion from rtl::OUStringNumber to
std::u16string_view, even if that remains unused as of now.

Change-Id: Ieb64bff0b59c22f3dec05c99fca5676b27a46e9a
Reviewed-on: https://gerrit.libreoffice.org/79750
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann
2019-09-27 23:41:23 +02:00
parent 94e22f5a2f
commit 9c9b1e95ae
2 changed files with 8 additions and 5 deletions
+5 -5
View File
@@ -155,19 +155,19 @@ void writeValueContent_(TempFile &handle, sal_Bool value) {
}
void writeValueContent_(TempFile &handle, sal_Int16 value) {
handle.writeString(OString(OString::number(value)));
handle.writeString(OString::number(value));
}
void writeValueContent_(TempFile &handle, sal_Int32 value) {
handle.writeString(OString(OString::number(value)));
handle.writeString(OString::number(value));
}
void writeValueContent_(TempFile &handle, sal_Int64 value) {
handle.writeString(OString(OString::number(value)));
handle.writeString(OString::number(value));
}
void writeValueContent_(TempFile &handle, double value) {
handle.writeString(OString(OString::number(value)));
handle.writeString(OString::number(value));
}
void writeValueContent_(TempFile &handle, const OUString& value) {
@@ -530,7 +530,7 @@ void writeValueContent(TempFile &handle, std::u16string_view value) {
{
handle.writeString(convertToUtf8(value.substr(i, j - i)));
handle.writeString("<unicode oor:scalar=\"");
handle.writeString(OString(OString::number(c)));
handle.writeString(OString::number(c));
handle.writeString("\"/>");
i = j + 1;
} else if (c == '\x0D') {
+3
View File
@@ -15,6 +15,7 @@
#include "rtl/ustring.h"
#include <cstddef>
#include <string_view>
#include <utility>
#include <string.h>
@@ -334,6 +335,7 @@ template <class Derived, int nBufSize> struct OStringNumberBase
rtl_str_toAsciiUpperCase_WithLength(buf, length);
return std::move(*static_cast<Derived*>(this));
}
operator std::string_view() const { return std::string_view(buf, length); }
char buf[nBufSize];
sal_Int32 length;
};
@@ -402,6 +404,7 @@ template <class Derived, int nBufSize> struct OUStringNumberBase
rtl_ustr_toAsciiUpperCase_WithLength(buf, length);
return std::move(*static_cast<Derived*>(this));
}
operator std::u16string_view() const { return std::u16string_view(buf, length); }
sal_Unicode buf[nBufSize];
sal_Int32 length;
};