compilerplugins/clang/stringconcatliterals.cxx | 3 config_host/config_global.h.in | 1 desktop/scripts/soffice.sh | 4 include/o3tl/string_view.hxx | 867 ++++++++++++++++++++ include/sal/log.hxx | 41 o3tl/CppunitTest_o3tl_tests.mk | 2 o3tl/qa/test-string_view.cxx | 212 ++++ officecfg/registry/schema/org/openoffice/Inet.xcs | 6 postprocess/Rdb_services.mk | 3 sal/osl/all/log.cxx | 42 solenv/clang-format/blacklist | 2 solenv/gdb/boost/util/printing.py | 2 solenv/gdb/libreoffice/util/printing.py | 2 ucb/CppunitTest_ucb_webdav_core.mk | 1 ucb/Library_ucpdav1.mk | 25 ucb/Module_ucb.mk | 2 ucb/source/ucp/webdav-curl/CurlSession.cxx | 31 ucb/source/ucp/webdav-curl/DAVProperties.cxx | 36 ucb/source/ucp/webdav-curl/DAVProperties.hxx | 26 ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx | 2 ucb/source/ucp/webdav-curl/UCBDeadPropertyValue.cxx | 18 ucb/source/ucp/webdav-curl/webdavcontent.cxx | 49 - ucb/source/ucp/webdav-curl/webdavcontentcaps.cxx | 3 ucb/source/ucp/webdav-curl/webdavprovider.cxx | 2 ucb/source/ucp/webdav-curl/webdavresponseparser.cxx | 2 ucb/source/ucp/webdav-neon/ucpdav1.component | 5 ucb/source/ucp/webdav-neon/webdavprovider.cxx | 42 ucb/source/ucp/webdav-neon/webdavprovider.hxx | 7 ucb/source/ucp/webdav-neon/webdavservices.cxx | 67 - ucb/source/ucp/webdav/webdavprovider.cxx | 10 30 files changed, 1312 insertions(+), 203 deletions(-)
New commits: commit 66a15ffedf2e41b25d06a61542434da2948dd4d8 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu Mar 10 16:47:16 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Mar 10 18:09:57 2022 +0100 ucb: add webdav configuration setting Change-Id: Ifc98baec69e32d231e44b389a870e90debd5a389 diff --git a/officecfg/registry/schema/org/openoffice/Inet.xcs b/officecfg/registry/schema/org/openoffice/Inet.xcs index 76d5d2ed0912..95d38403d19d 100644 --- a/officecfg/registry/schema/org/openoffice/Inet.xcs +++ b/officecfg/registry/schema/org/openoffice/Inet.xcs @@ -26,6 +26,12 @@ <info> <desc>Contains Internet-related configurations (servers, proxies, etc.).</desc> </info> + <prop oor:name="WebDAVCurl" oor:type="xs:boolean" oor:nillable="false"> + <info> + <desc>Use curl HTTP/WebDAV UCP instead of neon one.</desc> + </info> + <value>false</value> + </prop> <prop oor:name="ooInetNoProxy" oor:type="xs:string" oor:nillable="false"> <!-- OldPath: Inet/NoProxy --> <!-- OldLocation: soffice.ini --> diff --git a/ucb/CppunitTest_ucb_webdav_core.mk b/ucb/CppunitTest_ucb_webdav_core.mk index fbd3f59f55f6..aeea8033fa95 100644 --- a/ucb/CppunitTest_ucb_webdav_core.mk +++ b/ucb/CppunitTest_ucb_webdav_core.mk @@ -31,6 +31,7 @@ $(eval $(call gb_CppunitTest_use_library_objects,ucb_webdav_core, \ $(eval $(call gb_CppunitTest_use_externals,ucb_webdav_core,\ boost_headers \ libxml2 \ + neon \ curl \ )) diff --git a/ucb/Module_ucb.mk b/ucb/Module_ucb.mk index 19c1aec96591..cea03c49ec4a 100644 --- a/ucb/Module_ucb.mk +++ b/ucb/Module_ucb.mk @@ -31,7 +31,7 @@ $(eval $(call gb_Module_add_targets,ucb,\ )) endif -ifeq ($(WITH_WEBDAV),curl) +ifeq ($(WITH_WEBDAV),neon) $(eval $(call gb_Module_add_check_targets,ucb,\ CppunitTest_ucb_webdav_core \ diff --git a/ucb/source/ucp/webdav-neon/webdavprovider.cxx b/ucb/source/ucp/webdav-neon/webdavprovider.cxx index 40534e80a614..bbe18ecbac61 100644 --- a/ucb/source/ucp/webdav-neon/webdavprovider.cxx +++ b/ucb/source/ucp/webdav-neon/webdavprovider.cxx @@ -180,11 +180,21 @@ ContentProvider::queryContent( return xContent; } +#include <officecfg/Inet.hxx> + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +ucb_webdav_ContentProvider_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&); + extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* ucb_webdav_neon_ContentProvider_get_implementation( css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) { - return cppu::acquire(new ContentProvider(context)); + auto const useCurl(officecfg::Inet::Settings::WebDAVCurl::get(context)); + if (useCurl) + return ucb_webdav_ContentProvider_get_implementation(context, {}); + else + return cppu::acquire(new ContentProvider(context)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 0611bf69cde2a22094d9ac190f972777537d8225 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Thu Sep 24 09:53:24 2020 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Mar 10 17:51:42 2022 +0100 Fix Python deprecation warnings I noticed these "DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working" now when running tests with CPPUNITTRACE='gdb --args' on Fedora 32. Change-Id: If263dacb9df5c1fffd2be2418e13e69b96070c77 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103294 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> (cherry picked from commit 4a899a5f8a72ea29a6919316afe3627de9f33e95) diff --git a/solenv/gdb/boost/util/printing.py b/solenv/gdb/boost/util/printing.py index 1d5d0bac9fc6..4088f3a3fa3b 100644 --- a/solenv/gdb/boost/util/printing.py +++ b/solenv/gdb/boost/util/printing.py @@ -19,7 +19,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. -from collections import Mapping +from collections.abc import Mapping import gdb import re import six diff --git a/solenv/gdb/libreoffice/util/printing.py b/solenv/gdb/libreoffice/util/printing.py index 9cbae3080a64..7ce29899355a 100644 --- a/solenv/gdb/libreoffice/util/printing.py +++ b/solenv/gdb/libreoffice/util/printing.py @@ -7,7 +7,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # -from collections import Mapping +from collections.abc import Mapping import gdb import re import six commit e7c228f40f4b5c2ca810298ce22330f383c2ed92 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Thu Nov 19 13:35:28 2020 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Mar 10 17:51:42 2022 +0100 desktop: rr --ignore-nested was renamed to --nested=ignore Change-Id: Id1c1789c24b8eec27db0b24e1e43e2eb7d562509 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106291 Reviewed-by: Michael Stahl <michael.st...@cib.de> Tested-by: Jenkins (cherry picked from commit 1ab938155c875e65470b9f6b3b3ef65885462f7a) diff --git a/desktop/scripts/soffice.sh b/desktop/scripts/soffice.sh index 415ea047361d..021c706f5c78 100755 --- a/desktop/scripts/soffice.sh +++ b/desktop/scripts/soffice.sh @@ -78,8 +78,8 @@ for arg in "$@" $EXTRAOPT ; do case "$arg" in --record) if which rr >/dev/null 2>&1 ; then - # smoketest may already be recorded => use ignore-nested - RRCHECK="rr record --ignore-nested" + # smoketest may already be recorded => ignore nested + RRCHECK="rr record --nested=ignore" checks="c$checks" else echo "Error: Can't find the tool \"rr\", --record option will be ignored." commit e8cbf72ca0526301734dd0394da96bd0ea6a4224 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu Mar 10 13:07:48 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Mar 10 16:37:10 2022 +0100 ucb: webdav-curl: add sources to Library_ucpdav1.mk Change-Id: I040e18ae4ddca11d1ed7303fce5d343d36c1c3b0 diff --git a/ucb/Library_ucpdav1.mk b/ucb/Library_ucpdav1.mk index b9e1d1037897..01efc08fdc85 100644 --- a/ucb/Library_ucpdav1.mk +++ b/ucb/Library_ucpdav1.mk @@ -31,6 +31,30 @@ $(eval $(call gb_Library_use_libraries,ucpdav1,\ ifeq ($(WITH_WEBDAV),neon) +$(eval $(call gb_Library_use_externals,ucpdav1,\ + curl \ +)) + +$(eval $(call gb_Library_add_exception_objects,ucpdav1,\ + ucb/source/ucp/webdav-curl/ContentProperties \ + ucb/source/ucp/webdav-curl/CurlSession \ + ucb/source/ucp/webdav-curl/CurlUri \ + ucb/source/ucp/webdav-curl/DAVProperties \ + ucb/source/ucp/webdav-curl/DAVResourceAccess \ + ucb/source/ucp/webdav-curl/DAVSessionFactory \ + ucb/source/ucp/webdav-curl/DAVTypes \ + ucb/source/ucp/webdav-curl/DateTimeHelper \ + ucb/source/ucp/webdav-curl/PropfindCache \ + ucb/source/ucp/webdav-curl/SerfLockStore \ + ucb/source/ucp/webdav-curl/UCBDeadPropertyValue \ + ucb/source/ucp/webdav-curl/webdavcontent \ + ucb/source/ucp/webdav-curl/webdavcontentcaps \ + ucb/source/ucp/webdav-curl/webdavdatasupplier \ + ucb/source/ucp/webdav-curl/webdavprovider \ + ucb/source/ucp/webdav-curl/webdavresponseparser \ + ucb/source/ucp/webdav-curl/webdavresultset \ +)) + $(eval $(call gb_Library_use_externals,ucpdav1,\ boost_headers \ libxml2 \ commit f9cb06401d997fe419d0388764f63b5276b773ae Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Wed Jul 22 14:04:09 2020 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Mar 10 16:00:12 2022 +0100 ucb/neon: create instances with uno constructors See tdf#74608 for motivation. Change-Id: Ia86a4cc06819ce5820ab44d293790f7bd9a03711 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99224 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> (cherry picked from commit f3f0d05f72d8dbd9717910b4d6b42c54be3e106f) diff --git a/ucb/Library_ucpdav1.mk b/ucb/Library_ucpdav1.mk index c76489bd4847..b9e1d1037897 100644 --- a/ucb/Library_ucpdav1.mk +++ b/ucb/Library_ucpdav1.mk @@ -65,7 +65,6 @@ $(eval $(call gb_Library_add_exception_objects,ucpdav1,\ ucb/source/ucp/webdav-neon/webdavdatasupplier \ ucb/source/ucp/webdav-neon/webdavprovider \ ucb/source/ucp/webdav-neon/webdavresultset \ - ucb/source/ucp/webdav-neon/webdavservices \ )) else # WITH_WEBDAV == serf diff --git a/ucb/source/ucp/webdav-neon/ucpdav1.component b/ucb/source/ucp/webdav-neon/ucpdav1.component index 5bebe253554e..23be195bf453 100644 --- a/ucb/source/ucp/webdav-neon/ucpdav1.component +++ b/ucb/source/ucp/webdav-neon/ucpdav1.component @@ -27,8 +27,9 @@ **********************************************************************--> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="ucpdav1" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.WebDAVContentProvider"> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.WebDAVContentProvider" + constructor="ucb_webdav_neon_ContentProvider_get_implementation"> <service name="com.sun.star.ucb.WebDAVContentProvider"/> </implementation> </component> diff --git a/ucb/source/ucp/webdav-neon/webdavprovider.cxx b/ucb/source/ucp/webdav-neon/webdavprovider.cxx index c022e0f8f531..40534e80a614 100644 --- a/ucb/source/ucp/webdav-neon/webdavprovider.cxx +++ b/ucb/source/ucp/webdav-neon/webdavprovider.cxx @@ -96,38 +96,24 @@ XTYPEPROVIDER_IMPL_3( ContentProvider, // XServiceInfo methods. -XSERVICEINFO_COMMOM_IMPL( ContentProvider, - "com.sun.star.comp.WebDAVContentProvider" ) -/// @throws css::uno::Exception -static css::uno::Reference< css::uno::XInterface > -ContentProvider_CreateInstance( const css::uno::Reference< css::lang::XMultiServiceFactory> & rSMgr ) +OUString +ContentProvider::getImplementationName() { - css::lang::XServiceInfo* pX = new ContentProvider( ucbhelper::getComponentContext(rSMgr) ); - return css::uno::Reference< css::uno::XInterface >::query( pX ); + return "com.sun.star.comp.WebDAVContentProvider"; } css::uno::Sequence< OUString > -ContentProvider::getSupportedServiceNames_Static() +ContentProvider::getSupportedServiceNames() { - css::uno::Sequence< OUString > aSNS { WEBDAV_CONTENT_PROVIDER_SERVICE_NAME }; - return aSNS; + return { WEBDAV_CONTENT_PROVIDER_SERVICE_NAME }; } -// Service factory implementation. - - -css::uno::Reference< css::lang::XSingleServiceFactory > -ContentProvider::createServiceFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& rxServiceMgr ) +sal_Bool +ContentProvider::supportsService(const OUString& s) { - return cppu::createOneInstanceFactory( - rxServiceMgr, - ContentProvider::getImplementationName_Static(), - ContentProvider_CreateInstance, - ContentProvider::getSupportedServiceNames_Static() ); + return cppu::supportsService(this, s); } - - // XContentProvider methods. @@ -194,4 +180,11 @@ ContentProvider::queryContent( return xContent; } +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +ucb_webdav_neon_ContentProvider_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new ContentProvider(context)); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/source/ucp/webdav-neon/webdavprovider.hxx b/ucb/source/ucp/webdav-neon/webdavprovider.hxx index 80556ab23447..2e30d3f0a35d 100644 --- a/ucb/source/ucp/webdav-neon/webdavprovider.hxx +++ b/ucb/source/ucp/webdav-neon/webdavprovider.hxx @@ -90,13 +90,6 @@ public: virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - static OUString getImplementationName_Static(); - static css::uno::Sequence< OUString > getSupportedServiceNames_Static(); - - static css::uno::Reference< css::lang::XSingleServiceFactory > - createServiceFactory( const css::uno::Reference< - css::lang::XMultiServiceFactory >& rxServiceMgr ); - // XContentProvider virtual css::uno::Reference< css::ucb::XContent > SAL_CALL queryContent( const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier ) override; diff --git a/ucb/source/ucp/webdav-neon/webdavservices.cxx b/ucb/source/ucp/webdav-neon/webdavservices.cxx deleted file mode 100644 index f5a3116a9475..000000000000 --- a/ucb/source/ucp/webdav-neon/webdavservices.cxx +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include "webdavprovider.hxx" - -using namespace com::sun::star; - - -extern "C" SAL_DLLPUBLIC_EXPORT void * ucpdav1_component_getFactory( - const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ ) -{ - void * pRet = nullptr; - - uno::Reference< lang::XMultiServiceFactory > xSMgr( - static_cast< lang::XMultiServiceFactory * >( - pServiceManager ) ); - uno::Reference< lang::XSingleServiceFactory > xFactory; - - - // WebDAV Content Provider. - - - if ( ::webdav_ucp::ContentProvider::getImplementationName_Static(). - equalsAscii( pImplName ) ) - { - xFactory = ::webdav_ucp::ContentProvider::createServiceFactory( xSMgr ); - } - - - if ( xFactory.is() ) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - - return pRet; -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 8bb6d4d1737fe5600474cda5a0cf7b1f806752f5 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Jul 13 15:13:59 2020 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Mar 10 16:00:12 2022 +0100 expand out an UNO macro to make the ongoing convert-to-UNO-constructor work easier Change-Id: I99596561832b10538505cf4dfdabaf11d6e4d7cb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98664 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> (cherry picked from commit 15f44cb6fbf2459dca522e4f5b7f525fd1d6c5e7) diff --git a/ucb/source/ucp/webdav-neon/webdavprovider.cxx b/ucb/source/ucp/webdav-neon/webdavprovider.cxx index 2b0bd5bfe92b..c022e0f8f531 100644 --- a/ucb/source/ucp/webdav-neon/webdavprovider.cxx +++ b/ucb/source/ucp/webdav-neon/webdavprovider.cxx @@ -116,7 +116,16 @@ ContentProvider::getSupportedServiceNames_Static() // Service factory implementation. -ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider ); +css::uno::Reference< css::lang::XSingleServiceFactory > +ContentProvider::createServiceFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& rxServiceMgr ) +{ + return cppu::createOneInstanceFactory( + rxServiceMgr, + ContentProvider::getImplementationName_Static(), + ContentProvider_CreateInstance, + ContentProvider::getSupportedServiceNames_Static() ); +} + // XContentProvider methods. diff --git a/ucb/source/ucp/webdav/webdavprovider.cxx b/ucb/source/ucp/webdav/webdavprovider.cxx index 9a78c0648ebe..2fe0151c6cf8 100644 --- a/ucb/source/ucp/webdav/webdavprovider.cxx +++ b/ucb/source/ucp/webdav/webdavprovider.cxx @@ -103,8 +103,16 @@ ContentProvider::getSupportedServiceNames_Static() // Service factory implementation. +css::uno::Reference< css::lang::XSingleServiceFactory > +ContentProvider::createServiceFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& rxServiceMgr ) +{ + return cppu::createOneInstanceFactory( + rxServiceMgr, + ContentProvider::getImplementationName_Static(), + ContentProvider_CreateInstance, + ContentProvider::getSupportedServiceNames_Static() ); +} -ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider ); // XContentProvider methods. commit abb85b390bab2073fd03ac3732232e35b9519401 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu Mar 10 15:01:54 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Mar 10 16:00:11 2022 +0100 ucb: webdav-curl: demodernize code so it builds Change-Id: Ic12c38be4426d7cb3c4134585df34a7107e8f4ce diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx b/ucb/source/ucp/webdav-curl/CurlSession.cxx index 70f9f828467d..bddefa1ad117 100644 --- a/ucb/source/ucp/webdav-curl/CurlSession.cxx +++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx @@ -106,12 +106,12 @@ auto GetErrorString(CURLcode const rc, char const* const pErrorBuffer = nullptr) { char const* const pMessage( // static fallback (pErrorBuffer && pErrorBuffer[0] != '\0') ? pErrorBuffer : curl_easy_strerror(rc)); - return OString::Concat("(") + OString::number(sal_Int32(rc)) + ") " + pMessage; + return "(" + OString::number(sal_Int32(rc)) + ") " + pMessage; } auto GetErrorStringMulti(CURLMcode const mc) -> OString { - return OString::Concat("(") + OString::number(sal_Int32(mc)) + ") " + curl_multi_strerror(mc); + return "(" + OString::number(sal_Int32(mc)) + ") " + curl_multi_strerror(mc); } /// represent an option to be passed to curl_easy_setopt() @@ -300,9 +300,8 @@ static int debug_callback(CURL* handle, curl_infotype type, char* data, size_t s sal_Int32 const end(tmp.indexOf("\r\n", start)); assert(end != -1); sal_Int32 const len(SAL_N_ELEMENTS("Authorization: ") - 1); - tmp = tmp.replaceAt( - start + len, end - start - len, - OStringConcatenation(OString::number(end - start - len) + " bytes redacted")); + tmp = tmp.replaceAt(start + len, end - start - len, + OString::number(end - start - len) + " bytes redacted"); } SAL_INFO("ucb.ucp.webdav.curl", "CURLINFO_HEADER_OUT: " << handle << ": " << tmp); return 0; @@ -430,7 +429,7 @@ static size_t header_callback(char* const buffer, size_t const size, size_t cons return 0; // error } pHeaders->HeaderFields.back().first.back() - += OString::Concat(" ") + ::std::string_view(&buffer[i], nitems - i); + += OString(" ") + OString(&buffer[i], nitems - i); } else { @@ -492,8 +491,8 @@ static auto ProcessHeaders(::std::vector<OString> const& rHeaders) -> ::std::map --nEnd; } // RFC 7230 says that only ASCII works reliably anyway (neon also did this) - auto const value(::rtl::OStringToOUString(line.subView(nStart, nEnd - nStart), - RTL_TEXTENCODING_ASCII_US)); + auto const value( + ::rtl::OStringToOUString(line.copy(nStart, nEnd - nStart), RTL_TEXTENCODING_ASCII_US)); auto const it(ret.find(name)); if (it != ret.end()) { @@ -620,8 +619,8 @@ CurlSession::CurlSession(uno::Reference<uno::XComponentContext> const& xContext, // en.wikipedia.org:80 forces back 403 "Scripts should use an informative // User-Agent string with contact information, or they may be IP-blocked // without notice" otherwise: - OString const useragent(OString::Concat("LibreOffice " LIBO_VERSION_DOTTED " curl/") - + ::std::string_view(pVersion->version, strlen(pVersion->version)) + " " + OString const useragent(OString("LibreOffice " LIBO_VERSION_DOTTED " curl/") + + OString(pVersion->version, strlen(pVersion->version)) + " " + pVersion->ssl_version); // looks like an explicit "User-Agent" header in CURLOPT_HTTPHEADER // will override CURLOPT_USERAGENT, see Curl_http_useragent(), so no need @@ -1561,7 +1560,7 @@ auto CurlProcessor::PropFind( xWriter->startDocument(); rtl::Reference<::comphelper::AttributeList> const pAttrList(new ::comphelper::AttributeList); pAttrList->AddAttribute("xmlns", "CDATA", "DAV:"); - xWriter->startElement("propfind", pAttrList); + xWriter->startElement("propfind", pAttrList.get()); if (o_pResourceInfos) { xWriter->startElement("propname", nullptr); @@ -1583,7 +1582,7 @@ auto CurlProcessor::PropFind( DAVProperties::createSerfPropName(rName, name); pAttrList->Clear(); pAttrList->AddAttribute("xmlns", "CDATA", OUString::createFromAscii(name.nspace)); - xWriter->startElement(OUString::createFromAscii(name.name), pAttrList); + xWriter->startElement(OUString::createFromAscii(name.name), pAttrList.get()); xWriter->endElement(OUString::createFromAscii(name.name)); } xWriter->endElement("prop"); @@ -1701,7 +1700,7 @@ auto CurlSession::PROPPATCH(OUString const& rURIReference, xWriter->startDocument(); rtl::Reference<::comphelper::AttributeList> const pAttrList(new ::comphelper::AttributeList); pAttrList->AddAttribute("xmlns", "CDATA", "DAV:"); - xWriter->startElement("propertyupdate", pAttrList); + xWriter->startElement("propertyupdate", pAttrList.get()); for (ProppatchValue const& rPropValue : rValues) { assert(rPropValue.operation == PROPSET || rPropValue.operation == PROPREMOVE); @@ -1713,7 +1712,7 @@ auto CurlSession::PROPPATCH(OUString const& rURIReference, DAVProperties::createSerfPropName(rPropValue.name, name); pAttrList->Clear(); pAttrList->AddAttribute("xmlns", "CDATA", OUString::createFromAscii(name.nspace)); - xWriter->startElement(OUString::createFromAscii(name.name), pAttrList); + xWriter->startElement(OUString::createFromAscii(name.name), pAttrList.get()); if (rPropValue.operation == PROPSET) { if (DAVProperties::isUCBDeadProperty(name)) @@ -2024,7 +2023,7 @@ auto CurlProcessor::MoveOrCopy(CurlSession& rSession, OUString const& rSourceURI { throw uno::RuntimeException("curl_slist_append failed"); } - OString const utf8Overwrite(OString::Concat("Overwrite: ") + (isOverwrite ? "T" : "F")); + OString const utf8Overwrite(OString("Overwrite: ") + (isOverwrite ? "T" : "F")); pList.reset(curl_slist_append(pList.release(), utf8Overwrite.getStr())); if (!pList) { @@ -2164,7 +2163,7 @@ auto CurlSession::LOCK(OUString const& rURIReference, ucb::Lock /*const*/& rLock xWriter->startDocument(); rtl::Reference<::comphelper::AttributeList> const pAttrList(new ::comphelper::AttributeList); pAttrList->AddAttribute("xmlns", "CDATA", "DAV:"); - xWriter->startElement("lockinfo", pAttrList); + xWriter->startElement("lockinfo", pAttrList.get()); xWriter->startElement("lockscope", nullptr); switch (rLock.Scope) { diff --git a/ucb/source/ucp/webdav-curl/DAVProperties.cxx b/ucb/source/ucp/webdav-curl/DAVProperties.cxx index 746c82ad993d..b362d512c52a 100644 --- a/ucb/source/ucp/webdav-curl/DAVProperties.cxx +++ b/ucb/source/ucp/webdav-curl/DAVProperties.cxx @@ -26,38 +26,38 @@ using namespace http_dav_ucp; // static -void DAVProperties::createSerfPropName( ::std::u16string_view const rFullName, +void DAVProperties::createSerfPropName( OUString const& rFullName, SerfPropName & rName ) { - if (o3tl::starts_with(rFullName, u"DAV:")) + if (rFullName.startsWith("DAV:")) { rName.nspace = "DAV:"; rName.name = strdup( OUStringToOString( - rFullName.substr(RTL_CONSTASCII_LENGTH("DAV:")), + rFullName.copy(RTL_CONSTASCII_LENGTH("DAV:")), RTL_TEXTENCODING_UTF8 ).getStr() ); } - else if (o3tl::starts_with(rFullName, u"http://apache.org/dav/props/")) + else if (rFullName.startsWith("http://apache.org/dav/props/")) { rName.nspace = "http://apache.org/dav/props/"; rName.name = strdup( OUStringToOString( - rFullName.substr( + rFullName.copy( RTL_CONSTASCII_LENGTH( "http://apache.org/dav/props/" ) ), RTL_TEXTENCODING_UTF8 ).getStr() ); } - else if (o3tl::starts_with(rFullName, u"http://ucb.openoffice.org/dav/props/")) + else if (rFullName.startsWith("http://ucb.openoffice.org/dav/props/")) { rName.nspace = "http://ucb.openoffice.org/dav/props/"; rName.name = strdup( OUStringToOString( - rFullName.substr( + rFullName.copy( RTL_CONSTASCII_LENGTH( "http://ucb.openoffice.org/dav/props/" ) ), RTL_TEXTENCODING_UTF8 ).getStr() ); } - else if (o3tl::starts_with(rFullName, u"<prop:")) + else if (rFullName.startsWith("<prop:")) { // Support for 3rd party namespaces/props @@ -101,16 +101,16 @@ void DAVProperties::createUCBPropName( const char * nspace, // in this case, if name is a well-known dav property name. // Although this is not 100% correct, it solves many problems. - if (o3tl::equalsIgnoreAsciiCase(aName, std::u16string_view(DAVProperties::RESOURCETYPE).substr(4)) || - o3tl::equalsIgnoreAsciiCase(aName, std::u16string_view(DAVProperties::SUPPORTEDLOCK).substr(4)) || - o3tl::equalsIgnoreAsciiCase(aName, std::u16string_view(DAVProperties::LOCKDISCOVERY).substr(4)) || - o3tl::equalsIgnoreAsciiCase(aName, std::u16string_view(DAVProperties::CREATIONDATE).substr(4)) || - o3tl::equalsIgnoreAsciiCase(aName, std::u16string_view(DAVProperties::DISPLAYNAME).substr(4)) || - o3tl::equalsIgnoreAsciiCase(aName, std::u16string_view(DAVProperties::GETCONTENTLANGUAGE).substr(4)) || - o3tl::equalsIgnoreAsciiCase(aName, std::u16string_view(DAVProperties::GETCONTENTLENGTH).substr(4)) || - o3tl::equalsIgnoreAsciiCase(aName, std::u16string_view(DAVProperties::GETCONTENTTYPE).substr(4)) || - o3tl::equalsIgnoreAsciiCase(aName, std::u16string_view(DAVProperties::GETETAG).substr(4)) || - o3tl::equalsIgnoreAsciiCase(aName, std::u16string_view(DAVProperties::GETLASTMODIFIED).substr(4))) + if (aName.equalsIgnoreAsciiCase(OUString(DAVProperties::RESOURCETYPE).copy(4)) || + aName.equalsIgnoreAsciiCase(OUString(DAVProperties::SUPPORTEDLOCK).copy(4)) || + aName.equalsIgnoreAsciiCase(OUString(DAVProperties::LOCKDISCOVERY).copy(4)) || + aName.equalsIgnoreAsciiCase(OUString(DAVProperties::CREATIONDATE).copy(4)) || + aName.equalsIgnoreAsciiCase(OUString(DAVProperties::DISPLAYNAME).copy(4)) || + aName.equalsIgnoreAsciiCase(OUString(DAVProperties::GETCONTENTLANGUAGE).copy(4)) || + aName.equalsIgnoreAsciiCase(OUString(DAVProperties::GETCONTENTLENGTH).copy(4)) || + aName.equalsIgnoreAsciiCase(OUString(DAVProperties::GETCONTENTTYPE).copy(4)) || + aName.equalsIgnoreAsciiCase(OUString(DAVProperties::GETETAG).copy(4)) || + aName.equalsIgnoreAsciiCase(OUString(DAVProperties::GETLASTMODIFIED).copy(4))) { aNameSpace = "DAV:"; } diff --git a/ucb/source/ucp/webdav-curl/DAVProperties.hxx b/ucb/source/ucp/webdav-curl/DAVProperties.hxx index af005300c79d..ee64fcff70be 100644 --- a/ucb/source/ucp/webdav-curl/DAVProperties.hxx +++ b/ucb/source/ucp/webdav-curl/DAVProperties.hxx @@ -29,19 +29,19 @@ typedef struct { const char *nspace, *name; } SerfPropName; struct DAVProperties { - static constexpr OUStringLiteral CREATIONDATE = u"DAV:creationdate"; - static constexpr OUStringLiteral DISPLAYNAME = u"DAV:displayname"; - static constexpr OUStringLiteral GETCONTENTLANGUAGE = u"DAV:getcontentlanguage"; - static constexpr OUStringLiteral GETCONTENTLENGTH = u"DAV:getcontentlength"; - static constexpr OUStringLiteral GETCONTENTTYPE = u"DAV:getcontenttype"; - static constexpr OUStringLiteral GETETAG = u"DAV:getetag"; - static constexpr OUStringLiteral GETLASTMODIFIED = u"DAV:getlastmodified"; - static constexpr OUStringLiteral LOCKDISCOVERY = u"DAV:lockdiscovery"; - static constexpr OUStringLiteral RESOURCETYPE = u"DAV:resourcetype"; - static constexpr OUStringLiteral SUPPORTEDLOCK = u"DAV:supportedlock"; - static constexpr OUStringLiteral EXECUTABLE = u"http://apache.org/dav/props/executable"; - - static void createSerfPropName( ::std::u16string_view rFullName, + static constexpr OUStringLiteral CREATIONDATE = "DAV:creationdate"; + static constexpr OUStringLiteral DISPLAYNAME = "DAV:displayname"; + static constexpr OUStringLiteral GETCONTENTLANGUAGE = "DAV:getcontentlanguage"; + static constexpr OUStringLiteral GETCONTENTLENGTH = "DAV:getcontentlength"; + static constexpr OUStringLiteral GETCONTENTTYPE = "DAV:getcontenttype"; + static constexpr OUStringLiteral GETETAG = "DAV:getetag"; + static constexpr OUStringLiteral GETLASTMODIFIED = "DAV:getlastmodified"; + static constexpr OUStringLiteral LOCKDISCOVERY = "DAV:lockdiscovery"; + static constexpr OUStringLiteral RESOURCETYPE = "DAV:resourcetype"; + static constexpr OUStringLiteral SUPPORTEDLOCK = "DAV:supportedlock"; + static constexpr OUStringLiteral EXECUTABLE = "http://apache.org/dav/props/executable"; + + static void createSerfPropName( OUString const& rFullName, SerfPropName & rName ); static void createUCBPropName ( const char * nspace, const char * name, diff --git a/ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx b/ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx index 248d65b8c60c..988970b9a0df 100644 --- a/ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx +++ b/ucb/source/ucp/webdav-curl/DAVResourceAccess.cxx @@ -69,7 +69,7 @@ int DAVAuthListener_Impl::authenticate( m_aURL, inHostName, inRealm, inoutUserName, outPassWord, bCanUseSystemCredentials ); - xIH->handle( xRequest ); + xIH->handle( xRequest.get() ); rtl::Reference< ucbhelper::InteractionContinuation > xSelection = xRequest->getSelection(); diff --git a/ucb/source/ucp/webdav-curl/UCBDeadPropertyValue.cxx b/ucb/source/ucp/webdav-curl/UCBDeadPropertyValue.cxx index 4f3460a26785..9e7176a218b8 100644 --- a/ucb/source/ucp/webdav-curl/UCBDeadPropertyValue.cxx +++ b/ucb/source/ucp/webdav-curl/UCBDeadPropertyValue.cxx @@ -26,15 +26,15 @@ using namespace ::com::sun::star; // static -constexpr OUStringLiteral aTypeString = u"string"; -constexpr OUStringLiteral aTypeLong = u"long"; -constexpr OUStringLiteral aTypeShort = u"short"; -constexpr OUStringLiteral aTypeBoolean = u"boolean"; -constexpr OUStringLiteral aTypeChar = u"char"; -constexpr OUStringLiteral aTypeByte = u"byte"; -constexpr OUStringLiteral aTypeHyper = u"hyper"; -constexpr OUStringLiteral aTypeFloat = u"float"; -constexpr OUStringLiteral aTypeDouble = u"double"; +constexpr OUStringLiteral aTypeString = "string"; +constexpr OUStringLiteral aTypeLong = "long"; +constexpr OUStringLiteral aTypeShort = "short"; +constexpr OUStringLiteral aTypeBoolean = "boolean"; +constexpr OUStringLiteral aTypeChar = "char"; +constexpr OUStringLiteral aTypeByte = "byte"; +constexpr OUStringLiteral aTypeHyper = "hyper"; +constexpr OUStringLiteral aTypeFloat = "float"; +constexpr OUStringLiteral aTypeDouble = "double"; // static bool UCBDeadPropertyValue::supportsType( const uno::Type & rType ) diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx b/ucb/source/ucp/webdav-curl/webdavcontent.cxx index 1eb069a3480e..46eac2f6f03c 100644 --- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx +++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx @@ -1257,7 +1257,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues( xRow->appendPropertySet( xSet ); } - return uno::Reference<sdbc::XRow>(xRow); + return uno::Reference<sdbc::XRow>(xRow.get()); } namespace { @@ -1729,7 +1729,6 @@ uno::Sequence< uno::Any > Content::setPropertyValues( } uno::Sequence< uno::Any > aRet( rValues.getLength() ); - auto aRetRange = asNonConstRange(aRet); uno::Sequence< beans::PropertyChangeEvent > aChanges( rValues.getLength() ); sal_Int32 nChanged = 0; @@ -1767,7 +1766,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( if ( aTmpProp.Attributes & beans::PropertyAttribute::READONLY ) { // Read-only property! - aRetRange[ n ] <<= lang::IllegalAccessException( + aRet[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); continue; @@ -1780,21 +1779,21 @@ uno::Sequence< uno::Any > Content::setPropertyValues( if ( rName == "ContentType" ) { // Read-only property! - aRetRange[ n ] <<= lang::IllegalAccessException( + aRet[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else if ( rName == "IsDocument" ) { // Read-only property! - aRetRange[ n ] <<= lang::IllegalAccessException( + aRet[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else if ( rName == "IsFolder" ) { // Read-only property! - aRetRange[ n ] <<= lang::IllegalAccessException( + aRet[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1827,7 +1826,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( } catch ( DAVException const & ) { - aRetRange[ n ] <<= lang::IllegalArgumentException( + aRet[ n ] <<= lang::IllegalArgumentException( "Invalid content identifier!", static_cast< cppu::OWeakObject * >( this ), -1 ); @@ -1835,7 +1834,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( } else { - aRetRange[ n ] <<= lang::IllegalArgumentException( + aRet[ n ] <<= lang::IllegalArgumentException( "Empty title not allowed!", static_cast< cppu::OWeakObject * >( this ), -1 ); @@ -1843,7 +1842,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( } else { - aRetRange[ n ] <<= beans::IllegalTypeException( + aRet[ n ] <<= beans::IllegalTypeException( "Property value has wrong type!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1866,7 +1865,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( // Check, whether property exists. Skip otherwise. // PROPPATCH::set would add the property automatically, which // is not allowed for "setPropertyValues" command! - aRetRange[ n ] <<= beans::UnknownPropertyException( + aRet[ n ] <<= beans::UnknownPropertyException( "Property is unknown!", static_cast< cppu::OWeakObject * >( this ) ); continue; @@ -1875,21 +1874,21 @@ uno::Sequence< uno::Any > Content::setPropertyValues( if ( rName == "Size" ) { // Read-only property! - aRetRange[ n ] <<= lang::IllegalAccessException( + aRet[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else if ( rName == "DateCreated" ) { // Read-only property! - aRetRange[ n ] <<= lang::IllegalAccessException( + aRet[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } else if ( rName == "DateModified" ) { // Read-only property! - aRetRange[ n ] <<= lang::IllegalAccessException( + aRet[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1897,14 +1896,14 @@ uno::Sequence< uno::Any > Content::setPropertyValues( { // Read-only property! // (but could be writable, if 'getcontenttype' would be) - aRetRange[ n ] <<= lang::IllegalAccessException( + aRet[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } if ( rName == "CreatableContentsInfo" ) { // Read-only property! - aRetRange[ n ] <<= lang::IllegalAccessException( + aRet[ n ] <<= lang::IllegalAccessException( "Property is read-only!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -1952,24 +1951,24 @@ uno::Sequence< uno::Any > Content::setPropertyValues( } catch ( beans::UnknownPropertyException const & e ) { - aRetRange[ n ] <<= e; + aRet[ n ] <<= e; } catch ( lang::WrappedTargetException const & e ) { - aRetRange[ n ] <<= e; + aRet[ n ] <<= e; } catch ( beans::PropertyVetoException const & e ) { - aRetRange[ n ] <<= e; + aRet[ n ] <<= e; } catch ( lang::IllegalArgumentException const & e ) { - aRetRange[ n ] <<= e; + aRet[ n ] <<= e; } } else { - aRetRange[ n ] <<= uno::Exception( + aRet[ n ] <<= uno::Exception( "No property set for storing the value!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -2018,7 +2017,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( while ( it != end ) { // Set error. - aRetRange[ (*it) ] <<= MapDAVException( e, true ); + aRet[ (*it) ] <<= MapDAVException( e, true ); ++it; } #endif @@ -2080,7 +2079,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( aNewTitle.clear(); // Set error . - aRetRange[ nTitlePos ] <<= uno::Exception( + aRet[ nTitlePos ] <<= uno::Exception( "Exchange failed!", static_cast< cppu::OWeakObject * >( this ) ); } @@ -2091,7 +2090,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( aNewTitle.clear(); // Set error . - aRetRange[ nTitlePos ] = MapDAVException( e, true ); + aRet[ nTitlePos ] = MapDAVException( e, true ); } } @@ -2514,7 +2513,7 @@ void Content::insert( aExAsAny, ContinuationFlags::Approve | ContinuationFlags::Disapprove ); - xIH->handle( xRequest ); + xIH->handle( xRequest.get() ); const ContinuationFlags nResp = xRequest->getResponse(); @@ -2721,7 +2720,7 @@ void Content::transfer( xContext.set( m_xContext ); xIdentifier.set( m_xIdentifier ); - xProvider.set( m_xProvider ); + xProvider.set( m_xProvider.get() ); xResAccess.reset( new DAVResourceAccess( *m_xResAccess ) ); } diff --git a/ucb/source/ucp/webdav-curl/webdavcontentcaps.cxx b/ucb/source/ucp/webdav-curl/webdavcontentcaps.cxx index a7e2bb96893b..836edd7c75e8 100644 --- a/ucb/source/ucp/webdav-curl/webdavcontentcaps.cxx +++ b/ucb/source/ucp/webdav-curl/webdavcontentcaps.cxx @@ -479,7 +479,6 @@ uno::Sequence< beans::Property > Content::getProperties( // std::set -> uno::Sequence sal_Int32 nCount = aPropSet.size(); uno::Sequence< beans::Property > aProperties( nCount ); - auto aPropertiesRange = asNonConstRange(aProperties); beans::Property aProp; sal_Int32 n = 0; @@ -487,7 +486,7 @@ uno::Sequence< beans::Property > Content::getProperties( for ( const auto& rProp : aPropSet ) { xProvider->getProperty( rProp, aProp ); - aPropertiesRange[ n++ ] = aProp; + aProperties[ n++ ] = aProp; } return aProperties; diff --git a/ucb/source/ucp/webdav-curl/webdavprovider.cxx b/ucb/source/ucp/webdav-curl/webdavprovider.cxx index effd6665ad1d..972306cb3bf5 100644 --- a/ucb/source/ucp/webdav-curl/webdavprovider.cxx +++ b/ucb/source/ucp/webdav-curl/webdavprovider.cxx @@ -141,7 +141,7 @@ ContentProvider::queryContent( osl::MutexGuard aGuard( m_aMutex ); // Check, if a content with given id already exists... - uno::Reference<ucb::XContent> xContent = queryExistingContent(xCanonicId); + uno::Reference<ucb::XContent> xContent = queryExistingContent(xCanonicId).get(); if ( xContent.is() ) return xContent; diff --git a/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx b/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx index a236957c096e..33074b94040e 100644 --- a/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx +++ b/ucb/source/ucp/webdav-curl/webdavresponseparser.cxx @@ -928,7 +928,7 @@ namespace // create parser; connect parser and filter rtl::Reference<WebDAVResponseParser> const pWebDAVResponseParser( new WebDAVResponseParser(eWebDAVResponseParserMode)); - uno::Reference< xml::sax::XDocumentHandler > xWebDAVHdl(pWebDAVResponseParser); + uno::Reference< xml::sax::XDocumentHandler > xWebDAVHdl(pWebDAVResponseParser.get()); xParser->setDocumentHandler(xWebDAVHdl); // finally, parse the stream commit 4361caa98656ae95e27c89e03957089e4b4b4da3 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu Mar 10 15:58:10 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Mar 10 16:00:11 2022 +0100 Revert "TODO: does it need own component file?" This reverts commit 06e4c6fd51f60f1f7d474ede321fe031cde0b3ca. diff --git a/postprocess/Rdb_services.mk b/postprocess/Rdb_services.mk index 35955d90ac3e..f8c5047de79f 100644 --- a/postprocess/Rdb_services.mk +++ b/postprocess/Rdb_services.mk @@ -168,9 +168,6 @@ $(eval $(call gb_Rdb_add_components,services,\ $(if $(WITH_WEBDAV), \ ucb/source/ucp/webdav-neon/ucpdav1 \ ) \ - $(if $(filter curl,$(WITH_WEBDAV)), \ - ucb/source/ucp/webdav-curl/ucpdav1 \ - ) \ $(call gb_Helper_optional,SCRIPTING, \ basctl/util/basctl \ basic/util/sb \ commit 5e3d3f4b276916ddeb7b680c9513dc6d618fc3be Author: Jan-Marek Glogowski <glo...@fbihome.de> AuthorDate: Wed Jul 1 18:06:28 2020 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Mar 10 13:50:34 2022 +0100 Allow making SAL_LOG based output fatal This introduces the [+-]FATAL marker for SAL_LOG. This way you can set part of the matching SAL_LOG string to std::abort on match. The example "SAL_LOG=+FATAL+WARN.vcl.scheduler-FATAL+INFO" will abort for any "+WARN.vcl.scheduler" match, but will just print all additional "+INFO" logs. Change-Id: Ib77f194a78f5165e6c885c82374ae41293815ee9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97651 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> (cherry picked from commit b9d93fc47b2489764e251a11572fccef872df4e9) diff --git a/compilerplugins/clang/stringconcatliterals.cxx b/compilerplugins/clang/stringconcatliterals.cxx index 0f26f4f553bc..0b52bd0c9b4f 100644 --- a/compilerplugins/clang/stringconcatliterals.cxx +++ b/compilerplugins/clang/stringconcatliterals.cxx @@ -109,7 +109,8 @@ bool StringConcatLiterals::VisitCallExpr(CallExpr const * expr) { compiler.getSourceManager().getSpellingLoc( compiler.getSourceManager().getImmediateMacroCallerLoc( compiler.getSourceManager().getImmediateMacroCallerLoc( - compat::getBeginLoc(expr))))), + compiler.getSourceManager().getImmediateMacroCallerLoc( + compat::getBeginLoc(expr)))))), SRCDIR "/include/tools/diagnose_ex.h")) return true; diff --git a/include/sal/log.hxx b/include/sal/log.hxx index f85c7d882134..d4de09c201b4 100644 --- a/include/sal/log.hxx +++ b/include/sal/log.hxx @@ -26,11 +26,20 @@ /// @cond INTERNAL +enum sal_detail_LogAction +{ + SAL_DETAIL_LOG_ACTION_IGNORE, + SAL_DETAIL_LOG_ACTION_LOG, + SAL_DETAIL_LOG_ACTION_FATAL +}; + extern "C" SAL_DLLPUBLIC void SAL_CALL sal_detail_log( sal_detail_LogLevel level, char const * area, char const * where, char const * message, sal_uInt32 backtraceDepth); -extern "C" SAL_DLLPUBLIC sal_Bool SAL_CALL sal_detail_log_report( +// the return value is actually "enum sal_detail_LogAction", but due to ABI +// compatibility, it's left as the original "sal_Bool" / "unsigned char". +extern "C" SAL_DLLPUBLIC unsigned char SAL_CALL sal_detail_log_report( sal_detail_LogLevel level, char const * area); namespace sal { namespace detail { @@ -113,9 +122,9 @@ inline char const * unwrapStream(SAL_UNUSED_PARAMETER StreamIgnore const &) { } } -#define SAL_DETAIL_LOG_STREAM(condition, level, area, where, stream) \ - do { \ - if ((condition) && sal_detail_log_report(level, area)) { \ +// to prevent using a local variable, which can eventually shadow, +// resulting in compiler warnings (or even errors with -Werror) +#define SAL_DETAIL_LOG_STREAM_PRIVATE_(level, area, where, stream) \ if (sizeof ::sal::detail::getResult( \ ::sal::detail::StreamStart() << stream) == 1) \ { \ @@ -129,6 +138,22 @@ inline char const * unwrapStream(SAL_UNUSED_PARAMETER StreamIgnore const &) { sal_detail_stream << stream; \ ::sal::detail::log( \ (level), (area), (where), sal_detail_stream, 0); \ + } + +#define SAL_DETAIL_LOG_STREAM(condition, level, area, where, stream) \ + do { \ + if (condition) \ + { \ + switch (sal_detail_log_report(level, area)) \ + { \ + case SAL_DETAIL_LOG_ACTION_IGNORE: break; \ + case SAL_DETAIL_LOG_ACTION_LOG: \ + SAL_DETAIL_LOG_STREAM_PRIVATE_(level, area, where, stream); \ + break; \ + case SAL_DETAIL_LOG_ACTION_FATAL: \ + SAL_DETAIL_LOG_STREAM_PRIVATE_(level, area, where, stream); \ + std::abort(); \ + break; \ } \ } \ } while (false) @@ -238,7 +263,7 @@ inline char const * unwrapStream(SAL_UNUSED_PARAMETER StreamIgnore const &) { <switch> ::= <sense><item> <sense> ::= "+"|"-" <item> ::= <flag>|<level>("."<area>)? - <flag> ::= "TIMESTAMP"|"RELATIVETIMER" + <flag> ::= "TIMESTAMP"|"RELATIVETIMER"|"FATAL" <level> ::= "INFO"|"WARN" @endverbatim @@ -255,6 +280,12 @@ inline char const * unwrapStream(SAL_UNUSED_PARAMETER StreamIgnore const &) { the level switch(es)) to be prefixed by a relative timestamp in seconds since the first output line like 1.312. + The "+FATAL" flag will cause later matching rules to log and call + std::abort. This can be disabled at some later point by using the + "-FATAL" flag before specifying additional rules. The flag will just + abort on positive rules, as it doesn't seem to make sense to abort + on ignored output. + If both +TIMESTAMP and +RELATIVETIMER are specified, they are output in that order. diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx index 5a6ffdff9110..39ea42d7e130 100644 --- a/sal/osl/all/log.cxx +++ b/sal/osl/all/log.cxx @@ -344,7 +344,12 @@ void sal_detail_logFormat( sal_detail_LogLevel level, char const * area, char const * where, char const * format, ...) { - if (sal_detail_log_report(level, area)) { + const sal_detail_LogAction eAction + = static_cast<sal_detail_LogAction>(sal_detail_log_report(level, area)); + if (eAction == SAL_DETAIL_LOG_ACTION_IGNORE) + return; + + { std::va_list args; va_start(args, format); char buf[1024]; @@ -358,11 +363,15 @@ void sal_detail_logFormat( sal_detail_log(level, area, where, buf, 0); va_end(args); } + + if (eAction == SAL_DETAIL_LOG_ACTION_FATAL) + std::abort(); } -sal_Bool sal_detail_log_report(sal_detail_LogLevel level, char const * area) { +unsigned char sal_detail_log_report(sal_detail_LogLevel level, char const * area) +{ if (level == SAL_DETAIL_LOG_LEVEL_DEBUG) { - return true; + return SAL_DETAIL_LOG_ACTION_LOG; } assert(area != nullptr); static char const* const env = [] { @@ -378,17 +387,26 @@ sal_Bool sal_detail_log_report(sal_detail_LogLevel level, char const * area) { // no matching switches at all, the result will be negative (and // initializing with 1 is safe as the length of a valid switch, even // without the "+"/"-" prefix, will always be > 1) + bool senseFatal[2] = { false, false }; bool seenWarn = false; + bool bFlagFatal = false; for (char const * p = env;;) { Sense sense; switch (*p++) { case '\0': + { if (level == SAL_DETAIL_LOG_LEVEL_WARN && !seenWarn) return sal_detail_log_report(SAL_DETAIL_LOG_LEVEL_INFO, area); - return senseLen[POSITIVE] >= senseLen[NEGATIVE]; - // if a specific item is both positive and negative - // (senseLen[POSITIVE] == senseLen[NEGATIVE]), default to - // positive + + sal_detail_LogAction eAction = SAL_DETAIL_LOG_ACTION_IGNORE; + // if a specific item is positive and negative (==), default to positive + if (senseLen[POSITIVE] >= senseLen[NEGATIVE]) + { + if (senseFatal[POSITIVE]) eAction = SAL_DETAIL_LOG_ACTION_FATAL; + else eAction = SAL_DETAIL_LOG_ACTION_LOG; + } + return eAction; + } case '+': sense = POSITIVE; break; @@ -396,7 +414,7 @@ sal_Bool sal_detail_log_report(sal_detail_LogLevel level, char const * area) { sense = NEGATIVE; break; default: - return true; // upon an illegal SAL_LOG value, enable everything + return SAL_DETAIL_LOG_ACTION_LOG; // upon an illegal SAL_LOG value, enable everything } char const * p1 = p; while (*p1 != '.' && *p1 != '+' && *p1 != '-' && *p1 != '\0') { @@ -409,13 +427,17 @@ sal_Bool sal_detail_log_report(sal_detail_LogLevel level, char const * area) { { match = level == SAL_DETAIL_LOG_LEVEL_WARN; seenWarn = true; + } else if (equalStrings(p, p1 - p, RTL_CONSTASCII_STRINGPARAM("FATAL"))) + { + bFlagFatal = (sense == POSITIVE); + match = false; } else if (equalStrings(p, p1 - p, RTL_CONSTASCII_STRINGPARAM("TIMESTAMP")) || equalStrings(p, p1 - p, RTL_CONSTASCII_STRINGPARAM("RELATIVETIMER"))) { // handled later match = false; } else { - return true; + return SAL_DETAIL_LOG_ACTION_LOG; // upon an illegal SAL_LOG value, everything is considered // positive } @@ -432,9 +454,11 @@ sal_Bool sal_detail_log_report(sal_detail_LogLevel level, char const * area) { && equalStrings(p1, n, area, n))) { senseLen[sense] = p2 - p; + senseFatal[sense] = bFlagFatal; } } else { senseLen[sense] = p1 - p; + senseFatal[sense] = bFlagFatal; } } p = p2; commit f1843592b03b111daeb446e410b606e170dfa67e Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Fri Apr 7 15:59:12 2017 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Mar 10 13:50:34 2022 +0100 Introduce o3tl::string_view.hxx approximation of C++17 <string_view> ...and use it in configmgr/source/writemodfile.hxx Change-Id: Ie683dc21010ed45cc454ff89bea0376994b351f2 Reviewed-on: https://gerrit.libreoffice.org/36270 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Stephan Bergmann <sberg...@redhat.com> (cherry picked from commit 50057a37a877213d935958d5c643fde1434d680c) diff --git a/config_host/config_global.h.in b/config_host/config_global.h.in index 5b04594c12f5..4a4998e77aa5 100644 --- a/config_host/config_global.h.in +++ b/config_host/config_global.h.in @@ -12,6 +12,7 @@ Any change in this header will cause a rebuild of almost everything. #ifndef CONFIG_GLOBAL_H #define CONFIG_GLOBAL_H +#define HAVE_CXX14_CONSTEXPR 0 #define HAVE_GCC_BUILTIN_ATOMIC 0 #define HAVE_GCC_BUILTIN_FFS 0 /* _Pragma */ diff --git a/include/o3tl/string_view.hxx b/include/o3tl/string_view.hxx new file mode 100644 index 000000000000..9230909b7edf --- /dev/null +++ b/include/o3tl/string_view.hxx @@ -0,0 +1,867 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_O3TL_STRING_VIEW_HXX +#define INCLUDED_O3TL_STRING_VIEW_HXX + +#include <sal/config.h> + +#include <algorithm> +#include <cstddef> +#include <ios> +#include <iterator> +#include <ostream> +#include <stdexcept> +#include <string> +#include <type_traits> +#include <utility> + +#include <config_global.h> +#include <rtl/string.hxx> +#include <rtl/ustring.hxx> +#include <sal/types.h> + +// An approximation of C++17 <string_view>, including implicit conversion +// from rtl::OString and rtl::OUString. + +namespace o3tl { + +namespace detail { + +template<typename T> struct CharPtrDetector { + static constexpr bool ok = false; +}; + +template<> struct CharPtrDetector<char *> { + static constexpr bool ok = true; +}; + +template<> struct CharPtrDetector<char const *> { + static constexpr bool ok = true; +}; + +template<typename T> struct NonConstCharArrayDetector { + static constexpr bool ok = false; +}; + +template<std::size_t N> struct NonConstCharArrayDetector<char [N]> { + static constexpr bool ok = true; +}; + +template<typename T> struct ConstCharArrayDetector { + static constexpr bool ok = false; +}; + +template<std::size_t N> struct ConstCharArrayDetector<char const[N]> { + static constexpr bool ok = true; + static constexpr std::size_t length = N - 1; +}; + +template<typename T> struct Char16PtrDetector { + static constexpr bool ok = false; +}; + +template<> struct Char16PtrDetector<char16_t *> { + static constexpr bool ok = true; +}; + +template<> struct Char16PtrDetector<char16_t const *> { + static constexpr bool ok = true; +}; + +template<typename T> struct NonConstChar16ArrayDetector { + static constexpr bool ok = false; +}; + +template<std::size_t N> struct NonConstChar16ArrayDetector<char16_t [N]> { + static constexpr bool ok = true; +}; + +template<typename T> struct ConstChar16ArrayDetector { + static constexpr bool ok = false; +}; + +template<std::size_t N> struct ConstChar16ArrayDetector<char16_t const[N]> { + static constexpr bool ok = true; + static constexpr std::size_t length = N - 1; +}; + +template<typename T> struct Char32PtrDetector { + static constexpr bool ok = false; +}; + +template<> struct Char32PtrDetector<char32_t *> { + static constexpr bool ok = true; +}; + +template<> struct Char32PtrDetector<char32_t const *> { + static constexpr bool ok = true; +}; + +template<typename T> struct NonConstChar32ArrayDetector { + static constexpr bool ok = false; +}; + +template<std::size_t N> struct NonConstChar32ArrayDetector<char32_t [N]> { + static constexpr bool ok = true; +}; + +template<typename T> struct ConstChar32ArrayDetector { + static constexpr bool ok = false; +}; + +template<std::size_t N> struct ConstChar32ArrayDetector<char32_t const[N]> { + static constexpr bool ok = true; + static constexpr std::size_t length = N - 1; +}; + +template<typename T> struct WcharPtrDetector { + static constexpr bool ok = false; +}; + +template<> struct WcharPtrDetector<wchar_t *> { + static constexpr bool ok = true; +}; + +template<> struct WcharPtrDetector<wchar_t const *> { + static constexpr bool ok = true; +}; + +template<typename T> struct NonConstWcharArrayDetector { + static constexpr bool ok = false; +}; + +template<std::size_t N> struct NonConstWcharArrayDetector<wchar_t [N]> { + static constexpr bool ok = true; +}; + +template<typename T> struct ConstWcharArrayDetector { + static constexpr bool ok = false; +}; + +template<std::size_t N> struct ConstWcharArrayDetector<wchar_t const[N]> { + static constexpr bool ok = true; + static constexpr std::size_t length = N - 1; +}; + +} + +#if defined _MSC_VER +#pragma warning(push, 1) +#pragma warning(disable: 4814) // in C++14 'constexpr' will not imply 'const' +#endif + +template<typename charT, typename traits = std::char_traits<charT>> +class basic_string_view { +public: + using traits_type = traits; + using value_type = charT; + using pointer = value_type *; + using const_pointer = value_type const *; + using reference = value_type &; + using const_reference = value_type const &; + using const_iterator = const_pointer; + using iterator = const_iterator; + using const_reverse_iterator = std::reverse_iterator<const_iterator>; + using reverse_iterator = const_reverse_iterator; + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; + + static constexpr size_type npos = size_type(-1); + + constexpr basic_string_view() noexcept: data_(nullptr), size_(0) {} + + constexpr basic_string_view(basic_string_view const &) noexcept = default; + +#if HAVE_CXX14_CONSTEXPR + constexpr +#endif + basic_string_view & operator =(basic_string_view const & other) noexcept +#if defined _MSC_VER && _MSC_VER <= 1900 && !defined __clang__ + { + data_ = other.data_; + size_ = other.size_; + return *this; + } +#else + = default; +#endif + + // The various character types are handled below in the "LO specifics, to + // make up for traits::length not necessarily being constexpr yet for + // literal arguments" section: + template<typename T = charT> constexpr basic_string_view( + charT const * str, + typename std::enable_if< + !(std::is_same<T, char>::value || std::is_same<T, char16_t>::value + || std::is_same<T, char32_t>::value + || std::is_same<T, wchar_t>::value), + rtl::libreoffice_internal::Dummy>::type = {}): + data_(str), size_(traits::length(str)) {} + + constexpr basic_string_view(charT const * str, size_type len): + data_(str), size_(len) {} + + constexpr const_iterator begin() const noexcept { return data_; } + + constexpr const_iterator end() const noexcept { return begin() + size(); } + + constexpr const_iterator cbegin() const noexcept { return begin(); } + + constexpr const_iterator cend() const noexcept { return end(); } + + constexpr const_reverse_iterator rbegin() const noexcept + { return const_reverse_iterator(end()); } + + constexpr const_reverse_iterator rend() const noexcept + { return const_reverse_iterator(begin()); } + + constexpr const_reverse_iterator crbegin() const noexcept + { return rbegin(); } + + constexpr const_reverse_iterator crend() const noexcept { return rend(); } + + constexpr size_type size() const noexcept { return size_; } + + constexpr size_type length() const noexcept { return size(); } + +#if !defined __clang__ || HAVE_CXX14_CONSTEXPR + constexpr +#endif + size_type max_size() const noexcept { +#if defined __clang__ // avoid constexpr issues with other, older compilers + (void) this; // loplugin:staticmethods +#endif + return npos - 1; + } + + constexpr bool empty() const noexcept { return size_ == 0; } + + constexpr const_reference operator [](size_type pos) const { +#if HAVE_CXX14_CONSTEXPR + assert(pos < size()); +#endif + return data_[pos]; + } + +#if HAVE_CXX14_CONSTEXPR + constexpr +#endif + const_reference at(size_type pos) const { + if (pos >= size()) { + throw std::out_of_range("o3tl::basic_string_view::at"); + } + return operator [](pos); + } + + constexpr const_reference front() const { +#if HAVE_CXX14_CONSTEXPR + assert(!empty()); +#endif + return operator [](0); + } + + constexpr const_reference back() const { +#if HAVE_CXX14_CONSTEXPR + assert(!empty()); +#endif + return operator [](size() - 1); + } + + constexpr const_pointer data() const noexcept { return data_; } + +#if HAVE_CXX14_CONSTEXPR + constexpr +#endif + void remove_prefix(size_type n) { + assert(n <= size()); + data_ += n; + size_ -= n; + } + +#if HAVE_CXX14_CONSTEXPR + constexpr +#endif + void remove_suffix(size_type n) { + assert(n <= size()); + size_ -= n; + } + +#if HAVE_CXX14_CONSTEXPR + constexpr +#endif + void swap(basic_string_view & s) noexcept { + std::swap(data_, s.data_); + std::swap(size_, s.size_); + } + + size_type copy(charT * s, size_type n, size_type pos = 0) const { + if (pos > size()) { + throw std::out_of_range("o3tl::basic_string_view::copy"); + } + auto rlen = std::min(n, size_type(size() - pos)); + traits::copy(s, data() + pos, rlen); + return rlen; + } + +#if HAVE_CXX14_CONSTEXPR + constexpr +#endif + basic_string_view substr(size_type pos = 0, size_type n = npos) const { + if (pos > size()) { + throw std::out_of_range("o3tl::basic_string_view::copy"); + } + return basic_string_view( + data() + pos, std::min(n, size_type(size() - pos))); + } + +#if HAVE_CXX14_CONSTEXPR + constexpr +#endif + int compare(basic_string_view s) const noexcept { + auto n = traits::compare(data(), s.data(), std::min(size(), s.size())); + return n == 0 + ? (size() < s.size() ? -1 : size() == s.size() ? 0 : 1) : n; + } + + constexpr int compare(size_type pos1, size_type n1, basic_string_view s) + const + { return substr(pos1, n1).compare(s); } + + constexpr int compare( + size_type pos1, size_type n1, basic_string_view s, size_type pos2, + size_type n2) const + { return substr(pos1, n1).compare(s.substr(pos2, n2)); } + + constexpr int compare(charT const * s) const + { return compare(basic_string_view(s)); } + + constexpr int compare(size_type pos1, size_type n1, charT const * s) const + { return substr(pos1, n1).compare(s); } + + constexpr int compare( + size_type pos1, size_type n1, charT const * s, size_type n2) const + { return substr(pos1, n1).compare(basic_string_view(s, n2)); } + +#if HAVE_CXX14_CONSTEXPR + constexpr +#endif + size_type find(basic_string_view s, size_type pos = 0) const noexcept { + if (s.size() <= size()) { + for (auto xpos = pos; xpos <= size() - s.size(); ++xpos) { + bool match = true; + for (size_type i = 0; i != s.size(); ++i) { + if (!traits::eq(data_[xpos + i], s.data_[i])) { + match = false; + break; + } + } + if (match) { + return xpos; + } + } + } + return npos; + } + + constexpr size_type find(charT c, size_type pos = 0) const noexcept + { return find(basic_string_view(&c, 1), pos); } + + constexpr size_type find(charT const * s, size_type pos, size_type n) const + { return find(basic_string_view(s, n), pos); } + + constexpr size_type find(charT const * s, size_type pos = 0) const + { return find(basic_string_view(s), pos); } + +#if HAVE_CXX14_CONSTEXPR + constexpr +#endif + size_type rfind(basic_string_view s, size_type pos = npos) const noexcept { + if (s.size() <= size()) { + for (auto xpos = std::min<size_type>(size() - s.size(), pos);; + --xpos) + { + bool match = true; + for (size_type i = 0; i != s.size(); ++i) { + if (!traits::eq(data_[xpos + i], s.data_[i])) { + match = false; + break; + } + } + if (match) { + return xpos; + } + if (xpos == 0) { + break; + } + } + } + return npos; + } + + constexpr size_type rfind(charT c, size_type pos = npos) const noexcept + { return rfind(basic_string_view(&c, 1), pos); } + + constexpr size_type rfind(charT const * s, size_type pos, size_type n) const + { return rfind(basic_string_view(s, n), pos); } + + constexpr size_type rfind(charT const * s, size_type pos = npos) const + { return rfind(basic_string_view(s), pos); } + +#if HAVE_CXX14_CONSTEXPR + constexpr +#endif + size_type find_first_of(basic_string_view s, size_type pos = 0) const + noexcept + { + for (auto xpos = pos; xpos < size(); ++xpos) { + for (size_type i = 0; i != s.size(); ++i) { + if (traits::eq(data_[xpos], s.data_[i])) { + return xpos; + } + } + } + return npos; + } + + constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept + { return find_first_of(basic_string_view(&c, 1), pos); } + + constexpr size_type find_first_of( + charT const * s, size_type pos, size_type n) const + { return find_first_of(basic_string_view(s, n), pos); } + + constexpr size_type find_first_of(charT const * s, size_type pos = 0) const + { return find_first_of(basic_string_view(s), pos); } + +#if HAVE_CXX14_CONSTEXPR + constexpr +#endif + size_type find_last_of(basic_string_view s, size_type pos = npos) const + noexcept + { + if (!empty()) { + for (auto xpos = std::min<size_type>(size() - 1, pos);; --xpos) { + for (size_type i = 0; i != s.size(); ++i) { + if (traits::eq(data_[xpos], s.data_[i])) { + return xpos; + } + } + if (xpos == 0) { + break; + } + } + } + return npos; + } + + constexpr size_type find_last_of(charT c, size_type pos = npos) const + noexcept + { return find_last_of(basic_string_view(&c, 1), pos); } + + constexpr size_type find_last_of( + charT const * s, size_type pos, size_type n) const + { return find_last_of(basic_string_view(s, n), pos); } + + constexpr size_type find_last_of(charT const * s, size_type pos = npos) + const + { return find_last_of(basic_string_view(s), pos); } + +#if HAVE_CXX14_CONSTEXPR + constexpr +#endif + size_type find_first_not_of(basic_string_view s, size_type pos = 0) const + noexcept + { + for (auto xpos = pos; xpos < size(); ++xpos) { + bool match = true; + for (size_type i = 0; i != s.size(); ++i) { + if (traits::eq(data_[xpos], s.data_[i])) { + match = false; + break; + } + } + if (match) { + return xpos; + } + } + return npos; + } + + constexpr size_type find_first_not_of(charT c, size_type pos = 0) const + noexcept + { return find_first_not_of(basic_string_view(&c, 1), pos); } + + constexpr size_type find_first_not_of( + charT const * s, size_type pos, size_type n) const + { return find_first_not_of(basic_string_view(s, n), pos); } + + constexpr size_type find_first_not_of(charT const * s, size_type pos = 0) + const + { return find_first_not_of(basic_string_view(s), pos); } + +#if HAVE_CXX14_CONSTEXPR + constexpr +#endif + size_type find_last_not_of(basic_string_view s, size_type pos = npos) const + noexcept + { + if (!empty()) { + for (auto xpos = std::min<size_type>(size() - 1, pos);; --xpos) { + bool match = true; + for (size_type i = 0; i != s.size(); ++i) { + if (traits::eq(data_[xpos], s.data_[i])) { + match = false; + break; + } + } + if (match) { + return xpos; + } + if (xpos == 0) { + break; + } + } + } + return npos; + } + + constexpr size_type find_last_not_of(charT c, size_type pos = npos) const + noexcept + { return find_last_not_of(basic_string_view(&c, 1), pos); } + + constexpr size_type find_last_not_of( + charT const * s, size_type pos, size_type n) const + { return find_last_not_of(basic_string_view(s, n), pos); } + + constexpr size_type find_last_not_of(charT const * s, size_type pos = npos) + const + { return find_last_not_of(basic_string_view(s), pos); } + + // LO specifics: + + // For std::basic_string_view, this is provided via a non-explicit + // conversion operator from std::basic_string: + constexpr basic_string_view(std::basic_string<charT, traits> const & s): + data_(s.data()), size_(s.size()) {} + + // For std::string_view, this will be provided by a (LIBO_INTERNAL_ONLY) + // non-explicit conversion operator from rtl::OString: + template<typename T = charT> basic_string_view( + OString const & s, + typename std::enable_if< + std::is_same<T, char>::value, + rtl::libreoffice_internal::Dummy>::type = {}): + data_(s.getStr()), size_(s.getLength()) {} + + // For std::u16string_view, this will be provided by a (LIBO_INTERNAL_ONLY) + // non-explicit conversion operator from rtl::OUString: + template<typename T = charT> basic_string_view( + OUString const & s, + typename std::enable_if< + std::is_same<T, sal_Unicode>::value, + rtl::libreoffice_internal::Dummy>::type = {}): + data_(s.getStr()), size_(s.getLength()) {} + + // For std::u16string_view, this would either be provided by a + // (LIBO_INTERNAL_ONLY) non-explicit conversion operator from + // rtl::OUStringLiteral, or rtl::OUStringLiteral would be given up in favor + // of std::u16string_view anyway (but this constructor also serves to reject + // as ambiguous construction of a o3tl::u16string_view from a narrow string + // literal, which would otherwise go via the above rtl::OUString + // constructor): + template<typename T = charT> constexpr basic_string_view( + OUStringLiteral literal, + typename std::enable_if< + std::is_same<T, sal_Unicode>::value, + rtl::libreoffice_internal::Dummy>::type = {}): + data_(literal.data), size_(literal.size) {} + + // LO specifics, to make up for traits::length not necessarily being + // constexpr yet for literal arguments: + + template<typename T1, typename T2 = charT> constexpr basic_string_view( + T1 const & value, + typename std::enable_if< + std::is_same<T2, char>::value && detail::CharPtrDetector<T1>::ok, + rtl::libreoffice_internal::Dummy>::type = {}): + data_(value), size_(traits::length(value)) {} + + template<typename T1, typename T2 = charT> constexpr basic_string_view( + T1 & value, + typename std::enable_if< + (std::is_same<T2, char>::value + && detail::NonConstCharArrayDetector<T1>::ok), + rtl::libreoffice_internal::Dummy>::type = {}): + data_(value), size_(traits::length(value)) {} + + template<typename T1, typename T2 = charT> constexpr basic_string_view( + T1 & literal, + typename std::enable_if< + (std::is_same<T2, char>::value + && detail::ConstCharArrayDetector<T1>::ok), + rtl::libreoffice_internal::Dummy>::type = {}): + data_(literal), size_(detail::ConstCharArrayDetector<T1>::length) + { /*assert(size_ == traits::length(literal);*/ } + + template<typename T1, typename T2 = charT> constexpr basic_string_view( + T1 const & value, + typename std::enable_if< + (std::is_same<T2, char16_t>::value + && detail::Char16PtrDetector<T1>::ok), + rtl::libreoffice_internal::Dummy>::type = {}): + data_(value), size_(traits::length(value)) {} + + template<typename T1, typename T2 = charT> constexpr basic_string_view( + T1 & value, + typename std::enable_if< + (std::is_same<T2, char16_t>::value + && detail::NonConstChar16ArrayDetector<T1>::ok), + rtl::libreoffice_internal::Dummy>::type = {}): + data_(value), size_(traits::length(value)) {} + + template<typename T1, typename T2 = charT> constexpr basic_string_view( + T1 & literal, + typename std::enable_if< + (std::is_same<T2, char16_t>::value + && detail::ConstChar16ArrayDetector<T1>::ok), + rtl::libreoffice_internal::Dummy>::type = {}): + data_(literal), size_(detail::ConstChar16ArrayDetector<T1>::length) + { /*assert(size_ == traits::length(literal);*/ } + + template<typename T1, typename T2 = charT> constexpr basic_string_view( + T1 const & value, + typename std::enable_if< + (std::is_same<T2, char32_t>::value + && detail::Char32PtrDetector<T1>::ok), + rtl::libreoffice_internal::Dummy>::type = {}): + data_(value), size_(traits::length(value)) {} + + template<typename T1, typename T2 = charT> constexpr basic_string_view( + T1 & value, + typename std::enable_if< + (std::is_same<T2, char32_t>::value + && detail::NonConstChar32ArrayDetector<T1>::ok), + rtl::libreoffice_internal::Dummy>::type = {}): + data_(value), size_(traits::length(value)) {} + + template<typename T1, typename T2 = charT> constexpr basic_string_view( + T1 & literal, + typename std::enable_if< + (std::is_same<T2, char32_t>::value + && detail::ConstChar32ArrayDetector<T1>::ok), + rtl::libreoffice_internal::Dummy>::type = {}): + data_(literal), size_(detail::ConstChar32ArrayDetector<T1>::length) + { /*assert(size_ == traits::length(literal);*/ } + + template<typename T1, typename T2 = charT> constexpr basic_string_view( + T1 const & value, + typename std::enable_if< + (std::is_same<T2, wchar_t>::value + && detail::WcharPtrDetector<T1>::ok), + rtl::libreoffice_internal::Dummy>::type = {}): + data_(value), size_(traits::length(value)) {} + + template<typename T1, typename T2 = charT> constexpr basic_string_view( + T1 & value, + typename std::enable_if< + (std::is_same<T2, wchar_t>::value + && detail::NonConstWcharArrayDetector<T1>::ok), + rtl::libreoffice_internal::Dummy>::type = {}): + data_(value), size_(traits::length(value)) {} + + template<typename T1, typename T2 = charT> constexpr basic_string_view( + T1 & literal, + typename std::enable_if< + (std::is_same<T2, wchar_t>::value + && detail::ConstWcharArrayDetector<T1>::ok), + rtl::libreoffice_internal::Dummy>::type = {}): + data_(literal), size_(detail::ConstWcharArrayDetector<T1>::length) + { /*assert(size_ == traits::length(literal);*/ } + +private: + const_pointer data_; + size_type size_; +}; + +template<class charT, class traits> constexpr bool operator ==( + basic_string_view<charT, traits> x, basic_string_view<charT, traits> y) + noexcept +{ return x.compare(y) == 0; } + +template<class charT, class traits> constexpr bool operator ==( + basic_string_view<charT, traits> x, + typename std::decay<basic_string_view<charT, traits>>::type y) + noexcept +{ return x.compare(y) == 0; } + +template<class charT, class traits> constexpr bool operator ==( + typename std::decay<basic_string_view<charT, traits>>::type x, + basic_string_view<charT, traits> y) + noexcept +{ return x.compare(y) == 0; } + +template<class charT, class traits> constexpr bool operator !=( + basic_string_view<charT, traits> x, basic_string_view<charT, traits> y) + noexcept +{ return x.compare(y) != 0; } + +template<class charT, class traits> constexpr bool operator !=( + basic_string_view<charT, traits> x, + typename std::decay<basic_string_view<charT, traits>>::type y) + noexcept +{ return x.compare(y) != 0; } + +template<class charT, class traits> constexpr bool operator !=( + typename std::decay<basic_string_view<charT, traits>>::type x, + basic_string_view<charT, traits> y) + noexcept +{ return x.compare(y) != 0; } + +template<class charT, class traits> constexpr bool operator <( + basic_string_view<charT, traits> x, basic_string_view<charT, traits> y) + noexcept +{ return x.compare(y) < 0; } + +template<class charT, class traits> constexpr bool operator <( + basic_string_view<charT, traits> x, + typename std::decay<basic_string_view<charT, traits>>::type y) + noexcept +{ return x.compare(y) < 0; } + +template<class charT, class traits> constexpr bool operator <( + typename std::decay<basic_string_view<charT, traits>>::type x, + basic_string_view<charT, traits> y) + noexcept +{ return x.compare(y) < 0; } + +template<class charT, class traits> constexpr bool operator >( + basic_string_view<charT, traits> x, basic_string_view<charT, traits> y) + noexcept +{ return x.compare(y) > 0; } + +template<class charT, class traits> constexpr bool operator >( + basic_string_view<charT, traits> x, + typename std::decay<basic_string_view<charT, traits>>::type y) + noexcept +{ return x.compare(y) > 0; } + +template<class charT, class traits> constexpr bool operator >( + typename std::decay<basic_string_view<charT, traits>>::type x, + basic_string_view<charT, traits> y) + noexcept +{ return x.compare(y) > 0; } + +template<class charT, class traits> constexpr bool operator <=( + basic_string_view<charT, traits> x, basic_string_view<charT, traits> y) + noexcept +{ return x.compare(y) <= 0; } + +template<class charT, class traits> constexpr bool operator <=( + basic_string_view<charT, traits> x, + typename std::decay<basic_string_view<charT, traits>>::type y) + noexcept +{ return x.compare(y) <= 0; } + +template<class charT, class traits> constexpr bool operator <=( + typename std::decay<basic_string_view<charT, traits>>::type x, + basic_string_view<charT, traits> y) + noexcept +{ return x.compare(y) <= 0; } + +template<class charT, class traits> constexpr bool operator >=( + basic_string_view<charT, traits> x, basic_string_view<charT, traits> y) + noexcept +{ return x.compare(y) >= 0; } + +template<class charT, class traits> constexpr bool operator >=( + basic_string_view<charT, traits> x, + typename std::decay<basic_string_view<charT, traits>>::type y) + noexcept +{ return x.compare(y) >= 0; } + +template<class charT, class traits> constexpr bool operator >=( + typename std::decay<basic_string_view<charT, traits>>::type x, + basic_string_view<charT, traits> y) + noexcept +{ return x.compare(y) >= 0; } + +template<class charT, class traits> std::basic_ostream<charT, traits> & +operator <<( + std::basic_ostream<charT, traits> & os, + basic_string_view<charT, traits> str) +{ + typename std::basic_ostream<charT, traits>::sentry sentry; + if (sentry) { + auto const w = os.width(); + auto const pad + = std::max<std::make_unsigned<decltype(w + str.size())>::type>( + w < 0 ? 0 : w, str.size()); + auto const after = (os.flags() & std::ios_base::adjustfield) + == std::ios_base::left; + if (pad != 0 && !after) { + auto const c = os.fill(); + for (; pad != 0; --pad) { + os.rdbuf()->sputc(c); + } + } + os.rdbuf()->sputn(str.data(), str.size()); + if (pad != 0 && after) { + auto const c = os.fill(); + for (; pad != 0; --pad) { + os.rdbuf()->sputc(c); + } + } + os.width(0); + } else { + os.setstate(std::ios_base::failbit); + } + return os; +} + +#if defined _MSC_VER +#pragma warning(pop) +#endif + +using string_view = basic_string_view<char>; +using u16string_view = basic_string_view<char16_t>; +using u32string_view = basic_string_view<char32_t>; +using wstring_view = basic_string_view<wchar_t>; + +// no literals::string_view_literals::operator "" sv + +} + +namespace std { + +template<> struct hash<o3tl::string_view> { + std::size_t operator ()(o3tl::string_view s) + { return hash<string>()(string(s.data(), s.size())); } +}; + +template<> struct hash<o3tl::u16string_view> { + std::size_t operator ()(o3tl::u16string_view s) + { return hash<u16string>()(u16string(s.data(), s.size())); } +}; + +template<> struct hash<o3tl::u32string_view> { + std::size_t operator ()(o3tl::u32string_view s) + { return hash<u32string>()(u32string(s.data(), s.size())); } +}; + +template<> struct hash<o3tl::wstring_view> { + std::size_t operator ()(o3tl::wstring_view s) + { return hash<wstring>()(wstring(s.data(), s.size())); } +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/o3tl/CppunitTest_o3tl_tests.mk b/o3tl/CppunitTest_o3tl_tests.mk index 152fa48c72ca..7dd43402c7ab 100644 --- a/o3tl/CppunitTest_o3tl_tests.mk +++ b/o3tl/CppunitTest_o3tl_tests.mk @@ -32,7 +32,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,o3tl_tests,\ o3tl/qa/test-lru_map \ o3tl/qa/test-safeint \ o3tl/qa/test-sorted_vector \ - o3tl/qa/test-span \ + o3tl/qa/test-string_view \ o3tl/qa/test-typed_flags \ o3tl/qa/test-vector_pool \ )) diff --git a/o3tl/qa/test-string_view.cxx b/o3tl/qa/test-string_view.cxx new file mode 100644 index 000000000000..977cfebc460a --- /dev/null +++ b/o3tl/qa/test-string_view.cxx @@ -0,0 +1,212 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <sal/config.h> + +#include <stdexcept> + +#include <cppunit/TestAssert.h> +#include <cppunit/TestFixture.h> +#include <cppunit/extensions/HelperMacros.h> + +#include <o3tl/string_view.hxx> + +namespace { + +class Test: public CppUnit::TestFixture { +private: + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(testCharLiteral); + CPPUNIT_TEST(testChar16Literal); + CPPUNIT_TEST(testChar32Literal); + CPPUNIT_TEST(testWcharLiteral); + CPPUNIT_TEST(testOperations); + CPPUNIT_TEST_SUITE_END(); + + void testCharLiteral() { + char * const s1 = const_cast<char *>("foo"); + o3tl::string_view v1(s1); + CPPUNIT_ASSERT_EQUAL(o3tl::string_view::size_type(3), v1.size()); + char const * const s2 = "foo"; + o3tl::string_view v2(s2); + CPPUNIT_ASSERT_EQUAL(o3tl::string_view::size_type(3), v2.size()); + char s3[] = "foo"; + o3tl::string_view v3(s3); + CPPUNIT_ASSERT_EQUAL(o3tl::string_view::size_type(3), v3.size()); + o3tl::string_view v4("foo"); + CPPUNIT_ASSERT_EQUAL(o3tl::string_view::size_type(3), v4.size()); + } + + void testChar16Literal() { + char16_t * const s1 = const_cast<char16_t *>(u"foo"); + o3tl::u16string_view v1(s1); + CPPUNIT_ASSERT_EQUAL(o3tl::u16string_view::size_type(3), v1.size()); + char16_t const * const s2 = u"foo"; + o3tl::u16string_view v2(s2); + CPPUNIT_ASSERT_EQUAL(o3tl::u16string_view::size_type(3), v2.size()); + char16_t s3[] = u"foo"; + o3tl::u16string_view v3(s3); + CPPUNIT_ASSERT_EQUAL(o3tl::u16string_view::size_type(3), v3.size()); + o3tl::u16string_view v4(u"foo"); + CPPUNIT_ASSERT_EQUAL(o3tl::u16string_view::size_type(3), v4.size()); + } + + void testChar32Literal() { + char32_t * const s1 = const_cast<char32_t *>(U"foo"); + o3tl::u32string_view v1(s1); + CPPUNIT_ASSERT_EQUAL(o3tl::u32string_view::size_type(3), v1.size()); + char32_t const * const s2 = U"foo"; + o3tl::u32string_view v2(s2); + CPPUNIT_ASSERT_EQUAL(o3tl::u32string_view::size_type(3), v2.size()); + char32_t s3[] = U"foo"; + o3tl::u32string_view v3(s3); + CPPUNIT_ASSERT_EQUAL(o3tl::u32string_view::size_type(3), v3.size()); + o3tl::u32string_view v4(U"foo"); + CPPUNIT_ASSERT_EQUAL(o3tl::u32string_view::size_type(3), v4.size()); + } + + void testWcharLiteral() { + wchar_t * const s1 = const_cast<wchar_t *>(L"foo"); + o3tl::wstring_view v1(s1); + CPPUNIT_ASSERT_EQUAL(o3tl::wstring_view::size_type(3), v1.size()); + wchar_t const * const s2 = L"foo"; + o3tl::wstring_view v2(s2); + CPPUNIT_ASSERT_EQUAL(o3tl::wstring_view::size_type(3), v2.size()); + wchar_t s3[] = L"foo"; + o3tl::wstring_view v3(s3); + CPPUNIT_ASSERT_EQUAL(o3tl::wstring_view::size_type(3), v3.size()); + o3tl::wstring_view v4(L"foo"); + CPPUNIT_ASSERT_EQUAL(o3tl::wstring_view::size_type(3), v4.size()); + } + + void testOperations() { + o3tl::string_view const v("fox"); + auto npos = o3tl::string_view::npos; + // o3tl::basic_string_view::npos will be (implicitly) inline with + // C++17, but for now can't be passed as 'const T& expected' + // argument into CppUnit::assertEquals, so take this detour + CPPUNIT_ASSERT_EQUAL('f', *v.begin()); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::difference_type(3), v.end() - v.begin()); + CPPUNIT_ASSERT_EQUAL('f', *v.cbegin()); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::difference_type(3), v.cend() - v.cbegin()); + CPPUNIT_ASSERT_EQUAL('x', *v.rbegin()); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::difference_type(3), v.rend() - v.rbegin()); + CPPUNIT_ASSERT_EQUAL('x', *v.crbegin()); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::difference_type(3), v.crend() - v.crbegin()); + CPPUNIT_ASSERT_EQUAL(o3tl::string_view::size_type(3), v.size()); + CPPUNIT_ASSERT_EQUAL(o3tl::string_view::size_type(3), v.length()); + CPPUNIT_ASSERT_EQUAL(o3tl::string_view::npos - 1, v.max_size()); + CPPUNIT_ASSERT(!v.empty()); + CPPUNIT_ASSERT_EQUAL('o', v[1]); + try { + v.at(o3tl::string_view::npos); + CPPUNIT_FAIL("missing exception"); + } catch (std::out_of_range &) {} + CPPUNIT_ASSERT_EQUAL('f', v.at(0)); + CPPUNIT_ASSERT_EQUAL('x', v.at(2)); + try { + v.at(3); + CPPUNIT_FAIL("missing exception"); + } catch (std::out_of_range &) {} + CPPUNIT_ASSERT_EQUAL('f', v.front()); + CPPUNIT_ASSERT_EQUAL('x', v.back()); + CPPUNIT_ASSERT_EQUAL('f', *v.data()); + { + o3tl::string_view v1("fox"); + v1.remove_prefix(2); + CPPUNIT_ASSERT_EQUAL('x', v1.front()); + CPPUNIT_ASSERT_EQUAL(o3tl::string_view::size_type(1), v1.size()); + } + { + o3tl::string_view v1("fox"); + v1.remove_suffix(2); + CPPUNIT_ASSERT_EQUAL('f', v1.front()); + CPPUNIT_ASSERT_EQUAL(o3tl::string_view::size_type(1), v1.size()); + } + { + o3tl::string_view v1("fox"); + o3tl::string_view v2("giraffe"); + v1.swap(v2); + CPPUNIT_ASSERT_EQUAL(o3tl::string_view::size_type(7), v1.size()); + CPPUNIT_ASSERT_EQUAL(o3tl::string_view::size_type(3), v2.size()); + } + { + char a[2]; + auto n = v.copy(a, 10, 1); + CPPUNIT_ASSERT_EQUAL(o3tl::string_view::size_type(2), n); + CPPUNIT_ASSERT_EQUAL('o', a[0]); + CPPUNIT_ASSERT_EQUAL('x', a[1]); + } + { + auto v1 = v.substr(1); + CPPUNIT_ASSERT_EQUAL('o', v1.front()); + CPPUNIT_ASSERT_EQUAL(o3tl::string_view::size_type(2), v1.size()); + } + CPPUNIT_ASSERT(v.compare(o3tl::string_view("foo")) > 0); + CPPUNIT_ASSERT(v.compare(0, 2, o3tl::string_view("foo")) < 0); + CPPUNIT_ASSERT_EQUAL( + 0, v.compare(0, 2, o3tl::string_view("foo"), 0, 2)); + CPPUNIT_ASSERT_EQUAL(0, v.compare("fox")); + CPPUNIT_ASSERT(v.compare(1, 2, "abc") > 0); + CPPUNIT_ASSERT_EQUAL(0, v.compare(1, 2, "oxx", 2)); + CPPUNIT_ASSERT_EQUAL(o3tl::string_view::size_type(1), v.find("ox")); + CPPUNIT_ASSERT_EQUAL(o3tl::string_view::size_type(1), v.find('o')); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::size_type(1), v.find("oxx", 0, 2)); + CPPUNIT_ASSERT_EQUAL(npos, v.find("oxx")); + CPPUNIT_ASSERT_EQUAL(o3tl::string_view::size_type(1), v.rfind("ox")); + CPPUNIT_ASSERT_EQUAL(o3tl::string_view::size_type(1), v.rfind('o')); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::size_type(1), + v.rfind("oxx", o3tl::string_view::npos, 2)); + CPPUNIT_ASSERT_EQUAL(npos, v.rfind("oxx")); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::size_type(1), v.find_first_of("nop")); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::size_type(1), v.find_first_of('o')); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::size_type(1), v.find_first_of("nofx", 0, 2)); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::size_type(0), v.find_first_of("nofx")); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::size_type(1), v.find_last_of("nop")); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::size_type(1), v.find_last_of('o')); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::size_type(1), + v.find_last_of("nofx", o3tl::string_view::npos, 2)); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::size_type(2), v.find_last_of("nofx")); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::size_type(1), v.find_first_not_of("fx")); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::size_type(1), v.find_first_not_of('f')); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::size_type(1), v.find_first_not_of("fxo", 0, 2)); + CPPUNIT_ASSERT_EQUAL(npos, v.find_first_not_of("fxo")); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::size_type(1), v.find_last_not_of("fx")); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::size_type(1), v.find_last_not_of('x')); + CPPUNIT_ASSERT_EQUAL( + o3tl::string_view::size_type(1), + v.find_last_not_of("fxo", o3tl::string_view::npos, 2)); + CPPUNIT_ASSERT_EQUAL(npos, v.find_last_not_of("fxo")); + } +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(Test); + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist index 61fbcaeca801..3595505e018d 100644 --- a/solenv/clang-format/blacklist +++ b/solenv/clang-format/blacklist @@ -6387,6 +6387,7 @@ include/o3tl/runtimetooustring.hxx include/o3tl/safeint.hxx include/o3tl/sorted_vector.hxx include/o3tl/span.hxx +include/o3tl/string_view.hxx include/o3tl/strong_int.hxx include/o3tl/typed_flags_set.hxx include/o3tl/vector_pool.hxx @@ -8615,6 +8616,7 @@ o3tl/qa/test-lru_map.cxx o3tl/qa/test-safeint.cxx o3tl/qa/test-sorted_vector.cxx o3tl/qa/test-span.cxx +o3tl/qa/test-string_view.cxx o3tl/qa/test-typed_flags.cxx o3tl/qa/test-vector_pool.cxx odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.cxx