aboutsummaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-01-06 15:38:56 -0800
committerJosh Blum <josh@joshknows.com>2011-01-06 15:38:56 -0800
commit771b5cebda250f2a6a65aa7788e9051c94974c2b (patch)
tree78856934a0786b962d5acafde2eb3338ab5df582 /host/include
parent3d02c07470e83edfa118c7ff36e793ffa883ceff (diff)
downloaduhd-771b5cebda250f2a6a65aa7788e9051c94974c2b.tar.gz
uhd-771b5cebda250f2a6a65aa7788e9051c94974c2b.tar.bz2
uhd-771b5cebda250f2a6a65aa7788e9051c94974c2b.zip
uhd: integrated boost split or tokenizer into source files, remove string split from algorithms header
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/utils/algorithm.hpp29
1 files changed, 6 insertions, 23 deletions
diff --git a/host/include/uhd/utils/algorithm.hpp b/host/include/uhd/utils/algorithm.hpp
index 53c571e4e..ed0220a25 100644
--- a/host/include/uhd/utils/algorithm.hpp
+++ b/host/include/uhd/utils/algorithm.hpp
@@ -22,9 +22,6 @@
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/size.hpp>
-#include <boost/algorithm/string.hpp>
-#include <vector>
-#include <string>
/*! \file algorithm.hpp
* Useful templated functions and classes that I like to pretend are part of stl.
@@ -33,24 +30,6 @@
namespace std{
/*!
- * Split a string at the separation characters.
- * \param string the string to split
- * \param sep the separator characters
- * \return a range of strings
- */
- inline std::vector<std::string> split_string(
- const std::string &string, const std::string &sep = "\t "
- ){
- std::vector<std::string> strings;
- if (not string.empty()) boost::split(
- // do not split an empty string:
- // let me tell you about the time when boost::split segfaulted...
- strings, string, boost::is_any_of(sep)
- );
- return strings;
- }
-
- /*!
* A wrapper around std::copy that takes ranges instead of iterators.
*
* Copy the elements of the source range into the destination range.
@@ -164,8 +143,12 @@ namespace std{
* \param bound2 the upper or lower bound
* \return the value clipped at the bounds
*/
- template<typename T> inline T clip(T val, T bound1, T bound2){
- return std::min(std::max(val, std::min(bound1, bound2)), std::max(bound1, bound2));
+ template<typename T> inline T clip(const T &val, const T &bound1, const T &bound2){
+ const T minimum = std::min(bound1, bound2);
+ if (val < minimum) return minimum;
+ const T maximum = std::max(bound1, bound2);
+ if (val > maximum) return maximum;
+ return val;
}
}//namespace std