diff options
author | Josh Blum <josh@joshknows.com> | 2011-02-11 21:52:13 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-02-11 21:52:13 -0800 |
commit | 4613f454c781d258d6d9b210ff1b9043a2125981 (patch) | |
tree | b69eab37b2099a5d699ac6b480673134d29e7fda /host/lib | |
parent | 9de6f36bc5d9f5d9d602547166c92b53b278b428 (diff) | |
download | uhd-4613f454c781d258d6d9b210ff1b9043a2125981.tar.gz uhd-4613f454c781d258d6d9b210ff1b9043a2125981.tar.bz2 uhd-4613f454c781d258d6d9b210ff1b9043a2125981.zip |
uhd: added to_<type> calls to sensors to make it easy
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/types/sensors.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/host/lib/types/sensors.cpp b/host/lib/types/sensors.cpp index 2bff136a4..5f7115d70 100644 --- a/host/lib/types/sensors.cpp +++ b/host/lib/types/sensors.cpp @@ -17,6 +17,7 @@ #include <uhd/types/sensors.hpp> #include <uhd/utils/exception.hpp> +#include <boost/lexical_cast.hpp> #include <boost/format.hpp> using namespace uhd; @@ -35,7 +36,7 @@ sensor_value_t::sensor_value_t( sensor_value_t::sensor_value_t( const std::string &name, - int_type value, + signed value, const std::string &unit, const std::string &formatter ): @@ -47,7 +48,7 @@ sensor_value_t::sensor_value_t( sensor_value_t::sensor_value_t( const std::string &name, - real_type value, + double value, const std::string &unit, const std::string &formatter ): @@ -79,3 +80,15 @@ std::string sensor_value_t::to_pp_string(void) const{ } UHD_THROW_INVALID_CODE_PATH(); } + +bool sensor_value_t::to_bool(void) const{ + return value == "true"; +} + +signed sensor_value_t::to_int(void) const{ + return boost::lexical_cast<signed>(value); +} + +double sensor_value_t::to_real(void) const{ + return boost::lexical_cast<double>(value); +} |