diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-12-11 17:44:34 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-12-11 21:25:10 +0100 |
commit | 35e471bb4d1388cf5afcdcee214cf5111edf44e3 (patch) | |
tree | bb78f4f13f131f0cb206a9707cc3cfc495a3876a /sax | |
parent | 0c06e77c122f10a1842bc908bd6e25b1110ddbd2 (diff) |
Adapt the remaining OUString functions to std string_view
...for LIBO_INTERNAL_ONLY. These had been missed by
1b43cceaea2084a0489db68cd0113508f34b6643 "Make many OUString functions take
std::u16string_view parameters" because they did not match the multi-overload
pattern that was addressed there, but they nevertheless benefit from being
changed just as well (witness e.g. the various resulting changes from copy() to
subView()).
This showed a conversion from OStringChar to std::string_view to be missing
(while the corresponding conversion form OUStringChar to std::u16string_view was
already present).
The improvement to loplugin:stringadd became necessary to fix
> [CPT] compilerplugins/clang/test/stringadd.cxx
> error: 'error' diagnostics expected but not seen:
> File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 43 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:42): simplify by merging with the preceding assignment [loplugin:stringadd]
> File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 61 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:60): simplify by merging with the preceding assignment [loplugin:stringadd]
> 2 errors generated.
Change-Id: Ie40de0616a66e60e289c1af0ca60aed6f9ecc279
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107602
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sax')
-rw-r--r-- | sax/source/fastparser/fastparser.cxx | 5 | ||||
-rw-r--r-- | sax/source/tools/fastserializer.cxx | 2 | ||||
-rw-r--r-- | sax/source/tools/fastserializer.hxx | 3 | ||||
-rw-r--r-- | sax/source/tools/fshelper.cxx | 6 |
4 files changed, 9 insertions, 7 deletions
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx index 05288a4ef5f3..f0fe5aea2f67 100644 --- a/sax/source/fastparser/fastparser.cxx +++ b/sax/source/fastparser/fastparser.cxx @@ -41,6 +41,7 @@ #include <queue> #include <memory> #include <stack> +#include <string_view> #include <unordered_map> #include <vector> #include <cassert> @@ -228,7 +229,7 @@ public: void registerNamespace( const OUString& NamespaceURL, sal_Int32 NamespaceToken ); /// @throws css::lang::IllegalArgumentException /// @throws css::uno::RuntimeException - OUString const & getNamespaceURL( const OUString& rPrefix ); + OUString const & getNamespaceURL( std::u16string_view rPrefix ); /// @throws css::uno::RuntimeException void setErrorHandler( const css::uno::Reference< css::xml::sax::XErrorHandler >& Handler ); /// @throws css::uno::RuntimeException @@ -911,7 +912,7 @@ void FastSaxParserImpl::registerNamespace( const OUString& NamespaceURL, sal_Int throw IllegalArgumentException("namespace URL is already registered: " + NamespaceURL, css::uno::Reference<css::uno::XInterface >(), 0); } -OUString const & FastSaxParserImpl::getNamespaceURL( const OUString& rPrefix ) +OUString const & FastSaxParserImpl::getNamespaceURL( std::u16string_view rPrefix ) { try { diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx index 792784eb2a9c..e6538424891c 100644 --- a/sax/source/tools/fastserializer.cxx +++ b/sax/source/tools/fastserializer.cxx @@ -91,7 +91,7 @@ namespace sax_fastparser { mnDoubleStrCapacity = RTL_STR_MAX_VALUEOFDOUBLE; } - void FastSaxSerializer::write( const OUString& sOutput, bool bEscape ) + void FastSaxSerializer::write( std::u16string_view sOutput, bool bEscape ) { write( OUStringToOString(sOutput, RTL_TEXTENCODING_UTF8), bEscape ); diff --git a/sax/source/tools/fastserializer.hxx b/sax/source/tools/fastserializer.hxx index 0b7ad72d8c0c..109ada3c726f 100644 --- a/sax/source/tools/fastserializer.hxx +++ b/sax/source/tools/fastserializer.hxx @@ -28,6 +28,7 @@ #include "CachedOutputStream.hxx" #include <stack> +#include <string_view> #include <map> #include <memory> @@ -111,7 +112,7 @@ public: OString getId( ::sal_Int32 Element ); void write( double value ); - void write( const OUString& s, bool bEscape = false ); + void write( std::u16string_view s, bool bEscape = false ); void write( const OString& s, bool bEscape = false ); void write( const char* pStr, sal_Int32 nLen, bool bEscape = false ); diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx index 39b01f175176..b285ba9f3219 100644 --- a/sax/source/tools/fshelper.cxx +++ b/sax/source/tools/fshelper.cxx @@ -86,7 +86,7 @@ FastSerializerHelper* FastSerializerHelper::write(const OString& value) return this; } -FastSerializerHelper* FastSerializerHelper::write(const OUString& value) +FastSerializerHelper* FastSerializerHelper::write(std::u16string_view value) { mpSerializer->write(value); return this; @@ -116,9 +116,9 @@ FastSerializerHelper* FastSerializerHelper::writeEscaped(const char* value) return this; } -FastSerializerHelper* FastSerializerHelper::writeEscaped(const OUString& value) +FastSerializerHelper* FastSerializerHelper::writeEscaped(std::u16string_view value) { - if (!value.isEmpty()) + if (!value.empty()) mpSerializer->write(value, true); return this; } |