aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/include
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/include')
-rw-r--r--host/lib/include/uhdlib/usrp/constrained_device_args.hpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/host/lib/include/uhdlib/usrp/constrained_device_args.hpp b/host/lib/include/uhdlib/usrp/constrained_device_args.hpp
index 487337bae..b75fae75a 100644
--- a/host/lib/include/uhdlib/usrp/constrained_device_args.hpp
+++ b/host/lib/include/uhdlib/usrp/constrained_device_args.hpp
@@ -15,6 +15,7 @@
#include <boost/assign/list_of.hpp>
#include <vector>
#include <string>
+#include <sstream>
#include <unordered_map>
namespace uhd {
@@ -237,6 +238,16 @@ namespace usrp {
inline virtual std::string to_string() const = 0;
+ template <typename arg_type>
+ void parse_arg_default(
+ const device_addr_t& dev_args,
+ arg_type& constrained_arg
+ ) {
+ if (dev_args.has_key(constrained_arg.key())) {
+ constrained_arg.parse(dev_args[constrained_arg.key()]);
+ }
+ }
+
protected: //Methods
//Override _parse to provide an implementation to parse all
//client specific device args
@@ -270,10 +281,11 @@ namespace usrp {
if (!match) {
std::string valid_values_str;
for (size_t i = 0; i < valid_values.size(); i++) {
- valid_values_str += ((i==0)?"":", ") + std::to_string(valid_values[i]);
+ std::stringstream valid_values_ss;
+ valid_values_ss << ((i==0)?"":", ") << valid_values[i];
throw uhd::value_error(str(boost::format(
"Invalid device arg value: %s (Valid: {%s})") %
- arg.to_string() % valid_values_str
+ arg.to_string() % valid_values_ss.str()
));
}
}