Mercurial > projects > ldc
diff tango/tango/io/stream/LineStream.d @ 132:1700239cab2e trunk
[svn r136] MAJOR UNSTABLE UPDATE!!!
Initial commit after moving to Tango instead of Phobos.
Lots of bugfixes...
This build is not suitable for most things.
author | lindquist |
---|---|
date | Fri, 11 Jan 2008 17:57:40 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tango/tango/io/stream/LineStream.d Fri Jan 11 17:57:40 2008 +0100 @@ -0,0 +1,72 @@ +/******************************************************************************* + + copyright: Copyright (c) 2007 Kris Bell. All rights reserved + + license: BSD style: $(LICENSE) + + version: Initial release: Oct 2007 + + author: Kris + +*******************************************************************************/ + +module tango.io.stream.LineStream; + +private import tango.io.model.IConduit; + +private import tango.text.stream.LineIterator; + +/******************************************************************************* + + Simple way to hook up a line-tokenizer to an arbitrary InputStream, + such as a file conduit: + --- + auto input = new LineInput (new FileInput("path")); + foreach (line; input) + ... + input.close; + --- + + Note that this is just a simple wrapper around LineIterator, and + supports utf8 lines only. Use LineIterator directly for utf16/32 + support, or use the other tango.text.stream classes directly for + other tokenizing needs. + + Note that this class is a true instance of InputStream, by way of + inheritance via the Iterator superclass. + +*******************************************************************************/ + +class LineInput : LineIterator!(char) +{ + /*********************************************************************** + + Propagate ctor to superclass + + ***********************************************************************/ + + this (InputStream stream) + { + super (stream); + } +} + + +/******************************************************************************* + + +*******************************************************************************/ + +debug (LineStream) +{ + import tango.io.Stdout; + import tango.io.stream.FileStream; + + void main() + { + auto input = new LineInput (new FileInput("LineStream.d")); + foreach (line; input) + Stdout(line).newline; + input.close; + } +} \ No newline at end of file