diff dwt/dwthelper/utils.d @ 280:4ec36c3a04a3

sync with dwt-linux
author Frank Benoit <benoit@tionex.de>
date Thu, 07 Aug 2008 15:06:52 +0200
parents f18872e0f232
children 92e785261f30
line wrap: on
line diff
--- a/dwt/dwthelper/utils.d	Tue Aug 05 01:07:44 2008 +0200
+++ b/dwt/dwthelper/utils.d	Thu Aug 07 15:06:52 2008 +0200
@@ -845,12 +845,6 @@
     }
 }
 
-interface Enumeration {
-    public bool hasMoreElements();
-    public Object nextElement();
-}
-
-
 template arraycast(T) {
     T[] arraycast(U) (U[] u) {
         static if (
@@ -894,6 +888,35 @@
     return res;
 }
 
+String[] stringArrayFromObject( Object obj ){
+    if( auto wrapper = cast(ArrayWrapperString2)obj ){
+        return wrapper.array;
+    }
+    if( auto wrapper = cast(ArrayWrapperObject)obj ){
+        String[] res = new String[ wrapper.array.length ];
+        foreach( idx, o; wrapper.array ){
+            if( auto swrapper = cast(ArrayWrapperString) o ){
+                res[idx] = swrapper.array;
+            }
+        }
+        return res;
+    }
+    assert( obj is null ); // if not null, it was the wrong type
+    return null;
+}
+
+T[] arrayFromObject(T)( Object obj ){
+    if( auto wrapper = cast(ArrayWrapperObject)obj ){
+        T[] res = new T[ wrapper.array.length ];
+        foreach( idx, o; wrapper.array ){
+            res[idx] = cast(T)o;
+        }
+        return res;
+    }
+    assert( obj is null ); // if not null, it was the wrong type
+    return null;
+}
+
 
 bool ArrayEquals(T)( T[] a, T[] b ){
     if( a.length !is b.length ){
@@ -921,24 +944,6 @@
     return true;
 }
 
-class Arrays{
-    public static bool equals(Object[] a, Object[] b){
-        if( a.length !is b.length ){
-            return false;
-        }
-        for( int i = 0; i < a.length; i++ ){
-            if( a[i] is null && b[i] is null ){
-                continue;
-            }
-            if( a[i] !is null && b[i] !is null && a[i] == b[i] ){
-                continue;
-            }
-            return false;
-        }
-        return true;
-    }
-}
-
 int SeqIndexOf(T)( tango.util.collection.model.Seq.Seq!(T) s, T src ){
     int idx;
     foreach( e; s ){