@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:

Qt Code:
  1. // base class
  2. struct Matcher {
  3. virtual bool matches(line);
  4. virtual void doStuff();
  5. }
  6.  
  7. // impl
  8. struct Matcher1 : public Matcher {...}
  9. struct Matcher2 : public Matcher {...}
  10.  
  11. // algorithm
  12. // 1.) make a list of the matcher
  13.  
  14. foreach(const QString& line, lines) {
  15.  
  16. foreach(Matcher* matcher, list_of_matchers) {
  17.  
  18. if(matcher->matches(line)) {
  19. matcher->doStuff();
  20. break;
  21. }
  22. }
  23.  
  24. }
To copy to clipboard, switch view to plain text mode