37 #include <boost/core/ignore_unused.hpp>
38 #include <boost/spirit/include/qi_auto.hpp>
39 #include <boost/spirit/include/qi_core.hpp>
42 namespace qi = boost::spirit::qi;
43 namespace fusion = boost::fusion;
74 static_assert(std::is_integral<T>::value,
"Integer type required.");
75 for (T i = fusion::at_c<0>(num); i <= fusion::at_c<1>(num); ++i)
104 std::vector<unsigned int> &out)
108 auto it = str.begin();
109 bool success = qi::phrase_parse(
111 ((qi::uint_ >>
'-' >> qi::uint_)[f2] | qi::uint_[f1]) %
',',
114 return success && it == str.end();
128 template <
typename T>
131 auto it = str.begin();
133 qi::phrase_parse(it, str.end(), qi::auto_ %
',', qi::ascii::space, out);
134 return success && it == str.end();
138 const std::string &str, std::vector<int> &out);
140 const std::string &str, std::vector<long> &out);
142 const std::string &str, std::vector<unsigned int> &out);
144 const std::string &str, std::vector<double> &out);
146 const std::string &str, std::vector<float> &out);
156 const std::string &str, std::vector<std::string> &out)
158 auto it = str.begin();
159 bool success = qi::phrase_parse(it, str.end(), +~qi::char_(
",") %
',',
160 qi::ascii::space, out);
161 return success && it == str.end();
#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.
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.
The above copyright notice and this permission notice shall be included.
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)