comparison 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
comparison
equal deleted inserted replaced
131:5825d48b27d1 132:1700239cab2e
1 /*******************************************************************************
2
3 copyright: Copyright (c) 2007 Kris Bell. All rights reserved
4
5 license: BSD style: $(LICENSE)
6
7 version: Initial release: Oct 2007
8
9 author: Kris
10
11 *******************************************************************************/
12
13 module tango.io.stream.LineStream;
14
15 private import tango.io.model.IConduit;
16
17 private import tango.text.stream.LineIterator;
18
19 /*******************************************************************************
20
21 Simple way to hook up a line-tokenizer to an arbitrary InputStream,
22 such as a file conduit:
23 ---
24 auto input = new LineInput (new FileInput("path"));
25 foreach (line; input)
26 ...
27 input.close;
28 ---
29
30 Note that this is just a simple wrapper around LineIterator, and
31 supports utf8 lines only. Use LineIterator directly for utf16/32
32 support, or use the other tango.text.stream classes directly for
33 other tokenizing needs.
34
35 Note that this class is a true instance of InputStream, by way of
36 inheritance via the Iterator superclass.
37
38 *******************************************************************************/
39
40 class LineInput : LineIterator!(char)
41 {
42 /***********************************************************************
43
44 Propagate ctor to superclass
45
46 ***********************************************************************/
47
48 this (InputStream stream)
49 {
50 super (stream);
51 }
52 }
53
54
55 /*******************************************************************************
56
57
58 *******************************************************************************/
59
60 debug (LineStream)
61 {
62 import tango.io.Stdout;
63 import tango.io.stream.FileStream;
64
65 void main()
66 {
67 auto input = new LineInput (new FileInput("LineStream.d"));
68 foreach (line; input)
69 Stdout(line).newline;
70 input.close;
71 }
72 }