diff options
| author | Martin Braun <martin.braun@ettus.com> | 2019-09-28 13:13:41 +0200 | 
|---|---|---|
| committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 12:21:32 -0800 | 
| commit | f773cf9fb96e25d064f43cffdc893ac905d91f15 (patch) | |
| tree | b9aab514b0289687dcc006a831c832a53051f34d | |
| parent | fcc2e9c602a6103dfd0f75e035f614b177c5dc35 (diff) | |
| download | uhd-f773cf9fb96e25d064f43cffdc893ac905d91f15.tar.gz uhd-f773cf9fb96e25d064f43cffdc893ac905d91f15.tar.bz2 uhd-f773cf9fb96e25d064f43cffdc893ac905d91f15.zip  | |
uhd: Replace boost::regex with std::regex
boost::regex was a requirement until the minimum version of gcc was
increased. Since it is at version 5.3 now, using Boost.Regex is no
longer necessary.
This change is a pure search-and-replace; Boost and std versions of
regex are compatible and use the same syntax.
| -rw-r--r-- | host/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | host/cmake/debian/control | 1 | ||||
| -rw-r--r-- | host/lib/rfnoc/block_id.cpp | 18 | ||||
| -rw-r--r-- | host/lib/transport/nirio/lvbitx/template_lvbitx.cpp | 2 | ||||
| -rw-r--r-- | host/lib/transport/nirio/nifpga_lvbitx.cpp | 10 | ||||
| -rw-r--r-- | host/lib/types/device_addr.cpp | 6 | ||||
| -rw-r--r-- | host/lib/usrp/fe_connection.cpp | 8 | ||||
| -rw-r--r-- | host/lib/usrp/gps_ctrl.cpp | 10 | ||||
| -rw-r--r-- | host/lib/utils/paths.cpp | 10 | ||||
| -rw-r--r-- | host/tests/dpdk_test.cpp | 3 | 
10 files changed, 32 insertions, 37 deletions
diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 53e5cba7e..55110e12a 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -287,7 +287,6 @@ set(UHD_BOOST_REQUIRED_COMPONENTS      date_time      filesystem      program_options -    regex      system      unit_test_framework      serialization diff --git a/host/cmake/debian/control b/host/cmake/debian/control index 4a6bd19ee..107dd8852 100644 --- a/host/cmake/debian/control +++ b/host/cmake/debian/control @@ -10,7 +10,6 @@ Build-Depends:  cmake,                  libboost-dev,                  libboost-filesystem-dev,                  libboost-program-options-dev, -                libboost-regex-dev,                  libboost-serialization-dev,                  libboost-system-dev,                  libboost-test-dev, diff --git a/host/lib/rfnoc/block_id.cpp b/host/lib/rfnoc/block_id.cpp index 573b393e5..db7ddb032 100644 --- a/host/lib/rfnoc/block_id.cpp +++ b/host/lib/rfnoc/block_id.cpp @@ -11,7 +11,7 @@  #include <uhd/rfnoc/constants.hpp>  #include <boost/format.hpp>  #include <boost/lexical_cast.hpp> -#include <boost/regex.hpp> +#include <regex>  #include <iostream>  using namespace uhd::rfnoc; @@ -38,12 +38,12 @@ block_id_t::block_id_t(  bool block_id_t::is_valid_blockname(const std::string& block_name)  { -    return boost::regex_match(block_name, boost::regex(VALID_BLOCKNAME_REGEX)); +    return std::regex_match(block_name, std::regex(VALID_BLOCKNAME_REGEX));  }  bool block_id_t::is_valid_block_id(const std::string& block_name)  { -    return boost::regex_match(block_name, boost::regex(VALID_BLOCKID_REGEX)); +    return std::regex_match(block_name, std::regex(VALID_BLOCKID_REGEX));  }  std::string block_id_t::to_string() const @@ -63,9 +63,9 @@ uhd::fs_path block_id_t::get_tree_root() const  bool block_id_t::match(const std::string& block_str)  { -    boost::cmatch matches; -    if (not boost::regex_match( -            block_str.c_str(), matches, boost::regex(VALID_BLOCKID_REGEX))) { +    std::cmatch matches; +    if (not std::regex_match( +            block_str.c_str(), matches, std::regex(VALID_BLOCKID_REGEX))) {          return false;      }      try { @@ -82,9 +82,9 @@ bool block_id_t::match(const std::string& block_str)  bool block_id_t::set(const std::string& new_name)  { -    boost::cmatch matches; -    if (not boost::regex_match( -            new_name.c_str(), matches, boost::regex(VALID_BLOCKID_REGEX))) { +    std::cmatch matches; +    if (not std::regex_match( +            new_name.c_str(), matches, std::regex(VALID_BLOCKID_REGEX))) {          return false;      }      if (not(matches[1] == "")) { diff --git a/host/lib/transport/nirio/lvbitx/template_lvbitx.cpp b/host/lib/transport/nirio/lvbitx/template_lvbitx.cpp index 8f1fb6b36..4cae73f9c 100644 --- a/host/lib/transport/nirio/lvbitx/template_lvbitx.cpp +++ b/host/lib/transport/nirio/lvbitx/template_lvbitx.cpp @@ -7,7 +7,7 @@  #include <streambuf>  #include <boost/filesystem/path.hpp>  #include <boost/algorithm/string.hpp> -#include <boost/regex.hpp> +#include <regex>  #include <uhd/utils/paths.hpp>  namespace uhd {{ namespace niusrprio {{ diff --git a/host/lib/transport/nirio/nifpga_lvbitx.cpp b/host/lib/transport/nirio/nifpga_lvbitx.cpp index ef4a02aff..015344710 100644 --- a/host/lib/transport/nirio/nifpga_lvbitx.cpp +++ b/host/lib/transport/nirio/nifpga_lvbitx.cpp @@ -11,15 +11,15 @@  #include <fstream>  #include <streambuf>  #include <boost/algorithm/string.hpp> -#include <boost/regex.hpp> +#include <regex>  namespace uhd { namespace niusrprio {  std::string nifpga_lvbitx::_get_bitstream_checksum(const std::string& file_path)  { -    const boost::regex md5_regex( +    const std::regex md5_regex(          "<BitstreamMD5>([a-fA-F0-9]{32})<\\/BitstreamMD5>", -        boost::regex::icase); +        std::regex::icase);      std::ifstream lvbitx_stream(file_path.c_str());      if (!lvbitx_stream.is_open()) { @@ -32,9 +32,9 @@ std::string nifpga_lvbitx::_get_bitstream_checksum(const std::string& file_path)          try {              // short-circuiting the regex search with a simple find is faster              // for cases where the tag doesn't exist -            boost::smatch md5_match; +            std::smatch md5_match;              if (line.find("<BitstreamMD5>") != std::string::npos && -                boost::regex_search(line, md5_match, md5_regex)) +                std::regex_search(line, md5_match, md5_regex))              {                  checksum = std::string(md5_match[1].first, md5_match[1].second);                  break; diff --git a/host/lib/types/device_addr.cpp b/host/lib/types/device_addr.cpp index 65d265857..3e2fac94d 100644 --- a/host/lib/types/device_addr.cpp +++ b/host/lib/types/device_addr.cpp @@ -9,7 +9,7 @@  #include <boost/algorithm/string.hpp>  #include <boost/tokenizer.hpp>  #include <boost/format.hpp> -#include <boost/regex.hpp> +#include <regex>  #include <stdexcept>  #include <sstream> @@ -93,8 +93,8 @@ device_addrs_t uhd::separate_device_addr(const device_addr_t &dev_addr){      device_addrs_t dev_addrs(1); //must be at least one (obviously)      std::vector<std::string> global_keys; //keys that apply to all (no numerical suffix)      for(const std::string &key:  dev_addr.keys()){ -        boost::cmatch matches; -        if (not boost::regex_match(key.c_str(), matches, boost::regex("^(\\D+)(\\d*)$"))){ +        std::cmatch matches; +        if (not std::regex_match(key.c_str(), matches, std::regex("^(\\D+)(\\d*)$"))){              throw std::runtime_error("unknown key format: " + key);          }          std::string key_part(matches[1].first, matches[1].second); diff --git a/host/lib/usrp/fe_connection.cpp b/host/lib/usrp/fe_connection.cpp index 0c2574ed3..8e3c0c88b 100644 --- a/host/lib/usrp/fe_connection.cpp +++ b/host/lib/usrp/fe_connection.cpp @@ -7,7 +7,7 @@  #include <uhd/usrp/fe_connection.hpp>  #include <uhd/exception.hpp> -#include <boost/regex.hpp> +#include <regex>  #include <uhd/utils/math.hpp>  using namespace uhd::usrp; @@ -21,9 +21,9 @@ fe_connection_t::fe_connection_t(  }  fe_connection_t::fe_connection_t(const std::string& conn_str, double if_freq) { -    static const boost::regex conn_regex("([IQ])(b?)(([IQ])(b?))?"); -    boost::cmatch matches; -    if (boost::regex_match(conn_str.c_str(), matches, conn_regex)) { +    static const std::regex conn_regex("([IQ])(b?)(([IQ])(b?))?"); +    std::cmatch matches; +    if (std::regex_match(conn_str.c_str(), matches, conn_regex)) {          if (matches[3].length() == 0) {              //Connection in {I, Q, Ib, Qb}              _sampling_mode = REAL; diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp index 717654151..f9e03b16a 100644 --- a/host/lib/usrp/gps_ctrl.cpp +++ b/host/lib/usrp/gps_ctrl.cpp @@ -14,7 +14,7 @@  #include <boost/thread/thread.hpp>  #include <boost/tokenizer.hpp>  #include <boost/format.hpp> -#include <boost/regex.hpp> +#include <regex>  #include <boost/thread/mutex.hpp>  #include <boost/date_time.hpp>  #include <boost/tuple/tuple.hpp> @@ -137,8 +137,8 @@ private:      }      const std::list<std::string> keys{"GPGGA", "GPRMC", "SERVO"}; -    static const boost::regex servo_regex("^\\d\\d-\\d\\d-\\d\\d.*$"); -    static const boost::regex gp_msg_regex("^\\$GP.*,\\*[0-9A-F]{2}$"); +    static const std::regex servo_regex("^\\d\\d-\\d\\d-\\d\\d.*$"); +    static const std::regex gp_msg_regex("^\\$GP.*,\\*[0-9A-F]{2}$");      std::map<std::string,std::string> msgs;      // Get all GPSDO messages available @@ -162,11 +162,11 @@ private:          }          // Look for SERVO message -        if (boost::regex_search(msg, servo_regex, boost::regex_constants::match_continuous)) +        if (std::regex_search(msg, servo_regex, std::regex_constants::match_continuous))          {              msgs["SERVO"] = msg;          } -        else if (boost::regex_match(msg, gp_msg_regex) and is_nmea_checksum_ok(msg)) +        else if (std::regex_match(msg, gp_msg_regex) and is_nmea_checksum_ok(msg))          {              msgs[msg.substr(1,5)] = msg;          } diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp index 8a7ba001f..7fd64e6f5 100644 --- a/host/lib/utils/paths.cpp +++ b/host/lib/utils/paths.cpp @@ -14,7 +14,7 @@  #include <boost/bind.hpp>  #include <boost/filesystem.hpp>  #include <boost/format.hpp> -#include <boost/regex.hpp> +#include <regex>  #include <boost/tokenizer.hpp>  #include <cstdio> @@ -200,16 +200,16 @@ std::vector<fs::path> uhd::get_module_paths(void){   * \return The images path, formatted for windows.   */  std::string _get_images_path_from_registry(const std::string& registry_key_path) { -    boost::smatch reg_key_match; +    std::smatch reg_key_match;      //If a substring in the search path is enclosed in [] (square brackets) then it is interpreted as a registry path -    if (not boost::regex_search(registry_key_path, reg_key_match, boost::regex("\\[(.+)\\](.*)", boost::regex::icase))) +    if (not std::regex_search(registry_key_path, reg_key_match, std::regex("\\[(.+)\\](.*)", std::regex::icase)))          return std::string();      std::string reg_key_path = std::string(reg_key_match[1].first, reg_key_match[1].second);      std::string path_suffix = std::string(reg_key_match[2].first, reg_key_match[2].second);      //Split the registry path into parent, key-path and value. -    boost::smatch reg_parent_match; -    if (not boost::regex_search(reg_key_path, reg_parent_match, boost::regex("^(.+?)\\\\(.+)\\\\(.+)$", boost::regex::icase))) +    std::smatch reg_parent_match; +    if (not std::regex_search(reg_key_path, reg_parent_match, std::regex("^(.+?)\\\\(.+)\\\\(.+)$", std::regex::icase)))          return std::string();      std::string reg_parent = std::string(reg_parent_match[1].first, reg_parent_match[1].second);      std::string reg_path = std::string(reg_parent_match[2].first, reg_parent_match[2].second); diff --git a/host/tests/dpdk_test.cpp b/host/tests/dpdk_test.cpp index df4717154..c32e47824 100644 --- a/host/tests/dpdk_test.cpp +++ b/host/tests/dpdk_test.cpp @@ -17,14 +17,11 @@  #include <sys/time.h>  #include <unistd.h>  #include <boost/program_options.hpp> -#include <boost/regex.hpp>  #include <cstdbool>  #include <cstdio>  #include <cstring>  #include <iostream> -static const boost::regex colons(":"); -  namespace po = boost::program_options;  namespace {  | 
