diff options
Diffstat (limited to 'host')
-rw-r--r-- | host/include/uhd/config.hpp | 9 | ||||
-rw-r--r-- | host/include/uhd/types/ranges.hpp | 13 | ||||
-rw-r--r-- | host/include/uhd/types/ranges.ipp | 19 |
3 files changed, 34 insertions, 7 deletions
diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp index 043e8d884..316d60c2b 100644 --- a/host/include/uhd/config.hpp +++ b/host/include/uhd/config.hpp @@ -56,14 +56,17 @@ #define UHD_HELPER_DLL_IMPORT __declspec(dllimport) #define UHD_HELPER_DLL_EXPORT __declspec(dllexport) #define UHD_HELPER_DLL_LOCAL + #define UHD_HELPER_EXIMP_TMPL #elif defined(__GNUG__) && __GNUG__ >= 4 #define UHD_HELPER_DLL_IMPORT __attribute__ ((visibility("default"))) #define UHD_HELPER_DLL_EXPORT __attribute__ ((visibility("default"))) #define UHD_HELPER_DLL_LOCAL __attribute__ ((visibility("hidden"))) + #define UHD_HELPER_EXIMP_TMPL extern #else #define UHD_HELPER_DLL_IMPORT #define UHD_HELPER_DLL_EXPORT #define UHD_HELPER_DLL_LOCAL + #define UHD_HELPER_EXIMP_TMPL extern #endif // Now we use the generic helper definitions above to define UHD_API and UHD_LOCAL. @@ -75,16 +78,16 @@ #ifdef UHD_DLL // defined if UHD is compiled as a DLL #ifdef UHD_DLL_EXPORTS // defined if we are building the UHD DLL (instead of using it) #define UHD_API UHD_HELPER_DLL_EXPORT - #define EXIMP_TEMPLATE extern + #define UHD_EXIMP_TMPL UHD_HELPER_EXIMP_TMPL #else #define UHD_API UHD_HELPER_DLL_IMPORT - #define EXIMP_TEMPLATE + #define UHD_EXIMP_TMPL #endif // UHD_DLL_EXPORTS #define UHD_LOCAL UHD_HELPER_DLL_LOCAL #else // UHD_DLL is not defined: this means UHD is a static lib. #define UHD_API #define UHD_LOCAL - #define EXIMP_TEMPLATE + #define UHD_EXIMP_TMPL #endif // UHD_DLL // Define force inline macro diff --git a/host/include/uhd/types/ranges.hpp b/host/include/uhd/types/ranges.hpp index 25120de40..1bd87b468 100644 --- a/host/include/uhd/types/ranges.hpp +++ b/host/include/uhd/types/ranges.hpp @@ -21,6 +21,7 @@ #include <uhd/config.hpp> #include <uhd/utils/pimpl.hpp> #include <vector> +#include <string> namespace uhd{ @@ -55,8 +56,11 @@ namespace uhd{ //! Get the step value for this range. const T step(void) const; + //! Convert this range to a printable string + const std::string to_pp_string(void) const; + private: - UHD_PIMPL_DECL(impl) _impl; + UHD_PIMPL_DECL(impl) _impl; }; /*! @@ -102,14 +106,17 @@ namespace uhd{ */ const T clip(const T &value, bool clip_step = false) const; + //! Convert this meta-range to a printable string + const std::string to_pp_string(void) const; + }; //! export a symbol for the gain range type - EXIMP_TEMPLATE template struct UHD_API meta_range_t<float>; + UHD_EXIMP_TMPL template struct UHD_API meta_range_t<float>; typedef meta_range_t<float> gain_range_t; //! export a symbol for the freq range type - EXIMP_TEMPLATE template struct UHD_API meta_range_t<double>; + UHD_EXIMP_TMPL template struct UHD_API meta_range_t<double>; typedef meta_range_t<double> freq_range_t; diff --git a/host/include/uhd/types/ranges.ipp b/host/include/uhd/types/ranges.ipp index 8b602a24d..29f389fca 100644 --- a/host/include/uhd/types/ranges.ipp +++ b/host/include/uhd/types/ranges.ipp @@ -22,7 +22,7 @@ #include <boost/foreach.hpp> #include <algorithm> #include <stdexcept> -#include <iostream> +#include <sstream> namespace uhd{ @@ -66,6 +66,15 @@ namespace uhd{ return _impl->step; } + template <typename T> const std::string range_t<T>::to_pp_string(void) const{ + std::stringstream ss; + ss << "(" << this->start(); + if (this->start() != this->stop()) ss << ", " << this->stop(); + if (this->step() != T(0)) ss << ", " << this->step(); + ss << ")"; + return ss.str(); + } + /******************************************************************* * meta_range_t implementation code ******************************************************************/ @@ -163,6 +172,14 @@ namespace uhd{ return last_stop; } + template <typename T> const std::string meta_range_t<T>::to_pp_string(void) const{ + std::stringstream ss; + BOOST_FOREACH(const range_t<T> &r, (*this)){ + ss << r.to_pp_string() << std::endl; + } + return ss.str(); + } + } //namespace uhd #endif /* INCLUDED_UHD_TYPES_RANGES_IPP */ |