132
|
1 /*******************************************************************************
|
|
2
|
|
3 copyright: Copyright (c) 2007 Kris Bell. All rights reserved
|
|
4
|
|
5 license: BSD style: $(LICENSE)
|
|
6
|
|
7 version: Sep 2007: Initial release
|
|
8 version: Nov 2007: Added stream wrappers
|
|
9
|
|
10 author: Kris
|
|
11
|
|
12 *******************************************************************************/
|
|
13
|
|
14 module tango.text.convert.Format;
|
|
15
|
|
16 private import tango.io.model.IConduit;
|
|
17
|
|
18 private import tango.text.convert.Layout;
|
|
19
|
|
20 /******************************************************************************
|
|
21
|
|
22 Constructs a global utf8 instance of Layout
|
|
23
|
|
24 ******************************************************************************/
|
|
25
|
|
26 public Layout!(char) Format;
|
|
27
|
|
28 static this()
|
|
29 {
|
|
30 Format = new Layout!(char);
|
|
31 }
|
|
32
|
|
33 /******************************************************************************
|
|
34
|
|
35 Global function to format into a stream
|
|
36
|
|
37 ******************************************************************************/
|
|
38
|
|
39 deprecated void format (OutputStream output, char[] fmt, ...)
|
|
40 {
|
|
41 Format.convert ((char[] s){return output.write(s);}, _arguments, _argptr, fmt);
|
|
42 }
|
|
43
|
|
44 /******************************************************************************
|
|
45
|
|
46 Global function to format into a stream, and add a newline
|
|
47
|
|
48 ******************************************************************************/
|
|
49
|
|
50 deprecated void formatln (OutputStream output, char[] fmt, ...)
|
|
51 {
|
|
52 version (Win32)
|
|
53 const char[] Eol = "\r\n";
|
|
54 else
|
|
55 const char[] Eol = "\n";
|
|
56
|
|
57 Format.convert ((char[] s){return output.write(s);}, _arguments, _argptr, fmt);
|
|
58 output.write (Eol);
|
|
59 }
|
|
60
|
|
61
|
|
62 /******************************************************************************
|
|
63
|
|
64 ******************************************************************************/
|
|
65
|
|
66 debug (Format)
|
|
67 {
|
|
68 import tango.io.Console;
|
|
69
|
|
70 void main()
|
|
71 {
|
|
72 formatln (Cout.stream, "hello {}", "world");
|
|
73 }
|
|
74 }
|