From d69d4961fa5ee8504b05d3f73f081848920f88e4 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Tue, 16 Dec 2025 14:08:11 +0100 Subject: [PATCH] MT#59962 AmUtils: add string to double conversion Add support for floating types. Change-Id: I75ee2ff1a6f545a7a3cd2f27014029ca9880d207 --- core/AmUtils.cpp | 6 ++++++ core/AmUtils.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/core/AmUtils.cpp b/core/AmUtils.cpp index 56d272f7..04ac789c 100644 --- a/core/AmUtils.cpp +++ b/core/AmUtils.cpp @@ -284,6 +284,12 @@ bool str2int(const string& str, int& result) return str2int(s,result); } +bool str2int(const string& str, double& result) +{ + char* s = (char*)str.c_str(); + return atof(s); +} + bool str2int(char*& str, int& result, char sep) { int ret=0; diff --git a/core/AmUtils.h b/core/AmUtils.h index 69404b1b..6c2dc00f 100644 --- a/core/AmUtils.h +++ b/core/AmUtils.h @@ -148,6 +148,8 @@ bool str2int(char*& str, unsigned int& result, char sep = ' '); */ bool str2int(const string& str, int& result); +bool str2int(const string& str, double& result); + /** * Internal version of preceeding 'str2int' method. * @param str [in,out] gets incremented until sep char or error occurs