Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
July 11, 2008 std.stream for stdin? | ||||
---|---|---|---|---|
| ||||
I've been trying to write some small Unix-style utilities that read data from either a file or stdin, process it and write the results to stdout. Is there a way to create an object of the Stream class from Phobos or one of its subclasses that treats stdin as an input stream? I'd like to avoid using the C standard file/stream I/O if possible, since it doesn't handle exceptions automatically and is just in general butt ugly compared to Phobos's implementation. |
July 11, 2008 Re: std.stream for stdin? | ||||
---|---|---|---|---|
| ||||
Posted in reply to dsimcha | "dsimcha" <dsimcha@yahoo.com> wrote in message news:g57v7m$ss1$1@digitalmars.com... > I've been trying to write some small Unix-style utilities that read data > from > either a file or stdin, process it and write the results to stdout. Is > there > a way to create an object of the Stream class from Phobos or one of its > subclasses that treats stdin as an input stream? I'd like to avoid using > the > C standard file/stream I/O if possible, since it doesn't handle exceptions > automatically and is just in general butt ugly compared to Phobos's > implementation. import std.cstream, and use the din object :) |
July 11, 2008 Re: std.stream for stdin? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | How is this class supposed to be used? I wrote a simple test program, and it appears not to work the way other subclasses of Stream work. Here's the test program, which should just copy stdin to stdout, but seems to do absolutely nothing. void main () { foreach(char[] line; din) { writefln(line); } } Similar results occur when I use the readLine method. |
July 11, 2008 Re: std.stream for stdin? | ||||
---|---|---|---|---|
| ||||
Posted in reply to dsimch | "dsimch" <dsimcha@yahoo.com> wrote in message news:g58520$188d$1@digitalmars.com... > How is this class supposed to be used? I wrote a simple test program, and > it > appears not to work the way other subclasses of Stream work. Here's the > test > program, which should just copy stdin to stdout, but seems to do > absolutely nothing. > > void main () { > foreach(char[] line; din) { > writefln(line); > } > } > > Similar results occur when I use the readLine method. *shrug* I never had any problems using it. |
July 11, 2008 Re: std.stream for stdin? | ||||
---|---|---|---|---|
| ||||
Posted in reply to dsimch | Never mind. The problem was I had another test.exe file at a higher level in my path. |
July 11, 2008 Re: std.stream for stdin? | ||||
---|---|---|---|---|
| ||||
Posted in reply to dsimcha | "dsimcha" <dsimcha@yahoo.com> wrote in message news:g587ej$1cp1$1@digitalmars.com... > Never mind. The problem was I had another test.exe file at a higher level in my path. I hate those kinds of issues ;) |
Copyright © 1999-2021 by the D Language Foundation