1 /** 2 * Copyright: Copyright (c) 2007-2008 Jacob Carlborg. All rights reserved. 3 * Authors: Jacob Carlborg 4 * Version: Initial created: 2007 5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) 6 * 7 */ 8 module mambo.core.io; 9 10 version (Tango) 11 { 12 import tango.io.Stdout; 13 import tango.io.Console; 14 15 import mambo.core.string; 16 17 /** 18 * Print to the standard output 19 * 20 * Params: 21 * args = what to print 22 */ 23 void print (A...)(A args) 24 { 25 static enum string fmt = "{}{}{}{}{}{}{}{}" ~ 26 "{}{}{}{}{}{}{}{}" ~ 27 "{}{}{}{}{}{}{}{}"; 28 29 static assert (A.length <= fmt.length / 2, "mambo.io.print :: too many arguments"); 30 31 Stdout.format(fmt[0 .. args.length * 2], args).flush; 32 } 33 34 /** 35 * Print to the standard output, adds a new line 36 * 37 * Params: 38 * args = what to print 39 */ 40 void println (A...)(A args) 41 { 42 static enum string fmt = "{}{}{}{}{}{}{}{}" ~ 43 "{}{}{}{}{}{}{}{}" ~ 44 "{}{}{}{}{}{}{}{}"; 45 46 static assert (A.length <= fmt.length / 2, "mambo.io.println :: too many arguments"); 47 48 Stdout.formatln(fmt[0 .. args.length * 2], args); 49 } 50 } 51 52 else 53 { 54 import std.stdio; 55 56 /** 57 * Print to the standard output 58 * 59 * Params: 60 * args = what to print 61 */ 62 void print (A...)(A args) 63 { 64 write(args); 65 } 66 67 /** 68 * Print to the standard output, adds a new line 69 * 70 * Params: 71 * args = what to print 72 */ 73 void println (A...)(A args) 74 { 75 writeln(args); 76 } 77 }