Boost.regex examples using boost::mapfile::iterator and std::string::const_iterator

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Boost.regex examples using boost::mapfile::iterator and std::string::const_iterator

John Grabner
I used the regex library from version 1.28.0 with BCB6. I was able to
have a single function
CommentsStrings::MatchFound(boost::match_result<std::string::const_iterator>
what);

to process both a std::string and a boost::mapfile.

The calling functions are:

//---------------------------------------------------------------------------
void CommentsStrings::Analyse(const std::string& Buffer)
{
     Buffer_ = Buffer;
     AllCommentsStrings_.clear();

     // find comments and strings
     std::string::const_iterator start, end;
     start = Buffer_.begin();
     end = Buffer_.end();
     boost::regex_grep(
        std::bind1st(std::mem_fun(&CommentsStrings::MatchFound), this),
         start,
         end,
         CommentStringExpression);
}

//---------------------------------------------------------------------------
void CommentsStrings::Analyse(const char *file)
{
     currentFile = file;
     AllCommentsStrings_.clear();

     // find comments and strings
     boost::mapfile f(currentFile.c_str());
     boost::mapfile::iterator start, end;
     start = f.begin();
     end = f.end();
     boost::regex_grep(
        std::bind1st(std::mem_fun(&CommentsStrings::MatchFound), this),
         start,
         end,
         CommentStringExpression);
}

Now I am using BDS2006 and boost 1_33_1 I am getting an error

Could not find a match for
'std::bind1st<std::mem_fun_t<bool,CommentsStrings,smatch> >::operator
()(cmatch)'.

I know that the iterator for std::string is a class and not a char
pointer. I am at a loss as how to proceed.

John.

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Boost.regex examples using boost::mapfile::iteratorand std::string::const_iterator

John Maddock

> I know that the iterator for std::string is a class and not a char
> pointer. I am at a loss as how to proceed.

That would likely be the cause of the problem: you're trying to use the same
code with two different incompatible iterator types.  What you could do is
use:

mystring.c_str();  in place of mystring.begin()
mystring.c_str()+mystring.size(); in place of mystring.end()

So that you're back to using const char* as an iterator for std::string
again.

John.

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users