I wish to parse a string and ensure that it is lower case.
It has to be done at this stage because spirit builds tree out of it all.
so I have this rule
struct to_lower_object
{
typedef char result_type;
char operator()(char a) const
{
return std::tolower(a);
}
};
int main()
{
boost::phoenix::function<to_lower_object> lazy_lower;
qi::rule<std::string::iterator, char() >
lower_char=(qi::char_-":")
[
qi::_val=lazy_lower(qi::_1);
];
qi::rule<std::string::iterator, std::string() >
lower_string =
+lower_char;
:::
problem is that it doesn't compile, the error is massive also, to big to post.
Thanks
EDIT: I fixed the operator overload, that was my bad, but the problem persists. I beleive* it is to do with the placeholders
EDIT2: I have split the problem up to ensure that it is working on a char and not a series of them, but it still isn't working with the same reams of errors.
Well after much torment I finally got it working.
This:
struct to_lower_object
{
typedef char result_type;
char operator()(char a) const
{
return std::tolower(a);
}
};
Should have been:
struct to_lower_object
{
template<typename Arg>
struct result{
typedef char type;
};
template<typename Arg>
char operator()(Arg arg1) const
{
return std::tolower(a);
}
};
Super. This apparently is because I was reading some old docs.