From a7d3197f296cfc42ad110aa133833a9d6c0b5069 Mon Sep 17 00:00:00 2001
From: Adrien Beraud <adrien.beraud@savoirfairelinux.com>
Date: Thu, 21 Nov 2024 13:48:02 -0500
Subject: [PATCH] string utils: remove stoi/stod wrapper

Change-Id: I06afa15ff33a639458a618364d4eb00197de585a
---
 src/media/media_codec.cpp                       | 10 +++++-----
 src/media/video/video_device.h                  |  2 +-
 src/string_utils.h                              | 12 ------------
 test/unitTest/string_utils/testString_utils.cpp | 12 ------------
 4 files changed, 6 insertions(+), 30 deletions(-)

diff --git a/src/media/media_codec.cpp b/src/media/media_codec.cpp
index 8b425a089..3d710db91 100644
--- a/src/media/media_codec.cpp
+++ b/src/media/media_codec.cpp
@@ -116,10 +116,10 @@ SystemAudioCodecInfo::isPCMG722() const
 void
 SystemAudioCodecInfo::setCodecSpecifications(const std::map<std::string, std::string>& details)
 {
-    decltype(bitrate) tmp_bitrate = jami::stoi(
+    decltype(bitrate) tmp_bitrate = std::stoi(
         details.at(libjami::Account::ConfProperties::CodecInfo::BITRATE));
     decltype(audioformat) tmp_audioformat = audioformat;
-    tmp_audioformat.sample_rate = jami::stoi(
+    tmp_audioformat.sample_rate = std::stoi(
         details.at(libjami::Account::ConfProperties::CodecInfo::SAMPLE_RATE));
 
     // copy back if no exception was raised
@@ -180,15 +180,15 @@ SystemVideoCodecInfo::setCodecSpecifications(const std::map<std::string, std::st
 
     auto it = details.find(libjami::Account::ConfProperties::CodecInfo::BITRATE);
     if (it != details.end())
-        copy.bitrate = jami::stoi(it->second);
+        copy.bitrate = std::stoi(it->second);
 
     it = details.find(libjami::Account::ConfProperties::CodecInfo::FRAME_RATE);
     if (it != details.end())
-        copy.frameRate = jami::stoi(it->second);
+        copy.frameRate = std::stoi(it->second);
 
     it = details.find(libjami::Account::ConfProperties::CodecInfo::QUALITY);
     if (it != details.end())
-        copy.quality = jami::stoi(it->second);
+        copy.quality = std::stoi(it->second);
 
     it = details.find(libjami::Account::ConfProperties::CodecInfo::AUTO_QUALITY_ENABLED);
     if (it != details.end())
diff --git a/src/media/video/video_device.h b/src/media/video/video_device.h
index a4eb6a903..2c52e18d6 100644
--- a/src/media/video/video_device.h
+++ b/src/media/video/video_device.h
@@ -204,7 +204,7 @@ private:
         FrameRate closest {0};
         double rate_val = 0;
         try {
-            rate_val = rate.empty() ? 0 : jami::stod(rate);
+            rate_val = rate.empty() ? 0 : std::stod(rate);
         } catch (...) {
             JAMI_WARN("Unable to read framerate \"%s\"", rate.c_str());
         }
diff --git a/src/string_utils.h b/src/string_utils.h
index eb396a111..eba8c90d5 100644
--- a/src/string_utils.h
+++ b/src/string_utils.h
@@ -121,18 +121,6 @@ to_int(std::string_view str)
     throw std::system_error(std::make_error_code(ec));
 }
 
-static inline int
-stoi(const std::string& str)
-{
-    return std::stoi(str);
-}
-
-static inline double
-stod(const std::string& str)
-{
-    return std::stod(str);
-}
-
 static inline bool
 starts_with(std::string_view str, std::string_view prefix)
 {
diff --git a/test/unitTest/string_utils/testString_utils.cpp b/test/unitTest/string_utils/testString_utils.cpp
index be21f47be..bf4452d44 100644
--- a/test/unitTest/string_utils/testString_utils.cpp
+++ b/test/unitTest/string_utils/testString_utils.cpp
@@ -40,7 +40,6 @@ public:
 private:
     void bool_to_str_test();
     void to_string_test();
-    void to_number_test();
     void split_string_test();
     void starts_with_test();
     void version_test();
@@ -48,7 +47,6 @@ private:
     CPPUNIT_TEST_SUITE(StringUtilsTest);
     CPPUNIT_TEST(bool_to_str_test);
     CPPUNIT_TEST(to_string_test);
-    CPPUNIT_TEST(to_number_test);
     CPPUNIT_TEST(split_string_test);
     CPPUNIT_TEST(starts_with_test);
     CPPUNIT_TEST(version_test);
@@ -89,16 +87,6 @@ StringUtilsTest::to_string_test()
     CPPUNIT_ASSERT_EQUAL((uint64_t)16, from_hex_string("0000000000000010"s));
 }
 
-void
-StringUtilsTest::to_number_test()
-{
-    // test with int
-    CPPUNIT_ASSERT(jami::stoi(PI_42) == INT);
-
-    // test with double
-    CPPUNIT_ASSERT(jami::stod(PI_DOUBLE) == DOUBLE);
-}
-
 void
 StringUtilsTest::split_string_test()
 {
-- 
GitLab