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 /sal | |
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 'sal')
-rw-r--r-- | sal/cppunittester/cppunittester.cxx | 3 | ||||
-rw-r--r-- | sal/osl/unx/uunxapi.cxx | 10 | ||||
-rw-r--r-- | sal/osl/unx/uunxapi.hxx | 6 |
3 files changed, 14 insertions, 5 deletions
diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx index c6fd3b9a269e..7ab54da02106 100644 --- a/sal/cppunittester/cppunittester.cxx +++ b/sal/cppunittester/cppunittester.cxx @@ -61,6 +61,7 @@ #include <boost/algorithm/string.hpp> #include <algorithm> +#include <string_view> namespace { @@ -78,7 +79,7 @@ OUString getArgument(sal_Int32 index) { return arg; } -std::string convertLazy(OUString const & s16) { +std::string convertLazy(std::u16string_view s16) { OString s8(OUStringToOString(s16, osl_getThreadTextEncoding())); static_assert(sizeof (sal_Int32) <= sizeof (std::string::size_type), "must be at least the same size"); // ensure following cast is legitimate diff --git a/sal/osl/unx/uunxapi.cxx b/sal/osl/unx/uunxapi.cxx index e8901784c878..1f847cfd32a5 100644 --- a/sal/osl/unx/uunxapi.cxx +++ b/sal/osl/unx/uunxapi.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <string_view> + #include <config_features.h> #include "uunxapi.hxx" @@ -31,9 +35,9 @@ #include <osl/detail/android-bootstrap.h> #endif -OString osl::OUStringToOString(const OUString& s) +OString osl::OUStringToOString(std::u16string_view s) { - return OUStringToOString(s, osl_getThreadTextEncoding()); + return rtl::OUStringToOString(s, osl_getThreadTextEncoding()); } #if HAVE_FEATURE_MACOSX_SANDBOX @@ -198,7 +202,7 @@ namespace { OString toOString(OString const & s) { return s; } -OString toOString(OUString const & s) { return osl::OUStringToOString(s); } +OString toOString(std::u16string_view s) { return osl::OUStringToOString(s); } template<typename T> T fromOString(OString const &) = delete; diff --git a/sal/osl/unx/uunxapi.hxx b/sal/osl/unx/uunxapi.hxx index f182b755e53b..b5c0c9ed9d41 100644 --- a/sal/osl/unx/uunxapi.hxx +++ b/sal/osl/unx/uunxapi.hxx @@ -20,6 +20,10 @@ #ifndef INCLUDED_SAL_OSL_UNX_UUNXAPI_HXX #define INCLUDED_SAL_OSL_UNX_UUNXAPI_HXX +#include <sal/config.h> + +#include <string_view> + #include <unistd.h> #include <stdlib.h> #include <sys/types.h> @@ -42,7 +46,7 @@ int ftruncate_with_name(int fd, sal_uInt64 uSize, rtl_String* path); namespace osl { - OString OUStringToOString(const OUString& s); + OString OUStringToOString(std::u16string_view s); int access(const OString& strPath, int mode); |