diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-06-27 19:06:50 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-06-29 13:40:07 -0700 |
commit | 47cdd6319c74a7b823843aad5ff3fa370ed1e6ef (patch) | |
tree | 216e88f36dbb5ba0b933f0a5ec3c2a151e972589 /host/examples | |
parent | 412a7053cc0698fd8e1a09d9c40ec2f96cf629af (diff) | |
download | uhd-47cdd6319c74a7b823843aad5ff3fa370ed1e6ef.tar.gz uhd-47cdd6319c74a7b823843aad5ff3fa370ed1e6ef.tar.bz2 uhd-47cdd6319c74a7b823843aad5ff3fa370ed1e6ef.zip |
uhd: Replaced many lexical_cast with appropriate C++11 equivalents
Diffstat (limited to 'host/examples')
-rw-r--r-- | host/examples/benchmark_rate.cpp | 9 | ||||
-rw-r--r-- | host/examples/rx_multi_samples.cpp | 5 | ||||
-rw-r--r-- | host/examples/rx_timed_samples.cpp | 4 | ||||
-rw-r--r-- | host/examples/tx_bursts.cpp | 5 | ||||
-rw-r--r-- | host/examples/tx_waveforms.cpp | 8 | ||||
-rw-r--r-- | host/examples/txrx_loopback_to_file.cpp | 9 |
6 files changed, 18 insertions, 22 deletions
diff --git a/host/examples/benchmark_rate.cpp b/host/examples/benchmark_rate.cpp index 6854fa43d..80fc0be6c 100644 --- a/host/examples/benchmark_rate.cpp +++ b/host/examples/benchmark_rate.cpp @@ -23,7 +23,6 @@ #include <boost/format.hpp> #include <boost/thread/thread.hpp> #include <boost/algorithm/string.hpp> -#include <boost/lexical_cast.hpp> //#include <boost/atomic.hpp> #include <iostream> #include <complex> @@ -406,11 +405,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ boost::split(channel_strings, rx_channel_list, boost::is_any_of("\"',")); for (size_t ch = 0; ch < channel_strings.size(); ch++) { - size_t chan = boost::lexical_cast<int>(channel_strings[ch]); + size_t chan = std::stoul(channel_strings[ch]); if (chan >= usrp->get_rx_num_channels()) { throw std::runtime_error("Invalid channel(s) specified."); } else { - rx_channel_nums.push_back(boost::lexical_cast<int>(channel_strings[ch])); + rx_channel_nums.push_back(std::stoul(channel_strings[ch])); } } } @@ -423,11 +422,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ boost::split(channel_strings, tx_channel_list, boost::is_any_of("\"',")); for (size_t ch = 0; ch < channel_strings.size(); ch++) { - size_t chan = boost::lexical_cast<int>(channel_strings[ch]); + size_t chan = std::stoul(channel_strings[ch]); if (chan >= usrp->get_tx_num_channels()) { throw std::runtime_error("Invalid channel(s) specified."); } else { - tx_channel_nums.push_back(boost::lexical_cast<int>(channel_strings[ch])); + tx_channel_nums.push_back(std::stoul(channel_strings[ch])); } } } diff --git a/host/examples/rx_multi_samples.cpp b/host/examples/rx_multi_samples.cpp index a50b5f0e0..01c7332cd 100644 --- a/host/examples/rx_multi_samples.cpp +++ b/host/examples/rx_multi_samples.cpp @@ -21,7 +21,6 @@ #include <boost/program_options.hpp> #include <boost/format.hpp> #include <boost/thread.hpp> -#include <boost/lexical_cast.hpp> #include <boost/algorithm/string.hpp> #include <iostream> #include <complex> @@ -118,11 +117,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::vector<size_t> channel_nums; boost::split(channel_strings, channel_list, boost::is_any_of("\"',")); for(size_t ch = 0; ch < channel_strings.size(); ch++){ - size_t chan = boost::lexical_cast<int>(channel_strings[ch]); + size_t chan = std::stoi(channel_strings[ch]); if(chan >= usrp->get_rx_num_channels()){ throw std::runtime_error("Invalid channel(s) specified."); } - else channel_nums.push_back(boost::lexical_cast<int>(channel_strings[ch])); + else channel_nums.push_back(std::stoi(channel_strings[ch])); } //create a receive streamer diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp index 20abd92fe..a0f7e2821 100644 --- a/host/examples/rx_timed_samples.cpp +++ b/host/examples/rx_timed_samples.cpp @@ -72,11 +72,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::vector<size_t> channel_nums; boost::split(channel_strings, channel_list, boost::is_any_of("\"',")); for(size_t ch = 0; ch < channel_strings.size(); ch++){ - size_t chan = boost::lexical_cast<int>(channel_strings[ch]); + size_t chan = std::stoi(channel_strings[ch]); if(chan >= usrp->get_tx_num_channels() or chan >= usrp->get_rx_num_channels()){ throw std::runtime_error("Invalid channel(s) specified."); } - else channel_nums.push_back(boost::lexical_cast<int>(channel_strings[ch])); + else channel_nums.push_back(std::stoi(channel_strings[ch])); } //set the rx sample rate diff --git a/host/examples/tx_bursts.cpp b/host/examples/tx_bursts.cpp index 5ee00d5cd..d174f4d6f 100644 --- a/host/examples/tx_bursts.cpp +++ b/host/examples/tx_bursts.cpp @@ -21,7 +21,6 @@ #include <boost/program_options.hpp> #include <boost/thread/thread.hpp> #include <boost/format.hpp> -#include <boost/lexical_cast.hpp> #include <boost/algorithm/string.hpp> #include <csignal> #include <iostream> @@ -86,11 +85,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::vector<size_t> channel_nums; boost::split(channel_strings, channel_list, boost::is_any_of("\"',")); for(size_t ch = 0; ch < channel_strings.size(); ch++){ - size_t chan = boost::lexical_cast<int>(channel_strings[ch]); + size_t chan = std::stoi(channel_strings[ch]); if(chan >= usrp->get_tx_num_channels()){ throw std::runtime_error("Invalid channel(s) specified."); } - else channel_nums.push_back(boost::lexical_cast<int>(channel_strings[ch])); + else channel_nums.push_back(std::stoi(channel_strings[ch])); } //set the tx sample rate diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp index d596d9ed4..9e3c2cec6 100644 --- a/host/examples/tx_waveforms.cpp +++ b/host/examples/tx_waveforms.cpp @@ -25,11 +25,11 @@ #include <boost/math/special_functions/round.hpp> #include <boost/format.hpp> #include <boost/thread.hpp> -#include <boost/lexical_cast.hpp> #include <boost/algorithm/string.hpp> #include <stdint.h> #include <iostream> #include <csignal> +#include <string> namespace po = boost::program_options; @@ -93,11 +93,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::vector<size_t> channel_nums; boost::split(channel_strings, channel_list, boost::is_any_of("\"',")); for(size_t ch = 0; ch < channel_strings.size(); ch++){ - size_t chan = boost::lexical_cast<int>(channel_strings[ch]); + size_t chan = std::stoi(channel_strings[ch]); if(chan >= usrp->get_tx_num_channels()) throw std::runtime_error("Invalid channel(s) specified."); else - channel_nums.push_back(boost::lexical_cast<int>(channel_strings[ch])); + channel_nums.push_back(std::stoi(channel_strings[ch])); } @@ -212,7 +212,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //Check Ref and LO Lock detect std::vector<std::string> sensor_names; - const size_t tx_sensor_chan = channel_list.empty() ? 0 : boost::lexical_cast<size_t>(channel_list[0]); + const size_t tx_sensor_chan = channel_nums.empty() ? 0 : channel_nums[0]; sensor_names = usrp->get_tx_sensor_names(tx_sensor_chan); if (std::find(sensor_names.begin(), sensor_names.end(), "lo_locked") != sensor_names.end()) { uhd::sensor_value_t lo_locked = usrp->get_tx_sensor("lo_locked", tx_sensor_chan); diff --git a/host/examples/txrx_loopback_to_file.cpp b/host/examples/txrx_loopback_to_file.cpp index eb2cd72a3..b0907f162 100644 --- a/host/examples/txrx_loopback_to_file.cpp +++ b/host/examples/txrx_loopback_to_file.cpp @@ -26,7 +26,6 @@ #include <boost/program_options.hpp> #include <boost/math/special_functions/round.hpp> #include <boost/format.hpp> -#include <boost/lexical_cast.hpp> #include <boost/algorithm/string.hpp> #include <boost/filesystem.hpp> #include <iostream> @@ -267,21 +266,21 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::vector<size_t> tx_channel_nums; boost::split(tx_channel_strings, tx_channels, boost::is_any_of("\"',")); for(size_t ch = 0; ch < tx_channel_strings.size(); ch++){ - size_t chan = boost::lexical_cast<int>(tx_channel_strings[ch]); + size_t chan = std::stoi(tx_channel_strings[ch]); if(chan >= tx_usrp->get_tx_num_channels()){ throw std::runtime_error("Invalid TX channel(s) specified."); } - else tx_channel_nums.push_back(boost::lexical_cast<int>(tx_channel_strings[ch])); + else tx_channel_nums.push_back(std::stoi(tx_channel_strings[ch])); } std::vector<std::string> rx_channel_strings; std::vector<size_t> rx_channel_nums; boost::split(rx_channel_strings, rx_channels, boost::is_any_of("\"',")); for(size_t ch = 0; ch < rx_channel_strings.size(); ch++){ - size_t chan = boost::lexical_cast<int>(rx_channel_strings[ch]); + size_t chan = std::stoi(rx_channel_strings[ch]); if(chan >= rx_usrp->get_rx_num_channels()){ throw std::runtime_error("Invalid RX channel(s) specified."); } - else rx_channel_nums.push_back(boost::lexical_cast<int>(rx_channel_strings[ch])); + else rx_channel_nums.push_back(std::stoi(rx_channel_strings[ch])); } //Lock mboard clocks |