summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-11 14:49:08 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-11 17:44:46 +0200
commit6fc3dfd3f1b5cb13101299df42444f2ff0493846 (patch)
tree404a816727baa934e77c6e474cc57e83a7aa2754 /i18npool
parent8cbb08de38fc1a2f9d2ea0dfbdc2be8e8110ff73 (diff)
use more string_view
found by tweaking the loplugin:stringview and making it whitelist getLength Change-Id: Ic41cd4e3026d93b70a76fe1279c6de3abbe6b4a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132820 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/inc/nativenumbersupplier.hxx2
-rw-r--r--i18npool/inc/transliteration_Numeric.hxx2
-rw-r--r--i18npool/source/localedata/LocaleNode.cxx30
-rw-r--r--i18npool/source/localedata/LocaleNode.hxx12
-rw-r--r--i18npool/source/localedata/filewriter.cxx14
-rw-r--r--i18npool/source/nativenumber/nativenumbersupplier.cxx9
-rw-r--r--i18npool/source/transliteration/transliteration_Numeric.cxx6
7 files changed, 38 insertions, 37 deletions
diff --git a/i18npool/inc/nativenumbersupplier.hxx b/i18npool/inc/nativenumbersupplier.hxx
index 01459ce9f7a5..61e336024da4 100644
--- a/i18npool/inc/nativenumbersupplier.hxx
+++ b/i18npool/inc/nativenumbersupplier.hxx
@@ -68,7 +68,7 @@ public:
const css::lang::Locale& rLocale,
sal_Int16 nNativeNumberMode,
css::uno::Sequence<sal_Int32>* pOffset,
- const OUString& rNativeNumberParams = OUString());
+ std::u16string_view rNativeNumberParams = std::u16string_view());
/// @throws css::uno::RuntimeException
static sal_Unicode getNativeNumberChar( const sal_Unicode inChar,
const css::lang::Locale& aLocale, sal_Int16 nNativeNumberMode ) ;
diff --git a/i18npool/inc/transliteration_Numeric.hxx b/i18npool/inc/transliteration_Numeric.hxx
index a01f505b929a..7c0d7ec95dfc 100644
--- a/i18npool/inc/transliteration_Numeric.hxx
+++ b/i18npool/inc/transliteration_Numeric.hxx
@@ -49,7 +49,7 @@ protected:
private:
/// @throws css::uno::RuntimeException
OUString
- transliterateBullet( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
+ transliterateBullet( std::u16string_view inStr, sal_Int32 startPos, sal_Int32 nCount,
css::uno::Sequence< sal_Int32 >* pOffset ) const;
};
diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx
index f4c0aaefdc94..721f710151da 100644
--- a/i18npool/source/localedata/LocaleNode.cxx
+++ b/i18npool/source/localedata/LocaleNode.cxx
@@ -266,7 +266,7 @@ void LCInfoNode::generateCode (const OFileWriter &of) const
of.writeParameter("Variant", aVariant);
}
else
- of.writeParameter("Variant", OUString());
+ of.writeParameter("Variant", std::u16string_view());
of.writeAsciiString("\nstatic const sal_Unicode* LCInfoArray[] = {\n");
of.writeAsciiString("\tlangID,\n");
of.writeAsciiString("\tlangDefaultName,\n");
@@ -822,7 +822,7 @@ void LCFormatNode::generateCode (const OFileWriter &of) const
if (n)
of.writeParameter("FormatDefaultName", n->getValue(), formatCount);
else
- of.writeParameter("FormatDefaultName", OUString(), formatCount);
+ of.writeParameter("FormatDefaultName", std::u16string_view(), formatCount);
}
@@ -1613,7 +1613,7 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
}
}
if (!ref_name.isEmpty() && daysNode == nullptr) {
- of.writeParameter("dayRef", "ref", i);
+ of.writeParameter("dayRef", u"ref", i);
of.writeParameter("dayRefName", ref_name, i);
nbOfDays[i] = 0;
} else {
@@ -1646,7 +1646,7 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
}
}
if (!ref_name.isEmpty() && monthsNode == nullptr) {
- of.writeParameter("monthRef", "ref", i);
+ of.writeParameter("monthRef", u"ref", i);
of.writeParameter("monthRefName", ref_name, i);
nbOfMonths[i] = 0;
} else {
@@ -1682,7 +1682,7 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
}
}
if (!ref_name.isEmpty() && genitiveMonthsNode == nullptr) {
- of.writeParameter("genitiveMonthRef", "ref", i);
+ of.writeParameter("genitiveMonthRef", u"ref", i);
of.writeParameter("genitiveMonthRefName", ref_name, i);
nbOfGenitiveMonths[i] = 0;
} else {
@@ -1719,7 +1719,7 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
}
}
if (!ref_name.isEmpty() && partitiveMonthsNode == nullptr) {
- of.writeParameter("partitiveMonthRef", "ref", i);
+ of.writeParameter("partitiveMonthRef", u"ref", i);
of.writeParameter("partitiveMonthRefName", ref_name, i);
nbOfPartitiveMonths[i] = 0;
} else {
@@ -1752,7 +1752,7 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
}
}
if (!ref_name.isEmpty() && erasNode == nullptr) {
- of.writeParameter("eraRef", "ref", i);
+ of.writeParameter("eraRef", u"ref", i);
of.writeParameter("eraRefName", ref_name, i);
nbOfEras[i] = 0;
} else {
@@ -2118,9 +2118,9 @@ void LCMiscNode::generateCode (const OFileWriter &of) const
of.writeParameter( "forbiddenEnd", forbidNode -> getChildAt(1)->getValue());
of.writeParameter( "hangingChars", forbidNode -> getChildAt(2)->getValue());
} else {
- of.writeParameter( "forbiddenBegin", OUString());
- of.writeParameter( "forbiddenEnd", OUString());
- of.writeParameter( "hangingChars", OUString());
+ of.writeParameter( "forbiddenBegin", std::u16string_view());
+ of.writeParameter( "forbiddenEnd", std::u16string_view());
+ of.writeParameter( "hangingChars", std::u16string_view());
}
of.writeAsciiString("\nstatic const sal_Unicode* LCForbiddenCharactersArray[] = {\n");
of.writeAsciiString("\tforbiddenBegin,\n");
@@ -2136,11 +2136,11 @@ void LCMiscNode::generateCode (const OFileWriter &of) const
of.writeParameter( "CharacterMode", breakNode -> getChildAt(3)->getValue());
of.writeParameter( "LineMode", breakNode -> getChildAt(4)->getValue());
} else {
- of.writeParameter( "EditMode", OUString());
- of.writeParameter( "DictionaryMode", OUString());
- of.writeParameter( "WordCountMode", OUString());
- of.writeParameter( "CharacterMode", OUString());
- of.writeParameter( "LineMode", OUString());
+ of.writeParameter( "EditMode", std::u16string_view());
+ of.writeParameter( "DictionaryMode", std::u16string_view());
+ of.writeParameter( "WordCountMode", std::u16string_view());
+ of.writeParameter( "CharacterMode", std::u16string_view());
+ of.writeParameter( "LineMode", std::u16string_view());
}
of.writeAsciiString("\nstatic const sal_Unicode* LCBreakIteratorRulesArray[] = {\n");
of.writeAsciiString("\tEditMode,\n");
diff --git a/i18npool/source/localedata/LocaleNode.hxx b/i18npool/source/localedata/LocaleNode.hxx
index bdd3eb62762e..f49b01d796f5 100644
--- a/i18npool/source/localedata/LocaleNode.hxx
+++ b/i18npool/source/localedata/LocaleNode.hxx
@@ -37,7 +37,7 @@ class OFileWriter
public:
OFileWriter(const char *pcFile, const char *locale );
~OFileWriter();
- void writeStringCharacters(const OUString& str) const;
+ void writeStringCharacters(std::u16string_view str) const;
void writeAsciiString(const char *str)const ;
void writeInt(sal_Int16 nb) const;
void writeFunction(const char *func, const char *count, const char *array) const;
@@ -50,11 +50,11 @@ public:
void writeRefFunction3(const char *func, std::u16string_view useLocale) const;
void writeIntParameter(const char* pAsciiStr, const sal_Int16 count, sal_Int16 val) const;
bool writeDefaultParameter(const char* pAsciiStr, std::u16string_view str, sal_Int16 count) const;
- void writeParameter(const char* pAsciiStr, const OUString& aChars) const;
- void writeParameter(const char* pAsciiStr, const OUString& aChars, sal_Int16 count) const;
- void writeParameter(const char* pAsciiStr, const OUString& aChars, sal_Int16 count0, sal_Int16 count1) const;
- void writeParameter(const char* pTagStr, const char* pAsciiStr, const OUString& aChars, const sal_Int16 count) const;
- void writeParameter(const char* pTagStr, const char* pAsciiStr, const OUString& aChars, sal_Int16 count0, sal_Int16 count1) const;
+ void writeParameter(const char* pAsciiStr, std::u16string_view aChars) const;
+ void writeParameter(const char* pAsciiStr, std::u16string_view aChars, sal_Int16 count) const;
+ void writeParameter(const char* pAsciiStr, std::u16string_view aChars, sal_Int16 count0, sal_Int16 count1) const;
+ void writeParameter(const char* pTagStr, const char* pAsciiStr, std::u16string_view aChars, const sal_Int16 count) const;
+ void writeParameter(const char* pTagStr, const char* pAsciiStr, std::u16string_view aChars, sal_Int16 count0, sal_Int16 count1) const;
void closeOutput() const;
/// Return the locale string, something like en_US or de_DE
const char * getLocale() const { return theLocale.c_str(); }
diff --git a/i18npool/source/localedata/filewriter.cxx b/i18npool/source/localedata/filewriter.cxx
index 4c095b14bc84..ca656a05b49d 100644
--- a/i18npool/source/localedata/filewriter.cxx
+++ b/i18npool/source/localedata/filewriter.cxx
@@ -44,9 +44,9 @@ void OFileWriter::writeAsciiString(const char* str) const
fprintf(m_f, "%s", str);
}
-void OFileWriter::writeStringCharacters(const OUString& str) const
+void OFileWriter::writeStringCharacters(std::u16string_view str) const
{
- for(int i = 0; i < str.getLength(); i++)
+ for(size_t i = 0; i < str.size(); i++)
fprintf(m_f, "0x%x, ", str[i]);
}
@@ -133,35 +133,35 @@ bool OFileWriter::writeDefaultParameter(const char* pAsciiStr, std::u16string_vi
return bBool;
}
-void OFileWriter::writeParameter(const char* pAsciiStr, const OUString& aChars) const
+void OFileWriter::writeParameter(const char* pAsciiStr, std::u16string_view aChars) const
{
fprintf(m_f, "static const sal_Unicode %s[] = {", pAsciiStr);
writeStringCharacters(aChars);
fprintf(m_f, "0x0};\n");
}
-void OFileWriter::writeParameter(const char* pAsciiStr, const OUString& aChars, sal_Int16 count) const
+void OFileWriter::writeParameter(const char* pAsciiStr, std::u16string_view aChars, sal_Int16 count) const
{
fprintf(m_f, "static const sal_Unicode %s%d[] = {", pAsciiStr, count);
writeStringCharacters(aChars);
fprintf(m_f, "0x0};\n");
}
-void OFileWriter::writeParameter(const char* pAsciiStr, const OUString& aChars, sal_Int16 count0, sal_Int16 count1) const
+void OFileWriter::writeParameter(const char* pAsciiStr, std::u16string_view aChars, sal_Int16 count0, sal_Int16 count1) const
{
fprintf(m_f, "static const sal_Unicode %s%d%d[] = {", pAsciiStr, count0, count1);
writeStringCharacters(aChars);
fprintf(m_f, "0x0};\n");
}
-void OFileWriter::writeParameter(const char* pTagStr, const char* pAsciiStr, const OUString& aChars, const sal_Int16 count) const
+void OFileWriter::writeParameter(const char* pTagStr, const char* pAsciiStr, std::u16string_view aChars, const sal_Int16 count) const
{
fprintf(m_f, "static const sal_Unicode %s%s%d[] = {", pTagStr, pAsciiStr, count);
writeStringCharacters(aChars);
fprintf(m_f, "0x0};\n");
}
-void OFileWriter::writeParameter(const char* pTagStr, const char* pAsciiStr, const OUString& aChars, sal_Int16 count0, sal_Int16 count1) const
+void OFileWriter::writeParameter(const char* pTagStr, const char* pAsciiStr, std::u16string_view aChars, sal_Int16 count0, sal_Int16 count1) const
{
fprintf(m_f, "static const sal_Unicode %s%s%d%d[] = {", pTagStr, pAsciiStr, count0, count1);
writeStringCharacters(aChars);
diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx b/i18npool/source/nativenumber/nativenumbersupplier.cxx
index c3c1cc6139ff..0f5c74f8bd56 100644
--- a/i18npool/source/nativenumber/nativenumbersupplier.cxx
+++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx
@@ -26,6 +26,7 @@
#include "data/numberchar.h"
#include <comphelper/processfactory.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <o3tl/string_view.hxx>
#include <map>
#include <mutex>
#include <memory>
@@ -637,7 +638,7 @@ OUString getNumberText(const Locale& rLocale, const OUString& rNumberString,
OUString NativeNumberSupplierService::getNativeNumberString(const OUString& aNumberString, const Locale& rLocale,
sal_Int16 nNativeNumberMode,
Sequence<sal_Int32>* pOffset,
- const OUString& rNativeNumberParams)
+ std::u16string_view rNativeNumberParams)
{
if (!isValidNatNumImpl(rLocale, nNativeNumberMode))
return aNumberString;
@@ -672,17 +673,17 @@ OUString NativeNumberSupplierService::getNativeNumberString(const OUString& aNum
size_t nCasing;
for (nCasing = 0; nCasing < SAL_N_ELEMENTS(Casings); ++nCasing)
{
- if (rNativeNumberParams.startsWith( Casings[nCasing].aLiteral))
+ if (o3tl::starts_with(rNativeNumberParams, Casings[nCasing].aLiteral))
{
nStripCase = Casings[nCasing].aLiteral.size();
break;
}
}
- if (nStripCase > 0 && (rNativeNumberParams.getLength() == nStripCase ||
+ if (nStripCase > 0 && (static_cast<sal_Int32>(rNativeNumberParams.size()) == nStripCase ||
rNativeNumberParams[nStripCase++] == ' '))
{
- OUString aStr = getNumberText(rLocale, aNumberString, rNativeNumberParams.subView(nStripCase));
+ OUString aStr = getNumberText(rLocale, aNumberString, rNativeNumberParams.substr(nStripCase));
if (!xCharClass.is())
xCharClass = CharacterClassification::create(comphelper::getProcessComponentContext());
diff --git a/i18npool/source/transliteration/transliteration_Numeric.cxx b/i18npool/source/transliteration/transliteration_Numeric.cxx
index 57c5b7e9942b..e0717379ed4c 100644
--- a/i18npool/source/transliteration/transliteration_Numeric.cxx
+++ b/i18npool/source/transliteration/transliteration_Numeric.cxx
@@ -58,13 +58,13 @@ Sequence< OUString > SAL_CALL
#define NUMBER_ZERO 0x30
OUString
-transliteration_Numeric::transliterateBullet( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
+transliteration_Numeric::transliterateBullet( std::u16string_view inStr, sal_Int32 startPos, sal_Int32 nCount,
Sequence< sal_Int32 >* pOffset ) const
{
sal_Int32 number = -1, j = 0, endPos = startPos + nCount;
- if (endPos > inStr.getLength())
- endPos = inStr.getLength();
+ if (endPos > static_cast<sal_Int32>(inStr.size()))
+ endPos = inStr.size();
rtl_uString* pStr = rtl_uString_alloc(nCount);
sal_Unicode* out = pStr->buffer;