summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Habets <thomas@habets.se>2020-04-03 15:47:53 +0100
committerMarcus Müller <marcus@hostalia.de>2020-04-11 02:39:54 +0200
commit60144c3e2fc6e36a9a1a6ebefbbebe41adc79c2c (patch)
treecde54f4511fe427c643b6c5cf3662edcb4de28d8
parent3bab5f023ab406b9a4521e7c3be7fd4bd33135f7 (diff)
qtgui: Remove boost::lexical_cast for parsing
This is the last boost::lexical_cast in gnuradio.
-rw-r--r--gnuradio-runtime/lib/pmt/pmt_unv.cc6
-rw-r--r--gr-qtgui/include/gnuradio/qtgui/edit_box_msg.h8
-rw-r--r--gr-qtgui/lib/edit_box_msg_impl.cc18
3 files changed, 17 insertions, 15 deletions
diff --git a/gnuradio-runtime/lib/pmt/pmt_unv.cc b/gnuradio-runtime/lib/pmt/pmt_unv.cc
index 23135dd4fd..81030f8470 100644
--- a/gnuradio-runtime/lib/pmt/pmt_unv.cc
+++ b/gnuradio-runtime/lib/pmt/pmt_unv.cc
@@ -138,7 +138,8 @@ uint8_t* u8vector_writable_elements(pmt_t vector, size_t& len)
const std::string pmt_u8vector::string_ref(size_t k) const
{
- return std::to_string(ref(k));
+ const auto& ch = ref(k);
+ return std::string(&ch, &ch + 1);
}
} /* namespace pmt */
@@ -260,7 +261,8 @@ int8_t* s8vector_writable_elements(pmt_t vector, size_t& len)
const std::string pmt_s8vector::string_ref(size_t k) const
{
- return std::to_string(ref(k));
+ const auto& ch = ref(k);
+ return std::string(&ch, &ch + 1);
}
} /* namespace pmt */
diff --git a/gr-qtgui/include/gnuradio/qtgui/edit_box_msg.h b/gr-qtgui/include/gnuradio/qtgui/edit_box_msg.h
index d05a690324..10137f1261 100644
--- a/gr-qtgui/include/gnuradio/qtgui/edit_box_msg.h
+++ b/gr-qtgui/include/gnuradio/qtgui/edit_box_msg.h
@@ -57,10 +57,10 @@ namespace qtgui {
* how to handle complex numbers.
*
* Complex numbers are currently handled a bit differently than
- * expected. Because we use the Boost lexical_cast function,
- * complex numbers MUST be in the form "(a,b)" to represent "a +
- * jb". Note that you cannot even have a space after the comma, so
- * "(1.23,10.56)" is correct while "(1.23, 10.56)" will not parse.
+ * expected. Because we use the std iostream for complex, complex numbers MUST
+ * be in the form "(a,b)" to represent "a + jb". Note that you cannot even have
+ * a space after the comma, so "(1.23,10.56)" is correct while "(1.23, 10.56)"
+ * will not parse.
*
* The 'static' mode prevents the user from changing the data type
* or the key used in the widget. If also in 'pair' mode, the key
diff --git a/gr-qtgui/lib/edit_box_msg_impl.cc b/gr-qtgui/lib/edit_box_msg_impl.cc
index ce2c740c78..7bb41b9a0c 100644
--- a/gr-qtgui/lib/edit_box_msg_impl.cc
+++ b/gr-qtgui/lib/edit_box_msg_impl.cc
@@ -17,8 +17,7 @@
#include <gnuradio/io_signature.h>
#include <gnuradio/prefs.h>
#include <gnuradio/qtgui/utils.h>
-
-#include <boost/lexical_cast.hpp>
+#include <sstream>
namespace gr {
namespace qtgui {
@@ -371,7 +370,7 @@ void edit_box_msg_impl::set_value(pmt::pmt_t val)
void edit_box_msg_impl::edit_finished()
{
- QString text = d_val->text();
+ const QString text = d_val->text();
bool conv_ok = true;
int xi;
float xf;
@@ -455,16 +454,17 @@ void edit_box_msg_impl::edit_finished()
}
d_msg = pmt::init_f64vector(xv.size(), xv);
} break;
- case COMPLEX:
- try {
- xc = boost::lexical_cast<gr_complex>(text.toStdString());
- } catch (boost::bad_lexical_cast const& e) {
+ case COMPLEX: {
+ std::stringstream ss(text.toStdString());
+ ss >> xc;
+ if (static_cast<size_t>(ss.tellg()) != ss.str().size()) {
GR_LOG_WARN(d_logger,
- boost::format("Conversion to complex failed (%1%)") % e.what());
+ boost::format("Conversion of %s to complex failed") %
+ text.toStdString());
return;
}
d_msg = pmt::from_complex(xc.real(), xc.imag());
- break;
+ } break;
case COMPLEX_VEC: {
std::vector<gr_complex> xv;
QStringList text_list = text.split(",");