diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-12-11 17:44:34 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-12-11 21:25:10 +0100 |
commit | 35e471bb4d1388cf5afcdcee214cf5111edf44e3 (patch) | |
tree | bb78f4f13f131f0cb206a9707cc3cfc495a3876a /codemaker/source | |
parent | 0c06e77c122f10a1842bc908bd6e25b1110ddbd2 (diff) |
Adapt the remaining OUString functions to std string_view
...for LIBO_INTERNAL_ONLY. These had been missed by
1b43cceaea2084a0489db68cd0113508f34b6643 "Make many OUString functions take
std::u16string_view parameters" because they did not match the multi-overload
pattern that was addressed there, but they nevertheless benefit from being
changed just as well (witness e.g. the various resulting changes from copy() to
subView()).
This showed a conversion from OStringChar to std::string_view to be missing
(while the corresponding conversion form OUStringChar to std::u16string_view was
already present).
The improvement to loplugin:stringadd became necessary to fix
> [CPT] compilerplugins/clang/test/stringadd.cxx
> error: 'error' diagnostics expected but not seen:
> File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 43 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:42): simplify by merging with the preceding assignment [loplugin:stringadd]
> File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 61 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:60): simplify by merging with the preceding assignment [loplugin:stringadd]
> 2 errors generated.
Change-Id: Ie40de0616a66e60e289c1af0ca60aed6f9ecc279
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107602
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'codemaker/source')
-rw-r--r-- | codemaker/source/codemaker/global.cxx | 2 | ||||
-rw-r--r-- | codemaker/source/commoncpp/commoncpp.cxx | 4 | ||||
-rw-r--r-- | codemaker/source/cppumaker/cpputype.cxx | 35 | ||||
-rw-r--r-- | codemaker/source/cppumaker/dumputils.cxx | 2 | ||||
-rw-r--r-- | codemaker/source/cppumaker/includes.cxx | 2 | ||||
-rw-r--r-- | codemaker/source/cppumaker/includes.hxx | 3 |
6 files changed, 25 insertions, 23 deletions
diff --git a/codemaker/source/codemaker/global.cxx b/codemaker/source/codemaker/global.cxx index 8d9b5907252f..be8543cde74c 100644 --- a/codemaker/source/codemaker/global.cxx +++ b/codemaker/source/codemaker/global.cxx @@ -356,7 +356,7 @@ FileStream &operator<<(FileStream& o, const OStringBuffer& s) { return o; } -FileStream & operator <<(FileStream & out, OUString const & s) { +FileStream & operator <<(FileStream & out, std::u16string_view s) { return out << OUStringToOString(s, RTL_TEXTENCODING_UTF8); } diff --git a/codemaker/source/commoncpp/commoncpp.cxx b/codemaker/source/commoncpp/commoncpp.cxx index b7eaac4ae59e..efe0dd0b48bf 100644 --- a/codemaker/source/commoncpp/commoncpp.cxx +++ b/codemaker/source/commoncpp/commoncpp.cxx @@ -63,7 +63,7 @@ OString scopedCppName(OString const & type, bool ns_alias) } OString translateUnoToCppType( - codemaker::UnoType::Sort sort, OUString const & nucleus) + codemaker::UnoType::Sort sort, std::u16string_view nucleus) { OStringBuffer buf; if (sort <= codemaker::UnoType::Sort::Any) { @@ -75,7 +75,7 @@ OString translateUnoToCppType( buf.append(cppTypes[static_cast<int>(sort)]); } else { if (sort == codemaker::UnoType::Sort::Interface - && nucleus == "com.sun.star.uno.XInterface") + && nucleus == u"com.sun.star.uno.XInterface") { buf.append("::css::uno::XInterface"); } else { diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx index 75906b9c5f00..c98d8d76e214 100644 --- a/codemaker/source/cppumaker/cpputype.cxx +++ b/codemaker/source/cppumaker/cpputype.cxx @@ -25,6 +25,7 @@ #include <cstdlib> #include <map> #include <set> +#include <string_view> #include <memory> #include <vector> #include <iostream> @@ -164,7 +165,7 @@ public: void dump(CppuOptions const & options); void dumpFile( - OUString const & uri, OUString const & name, bool hpp, + std::u16string_view uri, OUString const & name, bool hpp, CppuOptions const & options); void dumpDependedTypes( @@ -219,7 +220,7 @@ protected: OUString resolveOuterTypedefs(OUString const & name) const; - OUString resolveAllTypedefs(OUString const & name) const; + OUString resolveAllTypedefs(std::u16string_view name) const; codemaker::cpp::IdentifierTranslationMode isGlobal() const; @@ -412,7 +413,7 @@ void CppuType::dump(CppuOptions const & options) } void CppuType::dumpFile( - OUString const & uri, OUString const & name, bool hpp, + std::u16string_view uri, OUString const & name, bool hpp, CppuOptions const & options) { OUString fileUri( @@ -990,7 +991,7 @@ OUString CppuType::resolveOuterTypedefs(OUString const & name) const } } -OUString CppuType::resolveAllTypedefs(OUString const & name) const +OUString CppuType::resolveAllTypedefs(std::u16string_view name) const { sal_Int32 k1; OUString n(b2u(codemaker::UnoType::decompose(u2b(name), &k1))); @@ -1126,11 +1127,11 @@ private: } void dumpExceptionTypeName( - FileStream & out, OUString const & prefix, sal_uInt32 index, - OUString const & name) const; + FileStream & out, std::u16string_view prefix, sal_uInt32 index, + std::u16string_view name) const; sal_Int32 dumpExceptionTypeNames( - FileStream & out, OUString const & prefix, + FileStream & out, std::u16string_view prefix, std::vector< OUString > const & exceptions, bool runtimeException) const; rtl::Reference< unoidl::InterfaceTypeEntity > entity_; @@ -1456,9 +1457,9 @@ void InterfaceType::dumpCppuAttributes(FileStream & out, sal_uInt32 & index) << "::rtl::OUString sAttributeName" << n << "( \"" << name_ << "::" << attr.name << "\" );\n"; sal_Int32 getExcn = dumpExceptionTypeNames( - out, "get", attr.getExceptions, false); + out, u"get", attr.getExceptions, false); sal_Int32 setExcn = dumpExceptionTypeNames( - out, "set", attr.setExceptions, false); + out, u"set", attr.setExceptions, false); out << indent() << ("typelib_typedescription_newExtendedInterfaceAttribute(" " &pAttribute,\n"); @@ -1525,7 +1526,7 @@ void InterfaceType::dumpCppuMethods(FileStream & out, sal_uInt32 & index) ++m; } sal_Int32 excn = dumpExceptionTypeNames( - out, "", method.exceptions, + out, u"", method.exceptions, method.name != "acquire" && method.name != "release"); out << indent() << "::rtl::OUString sReturnType" << n << "( \"" << returnType << "\" );\n" << indent() @@ -1589,15 +1590,15 @@ void InterfaceType::dumpMethodsCppuDecl( } void InterfaceType::dumpExceptionTypeName( - FileStream & out, OUString const & prefix, sal_uInt32 index, - OUString const & name) const + FileStream & out, std::u16string_view prefix, sal_uInt32 index, + std::u16string_view name) const { out << indent() << "::rtl::OUString the_" << prefix << "ExceptionName" << index << "( \"" << name << "\" );\n"; } sal_Int32 InterfaceType::dumpExceptionTypeNames( - FileStream & out, OUString const & prefix, + FileStream & out, std::u16string_view prefix, std::vector< OUString > const & exceptions, bool runtimeException) const { sal_Int32 count = 0; @@ -1608,7 +1609,7 @@ sal_Int32 InterfaceType::dumpExceptionTypeNames( } if (runtimeException) { dumpExceptionTypeName( - out, prefix, count++, "com.sun.star.uno.RuntimeException"); + out, prefix, count++, u"com.sun.star.uno.RuntimeException"); } if (count != 0) { out << indent() << "rtl_uString * the_" << prefix << "Exceptions[] = {"; @@ -1765,7 +1766,7 @@ void ConstantGroup::dumpDeclaration(FileStream & out) } } -void dumpTypeParameterName(FileStream & out, OUString const & name) +void dumpTypeParameterName(FileStream & out, std::u16string_view name) { // Prefix all type parameters with "typeparam_" to avoid problems when a // struct member has the same name as a type parameter, as in @@ -2722,7 +2723,7 @@ void PolyStructType::dumpTemplateParameters(FileStream & out) const out << " >"; } -OUString typeToIdentifier(OUString const & name) +OUString typeToIdentifier(std::u16string_view name) { sal_Int32 k; OUString n(b2u(codemaker::UnoType::decompose(u2b(name), &k))); @@ -3553,7 +3554,7 @@ private: }; void failsToSupply( - FileStream & o, OUString const & service, OString const & type) + FileStream & o, std::u16string_view service, OString const & type) { o << "::rtl::OUString(\"component context fails to supply service \") + \"" << service << "\" + \" of type \" + \"" << type << "\""; diff --git a/codemaker/source/cppumaker/dumputils.cxx b/codemaker/source/cppumaker/dumputils.cxx index 1f993b3ef7d8..15b62e04a407 100644 --- a/codemaker/source/cppumaker/dumputils.cxx +++ b/codemaker/source/cppumaker/dumputils.cxx @@ -70,7 +70,7 @@ bool dumpNamespaceClose( } void dumpTypeIdentifier(FileStream & out, OUString const & entityName) { - out << entityName.copy(entityName.lastIndexOf('.') + 1); + out << entityName.subView(entityName.lastIndexOf('.') + 1); } } diff --git a/codemaker/source/cppumaker/includes.cxx b/codemaker/source/cppumaker/includes.cxx index a07c651bec01..db7dae46bccc 100644 --- a/codemaker/source/cppumaker/includes.cxx +++ b/codemaker/source/cppumaker/includes.cxx @@ -265,7 +265,7 @@ void Includes::dumpInclude( << (hpp ? "hpp" : "hdl") << "\"\n"; } -bool Includes::isInterfaceType(OString const & entityName) const { +bool Includes::isInterfaceType(std::string_view entityName) const { return m_manager->getSort(b2u(entityName)) == UnoType::Sort::Interface; } diff --git a/codemaker/source/cppumaker/includes.hxx b/codemaker/source/cppumaker/includes.hxx index d8070217fe3b..0362c417ac2a 100644 --- a/codemaker/source/cppumaker/includes.hxx +++ b/codemaker/source/cppumaker/includes.hxx @@ -21,6 +21,7 @@ #include <rtl/ref.hxx> #include <rtl/ustring.hxx> +#include <string_view> #include <vector> #include "dependencies.hxx" @@ -68,7 +69,7 @@ private: Includes(Includes const &) = delete; Includes& operator =(const Includes&) = delete; - bool isInterfaceType(OString const & entityName) const; + bool isInterfaceType(std::string_view entityName) const; rtl::Reference< TypeManager > m_manager; Dependencies::Map m_map; |