view tango/tango/io/stream/LineStream.d @ 341:1bb99290e03a trunk

[svn r362] Started merging the old 'test' dir as well as the newer 'tangotests' dir into 'tests/mini' and 'tests/minicomplex'.
author lindquist
date Sun, 13 Jul 2008 02:51:19 +0200
parents 1700239cab2e
children
line wrap: on
line source

/*******************************************************************************

        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;
        }
}