summaryrefslogtreecommitdiff
path: root/ucb/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-09-28 15:00:28 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-09-28 16:04:31 +0200
commitaa770d615ec5722411cc4ab1f88de89d4cad5809 (patch)
treedebdeace25a7dc61ab845a17922870b9cf65c328 /ucb/source
parent42a73e2259d5937ffb8896f7cd24991f83b1ad82 (diff)
use more string_view in ucb
Change-Id: Id1d35aca0c8f62b3eb03eca9850a3f3c9799df98 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140706 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucb/source')
-rw-r--r--ucb/source/core/ucb.cxx12
-rw-r--r--ucb/source/core/ucb.hxx4
-rw-r--r--ucb/source/core/ucbstore.cxx6
-rw-r--r--ucb/source/ucp/ext/ucpext_content.cxx8
-rw-r--r--ucb/source/ucp/ext/ucpext_content.hxx2
-rw-r--r--ucb/source/ucp/file/filglob.cxx15
-rw-r--r--ucb/source/ucp/file/filglob.hxx8
-rw-r--r--ucb/source/ucp/hierarchy/hierarchydata.cxx6
-rw-r--r--ucb/source/ucp/webdav-curl/CurlSession.cxx14
-rw-r--r--ucb/source/ucp/webdav-curl/CurlUri.cxx19
-rw-r--r--ucb/source/ucp/webdav-curl/CurlUri.hxx2
-rw-r--r--ucb/source/ucp/webdav-curl/DAVProperties.cxx26
-rw-r--r--ucb/source/ucp/webdav-curl/DAVProperties.hxx2
13 files changed, 65 insertions, 59 deletions
diff --git a/ucb/source/core/ucb.cxx b/ucb/source/core/ucb.cxx
index e0e6953a63a7..26476a90562b 100644
--- a/ucb/source/core/ucb.cxx
+++ b/ucb/source/core/ucb.cxx
@@ -136,10 +136,10 @@ bool fillPlaceholders(OUString const & rInput,
}
void makeAndAppendXMLName(
- OUStringBuffer & rBuffer, const OUString & rIn )
+ OUStringBuffer & rBuffer, std::u16string_view rIn )
{
- sal_Int32 nCount = rIn.getLength();
- for ( sal_Int32 n = 0; n < nCount; ++n )
+ size_t nCount = rIn.size();
+ for ( size_t n = 0; n < nCount; ++n )
{
const sal_Unicode c = rIn[ n ];
switch ( c )
@@ -767,11 +767,11 @@ void UniversalContentBroker::prepareAndRegister(
bool UniversalContentBroker::getContentProviderData(
- const OUString & rKey1,
- const OUString & rKey2,
+ std::u16string_view rKey1,
+ std::u16string_view rKey2,
ContentProviderDataList & rListToFill )
{
- if ( !m_xContext.is() || rKey1.isEmpty() || rKey2.isEmpty() )
+ if ( !m_xContext.is() || rKey1.empty() || rKey2.empty() )
{
OSL_FAIL( "UniversalContentBroker::getContentProviderData - Invalid argument!" );
return false;
diff --git a/ucb/source/core/ucb.hxx b/ucb/source/core/ucb.hxx
index 49c6e0b37d8d..001987ed54c4 100644
--- a/ucb/source/core/ucb.hxx
+++ b/ucb/source/core/ucb.hxx
@@ -136,8 +136,8 @@ private:
void configureUcb();
bool getContentProviderData(
- const OUString & rKey1,
- const OUString & rKey2,
+ std::u16string_view rKey1,
+ std::u16string_view rKey2,
ucbhelper::ContentProviderDataList & rListToFill);
void prepareAndRegister( const ucbhelper::ContentProviderDataList& rData);
diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx
index be97f81f636f..5757f8369f40 100644
--- a/ucb/source/core/ucbstore.cxx
+++ b/ucb/source/core/ucbstore.cxx
@@ -59,13 +59,13 @@ using namespace com::sun::star::util;
using namespace comphelper;
using namespace cppu;
-static OUString makeHierarchalNameSegment( const OUString & rIn )
+static OUString makeHierarchalNameSegment( std::u16string_view rIn )
{
OUStringBuffer aBuffer;
aBuffer.append( "['" );
- sal_Int32 nCount = rIn.getLength();
- for ( sal_Int32 n = 0; n < nCount; ++n )
+ size_t nCount = rIn.size();
+ for ( size_t n = 0; n < nCount; ++n )
{
const sal_Unicode c = rIn[ n ];
switch ( c )
diff --git a/ucb/source/ucp/ext/ucpext_content.cxx b/ucb/source/ucp/ext/ucpext_content.cxx
index a04da9a96ecd..a1d2df55a092 100644
--- a/ucb/source/ucp/ext/ucpext_content.cxx
+++ b/ucb/source/ucp/ext/ucpext_content.cxx
@@ -279,16 +279,16 @@ namespace ucb::ucp::ext
}
- bool Content::denotesRootContent( const OUString& i_rContentIdentifier )
+ bool Content::denotesRootContent( std::u16string_view i_rContentIdentifier )
{
const OUString sRootURL( ContentProvider::getRootURL() );
if ( i_rContentIdentifier == sRootURL )
return true;
// the root URL contains only two trailing /, but we also recognize 3 of them as denoting the root URL
- if ( i_rContentIdentifier.match( sRootURL )
- && ( i_rContentIdentifier.getLength() == sRootURL.getLength() + 1 )
- && ( i_rContentIdentifier[ i_rContentIdentifier.getLength() - 1 ] == '/' )
+ if ( o3tl::starts_with(i_rContentIdentifier, sRootURL )
+ && ( sal_Int32(i_rContentIdentifier.size()) == sRootURL.getLength() + 1 )
+ && ( i_rContentIdentifier[ i_rContentIdentifier.size() - 1 ] == '/' )
)
return true;
diff --git a/ucb/source/ucp/ext/ucpext_content.hxx b/ucb/source/ucp/ext/ucpext_content.hxx
index 3e7136f07476..99df646f73c4 100644
--- a/ucb/source/ucp/ext/ucpext_content.hxx
+++ b/ucb/source/ucp/ext/ucpext_content.hxx
@@ -114,7 +114,7 @@ namespace ucb::ucp::ext
const css::uno::Sequence< css::beans::PropertyValue >& rValues
);
- static bool denotesRootContent( const OUString& i_rContentIdentifier );
+ static bool denotesRootContent( std::u16string_view i_rContentIdentifier );
bool impl_isFolder();
void impl_determineContentType();
diff --git a/ucb/source/ucp/file/filglob.cxx b/ucb/source/ucp/file/filglob.cxx
index 30b0f2679e53..a86716509a24 100644
--- a/ucb/source/ucp/file/filglob.cxx
+++ b/ucb/source/ucp/file/filglob.cxx
@@ -40,6 +40,7 @@
#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
+#include <o3tl/string_view.hxx>
#include <osl/diagnose.h>
#include <rtl/uri.hxx>
#include <rtl/ustring.hxx>
@@ -152,20 +153,20 @@ namespace {
namespace fileaccess {
- bool isChild( const OUString& srcUnqPath,
- const OUString& dstUnqPath )
+ bool isChild( std::u16string_view srcUnqPath,
+ std::u16string_view dstUnqPath )
{
static const sal_Unicode slash = '/';
// Simple lexical comparison
- sal_Int32 srcL = srcUnqPath.getLength();
- sal_Int32 dstL = dstUnqPath.getLength();
+ size_t srcL = srcUnqPath.size();
+ size_t dstL = dstUnqPath.size();
return (
( srcUnqPath == dstUnqPath )
||
( ( dstL > srcL )
&&
- dstUnqPath.startsWith(srcUnqPath)
+ o3tl::starts_with(dstUnqPath, srcUnqPath)
&&
( dstUnqPath[ srcL ] == slash ) )
);
@@ -174,10 +175,10 @@ namespace fileaccess {
OUString newName(
std::u16string_view aNewPrefix,
- const OUString& aOldPrefix,
+ std::u16string_view aOldPrefix,
std::u16string_view old_Name )
{
- sal_Int32 srcL = aOldPrefix.getLength();
+ size_t srcL = aOldPrefix.size();
return OUString::Concat(aNewPrefix) + old_Name.substr( srcL );
}
diff --git a/ucb/source/ucp/file/filglob.hxx b/ucb/source/ucp/file/filglob.hxx
index b1235056ee18..c113f62ecb03 100644
--- a/ucb/source/ucp/file/filglob.hxx
+++ b/ucb/source/ucp/file/filglob.hxx
@@ -40,14 +40,14 @@ namespace fileaccess {
// Returns true if dstUnqPath is a child from srcUnqPath or both are equal
- extern bool isChild( const OUString& srcUnqPath,
- const OUString& dstUnqPath );
+ extern bool isChild( std::u16string_view srcUnqPath,
+ std::u16string_view dstUnqPath );
// Changes the prefix in name
extern OUString newName( std::u16string_view aNewPrefix,
- const OUString& aOldPrefix,
- std::u16string_view old_Name );
+ std::u16string_view aOldPrefix,
+ std::u16string_view old_Name );
// returns the last part of the given url as title
extern std::u16string_view getTitle( std::u16string_view aPath );
diff --git a/ucb/source/ucp/hierarchy/hierarchydata.cxx b/ucb/source/ucp/hierarchy/hierarchydata.cxx
index 44c8ed3a51b8..c209f9bcf72c 100644
--- a/ucb/source/ucp/hierarchy/hierarchydata.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchydata.cxx
@@ -47,10 +47,10 @@ namespace hierarchy_ucp
{
-static void makeXMLName( const OUString & rIn, OUStringBuffer & rBuffer )
+static void makeXMLName( std::u16string_view rIn, OUStringBuffer & rBuffer )
{
- sal_Int32 nCount = rIn.getLength();
- for ( sal_Int32 n = 0; n < nCount; ++n )
+ size_t nCount = rIn.size();
+ for ( size_t n = 0; n < nCount; ++n )
{
const sal_Unicode c = rIn[ n ];
switch ( c )
diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx b/ucb/source/ucp/webdav-curl/CurlSession.cxx
index a7303fb7b3bc..415a21703dab 100644
--- a/ucb/source/ucp/webdav-curl/CurlSession.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx
@@ -760,7 +760,8 @@ auto CurlSession::abort() -> void
/// this is just a bunch of static member functions called from CurlSession
struct CurlProcessor
{
- static auto URIReferenceToURI(CurlSession& rSession, OUString const& rURIReference) -> CurlUri;
+ static auto URIReferenceToURI(CurlSession& rSession, std::u16string_view rURIReference)
+ -> CurlUri;
static auto ProcessRequestImpl(
CurlSession& rSession, CurlUri const& rURI, OUString const& rMethod,
@@ -785,7 +786,7 @@ struct CurlProcessor
::std::vector<DAVResourceInfo>* const o_pResourceInfos,
DAVRequestEnvironment const& rEnv) -> void;
- static auto MoveOrCopy(CurlSession& rSession, OUString const& rSourceURIReference,
+ static auto MoveOrCopy(CurlSession& rSession, std::u16string_view rSourceURIReference,
::std::u16string_view rDestinationURI, DAVRequestEnvironment const& rEnv,
bool isOverwrite, char const* pMethod) -> void;
@@ -799,19 +800,20 @@ struct CurlProcessor
DAVRequestEnvironment const* pEnv) -> void;
};
-auto CurlProcessor::URIReferenceToURI(CurlSession& rSession, OUString const& rURIReference)
+auto CurlProcessor::URIReferenceToURI(CurlSession& rSession, std::u16string_view rURIReference)
-> CurlUri
{
// No need to acquire rSession.m_Mutex because accessed members are const.
if (rSession.UsesProxy())
// very odd, but see DAVResourceAccess::getRequestURI() :-/
{
- assert(rURIReference.startsWith("http://") || rURIReference.startsWith("https://"));
+ assert(o3tl::starts_with(rURIReference, u"http://")
+ || o3tl::starts_with(rURIReference, u"https://"));
return CurlUri(rURIReference);
}
else
{
- assert(rURIReference.startsWith("/"));
+ assert(o3tl::starts_with(rURIReference, u"/"));
return rSession.m_URI.CloneWithRelativeRefPathAbsolute(rURIReference);
}
}
@@ -2047,7 +2049,7 @@ auto CurlSession::MKCOL(OUString const& rURIReference, DAVRequestEnvironment con
nullptr);
}
-auto CurlProcessor::MoveOrCopy(CurlSession& rSession, OUString const& rSourceURIReference,
+auto CurlProcessor::MoveOrCopy(CurlSession& rSession, std::u16string_view rSourceURIReference,
::std::u16string_view const rDestinationURI,
DAVRequestEnvironment const& rEnv, bool const isOverwrite,
char const* const pMethod) -> void
diff --git a/ucb/source/ucp/webdav-curl/CurlUri.cxx b/ucb/source/ucp/webdav-curl/CurlUri.cxx
index 570c7000f204..073a173a8352 100644
--- a/ucb/source/ucp/webdav-curl/CurlUri.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlUri.cxx
@@ -236,17 +236,17 @@ void CurlUri::AppendPath(::std::u16string_view const rPath)
m_Path = *oPath;
}
-CurlUri CurlUri::CloneWithRelativeRefPathAbsolute(OUString const& rRelativeRef) const
+CurlUri CurlUri::CloneWithRelativeRefPathAbsolute(std::u16string_view rRelativeRef) const
{
::std::unique_ptr<CURLU, deleter_from_fn<CURLU, curl_url_cleanup>> pUrl(
curl_url_dup(m_pUrl.get()));
- sal_Int32 indexEnd(rRelativeRef.getLength());
- auto const indexQuery(rRelativeRef.indexOf('?'));
- auto const indexFragment(rRelativeRef.indexOf('#'));
+ size_t indexEnd(rRelativeRef.size());
+ auto const indexQuery(rRelativeRef.find('?'));
+ auto const indexFragment(rRelativeRef.find('#'));
CURLUcode uc;
- if (indexFragment != -1)
+ if (indexFragment != std::u16string_view::npos)
{
- std::u16string_view const fragment(rRelativeRef.subView(indexFragment + 1));
+ std::u16string_view const fragment(rRelativeRef.substr(indexFragment + 1));
indexEnd = indexFragment;
OString const utf8Fragment(OUStringToOString(fragment, RTL_TEXTENCODING_UTF8));
uc = curl_url_set(pUrl.get(), CURLUPART_FRAGMENT, utf8Fragment.getStr(), 0);
@@ -260,10 +260,11 @@ CurlUri CurlUri::CloneWithRelativeRefPathAbsolute(OUString const& rRelativeRef)
SAL_WARN("ucb.ucp.webdav.curl", "curl_url_set failed: " << uc);
throw DAVException(DAVException::DAV_INVALID_ARG);
}
- if (indexQuery != -1 && (indexFragment == -1 || indexQuery < indexFragment))
+ if (indexQuery != std::u16string_view::npos
+ && (indexFragment == std::u16string_view::npos || indexQuery < indexFragment))
{
std::u16string_view const query(
- rRelativeRef.subView(indexQuery + 1, indexEnd - indexQuery - 1));
+ rRelativeRef.substr(indexQuery + 1, indexEnd - indexQuery - 1));
indexEnd = indexQuery;
OString const utf8Query(OUStringToOString(query, RTL_TEXTENCODING_UTF8));
uc = curl_url_set(pUrl.get(), CURLUPART_QUERY, utf8Query.getStr(), 0);
@@ -277,7 +278,7 @@ CurlUri CurlUri::CloneWithRelativeRefPathAbsolute(OUString const& rRelativeRef)
SAL_WARN("ucb.ucp.webdav.curl", "curl_url_set failed: " << uc);
throw DAVException(DAVException::DAV_INVALID_ARG);
}
- std::u16string_view const path(rRelativeRef.subView(0, indexEnd));
+ std::u16string_view const path(rRelativeRef.substr(0, indexEnd));
OString const utf8Path(OUStringToOString(path, RTL_TEXTENCODING_UTF8));
uc = curl_url_set(pUrl.get(), CURLUPART_PATH, utf8Path.getStr(), 0);
if (uc != CURLUE_OK)
diff --git a/ucb/source/ucp/webdav-curl/CurlUri.hxx b/ucb/source/ucp/webdav-curl/CurlUri.hxx
index 56336af78169..70a4ffb55c26 100644
--- a/ucb/source/ucp/webdav-curl/CurlUri.hxx
+++ b/ucb/source/ucp/webdav-curl/CurlUri.hxx
@@ -82,7 +82,7 @@ public:
void AppendPath(::std::u16string_view rPath);
/// @param matches: relative-ref = path-absolute [ "?" query ] [ "#" fragment ]
/// @throws DAVException
- CurlUri CloneWithRelativeRefPathAbsolute(OUString const& rRelativeRef) const;
+ CurlUri CloneWithRelativeRefPathAbsolute(std::u16string_view rRelativeRef) const;
};
OUString EncodeSegment(OUString const& rSegment);
diff --git a/ucb/source/ucp/webdav-curl/DAVProperties.cxx b/ucb/source/ucp/webdav-curl/DAVProperties.cxx
index 8b3dce369c5e..bd0be1a862c4 100644
--- a/ucb/source/ucp/webdav-curl/DAVProperties.cxx
+++ b/ucb/source/ucp/webdav-curl/DAVProperties.cxx
@@ -160,34 +160,36 @@ bool DAVProperties::isUCBDeadProperty( const SerfPropName & rName )
== 0 ) );
}
-bool DAVProperties::isUCBSpecialProperty(const OUString& rFullName, OUString& rParsedName)
+bool DAVProperties::isUCBSpecialProperty(std::u16string_view rFullName, OUString& rParsedName)
{
- sal_Int32 nLen = rFullName.getLength();
+ size_t nLen = rFullName.size();
if ( nLen <= 0 ||
- !rFullName.startsWith( "<prop:" ) ||
- !rFullName.endsWith( "\">" ) )
+ !o3tl::starts_with(rFullName, u"<prop:" ) ||
+ !o3tl::starts_with(rFullName, u"\">" ) )
return false;
sal_Int32 nStart = RTL_CONSTASCII_LENGTH( "<prop:" );
- sal_Int32 nEnd = rFullName.indexOf( ' ', nStart );
- if ( nEnd == -1 )
+ size_t nEnd = rFullName.find( ' ', nStart );
+ if ( nEnd == std::u16string_view::npos )
return false;
- OUString sPropName = rFullName.copy( nStart, nEnd - nStart );
- if ( !sPropName.getLength() )
+ std::u16string_view sPropName = rFullName.substr( nStart, nEnd - nStart );
+ if ( sPropName.empty() )
return false;
// TODO skip whitespaces?
- if ( !rFullName.match( "xmlns:prop=\"", ++nEnd ) )
+ ++nEnd;
+ if ( !o3tl::starts_with(rFullName.substr(nEnd), u"xmlns:prop=\"" ) )
return false;
nStart = nEnd + RTL_CONSTASCII_LENGTH( "xmlns:prop=\"" );
- nEnd = rFullName.indexOf( '"', nStart );
+ nEnd = rFullName.find( '"', nStart );
if ( nEnd != nLen - RTL_CONSTASCII_LENGTH( "\">" ) )
return false;
- OUString sNamesp = rFullName.copy( nStart, nEnd - nStart );
- if ( !( nLen = sNamesp.getLength() ) )
+ std::u16string_view sNamesp = rFullName.substr( nStart, nEnd - nStart );
+ nLen = sNamesp.size();
+ if ( !nLen )
return false;
OUStringBuffer aBuff( sNamesp );
diff --git a/ucb/source/ucp/webdav-curl/DAVProperties.hxx b/ucb/source/ucp/webdav-curl/DAVProperties.hxx
index af005300c79d..902e184e7b7d 100644
--- a/ucb/source/ucp/webdav-curl/DAVProperties.hxx
+++ b/ucb/source/ucp/webdav-curl/DAVProperties.hxx
@@ -48,7 +48,7 @@ struct DAVProperties
OUString & rFullName );
static bool isUCBDeadProperty( const SerfPropName & rName );
- static bool isUCBSpecialProperty( const OUString & rFullName,
+ static bool isUCBSpecialProperty( std::u16string_view rFullName,
OUString & rParsedName );
};