diff options
author | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2016-10-07 16:36:28 +0200 |
---|---|---|
committer | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2016-10-07 16:36:28 +0200 |
commit | f6aa2db83dfea89f9d2cfc6fcbd3da141ee77e02 (patch) | |
tree | 6de18fc05a9ee0cf033675aadfd8514a97d9e7d1 /src/Utilities.cpp | |
parent | 741675b458bf23cf437a6c56f95483c5c66af774 (diff) | |
parent | 8f2b55a66db9747419e75dae5973281a7536b934 (diff) | |
download | astra-f6aa2db83dfea89f9d2cfc6fcbd3da141ee77e02.tar.gz astra-f6aa2db83dfea89f9d2cfc6fcbd3da141ee77e02.tar.bz2 astra-f6aa2db83dfea89f9d2cfc6fcbd3da141ee77e02.tar.xz astra-f6aa2db83dfea89f9d2cfc6fcbd3da141ee77e02.zip |
Merge branch 'master' into parallel_vec
Diffstat (limited to 'src/Utilities.cpp')
-rw-r--r-- | src/Utilities.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/Utilities.cpp b/src/Utilities.cpp index c9740bf..8b0ca94 100644 --- a/src/Utilities.cpp +++ b/src/Utilities.cpp @@ -28,10 +28,6 @@ $Id$ #include "astra/Utilities.h" -#include <boost/algorithm/string.hpp> -#include <boost/algorithm/string/split.hpp> -#include <boost/algorithm/string/classification.hpp> - #include <sstream> #include <locale> #include <iomanip> @@ -84,18 +80,16 @@ std::vector<double> stringToDoubleVector(const std::string &s) template<typename T> std::vector<T> stringToVector(const std::string& s) { - // split - std::vector<std::string> items; - boost::split(items, s, boost::is_any_of(",;")); - - // init list std::vector<T> out; - out.resize(items.size()); + size_t current = 0; + size_t next; + do { + next = s.find_first_of(",;", current); + std::string t = s.substr(current, next - current); + out.push_back(stringTo<T>(t)); + current = next + 1; + } while (next != std::string::npos); - // loop elements - for (unsigned int i = 0; i < items.size(); i++) { - out[i] = stringTo<T>(items[i]); - } return out; } @@ -120,6 +114,18 @@ std::string doubleToString(double f) template<> std::string toString(float f) { return floatToString(f); } template<> std::string toString(double f) { return doubleToString(f); } +void splitString(std::vector<std::string> &items, const std::string& s, + const char *delim) +{ + items.clear(); + size_t current = 0; + size_t next; + do { + next = s.find_first_of(",;", current); + items.push_back(s.substr(current, next - current)); + current = next + 1; + } while (next != std::string::npos); +} } |