diff options
Diffstat (limited to 'host/lib/include')
| -rw-r--r-- | host/lib/include/uhdlib/usrp/constrained_device_args.hpp | 24 | 
1 files changed, 7 insertions, 17 deletions
| diff --git a/host/lib/include/uhdlib/usrp/constrained_device_args.hpp b/host/lib/include/uhdlib/usrp/constrained_device_args.hpp index 7c516f80c..6d836c84d 100644 --- a/host/lib/include/uhdlib/usrp/constrained_device_args.hpp +++ b/host/lib/include/uhdlib/usrp/constrained_device_args.hpp @@ -10,6 +10,7 @@  #include <uhd/exception.hpp>  #include <uhd/types/device_addr.hpp> +#include <uhd/utils/cast.hpp>  #include <unordered_map>  #include <boost/algorithm/string.hpp>  #include <boost/assign/list_of.hpp> @@ -220,27 +221,16 @@ public: // Types          inline void parse(const std::string& str_rep)          {              try { -                _value = (std::stoi(str_rep) != 0); -            } catch (std::exception& ex) {                  if (str_rep.empty()) { -                    // If str_rep is empty then the device_addr was set -                    // without a value which means that the user "set" the flag -                    _value = true; -                } else if (boost::algorithm::to_lower_copy(str_rep) == "true" -                           || boost::algorithm::to_lower_copy(str_rep) == "yes" -                           || boost::algorithm::to_lower_copy(str_rep) == "y" -                           || str_rep == "1") { +                    // If str_rep is empty, the flag is interpreted as set                      _value = true; -                } else if (boost::algorithm::to_lower_copy(str_rep) == "false" -                           || boost::algorithm::to_lower_copy(str_rep) == "no" -                           || boost::algorithm::to_lower_copy(str_rep) == "n" -                           || str_rep == "0") { -                    _value = false;                  } else { -                    throw uhd::value_error( -                        str(boost::format("Error parsing boolean parameter %s: %s.") -                            % key() % ex.what())); +                    _value = uhd::cast::from_str<bool>(str_rep);                  } +            } catch (std::exception& ex) { +                throw uhd::value_error( +                    str(boost::format("Error parsing boolean parameter %s: %s.") +                        % key() % ex.what()));              }          }          inline virtual std::string to_string() const | 
