14
|
1 /**
|
|
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
|
|
3 * Authors: Jacob Carlborg
|
|
4 * Version: Initial created: Aug 3, 2009
|
|
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
|
|
6 */
|
|
7 module dstep.foundation.NSPredicate;
|
|
8
|
|
9 import dstep.foundation.NSArray;
|
|
10 import dstep.foundation.NSObject;
|
|
11 import dstep.foundation.NSSet;
|
|
12 import dstep.objc.bridge.Bridge;
|
|
13 import dstep.objc.objc : id;
|
|
14
|
|
15 class NSPredicate : NSObject, INSCoding, INSCopying
|
|
16 {
|
|
17 mixin ObjcWrap;
|
|
18
|
|
19 static NSPredicate predicateWithFormat (NSString predicateFormat, NSArray arguments)
|
|
20 {
|
|
21 return invokeObjcSelfClass!(NSPredicate, "predicateWithFormat:argumentArray:", NSString, NSArray)(predicateFormat, argumentsreturn result is this.objcObject ? this : (result !is null ? new NSPredicate(result) : null); }
|
|
22
|
|
23 static NSPredicate predicateWithFormat (NSString predicateWithFormat, ...)
|
|
24 {
|
|
25 return invokeObjcSelfClass!(NSPredicate, "predicateWithFormat:", NSString)(predicateWithFormatreturn result is this.objcObject ? this : (result !is null ? new NSPredicate(result) : null); }
|
|
26
|
|
27 static NSPredicate predicateWithFormat (NSString predicateFormat, char* argList)
|
|
28 {
|
|
29 return invokeObjcSelfClass!(NSPredicate, "predicateWithFormat:arguments:", NSString, char*)(predicateFormat, argListreturn result is this.objcObject ? this : (result !is null ? new NSPredicate(result) : null); }
|
|
30
|
|
31 static NSPredicate predicateWithValue (bool value)
|
|
32 {
|
|
33 return invokeObjcSelfClass!(NSPredicate, "predicateWithValue:", bool)(valuereturn result is this.objcObject ? this : (result !is null ? new NSPredicate(result) : null); }
|
|
34
|
|
35 NSString predicateFormat ()
|
|
36 {
|
|
37 return invokeObjcSelf!(NSString, "predicateFormat");
|
|
38 }
|
|
39
|
|
40 NSPredicate predicateWithSubstitutionVariables (NSDictionary variables)
|
|
41 {
|
|
42 id result = invokeObjcSelf!(id, "predicateWithSubstitutionVariables:", NSDictionary)(variablesreturn result is this.objcObject ? this : (result !is null ? new NSPredicate(result) : null); }
|
|
43
|
|
44 bool evaluateWithObject (Object object)
|
|
45 {
|
|
46 return invokeObjcSelf!(bool, "evaluateWithObject:", Object)(object);
|
|
47 }
|
|
48
|
|
49 bool evaluateWithObject (Object object, NSDictionary bindings)
|
|
50 {
|
|
51 return invokeObjcSelf!(bool, "evaluateWithObject:substitutionVariables:", Object, NSDictionary)(object, bindings);
|
|
52 }
|
|
53
|
|
54 void encodeWithCoder (NSCoder aCoder)
|
|
55 {
|
|
56 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
|
|
57 }
|
|
58
|
|
59 Object initWithCoder (NSCoder aDecoder)
|
|
60 {
|
|
61 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder);
|
|
62 }
|
|
63
|
|
64 this (NSCoder aDecoder)
|
|
65 {
|
|
66 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
67 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder);
|
|
68
|
|
69 if (result)
|
|
70 objcObject = ret;
|
|
71
|
|
72 dObject = this;
|
|
73 }
|
|
74
|
|
75 Object copyWithZone (NSZone* zone)
|
|
76 {
|
|
77 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);
|
|
78 }
|
|
79 }
|
|
80
|
|
81 template TNSPredicateSupport ()
|
|
82 {
|
|
83 void filterUsingPredicate (NSPredicate predicate)
|
|
84 {
|
|
85 return invokeObjcSelf!(void, "filterUsingPredicate:", NSPredicate)(predicate);
|
|
86 }
|
|
87 }
|
|
88
|