I see visions of automap, but I like the idea. A number of easily accessable filters would help speed up a lot of common line iteration operations.
/ Peter Bortas
Previous text:
2003-01-01 18:13: Subject: stdin->line_iterator
With iterators, I guess one could have a basic line iterator that keeps the lineendings, and filter it like
foreach(f->line_iterator();; string x) ... /* Process full lines */
foreach(some_filter(f->line_iterator());; string x) ... /* Process filtered lines */
where some_filter could for example
- Strip line endings
- Strip strip line endings as well as other trailing white space
- Strip leading white space
- Strip empty lines
- Strip #-style comments
- Process -style lines continuations
etc. I'm not very familiar with the iterator stuff, but I hope it's reasonably easy to write such filters, by stacking one iterator on top of another.
And if anybody thinks that helps readability, perhaps one could arrange the line_iterator to take the filter as an argument (but on the other hand, it might make more sense to give line_iterator an optional argument that says what kind of end-of-line characters it should recognize).
/ Niels Möller ()