summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-09-27 09:37:15 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-09-27 13:31:20 +0200
commit0a7eac8576f313dcaf27ee45326d71fd6b5aea1e (patch)
tree1af6ac4da7b61da0eb5b1a68cc2d7a7491ec1f24 /configmgr
parent322ea272bba63ba779120ca5ead4a4b40d1bb93f (diff)
use more string_view in accessibility..configmgr
Change-Id: Ie16d36faac7d06e275348ed68e6c6b2518534fd6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140636 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/access.cxx15
-rw-r--r--configmgr/source/access.hxx2
-rw-r--r--configmgr/source/data.cxx20
-rw-r--r--configmgr/source/data.hxx2
-rw-r--r--configmgr/source/partial.cxx8
5 files changed, 24 insertions, 23 deletions
diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx
index 865d383002d3..06c000dcdbd3 100644
--- a/configmgr/source/access.cxx
+++ b/configmgr/source/access.cxx
@@ -74,6 +74,7 @@
#include <cppuhelper/queryinterface.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/weak.hxx>
+#include <o3tl/string_view.hxx>
#include <osl/interlck.h>
#include <osl/mutex.hxx>
#include <rtl/character.hxx>
@@ -1970,10 +1971,10 @@ rtl::Reference< ChildAccess > Access::getUnmodifiedChild(
return createUnmodifiedChild(name,node);
}
-rtl::Reference< ChildAccess > Access::getSubChild(OUString const & path) {
+rtl::Reference< ChildAccess > Access::getSubChild(std::u16string_view path) {
sal_Int32 i = 0;
// For backwards compatibility, allow absolute paths where meaningful:
- if( path.startsWith("/") ) {
+ if( o3tl::starts_with(path, u"/") ) {
++i;
if (!getRootAccess().is()) {
return rtl::Reference< ChildAccess >();
@@ -1986,7 +1987,7 @@ rtl::Reference< ChildAccess > Access::getSubChild(OUString const & path) {
OUString templateName1;
i = Data::parseSegment(
path, i, &name1, &setElement1, &templateName1);
- if (i == -1 || (i != path.getLength() && path[i] != '/')) {
+ if (i == -1 || (i != static_cast<sal_Int32>(path.size()) && path[i] != '/')) {
return rtl::Reference< ChildAccess >();
}
OUString name2;
@@ -1999,7 +2000,7 @@ rtl::Reference< ChildAccess > Access::getSubChild(OUString const & path) {
{
return rtl::Reference< ChildAccess >();
}
- if (i != path.getLength()) {
+ if (i != static_cast<sal_Int32>(path.size())) {
++i;
}
}
@@ -2009,7 +2010,7 @@ rtl::Reference< ChildAccess > Access::getSubChild(OUString const & path) {
bool setElement;
OUString templateName;
i = Data::parseSegment(path, i, &name, &setElement, &templateName);
- if (i == -1 || (i != path.getLength() && path[i] != '/')) {
+ if (i == -1 || (i != static_cast<sal_Int32>(path.size()) && path[i] != '/')) {
return rtl::Reference< ChildAccess >();
}
rtl::Reference< ChildAccess > child(parent->getChild(name));
@@ -2041,9 +2042,9 @@ rtl::Reference< ChildAccess > Access::getSubChild(OUString const & path) {
// For backwards compatibility, ignore a final slash after non-value
// nodes:
if (child->isValue()) {
- return i == path.getLength()
+ return i == static_cast<sal_Int32>(path.size())
? child : rtl::Reference< ChildAccess >();
- } else if (i >= path.getLength() - 1) {
+ } else if (i >= static_cast<sal_Int32>(path.size()) - 1) {
return child;
}
++i;
diff --git a/configmgr/source/access.hxx b/configmgr/source/access.hxx
index 51e43d5bcfcc..dba29c7c6495 100644
--- a/configmgr/source/access.hxx
+++ b/configmgr/source/access.hxx
@@ -366,7 +366,7 @@ private:
rtl::Reference< ChildAccess > getUnmodifiedChild(
OUString const & name);
- rtl::Reference< ChildAccess > getSubChild(OUString const & path);
+ rtl::Reference< ChildAccess > getSubChild(std::u16string_view path);
bool setChildProperty(
OUString const & name, css::uno::Any const & value,
diff --git a/configmgr/source/data.cxx b/configmgr/source/data.cxx
index f173ee1556fb..d321723eadda 100644
--- a/configmgr/source/data.cxx
+++ b/configmgr/source/data.cxx
@@ -110,18 +110,18 @@ OUString Data::createSegment(
}
sal_Int32 Data::parseSegment(
- OUString const & path, sal_Int32 index, OUString * name,
+ std::u16string_view path, sal_Int32 index, OUString * name,
bool * setElement, OUString * templateName)
{
assert(
- index >= 0 && index <= path.getLength() && name != nullptr &&
+ index >= 0 && index <= static_cast<sal_Int32>(path.size()) && name != nullptr &&
setElement != nullptr);
- sal_Int32 i = index;
- while (i < path.getLength() && path[i] != '/' && path[i] != '[') {
+ size_t i = index;
+ while (i < path.size() && path[i] != '/' && path[i] != '[') {
++i;
}
- if (i == path.getLength() || path[i] == '/') {
- *name = path.copy(index, i - index);
+ if (i == path.size() || path[i] == '/') {
+ *name = path.substr(index, i - index);
*setElement = false;
return i;
}
@@ -129,18 +129,18 @@ sal_Int32 Data::parseSegment(
if (i - index == 1 && path[index] == '*') {
templateName->clear();
} else {
- *templateName = path.copy(index, i - index);
+ *templateName = path.substr(index, i - index);
}
}
- if (++i == path.getLength()) {
+ if (++i == path.size()) {
return -1;
}
sal_Unicode del = path[i++];
if (del != '\'' && del != '"') {
return -1;
}
- sal_Int32 j = path.indexOf(del, i);
- if (j == -1 || j + 1 == path.getLength() || path[j + 1] != ']' ||
+ size_t j = path.find(del, i);
+ if (j == std::u16string_view::npos || j + 1 == path.size() || path[j + 1] != ']' ||
!decode(path, i, j, name))
{
return -1;
diff --git a/configmgr/source/data.hxx b/configmgr/source/data.hxx
index c3614e6435da..32a08e3437ce 100644
--- a/configmgr/source/data.hxx
+++ b/configmgr/source/data.hxx
@@ -54,7 +54,7 @@ struct Data {
std::u16string_view templateName, OUString const & name);
static sal_Int32 parseSegment(
- OUString const & path, sal_Int32 index, OUString * name,
+ std::u16string_view path, sal_Int32 index, OUString * name,
bool * setElement, OUString * templateName);
static OUString fullTemplateName(
diff --git a/configmgr/source/partial.cxx b/configmgr/source/partial.cxx
index f31e98549684..ae8ec599906e 100644
--- a/configmgr/source/partial.cxx
+++ b/configmgr/source/partial.cxx
@@ -34,10 +34,10 @@ namespace configmgr {
namespace {
bool parseSegment(
- OUString const & path, sal_Int32 * index, OUString * segment)
+ std::u16string_view path, sal_Int32 * index, OUString * segment)
{
assert(
- index != nullptr && *index >= 0 && *index <= path.getLength() &&
+ index != nullptr && *index >= 0 && *index <= static_cast<sal_Int32>(path.size()) &&
segment != nullptr);
if (path[(*index)++] == '/') {
OUString name;
@@ -47,10 +47,10 @@ bool parseSegment(
path, *index, &name, &setElement, &templateName);
if (*index != -1) {
*segment = Data::createSegment(templateName, name);
- return *index == path.getLength();
+ return *index == static_cast<sal_Int32>(path.size());
}
}
- throw css::uno::RuntimeException("bad path " + path);
+ throw css::uno::RuntimeException(OUString::Concat("bad path ") + path);
}
}