Mercurial > projects > ldc
comparison tango/tango/io/stream/FormatStream.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.FormatStream; | |
14 | |
15 private import tango.io.Print; | |
16 | |
17 private import tango.io.model.IConduit; | |
18 | |
19 private import tango.text.convert.Format; | |
20 | |
21 /******************************************************************************* | |
22 | |
23 Simple way to hook up a utf8 formatter to an arbitrary OutputStream, | |
24 such as a file: | |
25 --- | |
26 auto output = new FormatOutput (new FileOutput("path")); | |
27 output.formatln ("{} green bottles", 10); | |
28 output.close; | |
29 --- | |
30 | |
31 This is a trivial wrapper around the Print class, and is limited | |
32 to emitting utf8 output. Use the Print class directly in order to | |
33 generate utf16/32 output instead. | |
34 | |
35 Note that this class is a true instance of OutputStream, by way of | |
36 inheritance via the Print superclass. | |
37 | |
38 *******************************************************************************/ | |
39 | |
40 class FormatOutput : Print!(char) | |
41 { | |
42 /*********************************************************************** | |
43 | |
44 Create a Layout instance and bind it to the given stream. | |
45 The optional second argument controls implicit flushing of | |
46 newline(), where true enables flushing. An explicit flush() | |
47 will always flush the output. | |
48 | |
49 ***********************************************************************/ | |
50 | |
51 this (OutputStream stream, bool flush=false) | |
52 { | |
53 super (Format, stream); | |
54 super.flush = flush; | |
55 } | |
56 } | |
57 | |
58 |