view druntime/src/compiler/ldc/util/console.d @ 759:d3eb054172f9

Added copy of druntime from DMD 2.020 modified for LDC.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Tue, 11 Nov 2008 01:52:37 +0100
parents
children
line wrap: on
line source

/**
 * The console module contains some simple routines for console output.
 *
 * Copyright: Public Domain
 * License:   Public Domain
 * Authors:   Sean Kelly
 */
module rt.util.console;


private
{
    version (Windows)
    {
        import sys.windows.windows;
    }
    else version( Posix )
    {
        import stdc.posix.unistd;
    }
    import util.string;
}


struct Console
{
    Console opCall( in char[] val )
    {
        version( Windows )
        {
            uint count = void;
            WriteFile( GetStdHandle( 0xfffffff5 ), val.ptr, val.length, &count, null );
        }
        else version( Posix )
        {
            write( 2, val.ptr, val.length );
        }
        return *this;
    }


    Console opCall( uint val )
    {
            char[10] tmp = void;
            return opCall( tmp.intToString( val ) );
    }
}

Console console;