18#ifndef VOTCA_TOOLS_TOKENIZER_H
19#define VOTCA_TOOLS_TOKENIZER_H
22#include <boost/algorithm/string/case_conv.hpp>
29#include <boost/tokenizer.hpp>
40 typename std::enable_if_t<std::is_arithmetic<T>::value &&
41 !std::is_same<T, bool>::value,
48 typename std::enable_if_t<
49 std::is_constructible<T, std::string>::value,
bool> =
true>
55 if (boost::to_lower_copy(s) ==
"true" || s ==
"1") {
57 }
else if (boost::to_lower_copy(s) ==
"false" || s ==
"0") {
60 throw std::runtime_error(
"'" + s +
"' cannot be converted to bool.");
86 boost::char_separator<char> sep(separators);
87 tok_ = std::make_unique<boost::tokenizer<boost::char_separator<char>>>(
str_,
90 Tokenizer(
const std::string &str,
const std::string &separators)
108 template <
class T = std::
string>
110 std::vector<T> result;
111 for (
auto &seg : *
this) {
118 std::unique_ptr<boost::tokenizer<boost::char_separator<char>>>
tok_;
124int wildcmp(
const char *wild,
const char *
string);
125int wildcmp(
const std::string &wild,
const std::string &
string);
136 const std::string &s,
type<Eigen::Matrix<T, Eigen::Dynamic, 1>>) {
138 return Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, 1>>(tmp.data(),
144 type<Eigen::Matrix<T, 3, 1>>) {
146 if (tmp.size() != 3) {
147 throw std::runtime_error(
"Vector has " + std::to_string(tmp.size()) +
148 " instead of 3 entries");
150 return {tmp[0], tmp[1], tmp[2]};
base class for all analysis tools