diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-12 12:43:11 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-13 08:38:53 +0200 |
commit | fdfd517a6f75e394ddcb1e195decbfed33ba56b9 (patch) | |
tree | e3bff14e5531affcd908415b4e85d7ceac4aa1fd /unotools/source/misc | |
parent | e568c9dca8b93b96a8a130a8fb6f1bba1a33d6ea (diff) |
loplugin:stringviewparam whitelist some more functions
for which we have o3tl:: equivalents
Change-Id: I4670fd8b703ac47214be213f41e88d1c6ede7032
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132913
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unotools/source/misc')
-rw-r--r-- | unotools/source/misc/datetime.cxx | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/unotools/source/misc/datetime.cxx b/unotools/source/misc/datetime.cxx index 5bb7280bdf50..f1b1d6a8a33e 100644 --- a/unotools/source/misc/datetime.cxx +++ b/unotools/source/misc/datetime.cxx @@ -27,6 +27,7 @@ #include <rtl/math.hxx> #include <osl/diagnose.h> #include <comphelper/string.hxx> +#include <o3tl/string_view.hxx> #include <sstream> namespace @@ -56,7 +57,7 @@ namespace /** convert string to number with optional min and max values */ bool convertNumber32(sal_Int32& rValue, - const OUString& rString, + std::u16string_view rString, sal_Int32 /*nMin*/ = -1, sal_Int32 /*nMax*/ = -1) { if (!checkAllNumber(rString)) @@ -65,12 +66,12 @@ namespace return false; } - rValue = rString.toInt32(); + rValue = o3tl::toInt32(rString); return true; } bool convertNumber64(sal_Int64& rValue, - const OUString& rString, + std::u16string_view rString, sal_Int64 /*nMin*/ = -1, sal_Int64 /*nMax*/ = -1) { if (!checkAllNumber(rString)) @@ -79,7 +80,7 @@ namespace return false; } - rValue = rString.toInt64(); + rValue = o3tl::toInt64(rString); return true; } @@ -338,7 +339,7 @@ bool ISO8601parseDateTime(const OUString &rString, css::util::DateTime& rDateTim // TODO: supports only calendar dates YYYY-MM-DD // MISSING: calendar dates YYYYMMDD YYYY-MM // year, week date, ordinal date -bool ISO8601parseDate(const OUString &aDateStr, css::util::Date& rDate) +bool ISO8601parseDate(std::u16string_view aDateStr, css::util::Date& rDate) { const sal_Int32 nDateTokens {comphelper::string::getTokenCount(aDateStr, '-')}; @@ -350,13 +351,13 @@ bool ISO8601parseDate(const OUString &aDateStr, css::util::Date& rDate) sal_Int32 nDay = 30; sal_Int32 nIdx {0}; - if ( !convertNumber32( nYear, aDateStr.getToken( 0, '-', nIdx ), 0, 9999 ) ) + if ( !convertNumber32( nYear, o3tl::getToken(aDateStr, 0, '-', nIdx ), 0, 9999 ) ) return false; if ( nDateTokens >= 2 ) - if ( !convertNumber32( nMonth, aDateStr.getToken( 0, '-', nIdx ), 0, 12 ) ) + if ( !convertNumber32( nMonth, o3tl::getToken(aDateStr, 0, '-', nIdx ), 0, 12 ) ) return false; if ( nDateTokens >= 3 ) - if ( !convertNumber32( nDay, aDateStr.getToken( 0, '-', nIdx ), 0, 31 ) ) + if ( !convertNumber32( nDay, o3tl::getToken(aDateStr, 0, '-', nIdx ), 0, 31 ) ) return false; rDate.Year = static_cast<sal_uInt16>(nYear); |