aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/rfnoc
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-06-27 19:06:50 -0700
committerMartin Braun <martin.braun@ettus.com>2017-06-29 13:40:07 -0700
commit47cdd6319c74a7b823843aad5ff3fa370ed1e6ef (patch)
tree216e88f36dbb5ba0b933f0a5ec3c2a151e972589 /host/lib/rfnoc
parent412a7053cc0698fd8e1a09d9c40ec2f96cf629af (diff)
downloaduhd-47cdd6319c74a7b823843aad5ff3fa370ed1e6ef.tar.gz
uhd-47cdd6319c74a7b823843aad5ff3fa370ed1e6ef.tar.bz2
uhd-47cdd6319c74a7b823843aad5ff3fa370ed1e6ef.zip
uhd: Replaced many lexical_cast with appropriate C++11 equivalents
Diffstat (limited to 'host/lib/rfnoc')
-rw-r--r--host/lib/rfnoc/block_ctrl_base.cpp12
-rw-r--r--host/lib/rfnoc/blockdef_xml_impl.cpp2
-rw-r--r--host/lib/rfnoc/nocscript/expression.cpp16
-rw-r--r--host/lib/rfnoc/nocscript/expression.hpp3
4 files changed, 16 insertions, 17 deletions
diff --git a/host/lib/rfnoc/block_ctrl_base.cpp b/host/lib/rfnoc/block_ctrl_base.cpp
index e9d6c0030..1a753403a 100644
--- a/host/lib/rfnoc/block_ctrl_base.cpp
+++ b/host/lib/rfnoc/block_ctrl_base.cpp
@@ -195,8 +195,8 @@ void block_ctrl_base::_init_block_args()
fs_path arg_val_path = arg_path / arg["port"] / arg["name"] / "value";
if (not arg["value"].empty()) {
if (arg["type"] == "int_vector") { throw uhd::runtime_error("not yet implemented: int_vector"); }
- else if (arg["type"] == "int") { _tree->access<int>(arg_val_path).set(boost::lexical_cast<int>(arg["value"])); }
- else if (arg["type"] == "double") { _tree->access<double>(arg_val_path).set(boost::lexical_cast<double>(arg["value"])); }
+ else if (arg["type"] == "int") { _tree->access<int>(arg_val_path).set(std::stoi(arg["value"])); }
+ else if (arg["type"] == "double") { _tree->access<double>(arg_val_path).set(std::stod(arg["value"])); }
else if (arg["type"] == "string") { _tree->access<string>(arg_val_path).set(arg["value"]); }
else { UHD_THROW_INVALID_CODE_PATH(); }
}
@@ -453,10 +453,10 @@ void block_ctrl_base::set_arg(const std::string &key, const std::string &val, co
_tree->access<std::string>(arg_val_path).set(val);
}
else if (type == "int") {
- _tree->access<int>(arg_val_path).set(boost::lexical_cast<int>(val));
+ _tree->access<int>(arg_val_path).set(std::stoi(val));
}
else if (type == "double") {
- _tree->access<double>(arg_val_path).set(boost::lexical_cast<double>(val));
+ _tree->access<double>(arg_val_path).set(std::stod(val));
}
else if (type == "int_vector") {
throw uhd::runtime_error("not yet implemented: int_vector");
@@ -494,10 +494,10 @@ std::string block_ctrl_base::get_arg(const std::string &key, const size_t port)
return _tree->access<std::string>(arg_val_path).get();
}
else if (type == "int") {
- return boost::lexical_cast<std::string>(_tree->access<int>(arg_val_path).get());
+ return std::to_string(_tree->access<int>(arg_val_path).get());
}
else if (type == "double") {
- return boost::lexical_cast<std::string>(_tree->access<double>(arg_val_path).get());
+ return std::to_string(_tree->access<double>(arg_val_path).get());
}
else if (type == "int_vector") {
throw uhd::runtime_error("not yet implemented: int_vector");
diff --git a/host/lib/rfnoc/blockdef_xml_impl.cpp b/host/lib/rfnoc/blockdef_xml_impl.cpp
index 5f8af232d..cf975b3c2 100644
--- a/host/lib/rfnoc/blockdef_xml_impl.cpp
+++ b/host/lib/rfnoc/blockdef_xml_impl.cpp
@@ -310,7 +310,7 @@ public:
}
// We have to be extra-careful with the port numbers:
if (port["port"].empty()) {
- port["port"] = boost::lexical_cast<std::string>(n_ports);
+ port["port"] = std::to_string(n_ports);
}
size_t new_port_number;
try {
diff --git a/host/lib/rfnoc/nocscript/expression.cpp b/host/lib/rfnoc/nocscript/expression.cpp
index 257e0b447..4f7d98108 100644
--- a/host/lib/rfnoc/nocscript/expression.cpp
+++ b/host/lib/rfnoc/nocscript/expression.cpp
@@ -54,12 +54,12 @@ expression_literal::expression_literal(
if (_val.substr(0, 2) == "0x") {
_int_val = uhd::cast::hexstr_cast<int>(_val);
} else {
- _int_val = boost::lexical_cast<int>(_val);
+ _int_val = std::stoi(_val);
}
break;
case expression::TYPE_DOUBLE:
- _double_val = boost::lexical_cast<double>(_val);
+ _double_val = std::stod(_val);
break;
case expression::TYPE_BOOL:
@@ -67,7 +67,7 @@ expression_literal::expression_literal(
_bool_val = true;
} else {
// lexical cast to bool is too picky
- _bool_val = bool(boost::lexical_cast<int>(_val));
+ _bool_val = bool(std::stoi(_val));
}
break;
@@ -77,7 +77,7 @@ expression_literal::expression_literal(
std::vector<std::string> subtoken_list;
boost::split(subtoken_list, str_vec, boost::is_any_of(", "), boost::token_compress_on);
for(const std::string &t: subtoken_list) {
- _int_vector_val.push_back(boost::lexical_cast<int>(t));
+ _int_vector_val.push_back(std::stoi(t));
}
break;
}
@@ -142,11 +142,11 @@ bool expression_literal::to_bool() const
{
switch (_type) {
case TYPE_INT:
- return bool(boost::lexical_cast<int>(_val));
+ return bool(std::stoi(_val));
case TYPE_STRING:
return not _val.empty();
case TYPE_DOUBLE:
- return bool(boost::lexical_cast<double>(_val));
+ return bool(std::stod(_val));
case TYPE_BOOL:
return _bool_val;
case TYPE_INT_VECTOR:
@@ -205,11 +205,11 @@ std::string expression_literal::repr() const
{
switch (_type) {
case TYPE_INT:
- return boost::lexical_cast<std::string>(_int_val);
+ return std::to_string(_int_val);
case TYPE_STRING:
return _val;
case TYPE_DOUBLE:
- return boost::lexical_cast<std::string>(_double_val);
+ return std::to_string(_double_val);
case TYPE_BOOL:
return _bool_val ? "TRUE" : "FALSE";
case TYPE_INT_VECTOR:
diff --git a/host/lib/rfnoc/nocscript/expression.hpp b/host/lib/rfnoc/nocscript/expression.hpp
index 1acd02009..6cf649a59 100644
--- a/host/lib/rfnoc/nocscript/expression.hpp
+++ b/host/lib/rfnoc/nocscript/expression.hpp
@@ -17,7 +17,6 @@
#include <uhd/exception.hpp>
#include <boost/shared_ptr.hpp>
-#include <boost/lexical_cast.hpp>
#include <boost/function.hpp>
#include <boost/make_shared.hpp>
#include <vector>
@@ -300,7 +299,7 @@ class expression_function : public expression_container
const std::string &name,
const boost::shared_ptr<function_table> func_table
);
- ~expression_function(){};
+ ~expression_function(){}
//! Add an argument expression
virtual void add(expression::sptr new_expr);