37 #include <boost/core/ignore_unused.hpp> 38 #include <boost/spirit/include/qi_core.hpp> 39 #include <boost/spirit/include/qi_auto.hpp> 42 namespace qi = boost::spirit::qi;
43 namespace fusion = boost::fusion;
73 static_assert(std::is_integral<T>::value,
"Integer type required.");
74 for (T i = fusion::at_c<0>(num); i <= fusion::at_c<1>(num); ++i)
83 boost::ignore_unused(src);
109 const std::string &str, std::vector<unsigned int> &out)
113 auto it = str.begin();
114 bool success = qi::phrase_parse(
117 ((qi::uint_ >>
'-' >> qi::uint_)[f2] | qi::uint_[f1]) %
',',
120 return success && it == str.end();
134 template <
typename T>
137 auto it = str.begin();
138 bool success = qi::phrase_parse(
139 it, str.end(), qi::auto_ %
',', qi::ascii::space, out);
140 return success && it == str.end();
144 const std::string &str, std::vector<int> &out);
146 const std::string &str, std::vector<long> &out);
148 const std::string &str, std::vector<unsigned int> &out);
150 const std::string &str, std::vector<double> &out);
152 const std::string &str, std::vector<float> &out);
162 std::vector<std::string> &out)
164 auto it = str.begin();
165 bool success = qi::phrase_parse(
166 it, str.end(), +~qi::char_(
",") %
',', qi::ascii::space, out);
167 return success && it == str.end();
Helper functors for holding a vector of numbers to be parsed by boost::spirit.
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...
void operator()(T num) const
Pushes back values onto m_vec as given by num.
std::vector< T > & m_vec
Storage vector that will hold parsed variables from boost::spirit.
PushBackFunctor & operator=(const PushBackFunctor &src)
#define LIB_UTILITIES_EXPORT
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
PushBackFunctor(std::vector< T > &in)
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. ...