comparison dwt/dwthelper/utils.d @ 212:ab60f3309436

reverted the char[] to String and use the an alias.
author Frank Benoit <benoit@tionex.de>
date Mon, 05 May 2008 00:12:38 +0200
parents cca980503056
children 679fb4a215dc
comparison
equal deleted inserted replaced
211:ff59aeb96cac 212:ab60f3309436
33 // alias tango.util.collection.HashMap.HashMap!(Object,Object) HashMap; 33 // alias tango.util.collection.HashMap.HashMap!(Object,Object) HashMap;
34 34
35 alias char[] String; 35 alias char[] String;
36 alias tango.text.Text.Text!(char) StringBuffer; 36 alias tango.text.Text.Text!(char) StringBuffer;
37 37
38 void implMissing( char[] file, uint line ){ 38 void implMissing( String file, uint line ){
39 Stderr.formatln( "implementation missing in file {} line {}", file, line ); 39 Stderr.formatln( "implementation missing in file {} line {}", file, line );
40 Stderr.formatln( "exiting ..." ); 40 Stderr.formatln( "exiting ..." );
41 exit(1); 41 exit(1);
42 } 42 }
43 43
92 return false; 92 return false;
93 } 93 }
94 public bool booleanValue(){ 94 public bool booleanValue(){
95 return value; 95 return value;
96 } 96 }
97 public static Boolean valueOf( char[] s ){ 97 public static Boolean valueOf( String s ){
98 if( s == "yes" || s == "true" ){ 98 if( s == "yes" || s == "true" ){
99 return TRUE; 99 return TRUE;
100 } 100 }
101 return FALSE; 101 return FALSE;
102 } 102 }
107 107
108 alias Boolean ValueWrapperBool; 108 alias Boolean ValueWrapperBool;
109 109
110 110
111 class Byte : ValueWrapperT!(byte) { 111 class Byte : ValueWrapperT!(byte) {
112 public static byte parseByte( char[] s ){ 112 public static byte parseByte( String s ){
113 try{ 113 try{
114 int res = tango.text.convert.Integer.parse( s ); 114 int res = tango.text.convert.Integer.parse( s );
115 if( res < byte.min || res > byte.max ){ 115 if( res < byte.min || res > byte.max ){
116 throw new NumberFormatException( "out of range" ); 116 throw new NumberFormatException( "out of range" );
117 } 117 }
136 136
137 public this ( int value ){ 137 public this ( int value ){
138 super( value ); 138 super( value );
139 } 139 }
140 140
141 public this ( char[] s ){ 141 public this ( String s ){
142 super(parseInt(s)); 142 super(parseInt(s));
143 } 143 }
144 144
145 public static char[] toString( int i, int radix ){ 145 public static String toString( int i, int radix ){
146 switch( radix ){ 146 switch( radix ){
147 case 2: 147 case 2:
148 return toBinaryString(i); 148 return toBinaryString(i);
149 case 8: 149 case 8:
150 return toOctalString(i); 150 return toOctalString(i);
156 implMissing( __FILE__, __LINE__ ); 156 implMissing( __FILE__, __LINE__ );
157 return null; 157 return null;
158 } 158 }
159 } 159 }
160 160
161 public static char[] toHexString( int i ){ 161 public static String toHexString( int i ){
162 return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Hex ); 162 return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Hex );
163 } 163 }
164 164
165 public static char[] toOctalString( int i ){ 165 public static String toOctalString( int i ){
166 return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Octal ); 166 return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Octal );
167 } 167 }
168 168
169 public static char[] toBinaryString( int i ){ 169 public static String toBinaryString( int i ){
170 return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Binary ); 170 return tango.text.convert.Integer.toString(i, tango.text.convert.Integer.Style.Binary );
171 } 171 }
172 172
173 public static char[] toString( int i ){ 173 public static String toString( int i ){
174 return tango.text.convert.Integer.toString(i); 174 return tango.text.convert.Integer.toString(i);
175 } 175 }
176 176
177 public static int parseInt( char[] s, int radix ){ 177 public static int parseInt( String s, int radix ){
178 try{ 178 try{
179 return tango.text.convert.Integer.parse( s, cast(uint)radix ); 179 return tango.text.convert.Integer.parse( s, cast(uint)radix );
180 } 180 }
181 catch( IllegalArgumentException e ){ 181 catch( IllegalArgumentException e ){
182 throw new NumberFormatException( e ); 182 throw new NumberFormatException( e );
183 } 183 }
184 } 184 }
185 185
186 public static int parseInt( char[] s ){ 186 public static int parseInt( String s ){
187 try{ 187 try{
188 return tango.text.convert.Integer.parse( s ); 188 return tango.text.convert.Integer.parse( s );
189 } 189 }
190 catch( IllegalArgumentException e ){ 190 catch( IllegalArgumentException e ){
191 throw new NumberFormatException( e ); 191 throw new NumberFormatException( e );
192 } 192 }
193 } 193 }
194 194
195 public static Integer valueOf( char[] s, int radix ){ 195 public static Integer valueOf( String s, int radix ){
196 implMissing( __FILE__, __LINE__ ); 196 implMissing( __FILE__, __LINE__ );
197 return null; 197 return null;
198 } 198 }
199 199
200 public static Integer valueOf( char[] s ){ 200 public static Integer valueOf( String s ){
201 return valueOf( parseInt(s)); 201 return valueOf( parseInt(s));
202 } 202 }
203 203
204 public static Integer valueOf( int i ){ 204 public static Integer valueOf( int i ){
205 return new Integer(i); 205 return new Integer(i);
231 231
232 public override hash_t toHash(){ 232 public override hash_t toHash(){
233 return intValue(); 233 return intValue();
234 } 234 }
235 235
236 public override char[] toString(){ 236 public override String toString(){
237 return tango.text.convert.Integer.toString( value ); 237 return tango.text.convert.Integer.toString( value );
238 } 238 }
239 } 239 }
240 alias Integer ValueWrapperInt; 240 alias Integer ValueWrapperInt;
241 241
242 class Double : ValueWrapperT!(double) { 242 class Double : ValueWrapperT!(double) {
243 this( double value ){ 243 this( double value ){
244 super(value); 244 super(value);
245 } 245 }
246 this( char[] str ){ 246 this( String str ){
247 implMissing( __FILE__, __LINE__ ); 247 implMissing( __FILE__, __LINE__ );
248 super(0.0); 248 super(0.0);
249 } 249 }
250 public double doubleValue(){ 250 public double doubleValue(){
251 return value; 251 return value;
252 } 252 }
253 public static char[] toString( double value ){ 253 public static String toString( double value ){
254 implMissing( __FILE__, __LINE__ ); 254 implMissing( __FILE__, __LINE__ );
255 return null; 255 return null;
256 } 256 }
257 } 257 }
258 258
266 public static int SIZE = 32; 266 public static int SIZE = 32;
267 267
268 this( float value ){ 268 this( float value ){
269 super(value); 269 super(value);
270 } 270 }
271 this( char[] str ){ 271 this( String str ){
272 implMissing( __FILE__, __LINE__ ); 272 implMissing( __FILE__, __LINE__ );
273 super(0.0); 273 super(0.0);
274 } 274 }
275 public float floatValue(){ 275 public float floatValue(){
276 return value; 276 return value;
277 } 277 }
278 public static char[] toString( float value ){ 278 public static String toString( float value ){
279 implMissing( __FILE__, __LINE__ ); 279 implMissing( __FILE__, __LINE__ );
280 return null; 280 return null;
281 } 281 }
282 public static float parseFloat( char[] s ){ 282 public static float parseFloat( String s ){
283 try{ 283 try{
284 return tango.text.convert.Float.toFloat( s ); 284 return tango.text.convert.Float.toFloat( s );
285 } 285 }
286 catch( IllegalArgumentException e ){ 286 catch( IllegalArgumentException e ){
287 throw new NumberFormatException( e ); 287 throw new NumberFormatException( e );
291 } 291 }
292 class Long : ValueWrapperT!(long) { 292 class Long : ValueWrapperT!(long) {
293 this( long value ){ 293 this( long value ){
294 super(value); 294 super(value);
295 } 295 }
296 this( char[] str ){ 296 this( String str ){
297 implMissing( __FILE__, __LINE__ ); 297 implMissing( __FILE__, __LINE__ );
298 super(0); 298 super(0);
299 } 299 }
300 public long longValue(){ 300 public long longValue(){
301 return value; 301 return value;
302 } 302 }
303 public static long parseLong(char[] s){ 303 public static long parseLong(String s){
304 implMissing( __FILE__, __LINE__ ); 304 implMissing( __FILE__, __LINE__ );
305 return 0; 305 return 0;
306 } 306 }
307 public static char[] toString( double value ){ 307 public static String toString( double value ){
308 implMissing( __FILE__, __LINE__ ); 308 implMissing( __FILE__, __LINE__ );
309 return null; 309 return null;
310 } 310 }
311 } 311 }
312 alias Long ValueWrapperLong; 312 alias Long ValueWrapperLong;
316 316
317 alias ArrayWrapperT!(byte) ArrayWrapperByte; 317 alias ArrayWrapperT!(byte) ArrayWrapperByte;
318 alias ArrayWrapperT!(int) ArrayWrapperInt; 318 alias ArrayWrapperT!(int) ArrayWrapperInt;
319 alias ArrayWrapperT!(Object) ArrayWrapperObject; 319 alias ArrayWrapperT!(Object) ArrayWrapperObject;
320 alias ArrayWrapperT!(char) ArrayWrapperString; 320 alias ArrayWrapperT!(char) ArrayWrapperString;
321 alias ArrayWrapperT!(char[]) ArrayWrapperString2; 321 alias ArrayWrapperT!(String) ArrayWrapperString2;
322 322
323 Object[] StringArrayToObjectArray( String[] strs ){ 323 Object[] StringArrayToObjectArray( String[] strs ){
324 Object[] res = new Object[strs.length]; 324 Object[] res = new Object[strs.length];
325 foreach( idx, str; strs ){ 325 foreach( idx, str; strs ){
326 res[idx] = new ArrayWrapperString(str); 326 res[idx] = new ArrayWrapperString(str);
327 } 327 }
328 return res; 328 return res;
329 } 329 }
330 int codepointIndexToIndex( char[] str, int cpIndex ){ 330 int codepointIndexToIndex( String str, int cpIndex ){
331 int cps = cpIndex; 331 int cps = cpIndex;
332 int res = 0; 332 int res = 0;
333 while( cps > 0 ){ 333 while( cps > 0 ){
334 cps--; 334 cps--;
335 if( str[res] < 0x80 ){ 335 if( str[res] < 0x80 ){
345 res+=4; 345 res+=4;
346 } 346 }
347 } 347 }
348 return res; 348 return res;
349 } 349 }
350 int indexToCodepointIndex( char[] str, int index ){ 350 int indexToCodepointIndex( String str, int index ){
351 int i = 0; 351 int i = 0;
352 int res = 0; 352 int res = 0;
353 while( i < index ){ 353 while( i < index ){
354 if( str[i] < 0x80 ){ 354 if( str[i] < 0x80 ){
355 i+=1; 355 i+=1;
366 res++; 366 res++;
367 } 367 }
368 return res; 368 return res;
369 } 369 }
370 370
371 char[] firstCodePointStr( char[] str, out int consumed ){ 371 String firstCodePointStr( String str, out int consumed ){
372 dchar[1] buf; 372 dchar[1] buf;
373 uint ate; 373 uint ate;
374 dchar[] res = str.toString32( buf, &ate ); 374 dchar[] res = str.toString32( buf, &ate );
375 consumed = ate; 375 consumed = ate;
376 return str[ 0 .. ate ]; 376 return str[ 0 .. ate ];
377 } 377 }
378 378
379 dchar firstCodePoint( char[] str ){ 379 dchar firstCodePoint( String str ){
380 int dummy; 380 int dummy;
381 return firstCodePoint( str, dummy ); 381 return firstCodePoint( str, dummy );
382 } 382 }
383 dchar firstCodePoint( char[] str, out int consumed ){ 383 dchar firstCodePoint( String str, out int consumed ){
384 dchar[1] buf; 384 dchar[1] buf;
385 uint ate; 385 uint ate;
386 dchar[] res = str.toString32( buf, &ate ); 386 dchar[] res = str.toString32( buf, &ate );
387 consumed = ate; 387 consumed = ate;
388 if( ate is 0 || res.length is 0 ){ 388 if( ate is 0 || res.length is 0 ){
391 assert( ate > 0 ); 391 assert( ate > 0 );
392 assert( res.length is 1 ); 392 assert( res.length is 1 );
393 return res[0]; 393 return res[0];
394 } 394 }
395 395
396 char[] dcharToString( dchar key ){ 396 String dcharToString( dchar key ){
397 dchar[1] buf; 397 dchar[1] buf;
398 buf[0] = key; 398 buf[0] = key;
399 return tango.text.convert.Utf.toString( buf ); 399 return tango.text.convert.Utf.toString( buf );
400 } 400 }
401 401
402 int codepointCount( char[] str ){ 402 int codepointCount( String str ){
403 scope dchar[] buf = new dchar[]( str.length ); 403 scope dchar[] buf = new dchar[]( str.length );
404 uint ate; 404 uint ate;
405 dchar[] res = tango.text.convert.Utf.toString32( str, buf, &ate ); 405 dchar[] res = tango.text.convert.Utf.toString32( str, buf, &ate );
406 assert( ate is str.length ); 406 assert( ate is str.length );
407 return res.length; 407 return res.length;
408 } 408 }
409 409
410 alias tango.text.convert.Utf.toString16 toString16; 410 alias tango.text.convert.Utf.toString16 toString16;
411 alias tango.text.convert.Utf.toString toString; 411 alias tango.text.convert.Utf.toString toString;
412 412
413 int getRelativeCodePointOffset( char[] str, int startIndex, int searchRelCp ){ 413 int getRelativeCodePointOffset( String str, int startIndex, int searchRelCp ){
414 int ignore; 414 int ignore;
415 int i = startIndex; 415 int i = startIndex;
416 if( searchRelCp > 0 ){ 416 if( searchRelCp > 0 ){
417 while( searchRelCp !is 0 ){ 417 while( searchRelCp !is 0 ){
418 418
460 searchRelCp++; 460 searchRelCp++;
461 } 461 }
462 } 462 }
463 return i - startIndex; 463 return i - startIndex;
464 } 464 }
465 dchar getRelativeCodePoint( char[] str, int startIndex, int searchRelCp, out int relIndex ){ 465 dchar getRelativeCodePoint( String str, int startIndex, int searchRelCp, out int relIndex ){
466 relIndex = getRelativeCodePointOffset( str, startIndex, searchRelCp ); 466 relIndex = getRelativeCodePointOffset( str, startIndex, searchRelCp );
467 int ignore; 467 int ignore;
468 return firstCodePoint( str[ startIndex+relIndex .. $ ], ignore ); 468 return firstCodePoint( str[ startIndex+relIndex .. $ ], ignore );
469 } 469 }
470 470
471 int utf8AdjustOffset( char[] str, int offset ){ 471 int utf8AdjustOffset( String str, int offset ){
472 if( str.length <= offset || offset <= 0 ){ 472 if( str.length <= offset || offset <= 0 ){
473 return offset; 473 return offset;
474 } 474 }
475 while(( str[offset] & 0xC0 ) is 0x80 ){ 475 while(( str[offset] & 0xC0 ) is 0x80 ){
476 offset--; 476 offset--;
479 } 479 }
480 480
481 bool CharacterIsDefined( dchar ch ){ 481 bool CharacterIsDefined( dchar ch ){
482 return (ch in tango.text.UnicodeData.unicodeData) !is null; 482 return (ch in tango.text.UnicodeData.unicodeData) !is null;
483 } 483 }
484 dchar CharacterFirstToLower( char[] str ){ 484 dchar CharacterFirstToLower( String str ){
485 int consumed; 485 int consumed;
486 return CharacterFirstToLower( str, consumed ); 486 return CharacterFirstToLower( str, consumed );
487 } 487 }
488 dchar CharacterFirstToLower( char[] str, out int consumed ){ 488 dchar CharacterFirstToLower( String str, out int consumed ){
489 dchar[1] buf; 489 dchar[1] buf;
490 buf[0] = firstCodePoint( str, consumed ); 490 buf[0] = firstCodePoint( str, consumed );
491 dchar[] r = tango.text.Unicode.toLower( buf ); 491 dchar[] r = tango.text.Unicode.toLower( buf );
492 return r[0]; 492 return r[0];
493 } 493 }
507 return tango.text.Unicode.isDigit( c ); 507 return tango.text.Unicode.isDigit( c );
508 } 508 }
509 bool CharacterIsLetter( dchar c ){ 509 bool CharacterIsLetter( dchar c ){
510 return tango.text.Unicode.isLetter( c ); 510 return tango.text.Unicode.isLetter( c );
511 } 511 }
512 public char[] toUpperCase( char[] str ){ 512 public String toUpperCase( String str ){
513 return tango.text.Unicode.toUpper( str ); 513 return tango.text.Unicode.toUpper( str );
514 } 514 }
515 515
516 public int indexOf( char[] str, char searched ){ 516 public int indexOf( String str, char searched ){
517 int res = tango.text.Util.locate( str, searched ); 517 int res = tango.text.Util.locate( str, searched );
518 if( res is str.length ) res = -1; 518 if( res is str.length ) res = -1;
519 return res; 519 return res;
520 } 520 }
521 521
522 public int indexOf( char[] str, char searched, int startpos ){ 522 public int indexOf( String str, char searched, int startpos ){
523 int res = tango.text.Util.locate( str, searched, startpos ); 523 int res = tango.text.Util.locate( str, searched, startpos );
524 if( res is str.length ) res = -1; 524 if( res is str.length ) res = -1;
525 return res; 525 return res;
526 } 526 }
527 527
528 public int indexOf(char[] str, char[] ch){ 528 public int indexOf(String str, String ch){
529 return indexOf( str, ch, 0 ); 529 return indexOf( str, ch, 0 );
530 } 530 }
531 531
532 public int indexOf(char[] str, char[] ch, int start){ 532 public int indexOf(String str, String ch, int start){
533 int res = tango.text.Util.locatePattern( str, ch, start ); 533 int res = tango.text.Util.locatePattern( str, ch, start );
534 if( res is str.length ) res = -1; 534 if( res is str.length ) res = -1;
535 return res; 535 return res;
536 } 536 }
537 537
538 public int lastIndexOf(char[] str, char ch){ 538 public int lastIndexOf(String str, char ch){
539 return lastIndexOf( str, ch, str.length ); 539 return lastIndexOf( str, ch, str.length );
540 } 540 }
541 public int lastIndexOf(char[] str, char ch, int formIndex){ 541 public int lastIndexOf(String str, char ch, int formIndex){
542 int res = tango.text.Util.locatePrior( str, ch, formIndex ); 542 int res = tango.text.Util.locatePrior( str, ch, formIndex );
543 if( res is str.length ) res = -1; 543 if( res is str.length ) res = -1;
544 return res; 544 return res;
545 } 545 }
546 public int lastIndexOf(char[] str, char[] ch ){ 546 public int lastIndexOf(String str, String ch ){
547 return lastIndexOf( str, ch, str.length ); 547 return lastIndexOf( str, ch, str.length );
548 } 548 }
549 public int lastIndexOf(char[] str, char[] ch, int start ){ 549 public int lastIndexOf(String str, String ch, int start ){
550 int res = tango.text.Util.locatePatternPrior( str, ch, start ); 550 int res = tango.text.Util.locatePatternPrior( str, ch, start );
551 if( res is str.length ) res = -1; 551 if( res is str.length ) res = -1;
552 return res; 552 return res;
553 } 553 }
554 554
555 public char[] replace( char[] str, char from, char to ){ 555 public String replace( String str, char from, char to ){
556 return tango.text.Util.replace( str.dup, from, to ); 556 return tango.text.Util.replace( str.dup, from, to );
557 } 557 }
558 558
559 public char[] substring( char[] str, int start ){ 559 public String substring( String str, int start ){
560 return str[ start .. $ ].dup; 560 return str[ start .. $ ].dup;
561 } 561 }
562 562
563 public char[] substring( char[] str, int start, int end ){ 563 public String substring( String str, int start, int end ){
564 return str[ start .. end ].dup; 564 return str[ start .. end ].dup;
565 } 565 }
566 566
567 public wchar[] substring( wchar[] str, int start ){ 567 public wchar[] substring( wchar[] str, int start ){
568 return str[ start .. $ ].dup; 568 return str[ start .. $ ].dup;
570 570
571 public wchar[] substring( wchar[] str, int start, int end ){ 571 public wchar[] substring( wchar[] str, int start, int end ){
572 return str[ start .. end ].dup; 572 return str[ start .. end ].dup;
573 } 573 }
574 574
575 public char charAt( char[] str, int pos ){ 575 public char charAt( String str, int pos ){
576 return str[ pos ]; 576 return str[ pos ];
577 } 577 }
578 578
579 public void getChars( char[] src, int srcBegin, int srcEnd, char[] dst, int dstBegin){ 579 public void getChars( String src, int srcBegin, int srcEnd, String dst, int dstBegin){
580 dst[ dstBegin .. dstBegin + srcEnd - srcBegin ] = src[ srcBegin .. srcEnd ]; 580 dst[ dstBegin .. dstBegin + srcEnd - srcBegin ] = src[ srcBegin .. srcEnd ];
581 } 581 }
582 582
583 public wchar[] toCharArray( char[] str ){ 583 public wchar[] toCharArray( String str ){
584 return toString16( str ); 584 return toString16( str );
585 } 585 }
586 586
587 public bool endsWith( char[] src, char[] pattern ){ 587 public bool endsWith( String src, String pattern ){
588 if( src.length < pattern.length ){ 588 if( src.length < pattern.length ){
589 return false; 589 return false;
590 } 590 }
591 return src[ $-pattern.length .. $ ] == pattern; 591 return src[ $-pattern.length .. $ ] == pattern;
592 } 592 }
593 593
594 public bool equals( char[] src, char[] other ){ 594 public bool equals( String src, String other ){
595 return src == other; 595 return src == other;
596 } 596 }
597 597
598 public bool equalsIgnoreCase( char[] src, char[] other ){ 598 public bool equalsIgnoreCase( String src, String other ){
599 return tango.text.Unicode.toFold(src) == tango.text.Unicode.toFold(other); 599 return tango.text.Unicode.toFold(src) == tango.text.Unicode.toFold(other);
600 } 600 }
601 601
602 public bool startsWith( char[] src, char[] pattern ){ 602 public bool startsWith( String src, String pattern ){
603 if( src.length < pattern.length ){ 603 if( src.length < pattern.length ){
604 return false; 604 return false;
605 } 605 }
606 return src[ 0 .. pattern.length ] == pattern; 606 return src[ 0 .. pattern.length ] == pattern;
607 } 607 }
608 608
609 public char[] toLowerCase( char[] src ){ 609 public String toLowerCase( String src ){
610 return tango.text.Unicode.toLower( src ); 610 return tango.text.Unicode.toLower( src );
611 } 611 }
612 612
613 public hash_t toHash( char[] src ){ 613 public hash_t toHash( String src ){
614 return typeid(char[]).getHash(&src); 614 return typeid(String).getHash(&src);
615 } 615 }
616 616
617 public char[] trim( char[] str ){ 617 public String trim( String str ){
618 return tango.text.Util.trim( str ).dup; 618 return tango.text.Util.trim( str ).dup;
619 } 619 }
620 public char[] intern( char[] str ){ 620 public String intern( String str ){
621 return str; 621 return str;
622 } 622 }
623 623
624 public char* toStringzValidPtr( char[] src ){ 624 public char* toStringzValidPtr( String src ){
625 if( src ){ 625 if( src ){
626 return src.toStringz(); 626 return src.toStringz();
627 } 627 }
628 else{ 628 else{
629 static const char[] nullPtr = "\0"; 629 static const String nullPtr = "\0";
630 return nullPtr.ptr; 630 return nullPtr.ptr;
631 } 631 }
632 } 632 }
633 633
634 static char[] toHex(uint value, bool prefix = true, int radix = 8){ 634 static String toHex(uint value, bool prefix = true, int radix = 8){
635 return tango.text.convert.Integer.toString( 635 return tango.text.convert.Integer.toString(
636 value, 636 value,
637 radix is 10 ? tango.text.convert.Integer.Style.Signed : 637 radix is 10 ? tango.text.convert.Integer.Style.Signed :
638 radix is 8 ? tango.text.convert.Integer.Style.Octal : 638 radix is 8 ? tango.text.convert.Integer.Style.Octal :
639 radix is 16 ? tango.text.convert.Integer.Style.Hex : 639 radix is 16 ? tango.text.convert.Integer.Style.Hex :
641 prefix ? tango.text.convert.Integer.Flags.Prefix : tango.text.convert.Integer.Flags.None 641 prefix ? tango.text.convert.Integer.Flags.Prefix : tango.text.convert.Integer.Flags.None
642 ); 642 );
643 } 643 }
644 644
645 class RuntimeException : Exception { 645 class RuntimeException : Exception {
646 this( char[] e = null){ 646 this( String e = null){
647 super(e); 647 super(e);
648 } 648 }
649 this( Exception e ){ 649 this( Exception e ){
650 super(e.toString); 650 super(e.toString);
651 next = e; 651 next = e;
654 return next; 654 return next;
655 } 655 }
656 656
657 } 657 }
658 class IndexOutOfBoundsException : Exception { 658 class IndexOutOfBoundsException : Exception {
659 this( char[] e = null){ 659 this( String e = null){
660 super(e); 660 super(e);
661 } 661 }
662 } 662 }
663 663
664 class UnsupportedOperationException : RuntimeException { 664 class UnsupportedOperationException : RuntimeException {
665 this( char[] e = null){ 665 this( String e = null){
666 super(e); 666 super(e);
667 } 667 }
668 this( Exception e ){ 668 this( Exception e ){
669 super(e.toString); 669 super(e.toString);
670 } 670 }
671 } 671 }
672 class NumberFormatException : IllegalArgumentException { 672 class NumberFormatException : IllegalArgumentException {
673 this( char[] e ){ 673 this( String e ){
674 super(e); 674 super(e);
675 } 675 }
676 this( Exception e ){ 676 this( Exception e ){
677 super(e.toString); 677 super(e.toString);
678 } 678 }
679 } 679 }
680 class NullPointerException : Exception { 680 class NullPointerException : Exception {
681 this( char[] e = null ){ 681 this( String e = null ){
682 super(e); 682 super(e);
683 } 683 }
684 this( Exception e ){ 684 this( Exception e ){
685 super(e.toString); 685 super(e.toString);
686 } 686 }
687 } 687 }
688 class IllegalStateException : Exception { 688 class IllegalStateException : Exception {
689 this( char[] e = null ){ 689 this( String e = null ){
690 super(e); 690 super(e);
691 } 691 }
692 this( Exception e ){ 692 this( Exception e ){
693 super(e.toString); 693 super(e.toString);
694 } 694 }
695 } 695 }
696 class InterruptedException : Exception { 696 class InterruptedException : Exception {
697 this( char[] e = null ){ 697 this( String e = null ){
698 super(e); 698 super(e);
699 } 699 }
700 this( Exception e ){ 700 this( Exception e ){
701 super(e.toString); 701 super(e.toString);
702 } 702 }
703 } 703 }
704 class InvocationTargetException : Exception { 704 class InvocationTargetException : Exception {
705 Exception cause; 705 Exception cause;
706 this( Exception e = null, char[] msg = null ){ 706 this( Exception e = null, String msg = null ){
707 super(msg); 707 super(msg);
708 cause = e; 708 cause = e;
709 } 709 }
710 710
711 alias getCause getTargetException; 711 alias getCause getTargetException;
712 Exception getCause(){ 712 Exception getCause(){
713 return cause; 713 return cause;
714 } 714 }
715 } 715 }
716 class MissingResourceException : Exception { 716 class MissingResourceException : Exception {
717 char[] classname; 717 String classname;
718 char[] key; 718 String key;
719 this( char[] msg, char[] classname, char[] key ){ 719 this( String msg, String classname, String key ){
720 super(msg); 720 super(msg);
721 this.classname = classname; 721 this.classname = classname;
722 this.key = key; 722 this.key = key;
723 } 723 }
724 } 724 }
725 class ParseException : Exception { 725 class ParseException : Exception {
726 this( char[] e = null ){ 726 this( String e = null ){
727 super(e); 727 super(e);
728 } 728 }
729 } 729 }
730 730
731 interface Cloneable{ 731 interface Cloneable{
751 751
752 public Object getSource() { 752 public Object getSource() {
753 return source; 753 return source;
754 } 754 }
755 755
756 public override char[] toString() { 756 public override String toString() {
757 return this.classinfo.name ~ "[source=" ~ source.toString() ~ "]"; 757 return this.classinfo.name ~ "[source=" ~ source.toString() ~ "]";
758 } 758 }
759 } 759 }
760 760
761 private struct GCStats { 761 private struct GCStats {
829 return(res); 829 return(res);
830 } 830 }
831 } 831 }
832 } 832 }
833 833
834 char[] stringcast( Object o ){ 834 String stringcast( Object o ){
835 if( auto str = cast(ArrayWrapperString) o ){ 835 if( auto str = cast(ArrayWrapperString) o ){
836 return str.array; 836 return str.array;
837 } 837 }
838 return null; 838 return null;
839 } 839 }
840 char[][] stringcast( Object[] objs ){ 840 String[] stringcast( Object[] objs ){
841 char[][] res = new char[][](objs.length); 841 String[] res = new String[](objs.length);
842 foreach( idx, obj; objs ){ 842 foreach( idx, obj; objs ){
843 res[idx] = stringcast(obj); 843 res[idx] = stringcast(obj);
844 } 844 }
845 return res; 845 return res;
846 } 846 }
847 ArrayWrapperString stringcast( char[] str ){ 847 ArrayWrapperString stringcast( String str ){
848 return new ArrayWrapperString( str ); 848 return new ArrayWrapperString( str );
849 } 849 }
850 ArrayWrapperString[] stringcast( char[][] strs ){ 850 ArrayWrapperString[] stringcast( String[] strs ){
851 ArrayWrapperString[] res = new ArrayWrapperString[ strs.length ]; 851 ArrayWrapperString[] res = new ArrayWrapperString[ strs.length ];
852 foreach( idx, str; strs ){ 852 foreach( idx, str; strs ){
853 res[idx] = stringcast(str); 853 res[idx] = stringcast(str);
854 } 854 }
855 return res; 855 return res;
934 idx++; 934 idx++;
935 } 935 }
936 return res; 936 return res;
937 } 937 }
938 938
939 void PrintStackTrace( int deepth = 100, char[] prefix = "trc" ){ 939 void PrintStackTrace( int deepth = 100, String prefix = "trc" ){
940 auto e = new Exception( null ); 940 auto e = new Exception( null );
941 int idx = 0; 941 int idx = 0;
942 const start = 3; 942 const start = 3;
943 foreach( msg; e.info ){ 943 foreach( msg; e.info ){
944 if( idx >= start && idx < start+deepth ) { 944 if( idx >= start && idx < start+deepth ) {
948 } 948 }
949 } 949 }
950 950
951 struct ImportData{ 951 struct ImportData{
952 void[] data; 952 void[] data;
953 char[] name; 953 String name;
954 954
955 public static ImportData opCall( void[] data, char[] name ){ 955 public static ImportData opCall( void[] data, String name ){
956 ImportData res; 956 ImportData res;
957 res.data = data; 957 res.data = data;
958 res.name = name; 958 res.name = name;
959 return res; 959 return res;
960 } 960 }
961 } 961 }
962 962
963 template getImportData(char[] name ){ 963 template getImportData(String name ){
964 const ImportData getImportData = ImportData( import(name), name ); 964 const ImportData getImportData = ImportData( import(name), name );
965 } 965 }