Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
StringUtils.h
Go to the documentation of this file.
1
19#ifndef _ALEXANDRIAKERNEL_STRINGUTILS_H
20#define _ALEXANDRIAKERNEL_STRINGUTILS_H
21
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>
26#include <vector>
27
29
30namespace Euclid {
31
43template <typename T>
46 boost::trim(str);
47 boost::split(parts, str, boost::is_any_of(separators), boost::token_compress_on);
48 std::vector<T> result(parts.size());
49 try {
50 std::transform(parts.begin(), parts.end(), result.begin(), boost::lexical_cast<T, const std::string&>);
51 } catch (const boost::bad_lexical_cast& e) {
52 throw Elements::Exception(e.what());
53 }
54 return result;
55}
56
57} /* namespace Euclid */
58
59#endif /* _ALEXANDRIAKERNEL_STRINGUTILS_H */
T begin(T... args)
T end(T... args)
std::vector< T > stringToVector(std::string str, const std::string &separators=std::string(", "))
Definition StringUtils.h:44
T size(T... args)
T transform(T... args)