string utils: remove stoi/stod wrapper

Change-Id: I06afa15ff33a639458a618364d4eb00197de585a
This commit is contained in:
Adrien Beraud
2024-11-21 13:48:02 -05:00
committed by Adrien Béraud
parent 85e79e5618
commit a7d3197f29
4 changed files with 6 additions and 30 deletions

View File

@ -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())

View File

@ -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());
}

View File

@ -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)
{

View File

@ -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()
{