summaryrefslogtreecommitdiff
path: root/tools/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-28 14:12:35 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-29 08:53:22 +0200
commitd3849255b76e92a42f653c266b88945708984c4f (patch)
treeff1eab21b9e5a1ea00e1573db4b4595ba51b0098 /tools/source
parentf9b6bd6336b35de060f6f5bdd91517caf5e9a56e (diff)
use more string_view in INetURLObject
Change-Id: I4462f7cf4740fa4d1b129d76a0775f4250f41bbd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133555 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools/source')
-rw-r--r--tools/source/fsys/urlobj.cxx32
-rw-r--r--tools/source/inet/inetmsg.cxx32
2 files changed, 33 insertions, 31 deletions
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index a4bc5ab0922d..4d7a73999e7f 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -719,14 +719,14 @@ OUString parseScheme(
}
-bool INetURLObject::setAbsURIRef(OUString const & rTheAbsURIRef,
+bool INetURLObject::setAbsURIRef(std::u16string_view rTheAbsURIRef,
EncodeMechanism eMechanism,
rtl_TextEncoding eCharset,
bool bSmart,
FSysStyle eStyle)
{
- sal_Unicode const * pPos = rTheAbsURIRef.getStr();
- sal_Unicode const * pEnd = pPos + rTheAbsURIRef.getLength();
+ sal_Unicode const * pPos = rTheAbsURIRef.data();
+ sal_Unicode const * pEnd = pPos + rTheAbsURIRef.size();
setInvalid();
@@ -3200,13 +3200,13 @@ failed:
return false;
}
-bool INetURLObject::setPath(OUString const & rThePath,
+bool INetURLObject::setPath(std::u16string_view rThePath,
EncodeMechanism eMechanism,
rtl_TextEncoding eCharset)
{
OUStringBuffer aSynPath(256);
- sal_Unicode const * p = rThePath.getStr();
- sal_Unicode const * pEnd = p + rThePath.getLength();
+ sal_Unicode const * p = rThePath.data();
+ sal_Unicode const * pEnd = p + rThePath.size();
if (!parsePath(m_eScheme, &p, pEnd, eMechanism, eCharset, false,
'/', 0x80000000, 0x80000000, 0x80000000, aSynPath)
|| p != pEnd)
@@ -3773,7 +3773,7 @@ bool INetURLObject::ConcatData(INetProtocol eTheScheme,
std::u16string_view rThePassword,
std::u16string_view rTheHost,
sal_uInt32 nThePort,
- OUString const & rThePath)
+ std::u16string_view rThePath)
{
setInvalid();
m_eScheme = eTheScheme;
@@ -3885,8 +3885,8 @@ bool INetURLObject::ConcatData(INetProtocol eTheScheme,
}
}
OUStringBuffer aSynPath(256);
- sal_Unicode const * p = rThePath.getStr();
- sal_Unicode const * pEnd = p + rThePath.getLength();
+ sal_Unicode const * p = rThePath.data();
+ sal_Unicode const * pEnd = p + rThePath.size();
if (!parsePath(m_eScheme, &p, pEnd, EncodeMechanism::WasEncoded, RTL_TEXTENCODING_UTF8, false, '/',
0x80000000, 0x80000000, 0x80000000, aSynPath)
|| p != pEnd)
@@ -3900,7 +3900,7 @@ bool INetURLObject::ConcatData(INetProtocol eTheScheme,
}
// static
-OUString INetURLObject::GetAbsURL(OUString const & rTheBaseURIRef,
+OUString INetURLObject::GetAbsURL(std::u16string_view rTheBaseURIRef,
OUString const & rTheRelURIRef,
EncodeMechanism eEncodeMechanism,
DecodeMechanism eDecodeMechanism,
@@ -4102,9 +4102,9 @@ bool INetURLObject::setName(std::u16string_view rTheName, EncodeMechanism eMecha
++p;
return setPath(
- std::u16string_view(pPathBegin, pSegBegin - pPathBegin)
+ rtl::OUStringConcatenation(std::u16string_view(pPathBegin, pSegBegin - pPathBegin)
+ encodeText(rTheName, PART_PCHAR, eMechanism, eCharset, true)
- + std::u16string_view(p, pPathEnd - p),
+ + std::u16string_view(p, pPathEnd - p)),
EncodeMechanism::NotCanonical,
RTL_TEXTENCODING_UTF8);
}
@@ -4179,9 +4179,9 @@ bool INetURLObject::setBase(std::u16string_view rTheBase, sal_Int32 nIndex,
pExtension = p;
return setPath(
- std::u16string_view(pPathBegin, pSegBegin - pPathBegin)
+ rtl::OUStringConcatenation(std::u16string_view(pPathBegin, pSegBegin - pPathBegin)
+ encodeText(rTheBase, PART_PCHAR, eMechanism, eCharset, true)
- + std::u16string_view(pExtension, pPathEnd - pExtension),
+ + std::u16string_view(pExtension, pPathEnd - pExtension)),
EncodeMechanism::NotCanonical,
RTL_TEXTENCODING_UTF8);
}
@@ -4239,9 +4239,9 @@ bool INetURLObject::setExtension(std::u16string_view rTheExtension,
pExtension = p;
return setPath(
- OUString::Concat(std::u16string_view(pPathBegin, pExtension - pPathBegin)) + "."
+ rtl::OUStringConcatenation(OUString::Concat(std::u16string_view(pPathBegin, pExtension - pPathBegin)) + "."
+ encodeText(rTheExtension, PART_PCHAR, EncodeMechanism::WasEncoded, eCharset, true)
- + std::u16string_view(p, pPathEnd - p),
+ + std::u16string_view(p, pPathEnd - p)),
EncodeMechanism::NotCanonical,
RTL_TEXTENCODING_UTF8);
}
diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx
index bb8a700d16f1..d58581e74200 100644
--- a/tools/source/inet/inetmsg.cxx
+++ b/tools/source/inet/inetmsg.cxx
@@ -22,6 +22,8 @@
#include <tools/inetmsg.hxx>
#include <comphelper/string.hxx>
#include <rtl/character.hxx>
+#include <o3tl/safeint.hxx>
+#include <o3tl/string_view.hxx>
#include <map>
@@ -52,32 +54,32 @@ static const char *months[12] =
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
-static sal_uInt16 ParseNumber(const OString& rStr, sal_Int32& nIndex)
+static sal_uInt16 ParseNumber(std::string_view rStr, size_t& nIndex)
{
- sal_Int32 n = nIndex;
- while ((n < rStr.getLength())
+ size_t n = nIndex;
+ while ((n < rStr.size())
&& rtl::isAsciiDigit(static_cast<unsigned char>(rStr[n])))
n++;
- OString aNum(rStr.copy(nIndex, (n - nIndex)));
+ std::string_view aNum(rStr.substr(nIndex, (n - nIndex)));
nIndex = n;
- return static_cast<sal_uInt16>(aNum.toInt32());
+ return static_cast<sal_uInt16>(o3tl::toInt32(aNum));
}
-static sal_uInt16 ParseMonth(const OString& rStr, sal_Int32& nIndex)
+static sal_uInt16 ParseMonth(std::string_view rStr, size_t& nIndex)
{
- sal_Int32 n = nIndex;
- while ((n < rStr.getLength())
+ size_t n = nIndex;
+ while ((n < rStr.size())
&& rtl::isAsciiAlpha(static_cast<unsigned char>(rStr[n])))
n++;
- OString aMonth(rStr.copy(nIndex, 3));
+ std::string_view aMonth(rStr.substr(nIndex, 3));
nIndex = n;
sal_uInt16 i;
for (i = 0; i < 12; i++)
- if (aMonth.equalsIgnoreAsciiCase(months[i])) break;
+ if (o3tl::equalsIgnoreAsciiCase(aMonth, months[i])) break;
return (i + 1);
}
@@ -92,20 +94,20 @@ bool INetMIMEMessage::ParseDateField (
if (aDateField.indexOf(':') != -1)
{
// Some DateTime format.
- sal_Int32 nIndex = 0;
+ size_t nIndex = 0;
// Skip over <Wkd> or <Weekday>, leading and trailing space.
- while ((nIndex < aDateField.getLength()) &&
+ while ((nIndex < o3tl::make_unsigned(aDateField.getLength())) &&
(aDateField[nIndex] == ' '))
nIndex++;
while (
- (nIndex < aDateField.getLength()) &&
+ (nIndex < o3tl::make_unsigned(aDateField.getLength())) &&
(rtl::isAsciiAlpha (static_cast<unsigned char>(aDateField[nIndex])) ||
(aDateField[nIndex] == ',') ))
nIndex++;
- while ((nIndex < aDateField.getLength()) &&
+ while ((nIndex < o3tl::make_unsigned(aDateField.getLength())) &&
(aDateField[nIndex] == ' '))
nIndex++;
@@ -143,7 +145,7 @@ bool INetMIMEMessage::ParseDateField (
rDateTime.SetSec (ParseNumber (aDateField, nIndex)); nIndex++;
rDateTime.SetNanoSec (0);
- const char cPossiblePlusMinus = nIndex < aDateField.getLength() ? aDateField[nIndex] : 0;
+ const char cPossiblePlusMinus = nIndex < o3tl::make_unsigned(aDateField.getLength()) ? aDateField[nIndex] : 0;
if (cPossiblePlusMinus == '+' || cPossiblePlusMinus == '-')
{
// Offset from GMT: "(+|-)HHMM".