summaryrefslogtreecommitdiff
path: root/include/rtl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-26 17:47:18 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-27 12:19:55 +0200
commitd506ff97c25b5f433aa25d8b373f1a732af493d1 (patch)
tree600e211e3426a3b43407b01d6f93e5379d608b26 /include/rtl
parent148f45253f75bc724804f3231a0b04b2d453e0c7 (diff)
add string_view wrappers for rtl::math::stringToDouble
Change-Id: I114bec72cb933238675e539a8388a607226827cd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133455 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/rtl')
-rw-r--r--include/rtl/math.hxx38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/rtl/math.hxx b/include/rtl/math.hxx
index 7da30df6832b..661ddf1d131d 100644
--- a/include/rtl/math.hxx
+++ b/include/rtl/math.hxx
@@ -173,6 +173,23 @@ inline void doubleToUStringBuffer( rtl::OUStringBuffer& rBuffer, double fValue,
/** A wrapper around rtl_math_stringToDouble.
*/
+#ifdef LIBO_INTERNAL_ONLY
+inline double stringToDouble(std::string_view aString,
+ char cDecSeparator, char cGroupSeparator,
+ rtl_math_ConversionStatus * pStatus = NULL,
+ sal_Int32 * pParsedEnd = NULL)
+{
+ char const * pBegin = aString.data();
+ char const * pEnd;
+ double fResult = rtl_math_stringToDouble(pBegin,
+ pBegin + aString.size(),
+ cDecSeparator, cGroupSeparator,
+ pStatus, &pEnd);
+ if (pParsedEnd != NULL)
+ *pParsedEnd = static_cast<sal_Int32>(pEnd - pBegin);
+ return fResult;
+}
+#else
inline double stringToDouble(rtl::OString const & rString,
char cDecSeparator, char cGroupSeparator,
rtl_math_ConversionStatus * pStatus = NULL,
@@ -188,9 +205,29 @@ inline double stringToDouble(rtl::OString const & rString,
*pParsedEnd = static_cast<sal_Int32>(pEnd - pBegin);
return fResult;
}
+#endif
+
/** A wrapper around rtl_math_uStringToDouble.
*/
+#ifdef LIBO_INTERNAL_ONLY
+inline double stringToDouble(std::u16string_view aString,
+ sal_Unicode cDecSeparator,
+ sal_Unicode cGroupSeparator,
+ rtl_math_ConversionStatus * pStatus = NULL,
+ sal_Int32 * pParsedEnd = NULL)
+{
+ sal_Unicode const * pBegin = aString.data();
+ sal_Unicode const * pEnd;
+ double fResult = rtl_math_uStringToDouble(pBegin,
+ pBegin + aString.size(),
+ cDecSeparator, cGroupSeparator,
+ pStatus, &pEnd);
+ if (pParsedEnd != NULL)
+ *pParsedEnd = static_cast<sal_Int32>(pEnd - pBegin);
+ return fResult;
+}
+#else
inline double stringToDouble(rtl::OUString const & rString,
sal_Unicode cDecSeparator,
sal_Unicode cGroupSeparator,
@@ -207,6 +244,7 @@ inline double stringToDouble(rtl::OUString const & rString,
*pParsedEnd = static_cast<sal_Int32>(pEnd - pBegin);
return fResult;
}
+#endif
/** A wrapper around rtl_math_round.
*/