Moved string splitting functions; added string character removal function
parent
c0c6d00b12
commit
f01bcded1e
|
@ -20,6 +20,7 @@
|
|||
#include <functional>
|
||||
#include <complex>
|
||||
#include <random>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef OPENCL_API
|
||||
#include "clpp11.hpp"
|
||||
|
@ -258,6 +259,30 @@ std::string ToString(T value);
|
|||
|
||||
// =================================================================================================
|
||||
|
||||
// String splitting by a delimiter
|
||||
template<typename Out>
|
||||
void split(const std::string &s, char delimiter, Out result) {
|
||||
std::stringstream ss(s);
|
||||
std::string item;
|
||||
while (std::getline(ss, item, delimiter)) {
|
||||
*(result++) = item;
|
||||
}
|
||||
}
|
||||
|
||||
// See above
|
||||
inline std::vector<std::string> split(const std::string &s, char delimiter) {
|
||||
std::vector<std::string> elements;
|
||||
split(s, delimiter, std::back_inserter(elements));
|
||||
return elements;
|
||||
}
|
||||
|
||||
// String character removal
|
||||
inline void remove_character(std::string &str, char to_be_removed) {
|
||||
str.erase(std::remove(str.begin(), str.end(), to_be_removed), str.end());
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
|
||||
// Parses command-line and environmental-variable arguments into a std::vector of strings
|
||||
std::vector<std::string> RetrieveCommandLineArguments(int argc, char *argv[]);
|
||||
|
||||
|
|
|
@ -116,23 +116,6 @@ Buffer<T> CreateInvalidBuffer(const Context& context, const size_t size) {
|
|||
|
||||
// =================================================================================================
|
||||
|
||||
template<typename Out>
|
||||
void split(const std::string &s, char delimiter, Out result) {
|
||||
std::stringstream ss(s);
|
||||
std::string item;
|
||||
while (std::getline(ss, item, delimiter)) {
|
||||
*(result++) = item;
|
||||
}
|
||||
}
|
||||
|
||||
inline std::vector<std::string> split(const std::string &s, char delimiter) {
|
||||
std::vector<std::string> elements;
|
||||
split(s, delimiter, std::back_inserter(elements));
|
||||
return elements;
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
|
||||
using BestParameters = std::unordered_map<std::string,size_t>;
|
||||
using BestParametersCollection = std::unordered_map<std::string, BestParameters>;
|
||||
|
||||
|
|
Loading…
Reference in New Issue