Alexandria  2.19
Please provide a description of the project.
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 
30 namespace Euclid {
31 
43 template <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)
ELEMENTS_API auto split(Args &&... args) -> decltype(splitPath(std::forward< Args >(args)...))
constexpr double e
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)