view tango/tango/text/convert/Format.d @ 264:a9dae3da4e87 trunk

[svn r285] Fixed D -> bool LLVM helper for floating point values. Changed the way D-style varargs are passed, now each param should be aligned to size_t.sizeof.
author lindquist
date Sat, 14 Jun 2008 17:28:13 +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");
        }
}