diff options
author | Josh Blum <josh@joshknows.com> | 2011-11-03 19:28:43 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-11-03 19:28:43 -0700 |
commit | c086dd883e5c318dcdf8e654128abf671da90ec0 (patch) | |
tree | 8387598d7a512602d6f38998cc41c9a2384e5e0d /host/lib | |
parent | f8d66fcfb14062283cdb0d0cbe4f77e2964ceb82 (diff) | |
download | uhd-c086dd883e5c318dcdf8e654128abf671da90ec0.tar.gz uhd-c086dd883e5c318dcdf8e654128abf671da90ec0.tar.bz2 uhd-c086dd883e5c318dcdf8e654128abf671da90ec0.zip |
uhd: allow device addr (from string) to parse empty values
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/types/device_addr.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/host/lib/types/device_addr.cpp b/host/lib/types/device_addr.cpp index e329bd390..1554c3e4e 100644 --- a/host/lib/types/device_addr.cpp +++ b/host/lib/types/device_addr.cpp @@ -40,16 +40,15 @@ static std::string trim(const std::string &in){ device_addr_t::device_addr_t(const std::string &args){ BOOST_FOREACH(const std::string &pair, tokenizer(args, arg_delim)){ if (trim(pair) == "") continue; - std::string key; + std::vector<std::string> toks; BOOST_FOREACH(const std::string &tok, tokenizer(pair, pair_delim)){ - if (key.empty()) key = tok; - else{ - this->set(trim(key), trim(tok)); - goto continue_next_arg; - } + toks.push_back(tok); + } + if (toks.size() == 1) toks.push_back(""); //pad empty value + if (toks.size() == 2 and not trim(toks[0]).empty()){ //only valid combination + this->set(trim(toks[0]), trim(toks[1])); } - throw uhd::value_error("invalid args string: "+args); - continue_next_arg: continue; + else throw uhd::value_error("invalid args string: "+args); //otherwise error } } |