aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/utils
diff options
context:
space:
mode:
authorAndrej Rode <andrej.rode@ettus.com>2017-02-09 23:19:55 -0800
committerMartin Braun <martin.braun@ettus.com>2017-02-10 16:44:33 -0800
commit26cc20847cde543e759aa5cee9a27eaa69c5dd9e (patch)
treeeee102333381e2313af59e725d6b7a06b665161f /host/lib/utils
parentf3a004faf7d50cbb5564f5e2f67f54ee07e051dd (diff)
downloaduhd-26cc20847cde543e759aa5cee9a27eaa69c5dd9e.tar.gz
uhd-26cc20847cde543e759aa5cee9a27eaa69c5dd9e.tar.bz2
uhd-26cc20847cde543e759aa5cee9a27eaa69c5dd9e.zip
uhd: replace BOOST_FOREACH with C++11 range-based for loop
Note: This is the first commit that uses for-range, and range-based for-loops are now usable for UHD development.
Diffstat (limited to 'host/lib/utils')
-rw-r--r--host/lib/utils/csv.cpp3
-rw-r--r--host/lib/utils/gain_group.cpp13
-rw-r--r--host/lib/utils/load_modules.cpp3
-rw-r--r--host/lib/utils/msg.cpp5
-rw-r--r--host/lib/utils/paths.cpp9
5 files changed, 14 insertions, 19 deletions
diff --git a/host/lib/utils/csv.cpp b/host/lib/utils/csv.cpp
index 2ffa70196..e0cadcb96 100644
--- a/host/lib/utils/csv.cpp
+++ b/host/lib/utils/csv.cpp
@@ -16,7 +16,6 @@
//
#include <uhd/utils/csv.hpp>
-#include <boost/foreach.hpp>
using namespace uhd;
@@ -29,7 +28,7 @@ csv::rows_type csv::to_rows(std::istream &input){
bool in_quote = false;
char last_ch, next_ch = ' ';
//for each character in the line
- BOOST_FOREACH(char ch, line){
+ for(char ch: line){
last_ch = next_ch;
next_ch = ch;
//catch a quote character and change the state
diff --git a/host/lib/utils/gain_group.cpp b/host/lib/utils/gain_group.cpp
index 71caf33be..be5b55444 100644
--- a/host/lib/utils/gain_group.cpp
+++ b/host/lib/utils/gain_group.cpp
@@ -20,7 +20,6 @@
#include <uhd/types/dict.hpp>
#include <uhd/utils/algorithm.hpp>
#include <uhd/exception.hpp>
-#include <boost/foreach.hpp>
#include <boost/bind.hpp>
#include <algorithm>
#include <vector>
@@ -73,7 +72,7 @@ public:
if (not name.empty()) return _name_to_fcns.get(name).get_range();
double overall_min = 0, overall_max = 0, overall_step = 0;
- BOOST_FOREACH(const gain_fcns_t &fcns, get_all_fcns()){
+ for(const gain_fcns_t &fcns: get_all_fcns()){
const gain_range_t range = fcns.get_range();
overall_min += range.start();
overall_max += range.stop();
@@ -88,7 +87,7 @@ public:
if (not name.empty()) return _name_to_fcns.get(name).get_value();
double overall_gain = 0;
- BOOST_FOREACH(const gain_fcns_t &fcns, get_all_fcns()){
+ for(const gain_fcns_t &fcns: get_all_fcns()){
overall_gain += fcns.get_value();
}
return overall_gain;
@@ -102,7 +101,7 @@ public:
//get the max step size among the gains
double max_step = 0;
- BOOST_FOREACH(const gain_fcns_t &fcns, all_fcns){
+ for(const gain_fcns_t &fcns: all_fcns){
max_step = std::max(max_step, fcns.get_range().step());
}
@@ -111,7 +110,7 @@ public:
//distribute power according to priority (round to max step)
double gain_left_to_distribute = gain;
- BOOST_FOREACH(const gain_fcns_t &fcns, all_fcns){
+ for(const gain_fcns_t &fcns: all_fcns){
const gain_range_t range = fcns.get_range();
gain_bucket.push_back(floor_step(uhd::clip(
gain_left_to_distribute, range.start(), range.stop()
@@ -135,7 +134,7 @@ public:
//distribute the remainder (less than max step)
//fill in the largest step sizes first that are less than the remainder
- BOOST_FOREACH(size_t i, indexes_step_size_dec){
+ for(size_t i: indexes_step_size_dec){
const gain_range_t range = all_fcns.at(i).get_range();
double additional_gain = floor_step(uhd::clip(
gain_bucket.at(i) + gain_left_to_distribute, range.start(), range.stop()
@@ -173,7 +172,7 @@ private:
//! get the gain function sets in order (highest priority first)
std::vector<gain_fcns_t> get_all_fcns(void){
std::vector<gain_fcns_t> all_fcns;
- BOOST_FOREACH(size_t key, uhd::sorted(_registry.keys())){
+ for(size_t key: uhd::sorted(_registry.keys())){
const std::vector<gain_fcns_t> &fcns = _registry[key];
all_fcns.insert(all_fcns.begin(), fcns.begin(), fcns.end());
}
diff --git a/host/lib/utils/load_modules.cpp b/host/lib/utils/load_modules.cpp
index aba3adeed..3ef3c418c 100644
--- a/host/lib/utils/load_modules.cpp
+++ b/host/lib/utils/load_modules.cpp
@@ -19,7 +19,6 @@
#include <uhd/utils/static.hpp>
#include <uhd/exception.hpp>
#include <boost/format.hpp>
-#include <boost/foreach.hpp>
#include <boost/filesystem.hpp>
#include <iostream>
#include <string>
@@ -102,7 +101,7 @@ static void load_module_path(const fs::path &path){
* Load all the modules given in the module paths.
*/
UHD_STATIC_BLOCK(load_modules){
- BOOST_FOREACH(const fs::path &path, uhd::get_module_paths()){
+ for(const fs::path &path: uhd::get_module_paths()){
load_module_path(path);
}
}
diff --git a/host/lib/utils/msg.cpp b/host/lib/utils/msg.cpp
index d9d2fb66a..9a125515d 100644
--- a/host/lib/utils/msg.cpp
+++ b/host/lib/utils/msg.cpp
@@ -19,7 +19,6 @@
#include <uhd/utils/log.hpp>
#include <uhd/utils/static.hpp>
#include <boost/thread/mutex.hpp>
-#include <boost/foreach.hpp>
#include <boost/tokenizer.hpp>
#include <sstream>
#include <iostream>
@@ -35,7 +34,7 @@ static void msg_to_cout(const std::string &msg){
std::stringstream ss;
static bool just_had_a_newline = true;
- BOOST_FOREACH(char ch, msg){
+ for(char ch: msg){
if (just_had_a_newline){
just_had_a_newline = false;
ss << "-- ";
@@ -53,7 +52,7 @@ static void msg_to_cerr(const std::string &title, const std::string &msg){
std::stringstream ss;
ss << std::endl << title << ":" << std::endl;
- BOOST_FOREACH(const std::string &line, tokenizer(msg, "\n")){
+ for(const std::string &line: tokenizer(msg, "\n")){
ss << " " << line << std::endl;
}
diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp
index 38839c8d4..5d53f95bd 100644
--- a/host/lib/utils/paths.cpp
+++ b/host/lib/utils/paths.cpp
@@ -22,7 +22,6 @@
#include <boost/algorithm/string.hpp>
#include <boost/bind.hpp>
#include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
#include <boost/format.hpp>
#include <boost/regex.hpp>
#include <boost/tokenizer.hpp>
@@ -98,7 +97,7 @@ static std::vector<std::string> get_env_paths(const std::string &var_name){
//convert to full filesystem path, filter blank paths
if (var_value.empty()) return paths;
- BOOST_FOREACH(const std::string &path_string, path_tokenizer(var_value)){
+ for(const std::string &path_string: path_tokenizer(var_value)){
if (path_string.empty()) continue;
paths.push_back(fs::system_complete(path_string).string());
}
@@ -190,7 +189,7 @@ std::vector<fs::path> uhd::get_module_paths(void){
std::vector<fs::path> paths;
std::vector<std::string> env_paths = get_env_paths("UHD_MODULE_PATH");
- BOOST_FOREACH(std::string &str_path, env_paths) {
+ for(std::string &str_path: env_paths) {
paths.push_back(str_path);
}
@@ -272,7 +271,7 @@ std::string uhd::get_images_dir(const std::string &search_paths) {
/* We will start by looking for a path indicated by the `UHD_IMAGES_DIR`
* environment variable. */
std::vector<std::string> env_paths = get_env_paths("UHD_IMAGES_DIR");
- BOOST_FOREACH(possible_dir, env_paths) {
+ for(auto possible_dir: env_paths) {
if (fs::is_directory(fs::path(possible_dir))) {
return possible_dir;
}
@@ -293,7 +292,7 @@ std::string uhd::get_images_dir(const std::string &search_paths) {
std::vector<std::string> search_paths_vector;
boost::split(search_paths_vector, _search_paths, boost::is_any_of(",;"));
- BOOST_FOREACH(std::string& search_path, search_paths_vector) {
+ for(std::string& search_path: search_paths_vector) {
boost::algorithm::trim(search_path);
if (search_path.empty()) continue;