diff options
author | Josh Blum <josh@joshknows.com> | 2010-08-15 10:51:25 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-08-15 10:51:25 -0700 |
commit | 98ba0cc067489d417342314a7e7408d2dbbc8250 (patch) | |
tree | 7fdcaf08c5bbf150bd03711c9909ed5ca77f1818 /host/include | |
parent | 6c3d37caa3a47ca534c5e3a110adad0137d5d06d (diff) | |
download | uhd-98ba0cc067489d417342314a7e7408d2dbbc8250.tar.gz uhd-98ba0cc067489d417342314a7e7408d2dbbc8250.tar.bz2 uhd-98ba0cc067489d417342314a7e7408d2dbbc8250.zip |
uhd: extract named prop returns a named prop (not a tuple)
simplifies the code after the property set/get declaration
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/utils/props.hpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/host/include/uhd/utils/props.hpp b/host/include/uhd/utils/props.hpp index f376d2612..fbca03019 100644 --- a/host/include/uhd/utils/props.hpp +++ b/host/include/uhd/utils/props.hpp @@ -21,7 +21,6 @@ #include <uhd/config.hpp> #include <uhd/wax.hpp> #include <uhd/utils/exception.hpp> -#include <boost/tuple/tuple.hpp> #include <stdexcept> #include <vector> #include <string> @@ -36,8 +35,25 @@ namespace uhd{ * Allows properties to be sub-sectioned by name. */ struct UHD_API named_prop_t{ - wax::obj key; - std::string name; + const wax::obj key; + const std::string name; + + //! Convert the key to the specified type + template<typename T> inline T as(void){ + return key.as<T>(); + } + + /*! + * Utility function to convert generic key into a named prop. + * If the key was already a named prop, the prop will be split. + * Otherwise, the key will be the key, and the name will be used. + * \param key a reference to the prop object + * \param name a reference to the name object + * \return a named property struct with key and name + */ + static named_prop_t extract( + const wax::obj &key, const std::string &name = "" + ); /*! * Create a new named prop from key and name. @@ -48,17 +64,6 @@ namespace uhd{ }; /*! - * Utility function to separate a named property into its components. - * \param key a reference to the prop object - * \param name a reference to the name object - * \return a tuple that can be used with boost::tie - */ - UHD_API boost::tuple<wax::obj, std::string> extract_named_prop( - const wax::obj &key, - const std::string &name = "" - ); - - /*! * Throw when getting a not-implemented or write-only property. * Throw-site information will be included with this error. */ |