Mercurial > projects > dwt-linux
view dwt/dwthelper/Integer.d @ 158:de2578a843a7
Tango update to rev 3158, TracedException>Exception, fromUtf8z>fromStringz,Fix Bug in MenuItem Thanx to nascent for the report.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 10 Feb 2008 04:19:19 +0100 |
parents | 3d9bbe0a83a0 |
children | 9b4e6fc63930 |
line wrap: on
line source
/** * Authors: Frank Benoit <keinfarbton@googlemail.com> */ module dwt.dwthelper.Integer; import dwt.dwthelper.utils; static import tango.text.convert.Integer; private import tango.core.Exception; public final class Byte { public static byte parseByte( char[] s ){ try{ int res = tango.text.convert.Integer.parse( s ); if( res < byte.min || res > byte.max ){ throw new NumberFormatException( "out of range" ); } return res; } catch( IllegalArgumentException e ){ throw new NumberFormatException( e ); } } } public final class Integer { public static int MIN_VALUE = 0x80000000; public static int MAX_VALUE = 0x7fffffff; public static int SIZE = 32; public int value; public this ( int value ){ this.value = value; } public this ( char[] s ){ } public static char[] toString( int i, int radix ){ switch( radix ){ case 2: return toBinaryString(i); case 8: return toOctalString(i); case 10: return toString(i); case 16: return toHexString(i); default: implMissing( __FILE__, __LINE__ ); return null; } } public static char[] toHexString( int i ){ return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Hex ); } public static char[] toOctalString( int i ){ return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Octal ); } public static char[] toBinaryString( int i ){ return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Binary ); } public static char[] toString( int i ){ return tango.text.convert.Integer.toString(i); } public static int parseInt( char[] s, int radix ){ try{ return tango.text.convert.Integer.parse( s, cast(uint)radix ); } catch( IllegalArgumentException e ){ throw new NumberFormatException( e ); } } public static int parseInt( char[] s ){ try{ return tango.text.convert.Integer.parse( s ); } catch( IllegalArgumentException e ){ throw new NumberFormatException( e ); } } public static Integer valueOf( char[] s, int radix ){ implMissing( __FILE__, __LINE__ ); return null; } public static Integer valueOf( char[] s ){ implMissing( __FILE__, __LINE__ ); return null; } public static Integer valueOf( int i ){ implMissing( __FILE__, __LINE__ ); return null; } public byte byteValue(){ return cast(byte)value; } public short shortValue(){ return cast(short)value; } public int intValue(){ return value; } public long longValue(){ return cast(long)value; } public float floatValue(){ return cast(float)value; } public double doubleValue(){ return cast(double)value; } public override hash_t toHash(){ return intValue(); } public override int opEquals( Object obj ){ implMissing( __FILE__, __LINE__ ); return false; } public override char[] toString(){ return tango.text.convert.Integer.toString( value ); } }