summaryrefslogtreecommitdiffstats
path: root/cppuhelper
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-21 13:59:07 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-22 13:28:35 +0200
commit25ada1e520b50247aa27fdbb6f1ab35e678c7ef9 (patch)
tree84273aee328c778cfbd166d52d4e1a9fefeb4bf9 /cppuhelper
parentaddress review comments on "use more string in unoidl.." (diff)
downloadcore-25ada1e520b50247aa27fdbb6f1ab35e678c7ef9.tar.gz
core-25ada1e520b50247aa27fdbb6f1ab35e678c7ef9.zip
use more string_view in cppuhelper
Change-Id: I846a1201b1b4fb8ca694a0b78b7d4cc2973dfbd2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133258 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cppuhelper')
-rw-r--r--cppuhelper/source/factory.cxx19
-rw-r--r--cppuhelper/source/paths.cxx11
-rw-r--r--cppuhelper/source/paths.hxx3
-rw-r--r--cppuhelper/source/servicemanager.cxx14
-rw-r--r--cppuhelper/source/servicemanager.hxx2
-rw-r--r--cppuhelper/source/typemanager.cxx32
-rw-r--r--cppuhelper/source/typemanager.hxx10
7 files changed, 47 insertions, 44 deletions
diff --git a/cppuhelper/source/factory.cxx b/cppuhelper/source/factory.cxx
index 8768d9817ab7..98ac7e6a3746 100644
--- a/cppuhelper/source/factory.cxx
+++ b/cppuhelper/source/factory.cxx
@@ -29,6 +29,7 @@
#include <rtl/unload.h>
#include <cppuhelper/propshlp.hxx>
+#include <o3tl/string_view.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
@@ -700,7 +701,7 @@ Reference< XInterface > ORegistryFactoryHelper::createInstanceWithArgumentsAndCo
Reference< XInterface > ORegistryFactoryHelper::createModuleFactory()
{
OUString aActivatorUrl;
- OUString aActivatorName;
+ std::u16string_view aActivatorName;
OUString aLocation;
Reference<XRegistryKey > xActivatorKey = xImplementationKey->openKey(
@@ -709,7 +710,7 @@ Reference< XInterface > ORegistryFactoryHelper::createModuleFactory()
{
aActivatorUrl = xActivatorKey->getAsciiValue();
- aActivatorName = aActivatorUrl.getToken(0, ':');
+ aActivatorName = o3tl::getToken(aActivatorUrl, 0, ':');
Reference<XRegistryKey > xLocationKey = xImplementationKey->openKey(
"/UNO/LOCATION" );
@@ -732,20 +733,20 @@ Reference< XInterface > ORegistryFactoryHelper::createModuleFactory()
sal_Int32 nPos = aLocation.indexOf("://");
if( nPos != -1 )
{
- aActivatorName = aLocation.copy( 0, nPos );
- if( aActivatorName == "java" )
- aActivatorName = "com.sun.star.loader.Java";
- else if( aActivatorName == "module" )
- aActivatorName = "com.sun.star.loader.SharedLibrary";
+ aActivatorName = aLocation.subView( 0, nPos );
+ if( aActivatorName == u"java" )
+ aActivatorName = u"com.sun.star.loader.Java";
+ else if( aActivatorName == u"module" )
+ aActivatorName = u"com.sun.star.loader.SharedLibrary";
aLocation = aLocation.copy( nPos + 3 );
}
}
}
Reference< XInterface > xFactory;
- if( !aActivatorName.isEmpty() )
+ if( !aActivatorName.empty() )
{
- Reference<XInterface > x = xSMgr->createInstance( aActivatorName );
+ Reference<XInterface > x = xSMgr->createInstance( OUString(aActivatorName) );
Reference<XImplementationLoader > xLoader( x, UNO_QUERY );
if (xLoader.is())
{
diff --git a/cppuhelper/source/paths.cxx b/cppuhelper/source/paths.cxx
index b6a1e12600dd..ece7650ded4c 100644
--- a/cppuhelper/source/paths.cxx
+++ b/cppuhelper/source/paths.cxx
@@ -28,6 +28,7 @@
#include <osl/module.hxx>
#include <rtl/ustring.hxx>
#include <sal/types.h>
+#include <o3tl/string_view.hxx>
#include "paths.hxx"
@@ -108,18 +109,18 @@ bool cppu::nextDirectoryItem(osl::Directory & directory, OUString * url) {
}
}
-void cppu::decodeRdbUri(OUString * uri, bool * optional, bool * directory)
+void cppu::decodeRdbUri(std::u16string_view * uri, bool * optional, bool * directory)
{
assert(uri != nullptr && optional != nullptr && directory != nullptr);
- if(!(uri->isEmpty()))
+ if(!(uri->empty()))
{
*optional = (*uri)[0] == '?';
if (*optional) {
- *uri = uri->copy(1);
+ *uri = uri->substr(1);
}
- *directory = uri->startsWith("<") && uri->endsWith(">*");
+ *directory = o3tl::starts_with(*uri, u"<") && o3tl::ends_with(*uri, u">*");
if (*directory) {
- *uri = uri->copy(1, uri->getLength() - 3);
+ *uri = uri->substr(1, uri->size() - 3);
}
}
else
diff --git a/cppuhelper/source/paths.hxx b/cppuhelper/source/paths.hxx
index c1e3724c0aa1..b4681048998a 100644
--- a/cppuhelper/source/paths.hxx
+++ b/cppuhelper/source/paths.hxx
@@ -21,6 +21,7 @@
#include <sal/config.h>
#include <rtl/ustring.hxx>
+#include <string_view>
namespace osl
{
@@ -33,7 +34,7 @@ OUString getUnoIniUri();
bool nextDirectoryItem(osl::Directory& directory, OUString* url);
-void decodeRdbUri(OUString* uri, bool* optional, bool* directory);
+void decodeRdbUri(std::u16string_view* uri, bool* optional, bool* directory);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx
index 44044e28a54e..c128c4371e3f 100644
--- a/cppuhelper/source/servicemanager.cxx
+++ b/cppuhelper/source/servicemanager.cxx
@@ -1325,8 +1325,8 @@ void cppuhelper::ServiceManager::removeEventListenerFromComponent(
void cppuhelper::ServiceManager::init(std::u16string_view rdbUris) {
for (sal_Int32 i = 0; i != -1;) {
- OUString uri(o3tl::getToken(rdbUris, 0, ' ', i));
- if (uri.isEmpty()) {
+ std::u16string_view uri(o3tl::getToken(rdbUris, 0, ' ', i));
+ if (uri.empty()) {
continue;
}
bool optional;
@@ -1335,27 +1335,27 @@ void cppuhelper::ServiceManager::init(std::u16string_view rdbUris) {
if (directory) {
readRdbDirectory(uri, optional);
} else {
- readRdbFile(uri, optional);
+ readRdbFile(OUString(uri), optional);
}
}
}
void cppuhelper::ServiceManager::readRdbDirectory(
- OUString const & uri, bool optional)
+ std::u16string_view uri, bool optional)
{
- osl::Directory dir(uri);
+ osl::Directory dir = OUString(uri);
switch (dir.open()) {
case osl::FileBase::E_None:
break;
case osl::FileBase::E_NOENT:
if (optional) {
- SAL_INFO("cppuhelper", "Ignored optional " << uri);
+ SAL_INFO("cppuhelper", "Ignored optional " << OUString(uri));
return;
}
[[fallthrough]];
default:
throw css::uno::DeploymentException(
- "Cannot open directory " + uri,
+ OUString::Concat("Cannot open directory ") + uri,
static_cast< cppu::OWeakObject * >(this));
}
for (;;) {
diff --git a/cppuhelper/source/servicemanager.hxx b/cppuhelper/source/servicemanager.hxx
index 537194151735..2228cd1fbbf1 100644
--- a/cppuhelper/source/servicemanager.hxx
+++ b/cppuhelper/source/servicemanager.hxx
@@ -315,7 +315,7 @@ private:
void removeEventListenerFromComponent(
css::uno::Reference< css::lang::XComponent > const & component);
- void readRdbDirectory(OUString const & uri, bool optional);
+ void readRdbDirectory(std::u16string_view uri, bool optional);
void readRdbFile(OUString const & uri, bool optional);
diff --git a/cppuhelper/source/typemanager.cxx b/cppuhelper/source/typemanager.cxx
index 44105df033fa..28f831f0627c 100644
--- a/cppuhelper/source/typemanager.cxx
+++ b/cppuhelper/source/typemanager.cxx
@@ -1873,19 +1873,19 @@ css::uno::Any cppuhelper::TypeManager::find(OUString const & name) {
}
i = name.lastIndexOf('.');
if (i != -1) {
- OUString parent(name.copy(0, i));
+ std::u16string_view parent(name.subView(0, i));
ent = findEntity(parent);
if (ent.is()) {
switch (ent->getSort()) {
case unoidl::Entity::SORT_ENUM_TYPE:
return getEnumMember(
static_cast< unoidl::EnumTypeEntity * >(ent.get()),
- name.copy(i + 1));
+ name.subView(i + 1));
case unoidl::Entity::SORT_CONSTANT_GROUP:
return getConstant(
parent,
static_cast< unoidl::ConstantGroupEntity * >(ent.get()),
- name.copy(i + 1));
+ name.subView(i + 1));
default:
break;
}
@@ -2026,8 +2026,8 @@ cppuhelper::TypeManager::createTypeDescriptionEnumeration(
void cppuhelper::TypeManager::init(std::u16string_view rdbUris) {
for (sal_Int32 i = 0; i != -1;) {
- OUString uri(o3tl::getToken(rdbUris, 0, ' ', i));
- if (uri.isEmpty()) {
+ std::u16string_view uri(o3tl::getToken(rdbUris, 0, ' ', i));
+ if (uri.empty()) {
continue;
}
bool optional;
@@ -2042,21 +2042,21 @@ void cppuhelper::TypeManager::init(std::u16string_view rdbUris) {
}
void cppuhelper::TypeManager::readRdbDirectory(
- OUString const & uri, bool optional)
+ std::u16string_view uri, bool optional)
{
- osl::Directory dir(uri);
+ osl::Directory dir = OUString(uri);
switch (dir.open()) {
case osl::FileBase::E_None:
break;
case osl::FileBase::E_NOENT:
if (optional) {
- SAL_INFO("cppuhelper", "Ignored optional " << uri);
+ SAL_INFO("cppuhelper", "Ignored optional " << OUString(uri));
return;
}
[[fallthrough]];
default:
throw css::uno::DeploymentException(
- "Cannot open directory " + uri,
+ OUString::Concat("Cannot open directory ") + uri,
static_cast< cppu::OWeakObject * >(this));
}
for (;;) {
@@ -2069,17 +2069,17 @@ void cppuhelper::TypeManager::readRdbDirectory(
}
void cppuhelper::TypeManager::readRdbFile(
- OUString const & uri, bool optional)
+ std::u16string_view uri, bool optional)
{
try {
manager_->addProvider(uri);
} catch (unoidl::NoSuchFileException &) {
if (!optional) {
throw css::uno::DeploymentException(
- uri + ": no such file",
+ OUString::Concat(uri) + ": no such file",
static_cast< cppu::OWeakObject * >(this));
}
- SAL_INFO("cppuhelper", "Ignored optional " << uri);
+ SAL_INFO("cppuhelper", "Ignored optional " << OUString(uri));
} catch (unoidl::FileFormatException & e) {
throw css::uno::DeploymentException(
("unoidl::FileFormatException for <" + e.getUri() + ">: "
@@ -2265,7 +2265,7 @@ css::uno::Any cppuhelper::TypeManager::getNamed(
css::uno::Any cppuhelper::TypeManager::getEnumMember(
rtl::Reference< unoidl::EnumTypeEntity > const & entity,
- OUString const & member)
+ std::u16string_view member)
{
auto i = std::find_if(entity->getMembers().begin(), entity->getMembers().end(),
[&member](const unoidl::EnumTypeEntity::Member& rMember) { return rMember.name == member; });
@@ -2275,16 +2275,16 @@ css::uno::Any cppuhelper::TypeManager::getEnumMember(
}
css::uno::Any cppuhelper::TypeManager::getConstant(
- OUString const & constantGroupName,
+ std::u16string_view constantGroupName,
rtl::Reference< unoidl::ConstantGroupEntity > const & entity,
- OUString const & member)
+ std::u16string_view member)
{
auto i = std::find_if(entity->getMembers().begin(), entity->getMembers().end(),
[&member](const unoidl::ConstantGroupEntity::Member& rMember) { return rMember.name == member; });
if (i != entity->getMembers().end())
return css::uno::makeAny<
css::uno::Reference< css::reflection::XTypeDescription > >(
- new ConstantDescription(constantGroupName, *i));
+ new ConstantDescription(OUString(constantGroupName), *i));
return css::uno::Any();
}
diff --git a/cppuhelper/source/typemanager.hxx b/cppuhelper/source/typemanager.hxx
index 28c193191267..1a795fe22f8e 100644
--- a/cppuhelper/source/typemanager.hxx
+++ b/cppuhelper/source/typemanager.hxx
@@ -90,9 +90,9 @@ private:
css::uno::Sequence< css::uno::TypeClass > const & types,
css::reflection::TypeDescriptionSearchDepth depth) override;
- void readRdbDirectory(OUString const & uri, bool optional);
+ void readRdbDirectory(std::u16string_view uri, bool optional);
- void readRdbFile(OUString const & uri, bool optional);
+ void readRdbFile(std::u16string_view uri, bool optional);
css::uno::Any getSequenceType(OUString const & name);
@@ -108,12 +108,12 @@ private:
static css::uno::Any getEnumMember(
rtl::Reference< unoidl::EnumTypeEntity > const & entity,
- OUString const & member);
+ std::u16string_view member);
static css::uno::Any getConstant(
- OUString const & constantGroupName,
+ std::u16string_view constantGroupName,
rtl::Reference< unoidl::ConstantGroupEntity > const & entity,
- OUString const & member);
+ std::u16string_view member);
rtl::Reference< unoidl::Entity > findEntity(OUString const & name);