Mercurial > projects > dwt-win
diff dwt/dwthelper/utils.d @ 15:1bea9f0c6f63
FontData, Font
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 25 Jan 2008 19:16:45 +0100 |
parents | 5406a8f6526d |
children | 5f2e72114476 |
line wrap: on
line diff
--- a/dwt/dwthelper/utils.d Fri Jan 25 14:23:28 2008 +0100 +++ b/dwt/dwthelper/utils.d Fri Jan 25 19:16:45 2008 +0100 @@ -1,12 +1,17 @@ -/** +/** * Authors: Frank Benoit <keinfarbton@googlemail.com> */ module dwt.dwthelper.utils; public import dwt.dwthelper.System; +public import Math = tango.math.Math; import tango.io.Stdout; +import tango.stdc.stringz; +import tango.text.Util; import tango.text.Unicode; +import tango.text.convert.Utf; +import tango.core.Exception; import tango.stdc.stdlib : exit; void implMissing( char[] file, uint line ){ @@ -45,3 +50,66 @@ return r[0]; } +public int indexOf( char[] str, char searched ){ + int res = tango.text.Util.locate( str, searched ); + if( res is str.length ) res = -1; + return res; +} + +public int indexOf( char[] str, char searched, int startpos ){ + int res = tango.text.Util.locate( str, searched, startpos ); + if( res is str.length ) res = -1; + return res; +} + +public int indexOf(char[] str, char[] ch, int start){ + int res = tango.text.Util.locatePattern( str, ch, start ); + if( res is str.length ) res = -1; + return res; +} + +public char[] substring( char[] str, int start ){ + return str[ start .. $ ].dup; +} + +public char[] substring( char[] str, int start, int end ){ + return str[ start .. end ].dup; +} + +public wchar[] substring( wchar[] str, int start ){ + return str[ start .. $ ].dup; +} + +public wchar[] substring( wchar[] str, int start, int end ){ + return str[ start .. end ].dup; +} + +public char charAt( char[] str, int pos ){ + return str[ pos ]; +} + +static char[] toHex(uint value, bool prefix = true, int radix = 8){ + return tango.text.convert.Integer.toString( + value, + radix is 10 ? tango.text.convert.Integer.Style.Signed : + radix is 8 ? tango.text.convert.Integer.Style.Octal : + radix is 16 ? tango.text.convert.Integer.Style.Hex : + tango.text.convert.Integer.Style.Signed, + prefix ? tango.text.convert.Integer.Flags.Prefix : tango.text.convert.Integer.Flags.None + ); +} + +class NumberFormatException : IllegalArgumentException { + this( char[] e ){ + super(e); + } + this( TracedException e ){ + super(e.toString); + } +} + + + + + +