summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <wjp@usecode.org>2016-07-29 15:31:05 +0200
committerGitHub <noreply@github.com>2016-07-29 15:31:05 +0200
commit7bb42ddd9e26fc7c01734d26bc114b5a935d9110 (patch)
tree2318c1454f248991ea6d19b335b422bb20d17603 /src
parent63bb375eda41e5b5b3b88a0a308fea4c44e25fcf (diff)
parent584fb584816aefca42518c9a6075ac2df814dac6 (diff)
downloadastra-7bb42ddd9e26fc7c01734d26bc114b5a935d9110.tar.gz
astra-7bb42ddd9e26fc7c01734d26bc114b5a935d9110.tar.bz2
astra-7bb42ddd9e26fc7c01734d26bc114b5a935d9110.tar.xz
astra-7bb42ddd9e26fc7c01734d26bc114b5a935d9110.zip
Merge pull request #62 from wjp/stringutil
Minor string parsing changes
Diffstat (limited to 'src')
-rw-r--r--src/Utilities.cpp34
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);
+}
}