diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-26 13:27:39 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-26 19:37:20 +0200 |
commit | 5fe702f1b69a02a274621a01db68256a94edfd36 (patch) | |
tree | 8b07b80a9046040ba7da685e4063f5f21e1f0eaa /include | |
parent | cf2dc247ff5f726238856e9b46a4926a30430e14 (diff) |
add o3tl::toUInt32
Change-Id: I07f11bf12fbe1d1c2d812fa0965d6e632e1e1aba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133437
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r-- | include/o3tl/string_view.hxx | 16 | ||||
-rw-r--r-- | include/oox/helper/attributelist.hxx | 2 |
2 files changed, 17 insertions, 1 deletions
diff --git a/include/o3tl/string_view.hxx b/include/o3tl/string_view.hxx index 2438500768fe..6138f5c09c88 100644 --- a/include/o3tl/string_view.hxx +++ b/include/o3tl/string_view.hxx @@ -424,6 +424,22 @@ inline sal_Int32 toInt32(std::string_view str, sal_Int16 radix = 10) return n; } +// Like OString::toUInt32, but for std::string_view: +inline sal_uInt32 toUInt32(std::u16string_view str, sal_Int16 radix = 10) +{ + sal_Int64 n = rtl_ustr_toInt64_WithLength(str.data(), radix, str.size()); + if (n < 0 || n > SAL_MAX_UINT32) + n = 0; + return n; +} +inline sal_uInt32 toUInt32(std::string_view str, sal_Int16 radix = 10) +{ + sal_Int64 n = rtl_str_toInt64_WithLength(str.data(), radix, str.size()); + if (n < 0 || n > SAL_MAX_UINT32) + n = 0; + return n; +} + // Like OString::toInt64, but for std::string_view: inline sal_Int64 toInt64(std::u16string_view str, sal_Int16 radix = 10) { diff --git a/include/oox/helper/attributelist.hxx b/include/oox/helper/attributelist.hxx index 511b00fce2a2..27101657f140 100644 --- a/include/oox/helper/attributelist.hxx +++ b/include/oox/helper/attributelist.hxx @@ -69,7 +69,7 @@ public: static sal_Int64 decodeHyper( std::u16string_view rValue ); /** Returns the 32-bit signed integer value from the passed string (hexadecimal). */ - static sal_Int32 decodeIntegerHex( const OUString& rValue ); + static sal_Int32 decodeIntegerHex( std::u16string_view rValue ); }; |