diff options
author | Brent Stapleton <brent.stapleton@ettus.com> | 2019-01-14 10:35:25 -0800 |
---|---|---|
committer | Brent Stapleton <brent.stapleton@ettus.com> | 2019-01-16 11:40:23 -0800 |
commit | 967be2a4e82b1a125b26bb72a60318a4fb2b50c4 (patch) | |
tree | 8a24954b54d1546dc8049a17e485adb0a605f74f /host/examples/usrp_list_sensors.cpp | |
parent | aafe4e8b742a0e21d3818f21f34e3c8613132530 (diff) | |
download | uhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.tar.gz uhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.tar.bz2 uhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.zip |
uhd: mpm: apply clang-format to all files
Applying formatting changes to all .cpp and .hpp files in the following
directories:
```
find host/examples/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/tests/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/lib/usrp/dboard/neon/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/lib/usrp/dboard/magnesium/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/lib/usrp/device3/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/lib/usrp/mpmd/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/lib/usrp/x300/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/utils/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find mpm/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
```
Also formatted host/include/, except Cpp03 was used as a the language
standard instead of Cpp11.
```
sed -i 's/ Cpp11/ Cpp03/g' .clang-format
find host/include/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
```
Formatting style was designated by the .clang-format file.
Diffstat (limited to 'host/examples/usrp_list_sensors.cpp')
-rw-r--r-- | host/examples/usrp_list_sensors.cpp | 81 |
1 files changed, 36 insertions, 45 deletions
diff --git a/host/examples/usrp_list_sensors.cpp b/host/examples/usrp_list_sensors.cpp index 0ffe33e5a..56ecf9b7a 100644 --- a/host/examples/usrp_list_sensors.cpp +++ b/host/examples/usrp_list_sensors.cpp @@ -6,60 +6,53 @@ #include <uhd/usrp/multi_usrp.hpp> #include <uhd/utils/safe_main.hpp> -#include <boost/program_options.hpp> #include <boost/algorithm/string.hpp> //for split +#include <boost/program_options.hpp> #include <iostream> #include <sstream> namespace po = boost::program_options; namespace { - std::string make_border(const std::string &text) - { - std::stringstream ss; - ss << " _____________________________________________________\n"; - ss << " /" << std::endl; - std::vector<std::string> lines; - boost::split(lines, text, boost::is_any_of("\n")); - while (lines.back().empty()) { - lines.pop_back(); //strip trailing newlines - } - if (not lines.empty()) { - lines[0] = " " + lines[0]; //indent the title line - } - for (const std::string& line : lines) - { - ss << "| " << line << std::endl; - } - return ss.str(); +std::string make_border(const std::string& text) +{ + std::stringstream ss; + ss << " _____________________________________________________\n"; + ss << " /" << std::endl; + std::vector<std::string> lines; + boost::split(lines, text, boost::is_any_of("\n")); + while (lines.back().empty()) { + lines.pop_back(); // strip trailing newlines + } + if (not lines.empty()) { + lines[0] = " " + lines[0]; // indent the title line } + for (const std::string& line : lines) { + ss << "| " << line << std::endl; + } + return ss.str(); } +} // namespace using namespace uhd::usrp; std::string db_sensors_string( - const std::string& tx_rx, - multi_usrp::sptr usrp, - const size_t mb_idx -) { + const std::string& tx_rx, multi_usrp::sptr usrp, const size_t mb_idx) +{ std::stringstream ss; ss << tx_rx << " Sensors: \n" << std::endl; - const size_t num_chans = (tx_rx == "RX") - ? usrp->get_rx_subdev_spec(mb_idx).size() - : usrp->get_tx_subdev_spec(mb_idx).size() - ; + const size_t num_chans = (tx_rx == "RX") ? usrp->get_rx_subdev_spec(mb_idx).size() + : usrp->get_tx_subdev_spec(mb_idx).size(); for (size_t chan_idx = 0; chan_idx < num_chans; chan_idx++) { ss << "Chan " << chan_idx << ": " << std::endl; - const auto sensors = (tx_rx == "RX") - ? usrp->get_rx_sensor_names(chan_idx) - : usrp->get_tx_sensor_names(chan_idx); + const auto sensors = (tx_rx == "RX") ? usrp->get_rx_sensor_names(chan_idx) + : usrp->get_tx_sensor_names(chan_idx); for (const auto& sensor : sensors) { const auto sensor_value = (tx_rx == "RX") - ? usrp->get_rx_sensor(sensor, chan_idx) - : usrp->get_tx_sensor(sensor, chan_idx) - ; + ? usrp->get_rx_sensor(sensor, chan_idx) + : usrp->get_tx_sensor(sensor, chan_idx); ss << "* " << sensor_value.to_pp_string() << std::endl; } ss << std::endl; @@ -74,8 +67,7 @@ std::string mboard_sensors_string(multi_usrp::sptr usrp, const size_t mb_idx) ss << "Sensors for motherboard " << mb_idx << ": \n" << std::endl; const auto mboard_sensors = usrp->get_mboard_sensor_names(mb_idx); for (const auto& mboard_sensor : mboard_sensors) { - const auto sensor_value = - usrp->get_mboard_sensor(mboard_sensor, mb_idx); + const auto sensor_value = usrp->get_mboard_sensor(mboard_sensor, mb_idx); ss << "* " << sensor_value.to_pp_string() << std::endl; } ss << make_border(db_sensors_string("RX", usrp, mb_idx)) << std::endl; @@ -84,8 +76,8 @@ std::string mboard_sensors_string(multi_usrp::sptr usrp, const size_t mb_idx) return ss.str(); } -int UHD_SAFE_MAIN(int argc, char *argv[]){ - +int UHD_SAFE_MAIN(int argc, char* argv[]) +{ // Variables to be set by command line options std::string usrp_args; @@ -102,11 +94,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ po::notify(vm); // Print the help message - if (vm.count("help")){ - std::cout << std::endl << "Print sensor values" - << std::endl << std::endl; + if (vm.count("help")) { + std::cout << std::endl << "Print sensor values" << std::endl << std::endl; std::cout << "This example shows how to query sensors from" - << "a USRP device.\n" << std::endl; + << "a USRP device.\n" + << std::endl; std::cout << desc << std::endl; return EXIT_SUCCESS; } @@ -116,12 +108,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ multi_usrp::sptr usrp = multi_usrp::make(usrp_args); const size_t num_mboards = usrp->get_num_mboards(); - std::cout << "Device contains " << num_mboards - << " motherboard(s)." << std::endl << std::endl; + std::cout << "Device contains " << num_mboards << " motherboard(s)." << std::endl + << std::endl; for (size_t mboard_idx = 0; mboard_idx < num_mboards; mboard_idx++) { - std::cout << make_border(mboard_sensors_string(usrp, mboard_idx)) - << std::endl; + std::cout << make_border(mboard_sensors_string(usrp, mboard_idx)) << std::endl; } return EXIT_SUCCESS; |