Boost logo

Boost Users :

From: Metasebia Moges (mtsbmoges_at_[hidden])
Date: 2007-04-16 05:57:35


Dear Sir,

First of all, thank you for your reply. Your replies for my requests were very helpful.

>You can use Boost.Regex in a dll by defining BOOST_REGEX_DYN_LINK when
>building your dll, but as long as the regex code is isolated to your dll and
>doesn't spill over into it's public interface then this shouldn't be
>necessary. Other than that it's hard to say what the issue might be without
>seeing your code.

As you said, the regex code is isolated in my dll and doesn't spill over into the public interface. Then the problem could be with my code below. Would you please inspect and correct me if I am wrong somewhere?

I read a phrase from a file and search for words preceded by "W=" and if the word is different from !NULL, sil, and SIL, I store them in a list called PhraseList for further processing.

boost::regex re("W=\\w+");
boost::regex sre("!NULL|sil|SIL");
string s, sbuf;
string::const_iterator begin, end;
size_t length;
sbuf = phrase;
begin = sbuf.begin();
end = sbuf.end();
boost::match_results<std::string::const_iterator>matches;
boost::match_flag_type flags = boost::match_default;

while(boost::regex_search(begin, end, matches, re, flags))
{
    if(boost::regex_search(phrase, re))
        {
        s= matches.str();
        length=matches.str().size();
        string item =s.substr(2,length-1);
        if(boost::regex_match(item,sre))
            break;
        else{
            phraseList.addString (item.c_str());
             break;
            }//else
        } //if
    }//while
I have the following code which does the job without any problem at the expense of "not using boost".

I have a line read from a file:
// Parse the line
len=strlen(phrase);
//If the phrase is a content bearing term, put it into phrase list
while(i<len){
if(phrase[i] != 'W')
            i++;
else{
        i=i+2;
        item=&phrase[i];
        if (strncmp (item,"!NULL ",6) == 0|| strncmp(item,"sil ",4)==0 || strncmp(item,"SIL ",4)==0)
            break;
       else {
            memcpy(phrase, item, strlen(item)+1);
            phraseList.addString (phrase);
            break;
        }
    }
}

I don't like the second option in spite of the fact that it works. Moreover, I want to use boost.regex for other complex tasks and I want to test it with this simple real life problem. Your input is highly appreciated!

Thank you in advance!

Best regards,

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

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net