From 74957c7d2f3697fbf2b6f4d6a31c61d5d7df039b Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 13 Apr 2022 13:54:22 +0200 Subject: use more string_view in l10ntools Change-Id: I93958e8e2dc1e172413ff697d6b6be975cff064d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132956 Tested-by: Jenkins Reviewed-by: Noel Grandin --- l10ntools/source/helpex.cxx | 2 +- l10ntools/source/localize.cxx | 8 ++++---- l10ntools/source/merge.cxx | 16 ++++++++-------- l10ntools/source/po.cxx | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'l10ntools/source') diff --git a/l10ntools/source/helpex.cxx b/l10ntools/source/helpex.cxx index e9f744a95bbc..97e574fc7dde 100644 --- a/l10ntools/source/helpex.cxx +++ b/l10ntools/source/helpex.cxx @@ -81,7 +81,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) std::unique_ptr pMergeDataFile; if( aArgs.m_sLanguage != "qtz") { - pMergeDataFile.reset(new MergeDataFile(aArgs.m_sMergeSrc, OString(), false, false )); + pMergeDataFile.reset(new MergeDataFile(aArgs.m_sMergeSrc, "", false, false )); } std::string sTemp; aInput >> sTemp; diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx index d89f89150d04..2ec0123616f4 100644 --- a/l10ntools/source/localize.cxx +++ b/l10ntools/source/localize.cxx @@ -116,7 +116,7 @@ void handleCommand( } void InitPoFile( - std::string_view rProject, const OString& rInPath, + std::string_view rProject, std::string_view rInPath, std::string_view rPotDir, const OString& rOutPath ) { //Create directory for po file @@ -150,9 +150,9 @@ void InitPoFile( throw false; //TODO } - const sal_Int32 nProjectInd = rInPath.indexOf(rProject); - const OString relativPath = - rInPath.copy(nProjectInd, rInPath.lastIndexOf('/')- nProjectInd); + const size_t nProjectInd = rInPath.find(rProject); + const std::string_view relativPath = + rInPath.substr(nProjectInd, rInPath.rfind('/')- nProjectInd); PoHeader aTmp(relativPath); aPoOutPut.writeHeader(aTmp); diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx index 78334c70c8fe..8a6964c61fa4 100644 --- a/l10ntools/source/merge.cxx +++ b/l10ntools/source/merge.cxx @@ -32,12 +32,12 @@ namespace { - OString lcl_NormalizeFilename(const OString& rFilename) + OString lcl_NormalizeFilename(std::string_view rFilename) { - return rFilename.copy( + return OString(rFilename.substr( std::max( - rFilename.lastIndexOf( '\\' ), - rFilename.lastIndexOf( '/' ))+1); + rFilename.rfind( '\\' ), + rFilename.rfind( '/' ))+1)); }; bool lcl_ReadPoChecked( @@ -111,7 +111,7 @@ OString MergeEntrys::GetQTZText(const ResData& rResData, std::string_view rOrigT MergeDataFile::MergeDataFile( - const OString &rFileName, const OString &rFile, + const OString &rFileName, std::string_view rFile, bool bCaseSensitive, bool bWithQtz ) { auto const env = getenv("ENABLE_RELEASE_BUILD"); @@ -281,7 +281,7 @@ void MergeDataFile::InsertEntry( std::string_view rTYP, std::string_view rGID, std::string_view rLID, const OString &nLANG, const OString &rTEXT, const OString &rQHTEXT, - const OString &rTITLE, const OString &rInFilename, + const OString &rTITLE, std::string_view rInFilename, bool bFirstLang, bool bCaseSensitive ) { MergeEntrys *pMergeEntrys = nullptr; @@ -311,7 +311,7 @@ void MergeDataFile::InsertEntry( // insert the cur string if( nLANG =="qtz" ) { - const OString sTemp = rInFilename + rGID + rLID + rTYP; + const OString sTemp = OString::Concat(rInFilename) + rGID + rLID + rTYP; pMergeEntrys->InsertEntry( nLANG, rTEXT.isEmpty()? rTEXT : PoEntry::genKeyId(sTemp + rTEXT) + GetDoubleBars() + rTEXT, @@ -325,7 +325,7 @@ void MergeDataFile::InsertEntry( } OString MergeDataFile::CreateKey(std::string_view rTYP, std::string_view rGID, - std::string_view rLID, const OString& rFilename, bool bCaseSensitive) + std::string_view rLID, std::string_view rFilename, bool bCaseSensitive) { static const char sStroke[] = "-"; OString sKey = OString::Concat(rTYP) + sStroke + rGID + sStroke + rLID + sStroke + diff --git a/l10ntools/source/po.cxx b/l10ntools/source/po.cxx index 2bf522d4b05e..b93126838c99 100644 --- a/l10ntools/source/po.cxx +++ b/l10ntools/source/po.cxx @@ -240,12 +240,12 @@ PoEntry::PoEntry() } PoEntry::PoEntry( - const OString& rSourceFile, std::string_view rResType, std::string_view rGroupId, + std::string_view rSourceFile, std::string_view rResType, std::string_view rGroupId, std::string_view rLocalId, std::string_view rHelpText, const OString& rText, const TYPE eType ) : m_bIsInitialized( false ) { - if( rSourceFile.isEmpty() ) + if( rSourceFile.empty() ) throw NOSOURCFILE; else if ( rResType.empty() ) throw NORESTYPE; @@ -257,7 +257,7 @@ PoEntry::PoEntry( throw WRONGHELPTEXT; m_pGenPo.reset( new GenPoEntry() ); - OString sReference = rSourceFile.copy(rSourceFile.lastIndexOf('/')+1); + OString sReference(rSourceFile.substr(rSourceFile.rfind('/')+1)); m_pGenPo->setReference(sReference); OString sMsgCtxt = -- cgit