codemaker/source/codemaker/typemanager.cxx |    8 ++++----
 cppuhelper/source/typemanager.cxx          |    4 ++--
 cppuhelper/source/typemanager.hxx          |    2 +-
 include/codemaker/typemanager.hxx          |    4 ++--
 include/unoidl/unoidl.hxx                  |    8 ++++----
 unoidl/source/legacyprovider.cxx           |    5 ++---
 unoidl/source/legacyprovider.hxx           |    2 +-
 unoidl/source/sourcefileprovider.cxx       |    5 ++---
 unoidl/source/sourcefileprovider.hxx       |    2 +-
 unoidl/source/sourcetreeprovider.cxx       |    3 +--
 unoidl/source/sourcetreeprovider.hxx       |    2 +-
 unoidl/source/unoidl-read.cxx              |    2 +-
 unoidl/source/unoidl-write.cxx             |    2 +-
 unoidl/source/unoidl.cxx                   |    7 +++----
 unoidl/source/unoidlprovider.cxx           |   14 +++++++-------
 unoidl/source/unoidlprovider.hxx           |    2 +-
 16 files changed, 34 insertions(+), 38 deletions(-)

New commits:
commit 9820f11ad2b1ef32e5527eec519b0a7c766e2602
Author:     Noel Grandin <[email protected]>
AuthorDate: Thu Apr 21 21:09:07 2022 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Fri Apr 22 13:27:56 2022 +0200

    address review comments on "use more string in unoidl.."
    
    on
        commit 2d9291b9433c9645b0870525211f74bfb1151555
        Author: Noel Grandin <[email protected]>
        Date:   Thu Apr 21 12:53:15 2022 +0200
        use more string_view in unoidl,codemaker
    
    Primarily reverting the findEntity call-chain to use OUString
    instead of std::u16string_view.
    
    Change-Id: Ib01b9473c859bba3791563df753823bbf0a87ce0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133302
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/codemaker/source/codemaker/typemanager.cxx 
b/codemaker/source/codemaker/typemanager.cxx
index c684d048782b..194840ca9d5b 100644
--- a/codemaker/source/codemaker/typemanager.cxx
+++ b/codemaker/source/codemaker/typemanager.cxx
@@ -33,15 +33,15 @@ TypeManager::TypeManager(): manager_(new unoidl::Manager) {}
 
 TypeManager::~TypeManager() {}
 
-void TypeManager::loadProvider(std::u16string_view uri, bool primary) {
+void TypeManager::loadProvider(OUString const & uri, bool primary) {
     rtl::Reference< unoidl::Provider > prov(manager_->addProvider(uri));
     if (primary) {
         primaryProviders_.push_back(prov);
     }
 }
 
-bool TypeManager::foundAtPrimaryProvider(std::u16string_view name) const {
-    if (name.empty()) {
+bool TypeManager::foundAtPrimaryProvider(OUString const & name) const {
+    if (name.isEmpty()) {
         return !primaryProviders_.empty();
     }
     for (const rtl::Reference< unoidl::Provider >& xProvider : 
primaryProviders_)
@@ -51,7 +51,7 @@ bool TypeManager::foundAtPrimaryProvider(std::u16string_view 
name) const {
         }
     }
     if (!manager_->findEntity(name).is()) {
-        throw CannotDumpException(OUString::Concat("Unknown entity '") + name 
+ "'");
+        throw CannotDumpException("Unknown entity '" + name + "'");
     }
     return false;
 }
diff --git a/cppuhelper/source/typemanager.cxx 
b/cppuhelper/source/typemanager.cxx
index 0b19954f92d5..44105df033fa 100644
--- a/cppuhelper/source/typemanager.cxx
+++ b/cppuhelper/source/typemanager.cxx
@@ -2102,7 +2102,7 @@ css::uno::Any 
cppuhelper::TypeManager::getInstantiatedStruct(
     OUString const & name, sal_Int32 separator)
 {
     assert(name.indexOf('<') == separator && separator != -1);
-    rtl::Reference< unoidl::Entity > ent(findEntity(name.subView(0, 
separator)));
+    rtl::Reference< unoidl::Entity > ent(findEntity(name.copy(0, separator)));
     if (!ent.is()
         || (ent->getSort()
             != unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE))
@@ -2289,7 +2289,7 @@ css::uno::Any cppuhelper::TypeManager::getConstant(
 }
 
 rtl::Reference< unoidl::Entity > cppuhelper::TypeManager::findEntity(
-    std::u16string_view name)
+    OUString const & name)
 {
     try {
         return manager_->findEntity(name);
diff --git a/cppuhelper/source/typemanager.hxx 
b/cppuhelper/source/typemanager.hxx
index 615495ca7f80..28c193191267 100644
--- a/cppuhelper/source/typemanager.hxx
+++ b/cppuhelper/source/typemanager.hxx
@@ -115,7 +115,7 @@ private:
         rtl::Reference< unoidl::ConstantGroupEntity > const & entity,
         OUString const & member);
 
-    rtl::Reference< unoidl::Entity > findEntity(std::u16string_view name);
+    rtl::Reference< unoidl::Entity > findEntity(OUString const & name);
 
     rtl::Reference< unoidl::Manager > manager_;
 };
diff --git a/include/codemaker/typemanager.hxx 
b/include/codemaker/typemanager.hxx
index 0fa75caa359c..3e6f67fe4b3f 100644
--- a/include/codemaker/typemanager.hxx
+++ b/include/codemaker/typemanager.hxx
@@ -43,9 +43,9 @@ class TypeManager final : public 
salhelper::SimpleReferenceObject {
 public:
     TypeManager();
 
-    void loadProvider(std::u16string_view uri, bool primary);
+    void loadProvider(OUString const & uri, bool primary);
 
-    bool foundAtPrimaryProvider(std::u16string_view name) const;
+    bool foundAtPrimaryProvider(OUString const & name) const;
 
     codemaker::UnoType::Sort getSort(
         OUString const & name, rtl::Reference< unoidl::Entity > * entity = 
nullptr,
diff --git a/include/unoidl/unoidl.hxx b/include/unoidl/unoidl.hxx
index 50412d599e84..e2ae024d06f7 100644
--- a/include/unoidl/unoidl.hxx
+++ b/include/unoidl/unoidl.hxx
@@ -675,7 +675,7 @@ public:
     virtual rtl::Reference< MapCursor > createRootCursor() const = 0;
 
     // throws FileFormatException:
-    virtual rtl::Reference< Entity > findEntity(std::u16string_view name)
+    virtual rtl::Reference< Entity > findEntity(OUString const & name)
         const = 0;
 
 protected:
@@ -689,10 +689,10 @@ public:
     Manager() {}
 
     // throws FileFormatException, NoSuchFileException:
-    rtl::Reference< Provider > addProvider(std::u16string_view uri);
+    rtl::Reference< Provider > addProvider(OUString const & uri);
 
     // throws FileFormatException:
-    rtl::Reference< Entity > findEntity(std::u16string_view name) const;
+    rtl::Reference< Entity > findEntity(OUString const & name) const;
 
     // throws FileFormatException:
     rtl::Reference< MapCursor > createCursor(OUString const & name) const;
@@ -701,7 +701,7 @@ private:
     virtual SAL_DLLPRIVATE ~Manager() noexcept override;
 
     SAL_DLLPRIVATE rtl::Reference< Provider > loadProvider(
-        std::u16string_view uri);
+        OUString const & uri);
 
     mutable osl::Mutex mutex_;
     std::vector< rtl::Reference< Provider > > providers_;
diff --git a/unoidl/source/legacyprovider.cxx b/unoidl/source/legacyprovider.cxx
index 577febd9c1b0..ab99fcf59dd1 100644
--- a/unoidl/source/legacyprovider.cxx
+++ b/unoidl/source/legacyprovider.cxx
@@ -813,12 +813,11 @@ rtl::Reference< MapCursor > 
LegacyProvider::createRootCursor() const {
     return new Cursor(&manager_, ucr_, ucr_);
 }
 
-rtl::Reference< Entity > LegacyProvider::findEntity(std::u16string_view name)
+rtl::Reference< Entity > LegacyProvider::findEntity(OUString const & name)
     const
 {
-    OUString s(name);
     return ucr_.isValid()
-        ? readEntity(&manager_, ucr_, ucr_, s.replace('.', '/'), true)
+        ? readEntity(&manager_, ucr_, ucr_, name.replace('.', '/'), true)
         : rtl::Reference< Entity >();
 }
 
diff --git a/unoidl/source/legacyprovider.hxx b/unoidl/source/legacyprovider.hxx
index 8c22dbe0451c..caa1b38c84a4 100644
--- a/unoidl/source/legacyprovider.hxx
+++ b/unoidl/source/legacyprovider.hxx
@@ -26,7 +26,7 @@ public:
     virtual rtl::Reference< MapCursor > createRootCursor() const override;
 
     // throws FileFormatException:
-    virtual rtl::Reference< Entity > findEntity(std::u16string_view name)
+    virtual rtl::Reference< Entity > findEntity(OUString const & name)
         const override;
 
 private:
diff --git a/unoidl/source/sourcefileprovider.cxx 
b/unoidl/source/sourcefileprovider.cxx
index e487fcf47590..983b7d3c3403 100644
--- a/unoidl/source/sourcefileprovider.cxx
+++ b/unoidl/source/sourcefileprovider.cxx
@@ -15,7 +15,6 @@
 
 #include "sourcefileprovider.hxx"
 #include "sourceprovider-scanner.hxx"
-#include <o3tl/string_view.hxx>
 
 namespace unoidl::detail {
 
@@ -106,12 +105,12 @@ rtl::Reference<MapCursor> 
SourceFileProvider::createRootCursor() const {
     return new Cursor(rootMap_);
 }
 
-rtl::Reference<Entity> SourceFileProvider::findEntity(std::u16string_view name)
+rtl::Reference<Entity> SourceFileProvider::findEntity(OUString const & name)
     const
 {
     std::map< OUString, rtl::Reference<Entity> > const * map = &rootMap_;
     for (sal_Int32 i = 0;;) {
-        OUString id(o3tl::getToken(name, 0, '.', i));
+        OUString id(name.getToken(0, '.', i));
         std::map< OUString, rtl::Reference<Entity> >::const_iterator j(
             map->find(id));
         if (j == map->end()) {
diff --git a/unoidl/source/sourcefileprovider.hxx 
b/unoidl/source/sourcefileprovider.hxx
index 6e586294a0c4..52fd32f3c735 100644
--- a/unoidl/source/sourcefileprovider.hxx
+++ b/unoidl/source/sourcefileprovider.hxx
@@ -28,7 +28,7 @@ public:
     virtual rtl::Reference<MapCursor> createRootCursor() const override;
 
     // throws FileFormatException:
-    virtual rtl::Reference<Entity> findEntity(std::u16string_view name) const 
override;
+    virtual rtl::Reference<Entity> findEntity(OUString const& name) const 
override;
 
 private:
     virtual ~SourceFileProvider() noexcept override;
diff --git a/unoidl/source/sourcetreeprovider.cxx 
b/unoidl/source/sourcetreeprovider.cxx
index 2f115bef44bf..fea67405cd54 100644
--- a/unoidl/source/sourcetreeprovider.cxx
+++ b/unoidl/source/sourcetreeprovider.cxx
@@ -231,10 +231,9 @@ rtl::Reference<MapCursor> 
SourceTreeProvider::createRootCursor() const {
     return new Cursor(manager_, uri_);
 }
 
-rtl::Reference<Entity> SourceTreeProvider::findEntity(std::u16string_view 
_name)
+rtl::Reference<Entity> SourceTreeProvider::findEntity(OUString const & name)
     const
 {
-    OUString name(_name);
     std::map< OUString, rtl::Reference<Entity> >::iterator ci(
         cache_.find(name));
     if (ci != cache_.end()) {
diff --git a/unoidl/source/sourcetreeprovider.hxx 
b/unoidl/source/sourcetreeprovider.hxx
index 9b2d6fd55cb9..37bd6baa1286 100644
--- a/unoidl/source/sourcetreeprovider.hxx
+++ b/unoidl/source/sourcetreeprovider.hxx
@@ -28,7 +28,7 @@ public:
     virtual rtl::Reference<MapCursor> createRootCursor() const override;
 
     // throws FileFormatException:
-    virtual rtl::Reference<Entity> findEntity(std::u16string_view name) const 
override;
+    virtual rtl::Reference<Entity> findEntity(OUString const& name) const 
override;
 
 private:
     virtual ~SourceTreeProvider() noexcept override;
diff --git a/unoidl/source/unoidl-read.cxx b/unoidl/source/unoidl-read.cxx
index 794bd0b473e7..706fe7f3d64c 100644
--- a/unoidl/source/unoidl-read.cxx
+++ b/unoidl/source/unoidl-read.cxx
@@ -103,7 +103,7 @@ std::u16string_view decomposeType(
         do {
             ++i; // skip '<' or ','
             size_t j = i;
-            for (sal_Int32 level = 0; j != nucl.size(); ++j) {
+            for (size_t level = 0; j != nucl.size(); ++j) {
                 sal_Unicode c = nucl[j];
                 if (c == ',') {
                     if (level == 0) {
diff --git a/unoidl/source/unoidl-write.cxx b/unoidl/source/unoidl-write.cxx
index dafca970c246..5ddd98468359 100644
--- a/unoidl/source/unoidl-write.cxx
+++ b/unoidl/source/unoidl-write.cxx
@@ -394,7 +394,7 @@ void mapEntities(
                     std::map< OUString, Item >::iterator k(map2->find(id));
                     if (k == map2->end()) {
                         rtl::Reference< unoidl::Entity > ent2(
-                            manager->findEntity(t.subView(0, j - 1)));
+                            manager->findEntity(t.copy(0, j - 1)));
                         assert(ent2.is());
                         k = map2->insert(std::make_pair(id, Item(ent2))).first;
                     }
diff --git a/unoidl/source/unoidl.cxx b/unoidl/source/unoidl.cxx
index 5dfce2348d0c..749f9afe4f25 100644
--- a/unoidl/source/unoidl.cxx
+++ b/unoidl/source/unoidl.cxx
@@ -164,7 +164,7 @@ ServiceBasedSingletonEntity::~ServiceBasedSingletonEntity() 
noexcept {}
 
 Provider::~Provider() noexcept {}
 
-rtl::Reference< Provider > Manager::addProvider(std::u16string_view uri) {
+rtl::Reference< Provider > Manager::addProvider(OUString const & uri) {
     rtl::Reference< Provider > p(loadProvider(uri));
     assert(p.is());
     {
@@ -174,7 +174,7 @@ rtl::Reference< Provider > 
Manager::addProvider(std::u16string_view uri) {
     return p;
 }
 
-rtl::Reference< Entity > Manager::findEntity(std::u16string_view name) const {
+rtl::Reference< Entity > Manager::findEntity(OUString const & name) const {
     //TODO: caching? (here or in cppuhelper::TypeManager?)
     osl::MutexGuard g(mutex_);
     for (auto & i: providers_) {
@@ -194,8 +194,7 @@ rtl::Reference< MapCursor > Manager::createCursor(OUString 
const & name)
 
 Manager::~Manager() noexcept {}
 
-rtl::Reference< Provider > Manager::loadProvider(std::u16string_view _uri) {
-    OUString uri(_uri);
+rtl::Reference< Provider > Manager::loadProvider(OUString const & uri) {
     osl::DirectoryItem item;
     if (osl::DirectoryItem::get(uri, item) == osl::FileBase::E_None) {
         osl::FileStatus status(osl_FileStatus_Mask_Type);
diff --git a/unoidl/source/unoidlprovider.cxx b/unoidl/source/unoidlprovider.cxx
index de158f10b1b2..0b29906a8cb2 100644
--- a/unoidl/source/unoidlprovider.cxx
+++ b/unoidl/source/unoidlprovider.cxx
@@ -16,6 +16,7 @@
 #include <string_view>
 #include <vector>
 
+#include <o3tl/string_view.hxx>
 #include <osl/endian.h>
 #include <osl/file.h>
 #include <rtl/character.hxx>
@@ -27,7 +28,6 @@
 #include <sal/types.h>
 #include <salhelper/simplereferenceobject.hxx>
 #include <unoidl/unoidl.hxx>
-#include <o3tl/string_view.hxx>
 
 #include "unoidlprovider.hxx"
 
@@ -508,7 +508,7 @@ Compare compare(
 
 sal_uInt32 findInMap(
     rtl::Reference< MappedFile > const & file, MapEntry const * mapBegin,
-    sal_uInt32 mapSize, std::u16string_view name, sal_Int32 nameOffset,
+    sal_uInt32 mapSize, OUString const & name, sal_Int32 nameOffset,
     sal_Int32 nameLength)
 {
     if (mapSize == 0) {
@@ -1349,21 +1349,21 @@ rtl::Reference< MapCursor > 
UnoidlProvider::createRootCursor() const {
         rtl::Reference<UnoidlModuleEntity>(), map_);
 }
 
-rtl::Reference< Entity > UnoidlProvider::findEntity(std::u16string_view name) 
const
+rtl::Reference< Entity > UnoidlProvider::findEntity(OUString const & name) 
const
 {
     NestedMap map(map_);
     bool cgroup = false;
     for (sal_Int32 i = 0;;) {
-        size_t j = name.find('.', i);
-        if (j == std::u16string_view::npos) {
-            j = name.size();
+        sal_Int32 j = name.indexOf('.', i);
+        if (j == -1) {
+            j = name.getLength();
         }
         sal_Int32 off = findInMap(
             file_, map.map.begin, map.map.size, name, i, j - i);
         if (off == 0) {
             return rtl::Reference< Entity >();
         }
-        if (j == name.size()) {
+        if (j == name.getLength()) {
             return cgroup
                 ? rtl::Reference< Entity >()
                 : readEntity(file_, off, std::set(map.trace));
diff --git a/unoidl/source/unoidlprovider.hxx b/unoidl/source/unoidlprovider.hxx
index 244bd26f3513..734f8592b814 100644
--- a/unoidl/source/unoidlprovider.hxx
+++ b/unoidl/source/unoidlprovider.hxx
@@ -41,7 +41,7 @@ public:
     virtual rtl::Reference< MapCursor > createRootCursor() const override;
 
     // throws FileFormatException:
-    virtual rtl::Reference< Entity > findEntity(std::u16string_view name)
+    virtual rtl::Reference< Entity > findEntity(OUString const & name)
         const override;
 
 private:

Reply via email to