Show
Ignore:
Timestamp:
05/04/08 18:12:38 (8 months ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

reverted the char[] to String and use the an alias.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/dwthelper/utils.d

    r206 r212  
    3636alias tango.text.Text.Text!(char) StringBuffer; 
    3737 
    38 void implMissing( char[] file, uint line ){ 
     38void implMissing( String file, uint line ){ 
    3939    Stderr.formatln( "implementation missing in file {} line {}", file, line ); 
    4040    Stderr.formatln( "exiting ..." ); 
     
    9595        return value; 
    9696    } 
    97     public static Boolean valueOf( char[] s ){ 
     97    public static Boolean valueOf( String s ){ 
    9898        if( s == "yes" || s == "true" ){ 
    9999            return TRUE; 
     
    110110 
    111111class Byte : ValueWrapperT!(byte) { 
    112     public static byte parseByte( char[] s ){ 
     112    public static byte parseByte( String s ){ 
    113113        try{ 
    114114            int res = tango.text.convert.Integer.parse( s ); 
     
    139139    } 
    140140 
    141     public this ( char[] s ){ 
     141    public this ( String s ){ 
    142142        super(parseInt(s)); 
    143143    } 
    144144 
    145     public static char[] toString( int i, int radix ){ 
     145    public static String toString( int i, int radix ){ 
    146146        switch( radix ){ 
    147147        case 2: 
     
    159159    } 
    160160 
    161     public static char[] toHexString( int i ){ 
     161    public static String toHexString( int i ){ 
    162162        return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Hex ); 
    163163    } 
    164164 
    165     public static char[] toOctalString( int i ){ 
     165    public static String toOctalString( int i ){ 
    166166        return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Octal ); 
    167167    } 
    168168 
    169     public static char[] toBinaryString( int i ){ 
     169    public static String toBinaryString( int i ){ 
    170170        return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Binary ); 
    171171    } 
    172172 
    173     public static char[] toString( int i ){ 
     173    public static String toString( int i ){ 
    174174        return tango.text.convert.Integer.toString(i); 
    175175    } 
    176176 
    177     public static int parseInt( char[] s, int radix ){ 
     177    public static int parseInt( String s, int radix ){ 
    178178        try{ 
    179179            return tango.text.convert.Integer.parse( s, cast(uint)radix ); 
     
    184184    } 
    185185 
    186     public static int parseInt( char[] s ){ 
     186    public static int parseInt( String s ){ 
    187187        try{ 
    188188            return tango.text.convert.Integer.parse( s ); 
     
    193193    } 
    194194 
    195     public static Integer valueOf( char[] s, int radix ){ 
     195    public static Integer valueOf( String s, int radix ){ 
    196196        implMissing( __FILE__, __LINE__ ); 
    197197        return null; 
    198198    } 
    199199 
    200     public static Integer valueOf( char[] s ){ 
     200    public static Integer valueOf( String s ){ 
    201201        return valueOf( parseInt(s)); 
    202202    } 
     
    234234    } 
    235235 
    236     public override char[] toString(){ 
     236    public override String toString(){ 
    237237        return tango.text.convert.Integer.toString( value ); 
    238238    } 
     
    244244        super(value); 
    245245    } 
    246     this( char[] str ){ 
     246    this( String str ){ 
    247247        implMissing( __FILE__, __LINE__ ); 
    248248        super(0.0); 
     
    251251        return value; 
    252252    } 
    253     public static char[] toString( double value ){ 
     253    public static String toString( double value ){ 
    254254        implMissing( __FILE__, __LINE__ ); 
    255255        return null; 
     
    269269        super(value); 
    270270    } 
    271     this( char[] str ){ 
     271    this( String str ){ 
    272272        implMissing( __FILE__, __LINE__ ); 
    273273        super(0.0); 
     
    276276        return value; 
    277277    } 
    278     public static char[] toString( float value ){ 
     278    public static String toString( float value ){ 
    279279        implMissing( __FILE__, __LINE__ ); 
    280280        return null; 
    281281    } 
    282     public static float parseFloat( char[] s ){ 
     282    public static float parseFloat( String s ){ 
    283283        try{ 
    284284            return tango.text.convert.Float.toFloat( s ); 
     
    294294        super(value); 
    295295    } 
    296     this( char[] str ){ 
     296    this( String str ){ 
    297297        implMissing( __FILE__, __LINE__ ); 
    298298        super(0); 
     
    301301        return value; 
    302302    } 
    303     public static long parseLong(char[] s){ 
     303    public static long parseLong(String s){ 
    304304        implMissing( __FILE__, __LINE__ ); 
    305305        return 0; 
    306306    } 
    307     public static char[] toString( double value ){ 
     307    public static String toString( double value ){ 
    308308        implMissing( __FILE__, __LINE__ ); 
    309309        return null; 
     
    319319alias ArrayWrapperT!(Object)  ArrayWrapperObject; 
    320320alias ArrayWrapperT!(char)    ArrayWrapperString; 
    321 alias ArrayWrapperT!(char[])  ArrayWrapperString2; 
     321alias ArrayWrapperT!(String)  ArrayWrapperString2; 
    322322 
    323323Object[] StringArrayToObjectArray( String[] strs ){ 
     
    328328    return res; 
    329329} 
    330 int codepointIndexToIndex( char[] str, int cpIndex ){ 
     330int codepointIndexToIndex( String str, int cpIndex ){ 
    331331    int cps = cpIndex; 
    332332    int res = 0; 
     
    348348    return res; 
    349349} 
    350 int indexToCodepointIndex( char[] str, int index ){ 
     350int indexToCodepointIndex( String str, int index ){ 
    351351    int i = 0; 
    352352    int res = 0; 
     
    369369} 
    370370 
    371 char[] firstCodePointStr( char[] str, out int consumed ){ 
     371String firstCodePointStr( String str, out int consumed ){ 
    372372    dchar[1] buf; 
    373373    uint ate; 
     
    377377} 
    378378 
    379 dchar firstCodePoint( char[] str ){ 
     379dchar firstCodePoint( String str ){ 
    380380    int dummy; 
    381381    return firstCodePoint( str, dummy ); 
    382382} 
    383 dchar firstCodePoint( char[] str, out int consumed ){ 
     383dchar firstCodePoint( String str, out int consumed ){ 
    384384    dchar[1] buf; 
    385385    uint ate; 
     
    394394} 
    395395 
    396 char[] dcharToString( dchar key ){ 
     396String dcharToString( dchar key ){ 
    397397    dchar[1] buf; 
    398398    buf[0] = key; 
     
    400400} 
    401401 
    402 int codepointCount( char[] str ){ 
     402int codepointCount( String str ){ 
    403403    scope dchar[] buf = new dchar[]( str.length ); 
    404404    uint ate; 
     
    411411alias tango.text.convert.Utf.toString toString; 
    412412 
    413 int getRelativeCodePointOffset( char[] str, int startIndex, int searchRelCp ){ 
     413int getRelativeCodePointOffset( String str, int startIndex, int searchRelCp ){ 
    414414    int ignore; 
    415415    int i = startIndex; 
     
    463463    return i - startIndex; 
    464464} 
    465 dchar getRelativeCodePoint( char[] str, int startIndex, int searchRelCp, out int relIndex ){ 
     465dchar getRelativeCodePoint( String str, int startIndex, int searchRelCp, out int relIndex ){ 
    466466    relIndex = getRelativeCodePointOffset( str, startIndex, searchRelCp ); 
    467467    int ignore; 
     
    469469} 
    470470 
    471 int utf8AdjustOffset( char[] str, int offset ){ 
     471int utf8AdjustOffset( String str, int offset ){ 
    472472    if( str.length <= offset || offset <= 0 ){ 
    473473        return offset; 
     
    482482    return (ch in tango.text.UnicodeData.unicodeData) !is null; 
    483483} 
    484 dchar CharacterFirstToLower( char[] str ){ 
     484dchar CharacterFirstToLower( String str ){ 
    485485    int consumed; 
    486486    return CharacterFirstToLower( str, consumed ); 
    487487} 
    488 dchar CharacterFirstToLower( char[] str, out int consumed ){ 
     488dchar CharacterFirstToLower( String str, out int consumed ){ 
    489489    dchar[1] buf; 
    490490    buf[0] = firstCodePoint( str, consumed ); 
     
    510510    return tango.text.Unicode.isLetter( c ); 
    511511} 
    512 public char[] toUpperCase( char[] str ){ 
     512public String toUpperCase( String str ){ 
    513513    return tango.text.Unicode.toUpper( str ); 
    514514} 
    515515 
    516 public int indexOf( char[] str, char searched ){ 
     516public int indexOf( String str, char searched ){ 
    517517    int res = tango.text.Util.locate( str, searched ); 
    518518    if( res is str.length ) res = -1; 
     
    520520} 
    521521 
    522 public int indexOf( char[] str, char searched, int startpos ){ 
     522public int indexOf( String str, char searched, int startpos ){ 
    523523    int res = tango.text.Util.locate( str, searched, startpos ); 
    524524    if( res is str.length ) res = -1; 
     
    526526} 
    527527 
    528 public int indexOf(char[] str, char[] ch){ 
     528public int indexOf(String str, String ch){ 
    529529    return indexOf( str, ch, 0 ); 
    530530} 
    531531 
    532 public int indexOf(char[] str, char[] ch, int start){ 
     532public int indexOf(String str, String ch, int start){ 
    533533    int res = tango.text.Util.locatePattern( str, ch, start ); 
    534534    if( res is str.length ) res = -1; 
     
    536536} 
    537537 
    538 public int lastIndexOf(char[] str, char ch){ 
     538public int lastIndexOf(String str, char ch){ 
    539539    return lastIndexOf( str, ch, str.length ); 
    540540} 
    541 public int lastIndexOf(char[] str, char ch, int formIndex){ 
     541public int lastIndexOf(String str, char ch, int formIndex){ 
    542542    int res = tango.text.Util.locatePrior( str, ch, formIndex ); 
    543543    if( res is str.length ) res = -1; 
    544544    return res; 
    545545} 
    546 public int lastIndexOf(char[] str, char[] ch ){ 
     546public int lastIndexOf(String str, String ch ){ 
    547547    return lastIndexOf( str, ch, str.length ); 
    548548} 
    549 public int lastIndexOf(char[] str, char[] ch, int start ){ 
     549public int lastIndexOf(String str, String ch, int start ){ 
    550550    int res = tango.text.Util.locatePatternPrior( str, ch, start ); 
    551551    if( res is str.length ) res = -1; 
     
    553553} 
    554554 
    555 public char[] replace( char[] str, char from, char to ){ 
     555public String replace( String str, char from, char to ){ 
    556556    return tango.text.Util.replace( str.dup, from, to ); 
    557557} 
    558558 
    559 public char[] substring( char[] str, int start ){ 
     559public String substring( String str, int start ){ 
    560560    return str[ start .. $ ].dup; 
    561561} 
    562562 
    563 public char[] substring( char[] str, int start, int end ){ 
     563public String substring( String str, int start, int end ){ 
    564564    return str[ start .. end ].dup; 
    565565} 
     
    573573} 
    574574 
    575 public char charAt( char[] str, int pos ){ 
     575public char charAt( String str, int pos ){ 
    576576    return str[ pos ]; 
    577577} 
    578578 
    579 public void getChars( char[] src, int srcBegin, int srcEnd, char[] dst, int dstBegin){ 
     579public void getChars( String src, int srcBegin, int srcEnd, String dst, int dstBegin){ 
    580580    dst[ dstBegin .. dstBegin + srcEnd - srcBegin ] = src[ srcBegin .. srcEnd ]; 
    581581} 
    582582 
    583 public wchar[] toCharArray( char[] str ){ 
     583public wchar[] toCharArray( String str ){ 
    584584    return toString16( str ); 
    585585} 
    586586 
    587 public bool endsWith( char[] src, char[] pattern ){ 
     587public bool endsWith( String src, String pattern ){ 
    588588    if( src.length < pattern.length ){ 
    589589        return false; 
     
    592592} 
    593593 
    594 public bool equals( char[] src, char[] other ){ 
     594public bool equals( String src, String other ){ 
    595595    return src == other; 
    596596} 
    597597 
    598 public bool equalsIgnoreCase( char[] src, char[] other ){ 
     598public bool equalsIgnoreCase( String src, String other ){ 
    599599    return tango.text.Unicode.toFold(src) == tango.text.Unicode.toFold(other); 
    600600} 
    601601 
    602 public bool startsWith( char[] src, char[] pattern ){ 
     602public bool startsWith( String src, String pattern ){ 
    603603    if( src.length < pattern.length ){ 
    604604        return false; 
     
    607607} 
    608608 
    609 public char[] toLowerCase( char[] src ){ 
     609public String toLowerCase( String src ){ 
    610610    return tango.text.Unicode.toLower( src ); 
    611611} 
    612612 
    613 public hash_t toHash( char[] src ){ 
    614     return typeid(char[]).getHash(&src); 
    615 } 
    616  
    617 public char[] trim( char[] str ){ 
     613public hash_t toHash( String src ){ 
     614    return typeid(String).getHash(&src); 
     615} 
     616 
     617public String trim( String str ){ 
    618618    return tango.text.Util.trim( str ).dup; 
    619619} 
    620 public char[] intern( char[] str ){ 
     620public String intern( String str ){ 
    621621    return str; 
    622622} 
    623623 
    624 public char* toStringzValidPtr( char[] src ){ 
     624public char* toStringzValidPtr( String src ){ 
    625625    if( src ){ 
    626626        return src.toStringz(); 
    627627    } 
    628628    else{ 
    629         static const char[] nullPtr = "\0"; 
     629        static const String nullPtr = "\0"; 
    630630        return nullPtr.ptr; 
    631631    } 
    632632} 
    633633 
    634 static char[] toHex(uint value, bool prefix = true, int radix = 8){ 
     634static String toHex(uint value, bool prefix = true, int radix = 8){ 
    635635    return tango.text.convert.Integer.toString( 
    636636            value, 
     
    644644 
    645645class RuntimeException : Exception { 
    646     this( char[] e = null){ 
     646    this( String e = null){ 
    647647        super(e); 
    648648    } 
     
    657657} 
    658658class IndexOutOfBoundsException : Exception { 
    659     this( char[] e = null){ 
     659    this( String e = null){ 
    660660        super(e); 
    661661    } 
     
    663663 
    664664class UnsupportedOperationException : RuntimeException { 
    665     this( char[] e = null){ 
     665    this( String e = null){ 
    666666        super(e); 
    667667    } 
     
    671671} 
    672672class NumberFormatException : IllegalArgumentException { 
    673     this( char[] e ){ 
     673    this( String e ){ 
    674674        super(e); 
    675675    } 
     
    679679} 
    680680class NullPointerException : Exception { 
    681     this( char[] e = null ){ 
     681    this( String e = null ){ 
    682682        super(e); 
    683683    } 
     
    687687} 
    688688class IllegalStateException : Exception { 
    689     this( char[] e = null ){ 
     689    this( String e = null ){ 
    690690        super(e); 
    691691    } 
     
    695695} 
    696696class InterruptedException : Exception { 
    697     this( char[] e = null ){ 
     697    this( String e = null ){ 
    698698        super(e); 
    699699    } 
     
    704704class InvocationTargetException : Exception { 
    705705    Exception cause; 
    706     this( Exception e = null, char[] msg = null ){ 
     706    this( Exception e = null, String msg = null ){ 
    707707        super(msg); 
    708708        cause = e; 
     
    715715} 
    716716class MissingResourceException : Exception { 
    717     char[] classname; 
    718     char[] key; 
    719     this( char[] msg, char[] classname, char[] key ){ 
     717    String classname; 
     718    String key; 
     719    this( String msg, String classname, String key ){ 
    720720        super(msg); 
    721721        this.classname = classname; 
     
    724724} 
    725725class ParseException : Exception { 
    726     this( char[] e = null ){ 
     726    this( String e = null ){ 
    727727        super(e); 
    728728    } 
     
    754754    } 
    755755 
    756     public override char[] toString() { 
     756    public override String toString() { 
    757757        return this.classinfo.name ~ "[source=" ~ source.toString() ~ "]"; 
    758758    } 
     
    832832} 
    833833 
    834 char[] stringcast( Object o ){ 
     834String stringcast( Object o ){ 
    835835    if( auto str = cast(ArrayWrapperString) o ){ 
    836836        return str.array; 
     
    838838    return null; 
    839839} 
    840 char[][] stringcast( Object[] objs ){ 
    841     char[][] res = new char[][](objs.length); 
     840String[] stringcast( Object[] objs ){ 
     841    String[] res = new String[](objs.length); 
    842842    foreach( idx, obj; objs ){ 
    843843        res[idx] = stringcast(obj); 
     
    845845    return res; 
    846846} 
    847 ArrayWrapperString stringcast( char[] str ){ 
     847ArrayWrapperString stringcast( String str ){ 
    848848    return new ArrayWrapperString( str ); 
    849849} 
    850 ArrayWrapperString[] stringcast( char[][] strs ){ 
     850ArrayWrapperString[] stringcast( String[] strs ){ 
    851851    ArrayWrapperString[] res = new ArrayWrapperString[ strs.length ]; 
    852852    foreach( idx, str; strs ){ 
     
    937937} 
    938938 
    939 void PrintStackTrace( int deepth = 100, char[] prefix = "trc" ){ 
     939void PrintStackTrace( int deepth = 100, String prefix = "trc" ){ 
    940940    auto e = new Exception( null ); 
    941941    int idx = 0; 
     
    951951struct ImportData{ 
    952952    void[] data; 
    953     char[] name; 
    954  
    955     public static ImportData opCall( void[] data, char[] name ){ 
     953    String name; 
     954 
     955    public static ImportData opCall( void[] data, String name ){ 
    956956        ImportData res; 
    957957        res.data = data; 
     
    961961} 
    962962 
    963 template getImportData(char[] name ){ 
     963template getImportData(String name ){ 
    964964    const ImportData getImportData = ImportData( import(name), name ); 
    965965}