summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-12-28 17:56:40 +0100
committerStephan Bergmann <sbergman@redhat.com>2020-12-29 16:42:33 +0100
commit042033f1e6da22616cb76c8d950c20c9efecbad5 (patch)
tree26b3f1f42d067506f44550b410f3fb9640616a5b /l10ntools
parentccfd8e9d09f9ac0a0ea92d0f378391006faaf934 (diff)
loplugin:stringviewparam: operator +
Change-Id: I044dd21b63d7eb03224675584fa143009c6b6008 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108418 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'l10ntools')
-rw-r--r--l10ntools/inc/common.hxx4
-rw-r--r--l10ntools/inc/export.hxx11
-rw-r--r--l10ntools/inc/helper.hxx5
-rw-r--r--l10ntools/inc/helpmerge.hxx6
-rw-r--r--l10ntools/inc/po.hxx10
-rw-r--r--l10ntools/inc/xrmmerge.hxx4
-rw-r--r--l10ntools/source/common.cxx2
-rw-r--r--l10ntools/source/helper.cxx4
-rw-r--r--l10ntools/source/helpmerge.cxx2
-rw-r--r--l10ntools/source/merge.cxx12
-rw-r--r--l10ntools/source/po.cxx18
-rw-r--r--l10ntools/source/xrmmerge.cxx4
12 files changed, 47 insertions, 35 deletions
diff --git a/l10ntools/inc/common.hxx b/l10ntools/inc/common.hxx
index 993d5152967e..78bbbfdb83cc 100644
--- a/l10ntools/inc/common.hxx
+++ b/l10ntools/inc/common.hxx
@@ -15,6 +15,8 @@
#include <sal/config.h>
#include <iostream>
+#include <string_view>
+
#include <rtl/string.hxx>
#include "po.hxx"
@@ -48,7 +50,7 @@ void writeUsage(const OString& rName, const OString& rFileType);
/// Write out a PoEntry with attention to exceptions
void writePoEntry(
const OString& rExecutable, PoOfstream& rPoStream, const OString& rSourceFile,
- const OString& rResType, const OString& rGroupId, const OString& rLocalId,
+ std::string_view rResType, const OString& rGroupId, const OString& rLocalId,
const OString& rHelpText, const OString& rText, const PoEntry::TYPE eType = PoEntry::TTEXT );
}
diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx
index 1ca56e4fe75d..183cecea2531 100644
--- a/l10ntools/inc/export.hxx
+++ b/l10ntools/inc/export.hxx
@@ -36,6 +36,7 @@
#include <vector>
#include <queue>
#include <string>
+#include <string_view>
#ifdef _WIN32
#include <direct.h>
@@ -112,7 +113,7 @@ public:
Generate QTZ string with ResData
For executable which works one language and without PO files.
*/
- static OString GetQTZText(const ResData& rResData, const OString& rOrigText);
+ static OString GetQTZText(const ResData& rResData, std::string_view rOrigText);
};
@@ -126,8 +127,8 @@ class MergeDataFile
std::set<OString> aLanguageSet;
MergeEntrys *GetMergeData( ResData *pResData , bool bCaseSensitive = false );
- void InsertEntry(const OString &rTYP, const OString &rGID,
- const OString &rLID, const OString &nLang,
+ void 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 &sFilename,
bool bFirstLang, bool bCaseSensitive);
@@ -143,8 +144,8 @@ class MergeDataFile
MergeEntrys *GetMergeEntrys( ResData *pResData );
MergeEntrys *GetMergeEntrysCaseSensitive( ResData *pResData );
- static OString CreateKey(const OString& rTYP, const OString& rGID,
- const OString& rLID, const OString& rFilename, bool bCaseSensitive);
+ static OString CreateKey(std::string_view rTYP, std::string_view rGID,
+ std::string_view rLID, const OString& rFilename, bool bCaseSensitive);
};
diff --git a/l10ntools/inc/helper.hxx b/l10ntools/inc/helper.hxx
index 621218a0c1b7..c63f781a5d91 100644
--- a/l10ntools/inc/helper.hxx
+++ b/l10ntools/inc/helper.hxx
@@ -13,6 +13,9 @@
#define INCLUDED_L10NTOOLS_INC_HELPER_HXX
#include <sal/config.h>
+
+#include <string_view>
+
#include <sal/types.h>
#include <libxml/parser.h>
@@ -36,7 +39,7 @@ OString QuotHTML( const OString &rString );
OString UnQuotHTML( const OString& rString );
/// Check whether text is a valid XML expression
-bool isWellFormedXML( OString const & text );
+bool isWellFormedXML( std::string_view text );
/// Convert xmlChar* to OString
OString xmlStrToOString( const xmlChar* pString );
diff --git a/l10ntools/inc/helpmerge.hxx b/l10ntools/inc/helpmerge.hxx
index 99c9270df9fe..3f9426b6b4de 100644
--- a/l10ntools/inc/helpmerge.hxx
+++ b/l10ntools/inc/helpmerge.hxx
@@ -20,6 +20,10 @@
#ifndef INCLUDED_L10NTOOLS_INC_HELPMERGE_HXX
#define INCLUDED_L10NTOOLS_INC_HELPMERGE_HXX
+#include <sal/config.h>
+
+#include <string_view>
+
#include "xmlparse.hxx"
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
@@ -45,7 +49,7 @@ public:
/// Method append a PO file with the content of a parsed XML file
/// @PRECOND rHelpFile is valid
static bool CreatePO( const OString &rPOFile_in, const OString &sHelpFile,
- XMLFile *pXmlFile, const OString &rGsi1 );
+ XMLFile *pXmlFile, std::string_view rGsi1 );
/// Method merges the String into XMLfile, which must point to an existing file.
bool Merge( const OString &rDestinationFile_in ,
diff --git a/l10ntools/inc/po.hxx b/l10ntools/inc/po.hxx
index 778d70fe6cc9..db513cab1f8e 100644
--- a/l10ntools/inc/po.hxx
+++ b/l10ntools/inc/po.hxx
@@ -12,6 +12,8 @@
#include <fstream>
#include <memory>
+#include <string_view>
+
#include <rtl/string.hxx>
class PoOfstream;
@@ -44,8 +46,8 @@ public:
enum Exception { NOSOURCFILE, NORESTYPE, NOGROUPID, NOSTRING, WRONGHELPTEXT };
PoEntry();
- PoEntry( const OString& rSourceFile, const OString& rResType, const OString& rGroupId,
- const OString& rLocalId, const OString& rHelpText, const OString& rText,
+ PoEntry( const OString& rSourceFile, std::string_view rResType, std::string_view rGroupId,
+ std::string_view rLocalId, const OString& rHelpText, const OString& rText,
const TYPE eType );
~PoEntry();
@@ -87,8 +89,8 @@ public:
friend class PoOfstream;
friend class PoIfstream;
- PoHeader( const OString& rExtSrc ); ///< Template Constructor
- PoHeader( const OString& rExtSrc, const OString& rPoHeaderMsgStr );
+ PoHeader( std::string_view rExtSrc ); ///< Template Constructor
+ PoHeader( std::string_view rExtSrc, const OString& rPoHeaderMsgStr );
~PoHeader();
PoHeader(const PoHeader&) = delete;
PoHeader& operator=(const PoHeader&) = delete;
diff --git a/l10ntools/inc/xrmmerge.hxx b/l10ntools/inc/xrmmerge.hxx
index fd54f113b68b..7468f43f6122 100644
--- a/l10ntools/inc/xrmmerge.hxx
+++ b/l10ntools/inc/xrmmerge.hxx
@@ -24,7 +24,7 @@
#include <sal/config.h>
#include <fstream>
-
+#include <string_view>
/// Parser for *.xrm and description.xml files
class XRMResParser
@@ -39,7 +39,7 @@ private:
OString sCurrentCloseTag;
OString sCurrentText;
protected:
- static OString GetAttribute( const OString &rToken, const OString &rAttribute );
+ static OString GetAttribute( const OString &rToken, std::string_view rAttribute );
static void Error( const OString &rError );
virtual void Output( const OString& rOutput )=0;
diff --git a/l10ntools/source/common.cxx b/l10ntools/source/common.cxx
index 84adb767c7ba..e2d14ac36431 100644
--- a/l10ntools/source/common.cxx
+++ b/l10ntools/source/common.cxx
@@ -107,7 +107,7 @@ void writeUsage(const OString& rName, const OString& rFileType)
void writePoEntry(
const OString& rExecutable, PoOfstream& rPoStream, const OString& rSourceFile,
- const OString& rResType, const OString& rGroupId, const OString& rLocalId,
+ std::string_view rResType, const OString& rGroupId, const OString& rLocalId,
const OString& rHelpText, const OString& rText, const PoEntry::TYPE eType )
{
try
diff --git a/l10ntools/source/helper.cxx b/l10ntools/source/helper.cxx
index 053375085911..80b079e27151 100644
--- a/l10ntools/source/helper.cxx
+++ b/l10ntools/source/helper.cxx
@@ -122,12 +122,12 @@ OString UnQuotHTML( const OString& rString )
return sReturn.makeStringAndClear();
}
-bool isWellFormedXML( OString const & text )
+bool isWellFormedXML( std::string_view text )
{
xmlDocPtr doc;
bool result = true;
- OString content = "<root>" + text + "</root>";
+ OString content = OString::Concat("<root>") + text + "</root>";
doc = xmlParseMemory(content.getStr(),static_cast<int>(content.getLength()));
if (doc == nullptr) {
result = false;
diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx
index c4643ea4fac4..e1beff7a5da4 100644
--- a/l10ntools/source/helpmerge.cxx
+++ b/l10ntools/source/helpmerge.cxx
@@ -81,7 +81,7 @@ HelpParser::HelpParser( const OString &rHelpFile )
bool HelpParser::CreatePO(
/*****************************************************************************/
const OString &rPOFile_in, const OString &sHelpFile,
- XMLFile* pXmlFile, const OString &rGsi1){
+ XMLFile* pXmlFile, std::string_view rGsi1){
SimpleXMLParser aParser;
//TODO: explicit BOM handling?
diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx
index 22beb6f1b962..02bfd9a74bbc 100644
--- a/l10ntools/source/merge.cxx
+++ b/l10ntools/source/merge.cxx
@@ -98,7 +98,7 @@ namespace
}
}
-OString MergeEntrys::GetQTZText(const ResData& rResData, const OString& rOrigText)
+OString MergeEntrys::GetQTZText(const ResData& rResData, std::string_view rOrigText)
{
const OString sFilename = rResData.sFilename.copy(rResData.sFilename.lastIndexOf('/')+1);
const OString sKey =
@@ -276,8 +276,8 @@ MergeEntrys *MergeDataFile::GetMergeEntrysCaseSensitive( ResData *pResData )
}
void MergeDataFile::InsertEntry(
- const OString &rTYP, const OString &rGID,
- const OString &rLID, const OString &nLANG,
+ 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,
bool bFirstLang, bool bCaseSensitive )
@@ -318,11 +318,11 @@ void MergeDataFile::InsertEntry(
}
}
-OString MergeDataFile::CreateKey(const OString& rTYP, const OString& rGID,
- const OString& rLID, const OString& rFilename, bool bCaseSensitive)
+OString MergeDataFile::CreateKey(std::string_view rTYP, std::string_view rGID,
+ std::string_view rLID, const OString& rFilename, bool bCaseSensitive)
{
static const char sStroke[] = "-";
- OString sKey = rTYP + sStroke + rGID + sStroke + rLID + sStroke +
+ OString sKey = OString::Concat(rTYP) + sStroke + rGID + sStroke + rLID + sStroke +
lcl_NormalizeFilename(rFilename);
if(bCaseSensitive)
return sKey; // officecfg case sensitive identifier
diff --git a/l10ntools/source/po.cxx b/l10ntools/source/po.cxx
index 3d001f28e3f4..5269b5e0f7f3 100644
--- a/l10ntools/source/po.cxx
+++ b/l10ntools/source/po.cxx
@@ -245,16 +245,16 @@ PoEntry::PoEntry()
}
PoEntry::PoEntry(
- const OString& rSourceFile, const OString& rResType, const OString& rGroupId,
- const OString& rLocalId, const OString& rHelpText,
+ const OString& rSourceFile, std::string_view rResType, std::string_view rGroupId,
+ std::string_view rLocalId, const OString& rHelpText,
const OString& rText, const TYPE eType )
: m_bIsInitialized( false )
{
if( rSourceFile.isEmpty() )
throw NOSOURCFILE;
- else if ( rResType.isEmpty() )
+ else if ( rResType.empty() )
throw NORESTYPE;
- else if ( rGroupId.isEmpty() )
+ else if ( rGroupId.empty() )
throw NOGROUPID;
else if ( rText.isEmpty() )
throw NOSTRING;
@@ -268,7 +268,7 @@ PoEntry::PoEntry(
OString sMsgCtxt =
sReference + "\n" +
rGroupId + "\n" +
- (rLocalId.isEmpty() ? OString() : rLocalId + "\n") +
+ (rLocalId.empty() ? OString() : OString::Concat(rLocalId) + "\n") +
rResType;
switch(eType){
case TTEXT:
@@ -444,20 +444,20 @@ namespace
}
// when updating existing files (pocheck), reuse provided po-header
-PoHeader::PoHeader( const OString& rExtSrc, const OString& rPoHeaderMsgStr )
+PoHeader::PoHeader( std::string_view rExtSrc, const OString& rPoHeaderMsgStr )
: m_pGenPo( new GenPoEntry() )
, m_bIsInitialized( false )
{
- m_pGenPo->setExtractCom("extracted from " + rExtSrc);
+ m_pGenPo->setExtractCom(OString::Concat("extracted from ") + rExtSrc);
m_pGenPo->setMsgStr(rPoHeaderMsgStr);
m_bIsInitialized = true;
}
-PoHeader::PoHeader( const OString& rExtSrc )
+PoHeader::PoHeader( std::string_view rExtSrc )
: m_pGenPo( new GenPoEntry() )
, m_bIsInitialized( false )
{
- m_pGenPo->setExtractCom("extracted from " + rExtSrc);
+ m_pGenPo->setExtractCom(OString::Concat("extracted from ") + rExtSrc);
m_pGenPo->setMsgStr(
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: https://bugs.libreoffice.org/enter_bug.cgi?"
diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx
index 62734f04ddd9..6059ad19160d 100644
--- a/l10ntools/source/xrmmerge.cxx
+++ b/l10ntools/source/xrmmerge.cxx
@@ -258,9 +258,9 @@ void XRMResParser::Execute( int nToken, char * pToken )
}
}
-OString XRMResParser::GetAttribute( const OString &rToken, const OString &rAttribute )
+OString XRMResParser::GetAttribute( const OString &rToken, std::string_view rAttribute )
{
- const OString sSearch{ " " + rAttribute + "=" };
+ const OString sSearch{ OString::Concat(" ") + rAttribute + "=" };
OString sTmp{ rToken.replace('\t', ' ') };
sal_Int32 nPos = sTmp.indexOf( sSearch );