root/branches/v2.1/example/lineio.d

Revision 897, 1.1 kB (checked in by kris, 2 years ago)

removed tabs

Line 
1 private import  mango.io.Console,
2                 mango.io.FileConduit;
3
4 private import  mango.text.LineIterator;
5
6 /*******************************************************************************
7
8         Read a file line-by-line, sending each one to the console. This
9         illustrates how to bind a conduit to a text iterator. Iterators
10         also support the binding of buffer and string instances.
11
12         Note that iterators are templated for char, wchar and dchar ~
13         this example uses char
14
15 *******************************************************************************/
16
17 void main (char[][] args)
18 {
19         if (args.length == 2)
20            {
21            // open a file for reading
22            auto file = new FileConduit (args[1]);
23
24            // create an iterator and bind it to the file
25            auto line = new LineIterator (file);
26
27            // process file one line at a time
28            while (line.next)
29                   Cout (line.get) .newline;
30            }
31         else
32            Cout ("usage: lineio filename");
33 }
Note: See TracBrowser for help on using the browser.