From 7e3c2e46c61c4ff29b4f4e62aa7a7660042d091e Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 27 Apr 2022 16:08:54 +0200 Subject: use more string_view in unodevtools Change-Id: I60e090381e6e56d531b9727604b4755b96c608c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133516 Tested-by: Jenkins Reviewed-by: Noel Grandin --- unodevtools/source/skeletonmaker/cppcompskeleton.cxx | 6 +++--- unodevtools/source/unodevtools/options.cxx | 13 +++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'unodevtools/source') diff --git a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx index 301aebff8906..0e57d1132921 100644 --- a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx +++ b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx @@ -34,7 +34,7 @@ namespace skeletonmaker::cpp { static void generateIncludes(std::ostream & o, const std::set< OUString >& interfaces, - const OUString & propertyhelper, const bool serviceobject, + std::u16string_view propertyhelper, const bool serviceobject, const bool supportxcomponent) { o << "#include \"sal/config.h\"\n"; @@ -51,8 +51,8 @@ static void generateIncludes(std::ostream & o, o << "#include \"cppuhelper/implbase" << interfaces.size() << ".hxx\"\n"; } - if (propertyhelper.getLength() > 1) { - if (propertyhelper == "_") + if (propertyhelper.size() > 1) { + if (propertyhelper == u"_") o << "#include \"cppuhelper/rpopshlp.hxx\"\n"; else o << "#include \"cppuhelper/propertysetmixin.hxx\"\n"; diff --git a/unodevtools/source/unodevtools/options.cxx b/unodevtools/source/unodevtools/options.cxx index 290f70ce06ce..bf465af09f51 100644 --- a/unodevtools/source/unodevtools/options.cxx +++ b/unodevtools/source/unodevtools/options.cxx @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -28,18 +29,18 @@ namespace unodevtools { bool readOption( OUString * pValue, const char * pOpt, - sal_uInt32 * pnIndex, const OUString & aArg) + sal_uInt32 * pnIndex, std::u16string_view aArg) { static const OUStringLiteral dash = u"-"; - if(aArg.indexOf(dash) != 0) + if(aArg.find(dash) != 0) return false; OUString aOpt = OUString::createFromAscii( pOpt ); - if (aArg.getLength() < aOpt.getLength()) + if (aArg.size() < o3tl::make_unsigned(aOpt.getLength())) return false; - if (aOpt.equalsIgnoreAsciiCase( aArg.subView(1) )) { + if (aOpt.equalsIgnoreAsciiCase( aArg.substr(1) )) { // take next argument ++(*pnIndex); @@ -53,8 +54,8 @@ bool readOption( OUString * pValue, const char * pOpt, SAL_INFO("unodevtools", "identified option -" << pOpt << " = " << *pValue); ++(*pnIndex); return true; - } else if (aArg.indexOf(aOpt) == 1) { - *pValue = aArg.copy(1 + aOpt.getLength()); + } else if (aArg.find(aOpt) == 1) { + *pValue = aArg.substr(1 + aOpt.getLength()); SAL_INFO("unodevtools", "identified option -" << pOpt << " = " << *pValue); ++(*pnIndex); -- cgit