19 #ifndef _ALEXANDRIAKERNEL_STRINGUTILS_H 20 #define _ALEXANDRIAKERNEL_STRINGUTILS_H 22 #include <boost/algorithm/string/classification.hpp> 23 #include <boost/algorithm/string/split.hpp> 24 #include <boost/algorithm/string/trim.hpp> 25 #include <boost/lexical_cast.hpp> 44 std::vector<T>
stringToVector(std::string str,
const std::string& separators = std::string(
", ")) {
45 std::vector<std::string> parts;
47 boost::split(parts, str, boost::is_any_of(separators), boost::token_compress_on);
48 std::vector<T> result(parts.size());
50 std::transform(parts.begin(), parts.end(), result.begin(), boost::lexical_cast<T,
const std::string&>);
52 catch (
const boost::bad_lexical_cast&
e) {
ELEMENTS_API auto split(Args &&... args) -> decltype(splitPath(std::forward< Args >(args)...))
std::vector< T > stringToVector(std::string str, const std::string &separators=std::string(", "))