13
0

Replace boost::lexical_cast with std equivalent functions

This commit is contained in:
Alejandro Domínguez 2024-08-29 00:36:41 +02:00 committed by Robin Gareus
parent 7a0428644f
commit 915200699b
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 14 additions and 18 deletions

View File

@ -20,7 +20,6 @@
#include <iostream>
#endif
#include <boost/lexical_cast.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
#include <sstream>
@ -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<uint32_t> (it->second.data ()));
_state.add_addr (static_cast<uint32_t> (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<int> (val));
} catch (const boost::bad_lexical_cast&) {
_state.add_val (stoi (val));
} catch (...) {
try {
double d = boost::lexical_cast<double> (val);
double d = stod (val);
if (d >= JSON_INF) {
d = std::numeric_limits<double>::infinity ();
} else if (d <= -JSON_INF) {
d = -std::numeric_limits<double>::infinity ();
}
_state.add_val (d);
} catch (const boost::bad_lexical_cast&) {
} catch (...) {
if (val == "false") {
_state.add_val (false);
} else if (val == "true") {

View File

@ -16,8 +16,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <boost/lexical_cast.hpp>
#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<std::string>(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<std::string>(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<std::string>(strip_id) + " not found");
throw ArdourMixerNotFoundException ("strip id = " + std::to_string(strip_id) + " not found");
}
return *_strips[strip_id];

View File

@ -16,7 +16,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <boost/lexical_cast.hpp>
#include <cmath>
#include <limits>
#include <string>
@ -95,8 +94,8 @@ TypedValue::operator int () const
return static_cast<int> (_d);
case String:
try {
return boost::lexical_cast<int> (_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<double> (_i);
case String:
try {
return boost::lexical_cast<double> (_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<std::string> (_i);
return std::to_string (_i);
case Double:
return boost::lexical_cast<std::string> (_d);
return std::to_string (_d);
default:
return "";
}