diff options
author | Josh Blum <josh@joshknows.com> | 2011-09-15 13:10:02 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-09-15 13:10:02 -0700 |
commit | b20c9fc836a0f32666739dcd143692149eb66c68 (patch) | |
tree | 83e7a43b94fddec0d9d1da4dbb9dc4f9b6de0d98 /host/lib | |
parent | 748e4bafbaec39b90f80e54251de339ab5b90cb6 (diff) | |
download | uhd-b20c9fc836a0f32666739dcd143692149eb66c68.tar.gz uhd-b20c9fc836a0f32666739dcd143692149eb66c68.tar.bz2 uhd-b20c9fc836a0f32666739dcd143692149eb66c68.zip |
uhd: separate_device_addr, copy globals across entire address
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/types/device_addr.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/host/lib/types/device_addr.cpp b/host/lib/types/device_addr.cpp index 45d885adc..e329bd390 100644 --- a/host/lib/types/device_addr.cpp +++ b/host/lib/types/device_addr.cpp @@ -96,7 +96,8 @@ device_addrs_t uhd::separate_device_addr(const device_addr_t &dev_addr){ } } //------------------------------------------------------------------ - device_addrs_t dev_addrs; + 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) BOOST_FOREACH(const std::string &key, dev_addr.keys()){ boost::cmatch matches; if (not boost::regex_match(key.c_str(), matches, boost::regex("^(\\D+)(\\d*)$"))){ @@ -104,10 +105,21 @@ device_addrs_t uhd::separate_device_addr(const device_addr_t &dev_addr){ } std::string key_part(matches[1].first, matches[1].second); std::string num_part(matches[2].first, matches[2].second); - size_t num = (num_part.empty())? 0 : boost::lexical_cast<size_t>(num_part); + if (num_part.empty()){ //no number? save it for later + global_keys.push_back(key); + continue; + } + const size_t num = boost::lexical_cast<size_t>(num_part); dev_addrs.resize(std::max(num+1, dev_addrs.size())); dev_addrs[num][key_part] = dev_addr[key]; } + + //copy the global settings across all device addresses + BOOST_FOREACH(device_addr_t &my_dev_addr, dev_addrs){ + BOOST_FOREACH(const std::string &global_key, global_keys){ + my_dev_addr[global_key] = dev_addr[global_key]; + } + } return dev_addrs; } |