Mercurial > projects > orange
view orange/core/io.d @ 26:78e5fef4bbf2 experimental
Third step in refactoring the API. Stating to add unit tests.
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Tue, 19 Oct 2010 10:22:10 +0200 |
parents | |
children |
line wrap: on
line source
/** * Copyright: Copyright (c) 2007-2008 Jacob Carlborg. All rights reserved. * Authors: Jacob Carlborg * Version: Initial created: 2007 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) * */ module orange.core.io; version (Tango) { import tango.io.Stdout; import tango.io.Console; import orange.core.string; } else import std.stdio; /** * Print to the standard output * * Params: * args = what to print */ void print (A...)(A args) { version (Tango) { const string fmt = "{}{}{}{}{}{}{}{}" "{}{}{}{}{}{}{}{}" "{}{}{}{}{}{}{}{}"; static assert (A.length <= fmt.length / 2, "mambo.io.print :: too many arguments"); Stdout.format(fmt[0 .. args.length * 2], args).flush; } else write(args); } /** * Print to the standard output, adds a new line * * Params: * args = what to print */ void println (A...)(A args) { version (Tango) { const string fmt = "{}{}{}{}{}{}{}{}" "{}{}{}{}{}{}{}{}" "{}{}{}{}{}{}{}{}"; static assert (A.length <= fmt.length / 2, "mambo.io.println :: too many arguments"); Stdout.formatln(fmt[0 .. args.length * 2], args); } else writeln(args); }