Kaydet (Commit) dac7be50 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

o3tl::string_view -> std::string_view (in configmgr)

Change-Id: I64131f59ce859a252baa9c84291d262bcb04fffd
Reviewed-on: https://gerrit.libreoffice.org/66012
Tested-by: Jenkins
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst b8f497a0
...@@ -22,13 +22,13 @@ ...@@ -22,13 +22,13 @@
#include <cassert> #include <cassert>
#include <cstddef> #include <cstddef>
#include <limits> #include <limits>
#include <string_view>
#include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/RuntimeException.hpp> #include <com/sun/star/uno/RuntimeException.hpp>
#include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/uno/XInterface.hpp> #include <com/sun/star/uno/XInterface.hpp>
#include <o3tl/string_view.hxx>
#include <osl/file.h> #include <osl/file.h>
#include <osl/file.hxx> #include <osl/file.hxx>
#include <rtl/string.h> #include <rtl/string.h>
...@@ -60,7 +60,7 @@ class Components; ...@@ -60,7 +60,7 @@ class Components;
namespace { namespace {
OString convertToUtf8(o3tl::u16string_view text) { OString convertToUtf8(std::u16string_view text) {
OString s; OString s;
assert(text.size() <= sal_uInt32(std::numeric_limits<sal_Int32>::max())); assert(text.size() <= sal_uInt32(std::numeric_limits<sal_Int32>::max()));
if (!rtl_convertUStringToString( if (!rtl_convertUStringToString(
...@@ -140,7 +140,7 @@ oslFileError TempFile::flush() { ...@@ -140,7 +140,7 @@ oslFileError TempFile::flush() {
return e; return e;
} }
void TempFile::writeString(o3tl::string_view text) { void TempFile::writeString(std::string_view text) {
buffer.append(text.data(), text.size()); buffer.append(text.data(), text.size());
if (buffer.getLength() > 0x10000) if (buffer.getLength() > 0x10000)
flush(); flush();
...@@ -186,8 +186,8 @@ void writeValueContent_( ...@@ -186,8 +186,8 @@ void writeValueContent_(
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',
'D', 'E', 'F' }; 'D', 'E', 'F' };
handle.writeString( handle.writeString(
o3tl::string_view(hexDigit + ((value[i] >> 4) & 0xF), 1)); std::string_view(hexDigit + ((value[i] >> 4) & 0xF), 1));
handle.writeString(o3tl::string_view(hexDigit + (value[i] & 0xF), 1)); handle.writeString(std::string_view(hexDigit + (value[i] & 0xF), 1));
} }
} }
...@@ -281,7 +281,7 @@ void writeValue(TempFile &handle, Type type, css::uno::Any const & value) { ...@@ -281,7 +281,7 @@ void writeValue(TempFile &handle, Type type, css::uno::Any const & value) {
void writeNode( void writeNode(
Components & components, TempFile &handle, Components & components, TempFile &handle,
rtl::Reference< Node > const & parent, o3tl::u16string_view name, rtl::Reference< Node > const & parent, std::u16string_view name,
rtl::Reference< Node > const & node) rtl::Reference< Node > const & node)
{ {
static xmlreader::Span const typeNames[] = { static xmlreader::Span const typeNames[] = {
...@@ -316,7 +316,7 @@ void writeNode( ...@@ -316,7 +316,7 @@ void writeNode(
if (type != TYPE_NIL) { if (type != TYPE_NIL) {
handle.writeString(" oor:type=\""); handle.writeString(" oor:type=\"");
handle.writeString( handle.writeString(
o3tl::string_view( std::string_view(
typeNames[type].begin, typeNames[type].length)); typeNames[type].begin, typeNames[type].length));
handle.writeString("\""); handle.writeString("\"");
} }
...@@ -359,7 +359,7 @@ void writeNode( ...@@ -359,7 +359,7 @@ void writeNode(
if (type != TYPE_NIL) { if (type != TYPE_NIL) {
handle.writeString(" oor:type=\""); handle.writeString(" oor:type=\"");
handle.writeString( handle.writeString(
o3tl::string_view( std::string_view(
typeNames[type].begin, typeNames[type].length)); typeNames[type].begin, typeNames[type].length));
handle.writeString("\""); handle.writeString("\"");
} }
...@@ -479,7 +479,7 @@ void writeModifications( ...@@ -479,7 +479,7 @@ void writeModifications(
} }
void writeAttributeValue(TempFile &handle, o3tl::u16string_view value) { void writeAttributeValue(TempFile &handle, std::u16string_view value) {
std::size_t i = 0; std::size_t i = 0;
std::size_t j = i; std::size_t j = i;
for (; j != value.size(); ++j) { for (; j != value.size(); ++j) {
...@@ -524,7 +524,7 @@ void writeAttributeValue(TempFile &handle, o3tl::u16string_view value) { ...@@ -524,7 +524,7 @@ void writeAttributeValue(TempFile &handle, o3tl::u16string_view value) {
handle.writeString(convertToUtf8(value.substr(i, j - i))); handle.writeString(convertToUtf8(value.substr(i, j - i)));
} }
void writeValueContent(TempFile &handle, o3tl::u16string_view value) { void writeValueContent(TempFile &handle, std::u16string_view value) {
std::size_t i = 0; std::size_t i = 0;
std::size_t j = i; std::size_t j = i;
for (; j != value.size(); ++j) { for (; j != value.size(); ++j) {
......
...@@ -22,7 +22,8 @@ ...@@ -22,7 +22,8 @@
#include <sal/config.h> #include <sal/config.h>
#include <o3tl/string_view.hxx> #include <string_view>
#include <rtl/strbuf.hxx> #include <rtl/strbuf.hxx>
namespace configmgr { namespace configmgr {
...@@ -43,15 +44,15 @@ struct TempFile { ...@@ -43,15 +44,15 @@ struct TempFile {
#ifdef _WIN32 #ifdef _WIN32
oslFileError closeWithoutUnlink(); oslFileError closeWithoutUnlink();
#endif #endif
void writeString(o3tl::string_view text); void writeString(std::string_view text);
private: private:
TempFile(const TempFile&) = delete; TempFile(const TempFile&) = delete;
TempFile& operator=(const TempFile&) = delete; TempFile& operator=(const TempFile&) = delete;
}; };
void writeAttributeValue(TempFile &handle, o3tl::u16string_view value); void writeAttributeValue(TempFile &handle, std::u16string_view value);
void writeValueContent(TempFile &handle, o3tl::u16string_view value); void writeValueContent(TempFile &handle, std::u16string_view value);
void writeModFile( void writeModFile(
Components & components, OUString const & url, Data const & data); Components & components, OUString const & url, Data const & data);
......
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
#include <ostream> #include <ostream>
#include <string.h> #include <string.h>
#if defined LIBO_INTERNAL_ONLY
#include <string_view>
#endif
#include "rtl/textenc.h" #include "rtl/textenc.h"
#include "rtl/string.h" #include "rtl/string.h"
#include "rtl/stringutils.hxx" #include "rtl/stringutils.hxx"
...@@ -1787,6 +1791,9 @@ public: ...@@ -1787,6 +1791,9 @@ public:
return number(d); return number(d);
} }
#if defined LIBO_INTERNAL_ONLY
operator std::string_view() const { return {getStr(), sal_uInt32(getLength())}; }
#endif
}; };
/* ======================================================================= */ /* ======================================================================= */
......
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
#include <new> #include <new>
#include <ostream> #include <ostream>
#if defined LIBO_INTERNAL_ONLY
#include <string_view>
#endif
#include "rtl/ustring.h" #include "rtl/ustring.h"
#include "rtl/string.hxx" #include "rtl/string.hxx"
#include "rtl/stringutils.hxx" #include "rtl/stringutils.hxx"
...@@ -3544,6 +3548,10 @@ public: ...@@ -3544,6 +3548,10 @@ public:
return OUString( pNew, SAL_NO_ACQUIRE ); return OUString( pNew, SAL_NO_ACQUIRE );
} }
#if defined LIBO_INTERNAL_ONLY
operator std::u16string_view() const { return {getStr(), sal_uInt32(getLength())}; }
#endif
private: private:
OUString & internalAppend( rtl_uString* pOtherData ) OUString & internalAppend( rtl_uString* pOtherData )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment