diff dstep/foundation/NSPredicate.d @ 14:89f3c3ef1fd2

Added the Foundation framework
author Jacob Carlborg <doob@me.com>
date Mon, 03 Aug 2009 15:23:15 +0200
parents
children 7ff919f595d5
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dstep/foundation/NSPredicate.d	Mon Aug 03 15:23:15 2009 +0200
@@ -0,0 +1,88 @@
+/**
+ * Copyright: Copyright (c) 2009 Jacob Carlborg.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Aug 3, 2009 
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
+ */
+module dstep.foundation.NSPredicate;
+
+import dstep.foundation.NSArray;
+import dstep.foundation.NSObject;
+import dstep.foundation.NSSet;
+import dstep.objc.bridge.Bridge;
+import dstep.objc.objc : id;
+
+class NSPredicate : NSObject, INSCoding, INSCopying
+{
+	mixin ObjcWrap;
+
+	static NSPredicate predicateWithFormat (NSString predicateFormat, NSArray arguments)
+	{
+		return invokeObjcSelfClass!(NSPredicate, "predicateWithFormat:argumentArray:", NSString, NSArray)(predicateFormat, argumentsreturn result is this.objcObject ? this : (result !is null ? new NSPredicate(result) : null);	}
+
+	static NSPredicate predicateWithFormat (NSString predicateWithFormat, ...)
+	{
+		return invokeObjcSelfClass!(NSPredicate, "predicateWithFormat:", NSString)(predicateWithFormatreturn result is this.objcObject ? this : (result !is null ? new NSPredicate(result) : null);	}
+
+	static NSPredicate predicateWithFormat (NSString predicateFormat, char* argList)
+	{
+		return invokeObjcSelfClass!(NSPredicate, "predicateWithFormat:arguments:", NSString, char*)(predicateFormat, argListreturn result is this.objcObject ? this : (result !is null ? new NSPredicate(result) : null);	}
+
+	static NSPredicate predicateWithValue (bool value)
+	{
+		return invokeObjcSelfClass!(NSPredicate, "predicateWithValue:", bool)(valuereturn result is this.objcObject ? this : (result !is null ? new NSPredicate(result) : null);	}
+
+	NSString predicateFormat ()
+	{
+		return invokeObjcSelf!(NSString, "predicateFormat");
+	}
+
+	NSPredicate predicateWithSubstitutionVariables (NSDictionary variables)
+	{
+		id result = invokeObjcSelf!(id, "predicateWithSubstitutionVariables:", NSDictionary)(variablesreturn result is this.objcObject ? this : (result !is null ? new NSPredicate(result) : null);	}
+
+	bool evaluateWithObject (Object object)
+	{
+		return invokeObjcSelf!(bool, "evaluateWithObject:", Object)(object);
+	}
+
+	bool evaluateWithObject (Object object, NSDictionary bindings)
+	{
+		return invokeObjcSelf!(bool, "evaluateWithObject:substitutionVariables:", Object, NSDictionary)(object, bindings);
+	}
+
+	void encodeWithCoder (NSCoder aCoder)
+	{
+		return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
+	}
+
+	Object initWithCoder (NSCoder aDecoder)
+	{
+		return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder);
+	}
+
+	this (NSCoder aDecoder)
+	{
+		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
+		id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder);
+
+		if (result)
+			objcObject = ret;
+
+		dObject = this;
+	}
+
+	Object copyWithZone (NSZone* zone)
+	{
+		return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);
+	}
+}
+
+template TNSPredicateSupport ()
+{
+	void filterUsingPredicate (NSPredicate predicate)
+	{
+		return invokeObjcSelf!(void, "filterUsingPredicate:", NSPredicate)(predicate);
+	}
+}
+