From 915200699bd3082680d2e8e649403dd551c6149d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Dom=C3=ADnguez?= Date: Thu, 29 Aug 2024 00:36:41 +0200 Subject: [PATCH] Replace boost::lexical_cast with std equivalent functions --- libs/surfaces/websockets/message.cc | 11 +++++------ libs/surfaces/websockets/mixer.cc | 8 +++----- libs/surfaces/websockets/typed_value.cc | 13 ++++++------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/libs/surfaces/websockets/message.cc b/libs/surfaces/websockets/message.cc index 0aee14d0df..de7b2672ce 100644 --- a/libs/surfaces/websockets/message.cc +++ b/libs/surfaces/websockets/message.cc @@ -20,7 +20,6 @@ #include #endif -#include #include #include #include @@ -63,7 +62,7 @@ NodeStateMessage::NodeStateMessage (void* buf, size_t len) for (pt::ptree::iterator it = addr.begin (); it != addr.end (); ++it) { // throws if datatype not uint32_t - _state.add_addr (boost::lexical_cast (it->second.data ())); + _state.add_addr (static_cast (stoul (it->second.data ()))); } pt::ptree val = pt::ptree (); @@ -73,17 +72,17 @@ NodeStateMessage::NodeStateMessage (void* buf, size_t len) std::string val = it->second.data (); try { - _state.add_val (boost::lexical_cast (val)); - } catch (const boost::bad_lexical_cast&) { + _state.add_val (stoi (val)); + } catch (...) { try { - double d = boost::lexical_cast (val); + double d = stod (val); if (d >= JSON_INF) { d = std::numeric_limits::infinity (); } else if (d <= -JSON_INF) { d = -std::numeric_limits::infinity (); } _state.add_val (d); - } catch (const boost::bad_lexical_cast&) { + } catch (...) { if (val == "false") { _state.add_val (false); } else if (val == "true") { diff --git a/libs/surfaces/websockets/mixer.cc b/libs/surfaces/websockets/mixer.cc index 4bd237fb0a..0bd3600c35 100644 --- a/libs/surfaces/websockets/mixer.cc +++ b/libs/surfaces/websockets/mixer.cc @@ -16,8 +16,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include - #include "ardour/dB.h" #include "ardour/meter.h" #include "ardour/plugin_insert.h" @@ -95,7 +93,7 @@ ArdourMixerPlugin::param_control (uint32_t param_id) const if (!ok || !plugin->parameter_is_input (control_id)) { throw ArdourMixerNotFoundException ("invalid automation control for param id = " - + boost::lexical_cast(param_id)); + + std::to_string(param_id)); } return _insert->automation_control (Evoral::Parameter (PluginAutomation, 0, control_id)); @@ -159,7 +157,7 @@ ArdourMixerPlugin& ArdourMixerStrip::plugin (uint32_t plugin_id) { if (_plugins.find (plugin_id) == _plugins.end ()) { - throw ArdourMixerNotFoundException ("plugin id = " + boost::lexical_cast(plugin_id) + " not found"); + throw ArdourMixerNotFoundException ("plugin id = " + std::to_string(plugin_id) + " not found"); } return *_plugins[plugin_id]; @@ -325,7 +323,7 @@ ArdourMixerStrip& ArdourMixer::strip (uint32_t strip_id) { if (_strips.find (strip_id) == _strips.end ()) { - throw ArdourMixerNotFoundException ("strip id = " + boost::lexical_cast(strip_id) + " not found"); + throw ArdourMixerNotFoundException ("strip id = " + std::to_string(strip_id) + " not found"); } return *_strips[strip_id]; diff --git a/libs/surfaces/websockets/typed_value.cc b/libs/surfaces/websockets/typed_value.cc index 193ab83ffc..30ac5c73c0 100644 --- a/libs/surfaces/websockets/typed_value.cc +++ b/libs/surfaces/websockets/typed_value.cc @@ -16,7 +16,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include #include #include #include @@ -95,8 +94,8 @@ TypedValue::operator int () const return static_cast (_d); case String: try { - return boost::lexical_cast (_s); - } catch (const boost::bad_lexical_cast&) { + return stoi (_s); + } catch (...) { return 0; } default: @@ -115,8 +114,8 @@ TypedValue::operator double () const return static_cast (_i); case String: try { - return boost::lexical_cast (_s); - } catch (const boost::bad_lexical_cast&) { + return stod (_s); + } catch (...) { return 0; } default: @@ -132,9 +131,9 @@ TypedValue::operator std::string () const case Bool: return _b ? "true" : "false"; case Int: - return boost::lexical_cast (_i); + return std::to_string (_i); case Double: - return boost::lexical_cast (_d); + return std::to_string (_d); default: return ""; }