view tango/tango/text/convert/Format.d @ 341:1bb99290e03a trunk

[svn r362] Started merging the old 'test' dir as well as the newer 'tangotests' dir into 'tests/mini' and 'tests/minicomplex'.
author lindquist
date Sun, 13 Jul 2008 02:51:19 +0200
parents 1700239cab2e
children
line wrap: on
line source

/*******************************************************************************

        copyright:      Copyright (c) 2007 Kris Bell. All rights reserved

        license:        BSD style: $(LICENSE)
        
        version:        Sep 2007: Initial release
        version:        Nov 2007: Added stream wrappers

        author:         Kris

*******************************************************************************/

module tango.text.convert.Format;

private import tango.io.model.IConduit;

private import tango.text.convert.Layout;

/******************************************************************************

        Constructs a global utf8 instance of Layout

******************************************************************************/

public Layout!(char) Format;

static this()
{
        Format = new Layout!(char);
}

/******************************************************************************

        Global function to format into a stream

******************************************************************************/

deprecated void format (OutputStream output, char[] fmt, ...)
{
        Format.convert ((char[] s){return output.write(s);}, _arguments, _argptr, fmt);
}

/******************************************************************************

        Global function to format into a stream, and add a newline

******************************************************************************/

deprecated void formatln (OutputStream output, char[] fmt, ...)
{
        version (Win32)
                 const char[] Eol = "\r\n";
           else
              const char[] Eol = "\n";

        Format.convert ((char[] s){return output.write(s);}, _arguments, _argptr, fmt);
        output.write (Eol);
}


/******************************************************************************

******************************************************************************/

debug (Format)
{
        import tango.io.Console;

        void main()
        {
                formatln (Cout.stream, "hello {}", "world");
        }
}