@MarekR22: Could you explain why a while(1) should be better than a check of the end of the buffer/file/whatever?
But another idea:
// base class
struct Matcher {
virtual bool matches(line);
virtual void doStuff();
}
// impl
struct Matcher1 : public Matcher {...}
struct Matcher2 : public Matcher {...}
// algorithm
// 1.) make a list of the matcher
foreach(const QString& line, lines) {
foreach(Matcher* matcher, list_of_matchers) {
if(matcher->matches(line)) {
matcher->doStuff();
break;
}
}
}
// base class
struct Matcher {
virtual bool matches(line);
virtual void doStuff();
}
// impl
struct Matcher1 : public Matcher {...}
struct Matcher2 : public Matcher {...}
// algorithm
// 1.) make a list of the matcher
foreach(const QString& line, lines) {
foreach(Matcher* matcher, list_of_matchers) {
if(matcher->matches(line)) {
matcher->doStuff();
break;
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks