38#include <boost/lexical_cast.hpp>
39#include <boost/spirit/include/qi_auto.hpp>
40#include <boost/spirit/include/qi_core.hpp>
43namespace qi = boost::spirit::qi;
44namespace fusion = boost::fusion;
75 static_assert(std::is_integral<T>::value,
"Integer type required.");
76 for (T i = fusion::at_c<0>(num); i <= fusion::at_c<1>(num); ++i)
105 std::vector<unsigned int> &out)
109 auto it = str.begin();
110 bool success = qi::phrase_parse(
112 ((qi::uint_ >>
'-' >> qi::uint_)[f2] | qi::uint_[f1]) %
',',
115 return success && it == str.end();
132 auto it = str.begin();
134 qi::phrase_parse(it, str.end(), qi::auto_ %
',', qi::ascii::space, out);
135 return success && it == str.end();
139 const std::string &str, std::vector<int> &out);
141 const std::string &str, std::vector<long> &out);
143 const std::string &str, std::vector<unsigned int> &out);
145 const std::string &str, std::vector<double> &out);
147 const std::string &str, std::vector<float> &out);
157 const std::string &str, std::vector<std::string> &out)
159 auto it = str.begin();
160 bool success = qi::phrase_parse(it, str.end(), +~qi::char_(
",") %
',',
161 qi::ascii::space, out);
162 return success && it == str.end();
169 const std::vector<std::string> &variables,
172 std::vector<int> tempvect;
175 for (
auto i : tempvect)
186 const std::string &str,
const std::vector<std::string> &variables,
187 std::vector<int> &out)
190 std::vector<std::string> vars;
192 "Failed to interpret variable numbers or names from " + str);
193 for (std::string s : vars)
198 v = boost::lexical_cast<int>(s);
200 catch (
const boost::bad_lexical_cast &)
202 auto index =
find(variables.begin(), variables.end(), s);
203 v = index - variables.begin();
205 if (v < 0 || v >= variables.size())
207 WARNINGL0(
false,
"Warning: variable " + s +
" not found");
#define ASSERTL0(condition, msg)
#define WARNINGL0(condition, msg)
#define LIB_UTILITIES_EXPORT
static bool GenerateVariableSet(const std::string &str, const std::vector< std::string > &variables, std::set< int > &out)
Generate a set of variable locations.
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
static bool GenerateSeqVector(const std::string &str, std::vector< unsigned int > &out)
Takes a comma-separated compressed string and converts it to entries in a vector.
static bool GenerateVariableVector(const std::string &str, const std::vector< std::string > &variables, std::vector< int > &out)
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
Helper functors for holding a vector of numbers to be parsed by boost::spirit.
void operator()(T num) const
Pushes back values onto m_vec as given by num.
void operator()(fusion::vector< T, T > num) const
Pushes back values onto m_vec between the range supplied by num. Valid for only integer types.
std::vector< T > & m_vec
Storage vector that will hold parsed variables from boost::spirit.
PushBackFunctor(std::vector< T > &in)