├── .gitignore ├── .travis.yml ├── LICENSE.text ├── PredicatePal.xcodeproj ├── project.pbxproj └── xcshareddata │ └── xcschemes │ ├── PredicatePal (OS X).xcscheme │ ├── PredicatePal (iOS).xcscheme │ └── PredicatePal (tvOS).xcscheme ├── PredicatePal ├── AndPredicate.swift ├── AnyKey.swift ├── BinaryIndexExpression.swift ├── BinaryIntegerExpression.swift ├── BinaryLocationtoNumberExpression.swift ├── BinaryNumberExpression.swift ├── Block.swift ├── Boolean.swift ├── ComparisonPredicate.swift ├── Const.swift ├── DifferenceExpression.swift ├── Expression.swift ├── Info.plist ├── IntersectExpression.swift ├── Key.swift ├── NotPredicate.swift ├── NullaryDateExpression.swift ├── NullaryIntegerExpression.swift ├── Operators.swift ├── OrPredicate.swift ├── Predicate.swift ├── PredicatePal.h ├── Protocols.swift ├── QuantifiedPredicate.swift ├── SubqueryExpression.swift ├── This.swift ├── UnaryIntegerExpression.swift ├── UnaryNumberExpression.swift ├── UnarySequenceToNumberExpression.swift ├── UnaryStringExpression.swift ├── UnaryStringToIntegerExpression.swift ├── UnionExpression.swift └── Var.swift ├── PredicatePalTests ├── ExpressionTests.swift ├── Info.plist ├── PredicateTests.swift └── TermTests.swift └── README.markdown /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | xcuserdata 3 | project.xcworkspace 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode7.2 3 | xcode_project: PredicatePal.xcodeproj 4 | xcode_scheme: PredicatePal (OS X) 5 | -------------------------------------------------------------------------------- /LICENSE.text: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Pixelglow Software. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11 | -------------------------------------------------------------------------------- /PredicatePal.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D81BFB561C22789200C2F3CE /* OrPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81BFB551C22789200C2F3CE /* OrPredicate.swift */; }; 11 | D81BFB581C22789B00C2F3CE /* NotPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81BFB571C22789B00C2F3CE /* NotPredicate.swift */; }; 12 | D81BFB7E1C22C10C00C2F3CE /* NullaryDateExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81BFB7D1C22C10C00C2F3CE /* NullaryDateExpression.swift */; }; 13 | D81BFB801C23CBCF00C2F3CE /* Block.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81BFB7F1C23CBCF00C2F3CE /* Block.swift */; }; 14 | D81BFB821C23DAE300C2F3CE /* This.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81BFB811C23DAE300C2F3CE /* This.swift */; }; 15 | D81BFB871C2524EC00C2F3CE /* BinaryLocationtoNumberExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81BFB861C2524EC00C2F3CE /* BinaryLocationtoNumberExpression.swift */; }; 16 | D85B80781C279B9500A5EAC8 /* UnaryStringExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93F91C226E9C00B3AC6D /* UnaryStringExpression.swift */; }; 17 | D85B80791C279B9500A5EAC8 /* Predicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8DCA8AA1C0D2FF400F8755C /* Predicate.swift */; }; 18 | D85B807A1C279B9500A5EAC8 /* NullaryIntegerExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE264E1C153912003C3F78 /* NullaryIntegerExpression.swift */; }; 19 | D85B807B1C279B9500A5EAC8 /* BinaryIntegerExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93EB1C22687E00B3AC6D /* BinaryIntegerExpression.swift */; }; 20 | D85B807C1C279B9500A5EAC8 /* This.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81BFB811C23DAE300C2F3CE /* This.swift */; }; 21 | D85B807D1C279B9500A5EAC8 /* AnyKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE26581C153E8D003C3F78 /* AnyKey.swift */; }; 22 | D85B807E1C279B9500A5EAC8 /* QuantifiedPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D87E774B1C16A506006727A4 /* QuantifiedPredicate.swift */; }; 23 | D85B807F1C279B9500A5EAC8 /* Protocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8DCA8AE1C0D416F00F8755C /* Protocols.swift */; }; 24 | D85B80801C279B9500A5EAC8 /* SubqueryExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8E173481C1BC58400B2EA6A /* SubqueryExpression.swift */; }; 25 | D85B80811C279B9500A5EAC8 /* AndPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D87E774F1C16A817006727A4 /* AndPredicate.swift */; }; 26 | D85B80821C279B9500A5EAC8 /* BinaryNumberExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93E91C22686D00B3AC6D /* BinaryNumberExpression.swift */; }; 27 | D85B80831C279B9500A5EAC8 /* Var.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE264C1C1538FE003C3F78 /* Var.swift */; }; 28 | D85B80841C279B9500A5EAC8 /* NotPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81BFB571C22789B00C2F3CE /* NotPredicate.swift */; }; 29 | D85B80851C279B9500A5EAC8 /* UnaryIntegerExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93F51C226C3B00B3AC6D /* UnaryIntegerExpression.swift */; }; 30 | D85B80861C279B9500A5EAC8 /* Key.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE26561C15398B003C3F78 /* Key.swift */; }; 31 | D85B80871C279B9500A5EAC8 /* ComparisonPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D87E77471C16904C006727A4 /* ComparisonPredicate.swift */; }; 32 | D85B80881C279B9500A5EAC8 /* Boolean.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85D6E431C19262200ACBDCA /* Boolean.swift */; }; 33 | D85B80891C279B9500A5EAC8 /* UnaryStringToIntegerExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93F71C226C5C00B3AC6D /* UnaryStringToIntegerExpression.swift */; }; 34 | D85B808A1C279B9500A5EAC8 /* UnaryNumberExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93F11C226C0200B3AC6D /* UnaryNumberExpression.swift */; }; 35 | D85B808B1C279B9500A5EAC8 /* Expression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8DCA8AC1C0D303E00F8755C /* Expression.swift */; }; 36 | D85B808C1C279B9500A5EAC8 /* NullaryDateExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81BFB7D1C22C10C00C2F3CE /* NullaryDateExpression.swift */; }; 37 | D85B808D1C279B9500A5EAC8 /* DifferenceExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85D6E471C195C5800ACBDCA /* DifferenceExpression.swift */; }; 38 | D85B808F1C279B9500A5EAC8 /* Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85D6E411C19228800ACBDCA /* Operators.swift */; }; 39 | D85B80901C279B9500A5EAC8 /* UnarySequenceToNumberExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93F31C226C1C00B3AC6D /* UnarySequenceToNumberExpression.swift */; }; 40 | D85B80911C279B9500A5EAC8 /* OrPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81BFB551C22789200C2F3CE /* OrPredicate.swift */; }; 41 | D85B80921C279B9500A5EAC8 /* BinaryIndexExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93ED1C22688B00B3AC6D /* BinaryIndexExpression.swift */; }; 42 | D85B80931C279B9500A5EAC8 /* BinaryLocationtoNumberExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81BFB861C2524EC00C2F3CE /* BinaryLocationtoNumberExpression.swift */; }; 43 | D85B80941C279B9500A5EAC8 /* IntersectExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85D6E451C195C4800ACBDCA /* IntersectExpression.swift */; }; 44 | D85B80951C279B9500A5EAC8 /* Block.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81BFB7F1C23CBCF00C2F3CE /* Block.swift */; }; 45 | D85B80961C279B9500A5EAC8 /* UnionExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE26541C153937003C3F78 /* UnionExpression.swift */; }; 46 | D85B80971C279B9500A5EAC8 /* Const.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE264A1C1538F2003C3F78 /* Const.swift */; }; 47 | D85B809A1C279B9500A5EAC8 /* PredicatePal.h in Headers */ = {isa = PBXBuildFile; fileRef = D8DCA8931C0D2FB100F8755C /* PredicatePal.h */; settings = {ATTRIBUTES = (Public, ); }; }; 48 | D85B80A31C279BA400A5EAC8 /* UnaryStringExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93F91C226E9C00B3AC6D /* UnaryStringExpression.swift */; }; 49 | D85B80A41C279BA400A5EAC8 /* Predicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8DCA8AA1C0D2FF400F8755C /* Predicate.swift */; }; 50 | D85B80A51C279BA400A5EAC8 /* NullaryIntegerExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE264E1C153912003C3F78 /* NullaryIntegerExpression.swift */; }; 51 | D85B80A61C279BA400A5EAC8 /* BinaryIntegerExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93EB1C22687E00B3AC6D /* BinaryIntegerExpression.swift */; }; 52 | D85B80A71C279BA400A5EAC8 /* This.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81BFB811C23DAE300C2F3CE /* This.swift */; }; 53 | D85B80A81C279BA400A5EAC8 /* AnyKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE26581C153E8D003C3F78 /* AnyKey.swift */; }; 54 | D85B80A91C279BA400A5EAC8 /* QuantifiedPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D87E774B1C16A506006727A4 /* QuantifiedPredicate.swift */; }; 55 | D85B80AA1C279BA400A5EAC8 /* Protocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8DCA8AE1C0D416F00F8755C /* Protocols.swift */; }; 56 | D85B80AB1C279BA400A5EAC8 /* SubqueryExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8E173481C1BC58400B2EA6A /* SubqueryExpression.swift */; }; 57 | D85B80AC1C279BA400A5EAC8 /* AndPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D87E774F1C16A817006727A4 /* AndPredicate.swift */; }; 58 | D85B80AD1C279BA400A5EAC8 /* BinaryNumberExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93E91C22686D00B3AC6D /* BinaryNumberExpression.swift */; }; 59 | D85B80AE1C279BA400A5EAC8 /* Var.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE264C1C1538FE003C3F78 /* Var.swift */; }; 60 | D85B80AF1C279BA400A5EAC8 /* NotPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81BFB571C22789B00C2F3CE /* NotPredicate.swift */; }; 61 | D85B80B01C279BA400A5EAC8 /* UnaryIntegerExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93F51C226C3B00B3AC6D /* UnaryIntegerExpression.swift */; }; 62 | D85B80B11C279BA400A5EAC8 /* Key.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE26561C15398B003C3F78 /* Key.swift */; }; 63 | D85B80B21C279BA400A5EAC8 /* ComparisonPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D87E77471C16904C006727A4 /* ComparisonPredicate.swift */; }; 64 | D85B80B31C279BA400A5EAC8 /* Boolean.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85D6E431C19262200ACBDCA /* Boolean.swift */; }; 65 | D85B80B41C279BA400A5EAC8 /* UnaryStringToIntegerExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93F71C226C5C00B3AC6D /* UnaryStringToIntegerExpression.swift */; }; 66 | D85B80B51C279BA400A5EAC8 /* UnaryNumberExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93F11C226C0200B3AC6D /* UnaryNumberExpression.swift */; }; 67 | D85B80B61C279BA400A5EAC8 /* Expression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8DCA8AC1C0D303E00F8755C /* Expression.swift */; }; 68 | D85B80B71C279BA400A5EAC8 /* NullaryDateExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81BFB7D1C22C10C00C2F3CE /* NullaryDateExpression.swift */; }; 69 | D85B80B81C279BA400A5EAC8 /* DifferenceExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85D6E471C195C5800ACBDCA /* DifferenceExpression.swift */; }; 70 | D85B80BA1C279BA400A5EAC8 /* Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85D6E411C19228800ACBDCA /* Operators.swift */; }; 71 | D85B80BB1C279BA400A5EAC8 /* UnarySequenceToNumberExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93F31C226C1C00B3AC6D /* UnarySequenceToNumberExpression.swift */; }; 72 | D85B80BC1C279BA400A5EAC8 /* OrPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81BFB551C22789200C2F3CE /* OrPredicate.swift */; }; 73 | D85B80BD1C279BA400A5EAC8 /* BinaryIndexExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93ED1C22688B00B3AC6D /* BinaryIndexExpression.swift */; }; 74 | D85B80BE1C279BA400A5EAC8 /* BinaryLocationtoNumberExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81BFB861C2524EC00C2F3CE /* BinaryLocationtoNumberExpression.swift */; }; 75 | D85B80BF1C279BA400A5EAC8 /* IntersectExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85D6E451C195C4800ACBDCA /* IntersectExpression.swift */; }; 76 | D85B80C01C279BA400A5EAC8 /* Block.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81BFB7F1C23CBCF00C2F3CE /* Block.swift */; }; 77 | D85B80C11C279BA400A5EAC8 /* UnionExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE26541C153937003C3F78 /* UnionExpression.swift */; }; 78 | D85B80C21C279BA400A5EAC8 /* Const.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE264A1C1538F2003C3F78 /* Const.swift */; }; 79 | D85B80C51C279BA400A5EAC8 /* PredicatePal.h in Headers */ = {isa = PBXBuildFile; fileRef = D8DCA8931C0D2FB100F8755C /* PredicatePal.h */; settings = {ATTRIBUTES = (Public, ); }; }; 80 | D85B80D01C2817BC00A5EAC8 /* TermTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85B80CF1C2817BC00A5EAC8 /* TermTests.swift */; }; 81 | D85D6E421C19228800ACBDCA /* Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85D6E411C19228800ACBDCA /* Operators.swift */; }; 82 | D85D6E441C19262200ACBDCA /* Boolean.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85D6E431C19262200ACBDCA /* Boolean.swift */; }; 83 | D85D6E461C195C4800ACBDCA /* IntersectExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85D6E451C195C4800ACBDCA /* IntersectExpression.swift */; }; 84 | D85D6E481C195C5800ACBDCA /* DifferenceExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85D6E471C195C5800ACBDCA /* DifferenceExpression.swift */; }; 85 | D87E77481C16904C006727A4 /* ComparisonPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D87E77471C16904C006727A4 /* ComparisonPredicate.swift */; }; 86 | D87E774C1C16A506006727A4 /* QuantifiedPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D87E774B1C16A506006727A4 /* QuantifiedPredicate.swift */; }; 87 | D87E774E1C16A692006727A4 /* PredicateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D87E774D1C16A692006727A4 /* PredicateTests.swift */; }; 88 | D87E77501C16A817006727A4 /* AndPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D87E774F1C16A817006727A4 /* AndPredicate.swift */; }; 89 | D8AE264B1C1538F2003C3F78 /* Const.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE264A1C1538F2003C3F78 /* Const.swift */; }; 90 | D8AE264D1C1538FE003C3F78 /* Var.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE264C1C1538FE003C3F78 /* Var.swift */; }; 91 | D8AE264F1C153912003C3F78 /* NullaryIntegerExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE264E1C153912003C3F78 /* NullaryIntegerExpression.swift */; }; 92 | D8AE26551C153937003C3F78 /* UnionExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE26541C153937003C3F78 /* UnionExpression.swift */; }; 93 | D8AE26571C15398B003C3F78 /* Key.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE26561C15398B003C3F78 /* Key.swift */; }; 94 | D8AE26591C153E8D003C3F78 /* AnyKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AE26581C153E8D003C3F78 /* AnyKey.swift */; }; 95 | D8B40F5F1C1183540033C06E /* ExpressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8B40F5E1C1183540033C06E /* ExpressionTests.swift */; }; 96 | D8BE93EA1C22686D00B3AC6D /* BinaryNumberExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93E91C22686D00B3AC6D /* BinaryNumberExpression.swift */; }; 97 | D8BE93EC1C22687E00B3AC6D /* BinaryIntegerExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93EB1C22687E00B3AC6D /* BinaryIntegerExpression.swift */; }; 98 | D8BE93EE1C22688B00B3AC6D /* BinaryIndexExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93ED1C22688B00B3AC6D /* BinaryIndexExpression.swift */; }; 99 | D8BE93F21C226C0200B3AC6D /* UnaryNumberExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93F11C226C0200B3AC6D /* UnaryNumberExpression.swift */; }; 100 | D8BE93F41C226C1C00B3AC6D /* UnarySequenceToNumberExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93F31C226C1C00B3AC6D /* UnarySequenceToNumberExpression.swift */; }; 101 | D8BE93F61C226C3B00B3AC6D /* UnaryIntegerExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93F51C226C3B00B3AC6D /* UnaryIntegerExpression.swift */; }; 102 | D8BE93F81C226C5C00B3AC6D /* UnaryStringToIntegerExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93F71C226C5C00B3AC6D /* UnaryStringToIntegerExpression.swift */; }; 103 | D8BE93FA1C226E9C00B3AC6D /* UnaryStringExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8BE93F91C226E9C00B3AC6D /* UnaryStringExpression.swift */; }; 104 | D8DCA8941C0D2FB100F8755C /* PredicatePal.h in Headers */ = {isa = PBXBuildFile; fileRef = D8DCA8931C0D2FB100F8755C /* PredicatePal.h */; settings = {ATTRIBUTES = (Public, ); }; }; 105 | D8DCA89B1C0D2FB100F8755C /* PredicatePal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8DCA8901C0D2FB100F8755C /* PredicatePal.framework */; }; 106 | D8DCA8AB1C0D2FF500F8755C /* Predicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8DCA8AA1C0D2FF400F8755C /* Predicate.swift */; }; 107 | D8DCA8AD1C0D303E00F8755C /* Expression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8DCA8AC1C0D303E00F8755C /* Expression.swift */; }; 108 | D8DCA8AF1C0D416F00F8755C /* Protocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8DCA8AE1C0D416F00F8755C /* Protocols.swift */; }; 109 | D8E173491C1BC58400B2EA6A /* SubqueryExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8E173481C1BC58400B2EA6A /* SubqueryExpression.swift */; }; 110 | /* End PBXBuildFile section */ 111 | 112 | /* Begin PBXContainerItemProxy section */ 113 | D8DCA89C1C0D2FB100F8755C /* PBXContainerItemProxy */ = { 114 | isa = PBXContainerItemProxy; 115 | containerPortal = D8DCA8871C0D2FB100F8755C /* Project object */; 116 | proxyType = 1; 117 | remoteGlobalIDString = D8DCA88F1C0D2FB100F8755C; 118 | remoteInfo = PredicatePal; 119 | }; 120 | /* End PBXContainerItemProxy section */ 121 | 122 | /* Begin PBXFileReference section */ 123 | D81BFB551C22789200C2F3CE /* OrPredicate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrPredicate.swift; sourceTree = ""; }; 124 | D81BFB571C22789B00C2F3CE /* NotPredicate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotPredicate.swift; sourceTree = ""; }; 125 | D81BFB7D1C22C10C00C2F3CE /* NullaryDateExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NullaryDateExpression.swift; sourceTree = ""; }; 126 | D81BFB7F1C23CBCF00C2F3CE /* Block.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Block.swift; sourceTree = ""; }; 127 | D81BFB811C23DAE300C2F3CE /* This.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = This.swift; sourceTree = ""; }; 128 | D81BFB861C2524EC00C2F3CE /* BinaryLocationtoNumberExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BinaryLocationtoNumberExpression.swift; sourceTree = ""; }; 129 | D85B809F1C279B9500A5EAC8 /* PredicatePal.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PredicatePal.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 130 | D85B80CA1C279BA400A5EAC8 /* PredicatePal.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PredicatePal.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 131 | D85B80CF1C2817BC00A5EAC8 /* TermTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TermTests.swift; sourceTree = ""; }; 132 | D85D6E411C19228800ACBDCA /* Operators.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Operators.swift; sourceTree = ""; }; 133 | D85D6E431C19262200ACBDCA /* Boolean.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Boolean.swift; sourceTree = ""; }; 134 | D85D6E451C195C4800ACBDCA /* IntersectExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IntersectExpression.swift; sourceTree = ""; }; 135 | D85D6E471C195C5800ACBDCA /* DifferenceExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DifferenceExpression.swift; sourceTree = ""; }; 136 | D87E77471C16904C006727A4 /* ComparisonPredicate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComparisonPredicate.swift; sourceTree = ""; }; 137 | D87E774B1C16A506006727A4 /* QuantifiedPredicate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QuantifiedPredicate.swift; sourceTree = ""; }; 138 | D87E774D1C16A692006727A4 /* PredicateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PredicateTests.swift; sourceTree = ""; }; 139 | D87E774F1C16A817006727A4 /* AndPredicate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AndPredicate.swift; sourceTree = ""; }; 140 | D8AE264A1C1538F2003C3F78 /* Const.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Const.swift; sourceTree = ""; }; 141 | D8AE264C1C1538FE003C3F78 /* Var.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Var.swift; sourceTree = ""; }; 142 | D8AE264E1C153912003C3F78 /* NullaryIntegerExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NullaryIntegerExpression.swift; sourceTree = ""; }; 143 | D8AE26541C153937003C3F78 /* UnionExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnionExpression.swift; sourceTree = ""; }; 144 | D8AE26561C15398B003C3F78 /* Key.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Key.swift; sourceTree = ""; }; 145 | D8AE26581C153E8D003C3F78 /* AnyKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnyKey.swift; sourceTree = ""; }; 146 | D8B40F5E1C1183540033C06E /* ExpressionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExpressionTests.swift; sourceTree = ""; }; 147 | D8BE93E91C22686D00B3AC6D /* BinaryNumberExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BinaryNumberExpression.swift; sourceTree = ""; }; 148 | D8BE93EB1C22687E00B3AC6D /* BinaryIntegerExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BinaryIntegerExpression.swift; sourceTree = ""; }; 149 | D8BE93ED1C22688B00B3AC6D /* BinaryIndexExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BinaryIndexExpression.swift; sourceTree = ""; }; 150 | D8BE93F11C226C0200B3AC6D /* UnaryNumberExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnaryNumberExpression.swift; sourceTree = ""; }; 151 | D8BE93F31C226C1C00B3AC6D /* UnarySequenceToNumberExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnarySequenceToNumberExpression.swift; sourceTree = ""; }; 152 | D8BE93F51C226C3B00B3AC6D /* UnaryIntegerExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnaryIntegerExpression.swift; sourceTree = ""; }; 153 | D8BE93F71C226C5C00B3AC6D /* UnaryStringToIntegerExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnaryStringToIntegerExpression.swift; sourceTree = ""; }; 154 | D8BE93F91C226E9C00B3AC6D /* UnaryStringExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnaryStringExpression.swift; sourceTree = ""; }; 155 | D8DCA8901C0D2FB100F8755C /* PredicatePal.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PredicatePal.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 156 | D8DCA8931C0D2FB100F8755C /* PredicatePal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PredicatePal.h; sourceTree = ""; }; 157 | D8DCA8951C0D2FB100F8755C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 158 | D8DCA89A1C0D2FB100F8755C /* PredicatePalTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PredicatePalTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 159 | D8DCA8A11C0D2FB100F8755C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 160 | D8DCA8AA1C0D2FF400F8755C /* Predicate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Predicate.swift; sourceTree = ""; }; 161 | D8DCA8AC1C0D303E00F8755C /* Expression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Expression.swift; sourceTree = ""; }; 162 | D8DCA8AE1C0D416F00F8755C /* Protocols.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Protocols.swift; sourceTree = ""; }; 163 | D8E173481C1BC58400B2EA6A /* SubqueryExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SubqueryExpression.swift; sourceTree = ""; }; 164 | /* End PBXFileReference section */ 165 | 166 | /* Begin PBXFrameworksBuildPhase section */ 167 | D85B80981C279B9500A5EAC8 /* Frameworks */ = { 168 | isa = PBXFrameworksBuildPhase; 169 | buildActionMask = 2147483647; 170 | files = ( 171 | ); 172 | runOnlyForDeploymentPostprocessing = 0; 173 | }; 174 | D85B80C31C279BA400A5EAC8 /* Frameworks */ = { 175 | isa = PBXFrameworksBuildPhase; 176 | buildActionMask = 2147483647; 177 | files = ( 178 | ); 179 | runOnlyForDeploymentPostprocessing = 0; 180 | }; 181 | D8DCA88C1C0D2FB100F8755C /* Frameworks */ = { 182 | isa = PBXFrameworksBuildPhase; 183 | buildActionMask = 2147483647; 184 | files = ( 185 | ); 186 | runOnlyForDeploymentPostprocessing = 0; 187 | }; 188 | D8DCA8971C0D2FB100F8755C /* Frameworks */ = { 189 | isa = PBXFrameworksBuildPhase; 190 | buildActionMask = 2147483647; 191 | files = ( 192 | D8DCA89B1C0D2FB100F8755C /* PredicatePal.framework in Frameworks */, 193 | ); 194 | runOnlyForDeploymentPostprocessing = 0; 195 | }; 196 | /* End PBXFrameworksBuildPhase section */ 197 | 198 | /* Begin PBXGroup section */ 199 | D85B80CC1C28117300A5EAC8 /* Supporting Files */ = { 200 | isa = PBXGroup; 201 | children = ( 202 | D8DCA8951C0D2FB100F8755C /* Info.plist */, 203 | D8DCA8931C0D2FB100F8755C /* PredicatePal.h */, 204 | ); 205 | name = "Supporting Files"; 206 | sourceTree = ""; 207 | }; 208 | D85B80CD1C28119C00A5EAC8 /* Core */ = { 209 | isa = PBXGroup; 210 | children = ( 211 | D85D6E411C19228800ACBDCA /* Operators.swift */, 212 | D8DCA8AE1C0D416F00F8755C /* Protocols.swift */, 213 | ); 214 | name = Core; 215 | sourceTree = ""; 216 | }; 217 | D85B80CE1C28177B00A5EAC8 /* Terms */ = { 218 | isa = PBXGroup; 219 | children = ( 220 | D8AE26581C153E8D003C3F78 /* AnyKey.swift */, 221 | D81BFB7F1C23CBCF00C2F3CE /* Block.swift */, 222 | D85D6E431C19262200ACBDCA /* Boolean.swift */, 223 | D8AE264A1C1538F2003C3F78 /* Const.swift */, 224 | D8AE26561C15398B003C3F78 /* Key.swift */, 225 | D81BFB811C23DAE300C2F3CE /* This.swift */, 226 | D8AE264C1C1538FE003C3F78 /* Var.swift */, 227 | ); 228 | name = Terms; 229 | sourceTree = ""; 230 | }; 231 | D87E77511C16A823006727A4 /* Expressions */ = { 232 | isa = PBXGroup; 233 | children = ( 234 | D8BE93ED1C22688B00B3AC6D /* BinaryIndexExpression.swift */, 235 | D8BE93EB1C22687E00B3AC6D /* BinaryIntegerExpression.swift */, 236 | D81BFB861C2524EC00C2F3CE /* BinaryLocationtoNumberExpression.swift */, 237 | D8BE93E91C22686D00B3AC6D /* BinaryNumberExpression.swift */, 238 | D85D6E471C195C5800ACBDCA /* DifferenceExpression.swift */, 239 | D8DCA8AC1C0D303E00F8755C /* Expression.swift */, 240 | D85D6E451C195C4800ACBDCA /* IntersectExpression.swift */, 241 | D81BFB7D1C22C10C00C2F3CE /* NullaryDateExpression.swift */, 242 | D8AE264E1C153912003C3F78 /* NullaryIntegerExpression.swift */, 243 | D8E173481C1BC58400B2EA6A /* SubqueryExpression.swift */, 244 | D8BE93F51C226C3B00B3AC6D /* UnaryIntegerExpression.swift */, 245 | D8BE93F11C226C0200B3AC6D /* UnaryNumberExpression.swift */, 246 | D8BE93F31C226C1C00B3AC6D /* UnarySequenceToNumberExpression.swift */, 247 | D8BE93F91C226E9C00B3AC6D /* UnaryStringExpression.swift */, 248 | D8BE93F71C226C5C00B3AC6D /* UnaryStringToIntegerExpression.swift */, 249 | D8AE26541C153937003C3F78 /* UnionExpression.swift */, 250 | ); 251 | name = Expressions; 252 | sourceTree = ""; 253 | }; 254 | D87E77521C16A852006727A4 /* Predicates */ = { 255 | isa = PBXGroup; 256 | children = ( 257 | D87E774F1C16A817006727A4 /* AndPredicate.swift */, 258 | D87E77471C16904C006727A4 /* ComparisonPredicate.swift */, 259 | D81BFB571C22789B00C2F3CE /* NotPredicate.swift */, 260 | D81BFB551C22789200C2F3CE /* OrPredicate.swift */, 261 | D8DCA8AA1C0D2FF400F8755C /* Predicate.swift */, 262 | D87E774B1C16A506006727A4 /* QuantifiedPredicate.swift */, 263 | ); 264 | name = Predicates; 265 | sourceTree = ""; 266 | }; 267 | D8DCA8861C0D2FB100F8755C = { 268 | isa = PBXGroup; 269 | children = ( 270 | D8DCA8921C0D2FB100F8755C /* PredicatePal */, 271 | D8DCA89E1C0D2FB100F8755C /* PredicatePalTests */, 272 | D8DCA8911C0D2FB100F8755C /* Products */, 273 | ); 274 | sourceTree = ""; 275 | }; 276 | D8DCA8911C0D2FB100F8755C /* Products */ = { 277 | isa = PBXGroup; 278 | children = ( 279 | D8DCA8901C0D2FB100F8755C /* PredicatePal.framework */, 280 | D8DCA89A1C0D2FB100F8755C /* PredicatePalTests.xctest */, 281 | D85B809F1C279B9500A5EAC8 /* PredicatePal.framework */, 282 | D85B80CA1C279BA400A5EAC8 /* PredicatePal.framework */, 283 | ); 284 | name = Products; 285 | sourceTree = ""; 286 | }; 287 | D8DCA8921C0D2FB100F8755C /* PredicatePal */ = { 288 | isa = PBXGroup; 289 | children = ( 290 | D85B80CD1C28119C00A5EAC8 /* Core */, 291 | D87E77511C16A823006727A4 /* Expressions */, 292 | D87E77521C16A852006727A4 /* Predicates */, 293 | D85B80CE1C28177B00A5EAC8 /* Terms */, 294 | D85B80CC1C28117300A5EAC8 /* Supporting Files */, 295 | ); 296 | path = PredicatePal; 297 | sourceTree = ""; 298 | }; 299 | D8DCA89E1C0D2FB100F8755C /* PredicatePalTests */ = { 300 | isa = PBXGroup; 301 | children = ( 302 | D8DCA8A11C0D2FB100F8755C /* Info.plist */, 303 | D8B40F5E1C1183540033C06E /* ExpressionTests.swift */, 304 | D87E774D1C16A692006727A4 /* PredicateTests.swift */, 305 | D85B80CF1C2817BC00A5EAC8 /* TermTests.swift */, 306 | ); 307 | path = PredicatePalTests; 308 | sourceTree = ""; 309 | }; 310 | /* End PBXGroup section */ 311 | 312 | /* Begin PBXHeadersBuildPhase section */ 313 | D85B80991C279B9500A5EAC8 /* Headers */ = { 314 | isa = PBXHeadersBuildPhase; 315 | buildActionMask = 2147483647; 316 | files = ( 317 | D85B809A1C279B9500A5EAC8 /* PredicatePal.h in Headers */, 318 | ); 319 | runOnlyForDeploymentPostprocessing = 0; 320 | }; 321 | D85B80C41C279BA400A5EAC8 /* Headers */ = { 322 | isa = PBXHeadersBuildPhase; 323 | buildActionMask = 2147483647; 324 | files = ( 325 | D85B80C51C279BA400A5EAC8 /* PredicatePal.h in Headers */, 326 | ); 327 | runOnlyForDeploymentPostprocessing = 0; 328 | }; 329 | D8DCA88D1C0D2FB100F8755C /* Headers */ = { 330 | isa = PBXHeadersBuildPhase; 331 | buildActionMask = 2147483647; 332 | files = ( 333 | D8DCA8941C0D2FB100F8755C /* PredicatePal.h in Headers */, 334 | ); 335 | runOnlyForDeploymentPostprocessing = 0; 336 | }; 337 | /* End PBXHeadersBuildPhase section */ 338 | 339 | /* Begin PBXNativeTarget section */ 340 | D85B80761C279B9500A5EAC8 /* PredicatePal (iOS) */ = { 341 | isa = PBXNativeTarget; 342 | buildConfigurationList = D85B809C1C279B9500A5EAC8 /* Build configuration list for PBXNativeTarget "PredicatePal (iOS)" */; 343 | buildPhases = ( 344 | D85B80771C279B9500A5EAC8 /* Sources */, 345 | D85B80981C279B9500A5EAC8 /* Frameworks */, 346 | D85B80991C279B9500A5EAC8 /* Headers */, 347 | D85B809B1C279B9500A5EAC8 /* Resources */, 348 | ); 349 | buildRules = ( 350 | ); 351 | dependencies = ( 352 | ); 353 | name = "PredicatePal (iOS)"; 354 | productName = PredicatePal; 355 | productReference = D85B809F1C279B9500A5EAC8 /* PredicatePal.framework */; 356 | productType = "com.apple.product-type.framework"; 357 | }; 358 | D85B80A11C279BA400A5EAC8 /* PredicatePal (tvOS) */ = { 359 | isa = PBXNativeTarget; 360 | buildConfigurationList = D85B80C71C279BA400A5EAC8 /* Build configuration list for PBXNativeTarget "PredicatePal (tvOS)" */; 361 | buildPhases = ( 362 | D85B80A21C279BA400A5EAC8 /* Sources */, 363 | D85B80C31C279BA400A5EAC8 /* Frameworks */, 364 | D85B80C41C279BA400A5EAC8 /* Headers */, 365 | D85B80C61C279BA400A5EAC8 /* Resources */, 366 | ); 367 | buildRules = ( 368 | ); 369 | dependencies = ( 370 | ); 371 | name = "PredicatePal (tvOS)"; 372 | productName = PredicatePal; 373 | productReference = D85B80CA1C279BA400A5EAC8 /* PredicatePal.framework */; 374 | productType = "com.apple.product-type.framework"; 375 | }; 376 | D8DCA88F1C0D2FB100F8755C /* PredicatePal (OS X) */ = { 377 | isa = PBXNativeTarget; 378 | buildConfigurationList = D8DCA8A41C0D2FB100F8755C /* Build configuration list for PBXNativeTarget "PredicatePal (OS X)" */; 379 | buildPhases = ( 380 | D8DCA88B1C0D2FB100F8755C /* Sources */, 381 | D8DCA88C1C0D2FB100F8755C /* Frameworks */, 382 | D8DCA88D1C0D2FB100F8755C /* Headers */, 383 | D8DCA88E1C0D2FB100F8755C /* Resources */, 384 | ); 385 | buildRules = ( 386 | ); 387 | dependencies = ( 388 | ); 389 | name = "PredicatePal (OS X)"; 390 | productName = PredicatePal; 391 | productReference = D8DCA8901C0D2FB100F8755C /* PredicatePal.framework */; 392 | productType = "com.apple.product-type.framework"; 393 | }; 394 | D8DCA8991C0D2FB100F8755C /* PredicatePalTests */ = { 395 | isa = PBXNativeTarget; 396 | buildConfigurationList = D8DCA8A71C0D2FB100F8755C /* Build configuration list for PBXNativeTarget "PredicatePalTests" */; 397 | buildPhases = ( 398 | D8DCA8961C0D2FB100F8755C /* Sources */, 399 | D8DCA8971C0D2FB100F8755C /* Frameworks */, 400 | D8DCA8981C0D2FB100F8755C /* Resources */, 401 | ); 402 | buildRules = ( 403 | ); 404 | dependencies = ( 405 | D8DCA89D1C0D2FB100F8755C /* PBXTargetDependency */, 406 | ); 407 | name = PredicatePalTests; 408 | productName = PredicatePalTests; 409 | productReference = D8DCA89A1C0D2FB100F8755C /* PredicatePalTests.xctest */; 410 | productType = "com.apple.product-type.bundle.unit-test"; 411 | }; 412 | /* End PBXNativeTarget section */ 413 | 414 | /* Begin PBXProject section */ 415 | D8DCA8871C0D2FB100F8755C /* Project object */ = { 416 | isa = PBXProject; 417 | attributes = { 418 | LastSwiftUpdateCheck = 0710; 419 | LastUpgradeCheck = 0710; 420 | ORGANIZATIONNAME = "Glen Low"; 421 | TargetAttributes = { 422 | D8DCA88F1C0D2FB100F8755C = { 423 | CreatedOnToolsVersion = 7.1.1; 424 | }; 425 | D8DCA8991C0D2FB100F8755C = { 426 | CreatedOnToolsVersion = 7.1.1; 427 | }; 428 | }; 429 | }; 430 | buildConfigurationList = D8DCA88A1C0D2FB100F8755C /* Build configuration list for PBXProject "PredicatePal" */; 431 | compatibilityVersion = "Xcode 3.2"; 432 | developmentRegion = English; 433 | hasScannedForEncodings = 0; 434 | knownRegions = ( 435 | en, 436 | ); 437 | mainGroup = D8DCA8861C0D2FB100F8755C; 438 | productRefGroup = D8DCA8911C0D2FB100F8755C /* Products */; 439 | projectDirPath = ""; 440 | projectRoot = ""; 441 | targets = ( 442 | D85B80761C279B9500A5EAC8 /* PredicatePal (iOS) */, 443 | D8DCA88F1C0D2FB100F8755C /* PredicatePal (OS X) */, 444 | D85B80A11C279BA400A5EAC8 /* PredicatePal (tvOS) */, 445 | D8DCA8991C0D2FB100F8755C /* PredicatePalTests */, 446 | ); 447 | }; 448 | /* End PBXProject section */ 449 | 450 | /* Begin PBXResourcesBuildPhase section */ 451 | D85B809B1C279B9500A5EAC8 /* Resources */ = { 452 | isa = PBXResourcesBuildPhase; 453 | buildActionMask = 2147483647; 454 | files = ( 455 | ); 456 | runOnlyForDeploymentPostprocessing = 0; 457 | }; 458 | D85B80C61C279BA400A5EAC8 /* Resources */ = { 459 | isa = PBXResourcesBuildPhase; 460 | buildActionMask = 2147483647; 461 | files = ( 462 | ); 463 | runOnlyForDeploymentPostprocessing = 0; 464 | }; 465 | D8DCA88E1C0D2FB100F8755C /* Resources */ = { 466 | isa = PBXResourcesBuildPhase; 467 | buildActionMask = 2147483647; 468 | files = ( 469 | ); 470 | runOnlyForDeploymentPostprocessing = 0; 471 | }; 472 | D8DCA8981C0D2FB100F8755C /* Resources */ = { 473 | isa = PBXResourcesBuildPhase; 474 | buildActionMask = 2147483647; 475 | files = ( 476 | ); 477 | runOnlyForDeploymentPostprocessing = 0; 478 | }; 479 | /* End PBXResourcesBuildPhase section */ 480 | 481 | /* Begin PBXSourcesBuildPhase section */ 482 | D85B80771C279B9500A5EAC8 /* Sources */ = { 483 | isa = PBXSourcesBuildPhase; 484 | buildActionMask = 2147483647; 485 | files = ( 486 | D85B80781C279B9500A5EAC8 /* UnaryStringExpression.swift in Sources */, 487 | D85B80791C279B9500A5EAC8 /* Predicate.swift in Sources */, 488 | D85B807A1C279B9500A5EAC8 /* NullaryIntegerExpression.swift in Sources */, 489 | D85B807B1C279B9500A5EAC8 /* BinaryIntegerExpression.swift in Sources */, 490 | D85B807C1C279B9500A5EAC8 /* This.swift in Sources */, 491 | D85B807D1C279B9500A5EAC8 /* AnyKey.swift in Sources */, 492 | D85B807E1C279B9500A5EAC8 /* QuantifiedPredicate.swift in Sources */, 493 | D85B807F1C279B9500A5EAC8 /* Protocols.swift in Sources */, 494 | D85B80801C279B9500A5EAC8 /* SubqueryExpression.swift in Sources */, 495 | D85B80811C279B9500A5EAC8 /* AndPredicate.swift in Sources */, 496 | D85B80821C279B9500A5EAC8 /* BinaryNumberExpression.swift in Sources */, 497 | D85B80831C279B9500A5EAC8 /* Var.swift in Sources */, 498 | D85B80841C279B9500A5EAC8 /* NotPredicate.swift in Sources */, 499 | D85B80851C279B9500A5EAC8 /* UnaryIntegerExpression.swift in Sources */, 500 | D85B80861C279B9500A5EAC8 /* Key.swift in Sources */, 501 | D85B80871C279B9500A5EAC8 /* ComparisonPredicate.swift in Sources */, 502 | D85B80881C279B9500A5EAC8 /* Boolean.swift in Sources */, 503 | D85B80891C279B9500A5EAC8 /* UnaryStringToIntegerExpression.swift in Sources */, 504 | D85B808A1C279B9500A5EAC8 /* UnaryNumberExpression.swift in Sources */, 505 | D85B808B1C279B9500A5EAC8 /* Expression.swift in Sources */, 506 | D85B808C1C279B9500A5EAC8 /* NullaryDateExpression.swift in Sources */, 507 | D85B808D1C279B9500A5EAC8 /* DifferenceExpression.swift in Sources */, 508 | D85B808F1C279B9500A5EAC8 /* Operators.swift in Sources */, 509 | D85B80901C279B9500A5EAC8 /* UnarySequenceToNumberExpression.swift in Sources */, 510 | D85B80911C279B9500A5EAC8 /* OrPredicate.swift in Sources */, 511 | D85B80921C279B9500A5EAC8 /* BinaryIndexExpression.swift in Sources */, 512 | D85B80931C279B9500A5EAC8 /* BinaryLocationtoNumberExpression.swift in Sources */, 513 | D85B80941C279B9500A5EAC8 /* IntersectExpression.swift in Sources */, 514 | D85B80951C279B9500A5EAC8 /* Block.swift in Sources */, 515 | D85B80961C279B9500A5EAC8 /* UnionExpression.swift in Sources */, 516 | D85B80971C279B9500A5EAC8 /* Const.swift in Sources */, 517 | ); 518 | runOnlyForDeploymentPostprocessing = 0; 519 | }; 520 | D85B80A21C279BA400A5EAC8 /* Sources */ = { 521 | isa = PBXSourcesBuildPhase; 522 | buildActionMask = 2147483647; 523 | files = ( 524 | D85B80A31C279BA400A5EAC8 /* UnaryStringExpression.swift in Sources */, 525 | D85B80A41C279BA400A5EAC8 /* Predicate.swift in Sources */, 526 | D85B80A51C279BA400A5EAC8 /* NullaryIntegerExpression.swift in Sources */, 527 | D85B80A61C279BA400A5EAC8 /* BinaryIntegerExpression.swift in Sources */, 528 | D85B80A71C279BA400A5EAC8 /* This.swift in Sources */, 529 | D85B80A81C279BA400A5EAC8 /* AnyKey.swift in Sources */, 530 | D85B80A91C279BA400A5EAC8 /* QuantifiedPredicate.swift in Sources */, 531 | D85B80AA1C279BA400A5EAC8 /* Protocols.swift in Sources */, 532 | D85B80AB1C279BA400A5EAC8 /* SubqueryExpression.swift in Sources */, 533 | D85B80AC1C279BA400A5EAC8 /* AndPredicate.swift in Sources */, 534 | D85B80AD1C279BA400A5EAC8 /* BinaryNumberExpression.swift in Sources */, 535 | D85B80AE1C279BA400A5EAC8 /* Var.swift in Sources */, 536 | D85B80AF1C279BA400A5EAC8 /* NotPredicate.swift in Sources */, 537 | D85B80B01C279BA400A5EAC8 /* UnaryIntegerExpression.swift in Sources */, 538 | D85B80B11C279BA400A5EAC8 /* Key.swift in Sources */, 539 | D85B80B21C279BA400A5EAC8 /* ComparisonPredicate.swift in Sources */, 540 | D85B80B31C279BA400A5EAC8 /* Boolean.swift in Sources */, 541 | D85B80B41C279BA400A5EAC8 /* UnaryStringToIntegerExpression.swift in Sources */, 542 | D85B80B51C279BA400A5EAC8 /* UnaryNumberExpression.swift in Sources */, 543 | D85B80B61C279BA400A5EAC8 /* Expression.swift in Sources */, 544 | D85B80B71C279BA400A5EAC8 /* NullaryDateExpression.swift in Sources */, 545 | D85B80B81C279BA400A5EAC8 /* DifferenceExpression.swift in Sources */, 546 | D85B80BA1C279BA400A5EAC8 /* Operators.swift in Sources */, 547 | D85B80BB1C279BA400A5EAC8 /* UnarySequenceToNumberExpression.swift in Sources */, 548 | D85B80BC1C279BA400A5EAC8 /* OrPredicate.swift in Sources */, 549 | D85B80BD1C279BA400A5EAC8 /* BinaryIndexExpression.swift in Sources */, 550 | D85B80BE1C279BA400A5EAC8 /* BinaryLocationtoNumberExpression.swift in Sources */, 551 | D85B80BF1C279BA400A5EAC8 /* IntersectExpression.swift in Sources */, 552 | D85B80C01C279BA400A5EAC8 /* Block.swift in Sources */, 553 | D85B80C11C279BA400A5EAC8 /* UnionExpression.swift in Sources */, 554 | D85B80C21C279BA400A5EAC8 /* Const.swift in Sources */, 555 | ); 556 | runOnlyForDeploymentPostprocessing = 0; 557 | }; 558 | D8DCA88B1C0D2FB100F8755C /* Sources */ = { 559 | isa = PBXSourcesBuildPhase; 560 | buildActionMask = 2147483647; 561 | files = ( 562 | D8BE93FA1C226E9C00B3AC6D /* UnaryStringExpression.swift in Sources */, 563 | D8DCA8AB1C0D2FF500F8755C /* Predicate.swift in Sources */, 564 | D8AE264F1C153912003C3F78 /* NullaryIntegerExpression.swift in Sources */, 565 | D8BE93EC1C22687E00B3AC6D /* BinaryIntegerExpression.swift in Sources */, 566 | D81BFB821C23DAE300C2F3CE /* This.swift in Sources */, 567 | D8AE26591C153E8D003C3F78 /* AnyKey.swift in Sources */, 568 | D87E774C1C16A506006727A4 /* QuantifiedPredicate.swift in Sources */, 569 | D8DCA8AF1C0D416F00F8755C /* Protocols.swift in Sources */, 570 | D8E173491C1BC58400B2EA6A /* SubqueryExpression.swift in Sources */, 571 | D87E77501C16A817006727A4 /* AndPredicate.swift in Sources */, 572 | D8BE93EA1C22686D00B3AC6D /* BinaryNumberExpression.swift in Sources */, 573 | D8AE264D1C1538FE003C3F78 /* Var.swift in Sources */, 574 | D81BFB581C22789B00C2F3CE /* NotPredicate.swift in Sources */, 575 | D8BE93F61C226C3B00B3AC6D /* UnaryIntegerExpression.swift in Sources */, 576 | D8AE26571C15398B003C3F78 /* Key.swift in Sources */, 577 | D87E77481C16904C006727A4 /* ComparisonPredicate.swift in Sources */, 578 | D85D6E441C19262200ACBDCA /* Boolean.swift in Sources */, 579 | D8BE93F81C226C5C00B3AC6D /* UnaryStringToIntegerExpression.swift in Sources */, 580 | D8BE93F21C226C0200B3AC6D /* UnaryNumberExpression.swift in Sources */, 581 | D8DCA8AD1C0D303E00F8755C /* Expression.swift in Sources */, 582 | D81BFB7E1C22C10C00C2F3CE /* NullaryDateExpression.swift in Sources */, 583 | D85D6E481C195C5800ACBDCA /* DifferenceExpression.swift in Sources */, 584 | D85D6E421C19228800ACBDCA /* Operators.swift in Sources */, 585 | D8BE93F41C226C1C00B3AC6D /* UnarySequenceToNumberExpression.swift in Sources */, 586 | D81BFB561C22789200C2F3CE /* OrPredicate.swift in Sources */, 587 | D8BE93EE1C22688B00B3AC6D /* BinaryIndexExpression.swift in Sources */, 588 | D81BFB871C2524EC00C2F3CE /* BinaryLocationtoNumberExpression.swift in Sources */, 589 | D85D6E461C195C4800ACBDCA /* IntersectExpression.swift in Sources */, 590 | D81BFB801C23CBCF00C2F3CE /* Block.swift in Sources */, 591 | D8AE26551C153937003C3F78 /* UnionExpression.swift in Sources */, 592 | D8AE264B1C1538F2003C3F78 /* Const.swift in Sources */, 593 | ); 594 | runOnlyForDeploymentPostprocessing = 0; 595 | }; 596 | D8DCA8961C0D2FB100F8755C /* Sources */ = { 597 | isa = PBXSourcesBuildPhase; 598 | buildActionMask = 2147483647; 599 | files = ( 600 | D8B40F5F1C1183540033C06E /* ExpressionTests.swift in Sources */, 601 | D87E774E1C16A692006727A4 /* PredicateTests.swift in Sources */, 602 | D85B80D01C2817BC00A5EAC8 /* TermTests.swift in Sources */, 603 | ); 604 | runOnlyForDeploymentPostprocessing = 0; 605 | }; 606 | /* End PBXSourcesBuildPhase section */ 607 | 608 | /* Begin PBXTargetDependency section */ 609 | D8DCA89D1C0D2FB100F8755C /* PBXTargetDependency */ = { 610 | isa = PBXTargetDependency; 611 | target = D8DCA88F1C0D2FB100F8755C /* PredicatePal (OS X) */; 612 | targetProxy = D8DCA89C1C0D2FB100F8755C /* PBXContainerItemProxy */; 613 | }; 614 | /* End PBXTargetDependency section */ 615 | 616 | /* Begin XCBuildConfiguration section */ 617 | D85B809D1C279B9500A5EAC8 /* Debug */ = { 618 | isa = XCBuildConfiguration; 619 | buildSettings = { 620 | CLANG_ENABLE_MODULES = YES; 621 | COMBINE_HIDPI_IMAGES = YES; 622 | DEFINES_MODULE = YES; 623 | DYLIB_COMPATIBILITY_VERSION = 1; 624 | DYLIB_CURRENT_VERSION = 1; 625 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 626 | FRAMEWORK_VERSION = A; 627 | INFOPLIST_FILE = PredicatePal/Info.plist; 628 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 629 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 630 | PRODUCT_BUNDLE_IDENTIFIER = com.pixelglow.PredicatePal; 631 | PRODUCT_NAME = PredicatePal; 632 | SDKROOT = iphoneos; 633 | SKIP_INSTALL = YES; 634 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 635 | }; 636 | name = Debug; 637 | }; 638 | D85B809E1C279B9500A5EAC8 /* Release */ = { 639 | isa = XCBuildConfiguration; 640 | buildSettings = { 641 | CLANG_ENABLE_MODULES = YES; 642 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 643 | COMBINE_HIDPI_IMAGES = YES; 644 | DEFINES_MODULE = YES; 645 | DYLIB_COMPATIBILITY_VERSION = 1; 646 | DYLIB_CURRENT_VERSION = 1; 647 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 648 | FRAMEWORK_VERSION = A; 649 | INFOPLIST_FILE = PredicatePal/Info.plist; 650 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 651 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 652 | PRODUCT_BUNDLE_IDENTIFIER = com.pixelglow.PredicatePal; 653 | PRODUCT_NAME = PredicatePal; 654 | SDKROOT = iphoneos; 655 | SKIP_INSTALL = YES; 656 | }; 657 | name = Release; 658 | }; 659 | D85B80C81C279BA400A5EAC8 /* Debug */ = { 660 | isa = XCBuildConfiguration; 661 | buildSettings = { 662 | CLANG_ENABLE_MODULES = YES; 663 | COMBINE_HIDPI_IMAGES = YES; 664 | DEFINES_MODULE = YES; 665 | DYLIB_COMPATIBILITY_VERSION = 1; 666 | DYLIB_CURRENT_VERSION = 1; 667 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 668 | FRAMEWORK_VERSION = A; 669 | INFOPLIST_FILE = PredicatePal/Info.plist; 670 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 671 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 672 | PRODUCT_BUNDLE_IDENTIFIER = com.pixelglow.PredicatePal; 673 | PRODUCT_NAME = PredicatePal; 674 | SDKROOT = appletvos; 675 | SKIP_INSTALL = YES; 676 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 677 | }; 678 | name = Debug; 679 | }; 680 | D85B80C91C279BA400A5EAC8 /* Release */ = { 681 | isa = XCBuildConfiguration; 682 | buildSettings = { 683 | CLANG_ENABLE_MODULES = YES; 684 | "CODE_SIGN_IDENTITY[sdk=appletvos*]" = "iPhone Developer"; 685 | COMBINE_HIDPI_IMAGES = YES; 686 | DEFINES_MODULE = YES; 687 | DYLIB_COMPATIBILITY_VERSION = 1; 688 | DYLIB_CURRENT_VERSION = 1; 689 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 690 | FRAMEWORK_VERSION = A; 691 | INFOPLIST_FILE = PredicatePal/Info.plist; 692 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 693 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 694 | PRODUCT_BUNDLE_IDENTIFIER = com.pixelglow.PredicatePal; 695 | PRODUCT_NAME = PredicatePal; 696 | SDKROOT = appletvos; 697 | SKIP_INSTALL = YES; 698 | }; 699 | name = Release; 700 | }; 701 | D8DCA8A21C0D2FB100F8755C /* Debug */ = { 702 | isa = XCBuildConfiguration; 703 | buildSettings = { 704 | ALWAYS_SEARCH_USER_PATHS = NO; 705 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 706 | CLANG_CXX_LIBRARY = "libc++"; 707 | CLANG_ENABLE_MODULES = YES; 708 | CLANG_ENABLE_OBJC_ARC = YES; 709 | CLANG_WARN_BOOL_CONVERSION = YES; 710 | CLANG_WARN_CONSTANT_CONVERSION = YES; 711 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 712 | CLANG_WARN_EMPTY_BODY = YES; 713 | CLANG_WARN_ENUM_CONVERSION = YES; 714 | CLANG_WARN_INT_CONVERSION = YES; 715 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 716 | CLANG_WARN_UNREACHABLE_CODE = YES; 717 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 718 | COPY_PHASE_STRIP = NO; 719 | CURRENT_PROJECT_VERSION = 1; 720 | DEBUG_INFORMATION_FORMAT = dwarf; 721 | ENABLE_STRICT_OBJC_MSGSEND = YES; 722 | ENABLE_TESTABILITY = YES; 723 | GCC_C_LANGUAGE_STANDARD = gnu99; 724 | GCC_DYNAMIC_NO_PIC = NO; 725 | GCC_NO_COMMON_BLOCKS = YES; 726 | GCC_OPTIMIZATION_LEVEL = 0; 727 | GCC_PREPROCESSOR_DEFINITIONS = ( 728 | "DEBUG=1", 729 | "$(inherited)", 730 | ); 731 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 732 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 733 | GCC_WARN_UNDECLARED_SELECTOR = YES; 734 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 735 | GCC_WARN_UNUSED_FUNCTION = YES; 736 | GCC_WARN_UNUSED_VARIABLE = YES; 737 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 738 | MACOSX_DEPLOYMENT_TARGET = 10.10; 739 | MTL_ENABLE_DEBUG_INFO = YES; 740 | ONLY_ACTIVE_ARCH = YES; 741 | SDKROOT = macosx; 742 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 743 | TARGETED_DEVICE_FAMILY = "1,2"; 744 | TVOS_DEPLOYMENT_TARGET = 9.0; 745 | VERSIONING_SYSTEM = "apple-generic"; 746 | VERSION_INFO_PREFIX = ""; 747 | }; 748 | name = Debug; 749 | }; 750 | D8DCA8A31C0D2FB100F8755C /* Release */ = { 751 | isa = XCBuildConfiguration; 752 | buildSettings = { 753 | ALWAYS_SEARCH_USER_PATHS = NO; 754 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 755 | CLANG_CXX_LIBRARY = "libc++"; 756 | CLANG_ENABLE_MODULES = YES; 757 | CLANG_ENABLE_OBJC_ARC = YES; 758 | CLANG_WARN_BOOL_CONVERSION = YES; 759 | CLANG_WARN_CONSTANT_CONVERSION = YES; 760 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 761 | CLANG_WARN_EMPTY_BODY = YES; 762 | CLANG_WARN_ENUM_CONVERSION = YES; 763 | CLANG_WARN_INT_CONVERSION = YES; 764 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 765 | CLANG_WARN_UNREACHABLE_CODE = YES; 766 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 767 | COPY_PHASE_STRIP = NO; 768 | CURRENT_PROJECT_VERSION = 1; 769 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 770 | ENABLE_NS_ASSERTIONS = NO; 771 | ENABLE_STRICT_OBJC_MSGSEND = YES; 772 | GCC_C_LANGUAGE_STANDARD = gnu99; 773 | GCC_NO_COMMON_BLOCKS = YES; 774 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 775 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 776 | GCC_WARN_UNDECLARED_SELECTOR = YES; 777 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 778 | GCC_WARN_UNUSED_FUNCTION = YES; 779 | GCC_WARN_UNUSED_VARIABLE = YES; 780 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 781 | MACOSX_DEPLOYMENT_TARGET = 10.10; 782 | MTL_ENABLE_DEBUG_INFO = NO; 783 | SDKROOT = macosx; 784 | TARGETED_DEVICE_FAMILY = "1,2"; 785 | TVOS_DEPLOYMENT_TARGET = 9.0; 786 | VERSIONING_SYSTEM = "apple-generic"; 787 | VERSION_INFO_PREFIX = ""; 788 | }; 789 | name = Release; 790 | }; 791 | D8DCA8A51C0D2FB100F8755C /* Debug */ = { 792 | isa = XCBuildConfiguration; 793 | buildSettings = { 794 | CLANG_ENABLE_MODULES = YES; 795 | COMBINE_HIDPI_IMAGES = YES; 796 | DEFINES_MODULE = YES; 797 | DYLIB_COMPATIBILITY_VERSION = 1; 798 | DYLIB_CURRENT_VERSION = 1; 799 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 800 | FRAMEWORK_VERSION = A; 801 | INFOPLIST_FILE = PredicatePal/Info.plist; 802 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 803 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 804 | PRODUCT_BUNDLE_IDENTIFIER = com.pixelglow.PredicatePal; 805 | PRODUCT_NAME = PredicatePal; 806 | SKIP_INSTALL = YES; 807 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 808 | }; 809 | name = Debug; 810 | }; 811 | D8DCA8A61C0D2FB100F8755C /* Release */ = { 812 | isa = XCBuildConfiguration; 813 | buildSettings = { 814 | CLANG_ENABLE_MODULES = YES; 815 | "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer"; 816 | COMBINE_HIDPI_IMAGES = YES; 817 | DEFINES_MODULE = YES; 818 | DYLIB_COMPATIBILITY_VERSION = 1; 819 | DYLIB_CURRENT_VERSION = 1; 820 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 821 | FRAMEWORK_VERSION = A; 822 | INFOPLIST_FILE = PredicatePal/Info.plist; 823 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 824 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 825 | PRODUCT_BUNDLE_IDENTIFIER = com.pixelglow.PredicatePal; 826 | PRODUCT_NAME = PredicatePal; 827 | SKIP_INSTALL = YES; 828 | }; 829 | name = Release; 830 | }; 831 | D8DCA8A81C0D2FB100F8755C /* Debug */ = { 832 | isa = XCBuildConfiguration; 833 | buildSettings = { 834 | COMBINE_HIDPI_IMAGES = YES; 835 | INFOPLIST_FILE = PredicatePalTests/Info.plist; 836 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 837 | PRODUCT_BUNDLE_IDENTIFIER = com.pixelglow.PredicatePalTests; 838 | PRODUCT_NAME = "$(TARGET_NAME)"; 839 | }; 840 | name = Debug; 841 | }; 842 | D8DCA8A91C0D2FB100F8755C /* Release */ = { 843 | isa = XCBuildConfiguration; 844 | buildSettings = { 845 | COMBINE_HIDPI_IMAGES = YES; 846 | INFOPLIST_FILE = PredicatePalTests/Info.plist; 847 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 848 | PRODUCT_BUNDLE_IDENTIFIER = com.pixelglow.PredicatePalTests; 849 | PRODUCT_NAME = "$(TARGET_NAME)"; 850 | }; 851 | name = Release; 852 | }; 853 | /* End XCBuildConfiguration section */ 854 | 855 | /* Begin XCConfigurationList section */ 856 | D85B809C1C279B9500A5EAC8 /* Build configuration list for PBXNativeTarget "PredicatePal (iOS)" */ = { 857 | isa = XCConfigurationList; 858 | buildConfigurations = ( 859 | D85B809D1C279B9500A5EAC8 /* Debug */, 860 | D85B809E1C279B9500A5EAC8 /* Release */, 861 | ); 862 | defaultConfigurationIsVisible = 0; 863 | defaultConfigurationName = Release; 864 | }; 865 | D85B80C71C279BA400A5EAC8 /* Build configuration list for PBXNativeTarget "PredicatePal (tvOS)" */ = { 866 | isa = XCConfigurationList; 867 | buildConfigurations = ( 868 | D85B80C81C279BA400A5EAC8 /* Debug */, 869 | D85B80C91C279BA400A5EAC8 /* Release */, 870 | ); 871 | defaultConfigurationIsVisible = 0; 872 | defaultConfigurationName = Release; 873 | }; 874 | D8DCA88A1C0D2FB100F8755C /* Build configuration list for PBXProject "PredicatePal" */ = { 875 | isa = XCConfigurationList; 876 | buildConfigurations = ( 877 | D8DCA8A21C0D2FB100F8755C /* Debug */, 878 | D8DCA8A31C0D2FB100F8755C /* Release */, 879 | ); 880 | defaultConfigurationIsVisible = 0; 881 | defaultConfigurationName = Release; 882 | }; 883 | D8DCA8A41C0D2FB100F8755C /* Build configuration list for PBXNativeTarget "PredicatePal (OS X)" */ = { 884 | isa = XCConfigurationList; 885 | buildConfigurations = ( 886 | D8DCA8A51C0D2FB100F8755C /* Debug */, 887 | D8DCA8A61C0D2FB100F8755C /* Release */, 888 | ); 889 | defaultConfigurationIsVisible = 0; 890 | defaultConfigurationName = Release; 891 | }; 892 | D8DCA8A71C0D2FB100F8755C /* Build configuration list for PBXNativeTarget "PredicatePalTests" */ = { 893 | isa = XCConfigurationList; 894 | buildConfigurations = ( 895 | D8DCA8A81C0D2FB100F8755C /* Debug */, 896 | D8DCA8A91C0D2FB100F8755C /* Release */, 897 | ); 898 | defaultConfigurationIsVisible = 0; 899 | defaultConfigurationName = Release; 900 | }; 901 | /* End XCConfigurationList section */ 902 | }; 903 | rootObject = D8DCA8871C0D2FB100F8755C /* Project object */; 904 | } 905 | -------------------------------------------------------------------------------- /PredicatePal.xcodeproj/xcshareddata/xcschemes/PredicatePal (OS X).xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 65 | 71 | 72 | 73 | 74 | 75 | 76 | 82 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /PredicatePal.xcodeproj/xcshareddata/xcschemes/PredicatePal (iOS).xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /PredicatePal.xcodeproj/xcshareddata/xcschemes/PredicatePal (tvOS).xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /PredicatePal/AndPredicate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AndPredicate.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 8/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// AND predicate composing two subpredicates. 12 | /// - parameter P1: Full type of the LHS subpredicate. 13 | /// - parameter P2: Full type of the RHS subpredicate. 14 | public struct AndPredicate: Predicate { 15 | let leftSub: P1 16 | let rightSub: P2 17 | 18 | public func andSubpredicates() -> [NSPredicate] { 19 | return leftSub.andSubpredicates() + rightSub.andSubpredicates() 20 | } 21 | 22 | public func orSubpredicates() -> [NSPredicate] { 23 | return [*self] 24 | } 25 | } 26 | 27 | /// Build the `NSPredicate`. 28 | public prefix func*(predicate: AndPredicate) -> NSPredicate { 29 | return NSCompoundPredicate(andPredicateWithSubpredicates: predicate.andSubpredicates()) 30 | } 31 | 32 | /// Logical AND of two predicates. 33 | /// - parameter leftSub: The LHS subpredicate. 34 | /// - parameter rightSub: The RHS subpredicate. 35 | /// - returns: The resulting predicate. 36 | public func &&(leftSub: P1, rightSub: P2) -> AndPredicate { 37 | return AndPredicate(leftSub: leftSub, rightSub: rightSub) 38 | } 39 | -------------------------------------------------------------------------------- /PredicatePal/AnyKey.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnyKey.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 7/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Any key term. 12 | /// - parameter T: The type of the key. 13 | public struct AnyKey: Expression { 14 | public typealias ExpressionType = T 15 | 16 | /// Create an any key term. 17 | public init() { } 18 | } 19 | 20 | /// Build the `NSExpression`. 21 | public prefix func*(expression: AnyKey) -> NSExpression { 22 | return NSExpression.expressionForAnyKey() 23 | } 24 | 25 | -------------------------------------------------------------------------------- /PredicatePal/BinaryIndexExpression.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BinaryIndexExpression.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 17/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum BinaryIndexFunction { 12 | case Index 13 | 14 | var tag: String { 15 | switch self { 16 | case .Index: 17 | return "objectFrom:withIndex:" 18 | } 19 | } 20 | } 21 | 22 | /// Value expression composing an indexable subexpression and a key expression. 23 | /// - parameter E1: Full type of the LHS indexable subexpression. 24 | /// - parameter E2: Full type of the RHS key subexpression. 25 | public struct BinaryIndexExpression: Expression { 26 | public typealias ExpressionType = E1.ExpressionType.Value 27 | 28 | let function: BinaryIndexFunction 29 | let leftSub: E1 30 | let rightSub: E2 31 | } 32 | 33 | /// Builds the `NSExpression`. 34 | public prefix func*(expression: BinaryIndexExpression) -> NSExpression { 35 | return NSExpression(forFunction: expression.function.tag, arguments: [*expression.leftSub, *expression.rightSub]) 36 | } 37 | 38 | public extension Expression where ExpressionType: IndexType { 39 | /// Index an expression with a constant. 40 | /// - parameter index: The RHS key constant. 41 | /// - returns: The resulting value expression. 42 | subscript(index: Self.ExpressionType.Key) -> BinaryIndexExpression> { 43 | return BinaryIndexExpression(function: .Index, leftSub: self, rightSub: Const(index)) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /PredicatePal/BinaryIntegerExpression.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BinaryIntegerExpression.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 17/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum BinaryIntegerFunction { 12 | case BitAnd 13 | case BitOr 14 | case BitXor 15 | case LeftShift 16 | case RightShift 17 | 18 | var tag: String { 19 | switch self { 20 | case .BitAnd: 21 | return "bitwiseAnd:with:" 22 | case .BitOr: 23 | return "bitwiseOr:with:" 24 | case .BitXor: 25 | return "bitwiseXor:with:" 26 | case .LeftShift: 27 | return "leftshift:by:" 28 | case .RightShift: 29 | return "rightshift:by:" 30 | } 31 | } 32 | } 33 | 34 | /// Integer expression composing two integer subexpressions. 35 | /// - parameter E1: Full type of the LHS integer subexpression. 36 | /// - parameter E2: Full type of the RHS integer subexpression. 37 | public struct BinaryIntegerExpression: Expression { 38 | public typealias ExpressionType = E1.ExpressionType 39 | 40 | let function: BinaryIntegerFunction 41 | let leftSub: E1 42 | let rightSub: E2 43 | } 44 | 45 | /// Build the `NSExpression`. 46 | public prefix func*(expression: BinaryIntegerExpression) -> NSExpression { 47 | return NSExpression(forFunction: expression.function.tag, arguments: [*expression.leftSub, *expression.rightSub]) 48 | } 49 | 50 | /// Bitwise AND of two expressions. 51 | /// - parameter leftSub: The LHS integer subexpression. 52 | /// - parameter rightSub: The RHS integer subexpression. 53 | /// - returns: The resulting integer expression. 54 | public func &(leftSub: E1, rightSub: E2) -> BinaryIntegerExpression { 55 | return BinaryIntegerExpression(function: .BitAnd, leftSub: leftSub, rightSub: rightSub) 56 | } 57 | 58 | /// Bitwise AND of an expression and a constant. 59 | /// - parameter leftSub: The LHS integer subexpression. 60 | /// - parameter rightConst: The RHS integer constant. 61 | /// - returns: The resulting integer expression. 62 | public func &(leftSub: E1, rightConst: E1.ExpressionType) -> BinaryIntegerExpression> { 63 | return BinaryIntegerExpression(function: .BitAnd, leftSub: leftSub, rightSub: Const(rightConst)) 64 | } 65 | 66 | /// Bitwise AND of a constant and an expression. 67 | /// - parameter leftConst: The LHS integer constant. 68 | /// - parameter rightSub: The RHS integer subexpression. 69 | /// - returns: The resulting integer expression. 70 | public func &(leftConst: E2.ExpressionType, rightSub: E2) -> BinaryIntegerExpression, E2> { 71 | return BinaryIntegerExpression(function: .BitAnd, leftSub: Const(leftConst), rightSub: rightSub) 72 | } 73 | 74 | /// Bitwise OR of two expressions. 75 | /// - parameter leftSub: The LHS integer subexpression. 76 | /// - parameter rightSub: The RHS integer subexpression. 77 | /// - returns: The resulting integer expression. 78 | public func |(leftSub: E1, rightSub: E2) -> BinaryIntegerExpression { 79 | return BinaryIntegerExpression(function: .BitOr, leftSub: leftSub, rightSub: rightSub) 80 | } 81 | 82 | /// Bitwise OR of an expression and a constant. 83 | /// - parameter leftSub: The LHS integer subexpression. 84 | /// - parameter rightConst: The RHS integer constant. 85 | /// - returns: The resulting integer expression. 86 | public func |(leftSub: E1, rightConst: E1.ExpressionType) -> BinaryIntegerExpression> { 87 | return BinaryIntegerExpression(function: .BitOr, leftSub: leftSub, rightSub: Const(rightConst)) 88 | } 89 | 90 | /// Bitwise OR of a constant and an expression. 91 | /// - parameter leftConst: The LHS integer constant. 92 | /// - parameter rightSub: The RHS integer subexpression. 93 | /// - returns: The resulting integer expression. 94 | public func |(leftConst: E2.ExpressionType, rightSub: E2) -> BinaryIntegerExpression, E2> { 95 | return BinaryIntegerExpression(function: .BitOr, leftSub: Const(leftConst), rightSub: rightSub) 96 | } 97 | 98 | /// Bitwise XOR of two expressions. 99 | /// - parameter leftSub: The LHS integer subexpression. 100 | /// - parameter rightSub: The RHS integer subexpression. 101 | /// - returns: The resulting integer expression. 102 | public func ^(leftSub: E1, rightSub: E2) -> BinaryIntegerExpression { 103 | return BinaryIntegerExpression(function: .BitXor, leftSub: leftSub, rightSub: rightSub) 104 | } 105 | 106 | /// Bitwise OR of an expression and a constant. 107 | /// - parameter leftSub: The LHS integer subexpression. 108 | /// - parameter rightConst: The RHS integer constant. 109 | /// - returns: The resulting integer expression. 110 | public func ^(leftSub: E1, rightConst: E1.ExpressionType) -> BinaryIntegerExpression> { 111 | return BinaryIntegerExpression(function: .BitXor, leftSub: leftSub, rightSub: Const(rightConst)) 112 | } 113 | 114 | /// Bitwise XOR of a constant and an expression. 115 | /// - parameter leftConst: The LHS integer constant. 116 | /// - parameter rightSub: The RHS integer subexpression. 117 | /// - returns: The resulting integer expression. 118 | public func ^(leftConst: E2.ExpressionType, rightSub: E2) -> BinaryIntegerExpression, E2> { 119 | return BinaryIntegerExpression(function: .BitXor, leftSub: Const(leftConst), rightSub: rightSub) 120 | } 121 | 122 | /// Left-shift an expression by another expression. 123 | /// - parameter leftSub: The LHS integer subexpression. 124 | /// - parameter rightSub: The RHS integer subexpression. 125 | /// - returns: The resulting integer expression. 126 | public func <<(leftSub: E1, rightSub: E2) -> BinaryIntegerExpression { 127 | return BinaryIntegerExpression(function: .LeftShift, leftSub: leftSub, rightSub: rightSub) 128 | } 129 | 130 | /// Left-shift an expression by a constant. 131 | /// - parameter leftSub: The LHS integer subexpression. 132 | /// - parameter rightConst: The RHS integer constant. 133 | /// - returns: The resulting integer expression. 134 | public func <<(leftSub: E1, rightConst: E1.ExpressionType) -> BinaryIntegerExpression> { 135 | return BinaryIntegerExpression(function: .LeftShift, leftSub: leftSub, rightSub: Const(rightConst)) 136 | } 137 | 138 | /// Left-shift a constant by an expression. 139 | /// - parameter leftConst: The LHS integer constant. 140 | /// - parameter rightSub: The RHS integer subexpression. 141 | /// - returns: The resulting integer expression. 142 | public func <<(leftConst: E2.ExpressionType, rightSub: E2) -> BinaryIntegerExpression, E2> { 143 | return BinaryIntegerExpression(function: .LeftShift, leftSub: Const(leftConst), rightSub: rightSub) 144 | } 145 | 146 | /// Right-shift an expression by another expression. 147 | /// - parameter leftSub: The LHS integer subexpression. 148 | /// - parameter rightSub: The RHS integer subexpression. 149 | /// - returns: The resulting integer expression. 150 | public func >>(leftSub: E1, rightSub: E2) -> BinaryIntegerExpression { 151 | return BinaryIntegerExpression(function: .RightShift, leftSub: leftSub, rightSub: rightSub) 152 | } 153 | 154 | /// Right-shift an expression by a constant. 155 | /// - parameter leftSub: The LHS integer subexpression. 156 | /// - parameter rightConst: The RHS integer constant. 157 | /// - returns: The resulting integer expression. 158 | public func >>(leftSub: E1, rightConst: E1.ExpressionType) -> BinaryIntegerExpression> { 159 | return BinaryIntegerExpression(function: .RightShift, leftSub: leftSub, rightSub: Const(rightConst)) 160 | } 161 | 162 | /// Right-shift an expression by another expression. 163 | /// - parameter leftSub: The LHS integer subexpression. 164 | /// - parameter rightSub: The RHS integer subexpression. 165 | /// - returns: The resulting integer expression. 166 | public func >>(leftConst: E2.ExpressionType, rightSub: E2) -> BinaryIntegerExpression, E2> { 167 | return BinaryIntegerExpression(function: .RightShift, leftSub: Const(leftConst), rightSub: rightSub) 168 | } 169 | -------------------------------------------------------------------------------- /PredicatePal/BinaryLocationtoNumberExpression.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BinaryLocationtoNumberExpression.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 19/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum BinaryLocationtoNumberFunction { 12 | case Distance 13 | 14 | var tag: String { 15 | switch self { 16 | case .Distance: 17 | return "distanceToLocation:fromLocation:" 18 | } 19 | } 20 | } 21 | 22 | /// Number expression composing two location subexpressions. 23 | /// - parameter E1: Full type of the LHS location subexpression. 24 | /// - parameter E2: Full type of the RHS location subexpression. 25 | public struct BinaryLocationtoNumberFunctionExpression: Expression { 26 | public typealias ExpressionType = Double 27 | 28 | let function: BinaryLocationtoNumberFunction 29 | let leftSub: E1 30 | let rightSub: E2 31 | } 32 | 33 | /// Build the `NSExpression`. 34 | public prefix func*(expression: BinaryLocationtoNumberFunctionExpression) -> NSExpression { 35 | return NSExpression(forFunction: expression.function.tag, arguments: [*expression.leftSub, *expression.rightSub]) 36 | } 37 | 38 | /// Distance between two expressions. 39 | /// - parameter leftSub: The LHS location subexpression. 40 | /// - parameter rightSub: The RHS location subexpression. 41 | /// - returns: The resulting number expression. 42 | public func distance(leftSub: E1, _ rightSub: E2) -> BinaryLocationtoNumberFunctionExpression { 43 | return BinaryLocationtoNumberFunctionExpression(function: .Distance, leftSub: leftSub, rightSub: rightSub) 44 | } 45 | 46 | /// Distance between an expression and a constant. 47 | /// - parameter leftSub: The LHS location subexpression. 48 | /// - parameter rightConst: The RHS location constant. 49 | /// - returns: The resulting number expression. 50 | public func distance(leftSub: E1, _ rightConst: E1.ExpressionType) -> BinaryLocationtoNumberFunctionExpression> { 51 | return BinaryLocationtoNumberFunctionExpression(function: .Distance, leftSub: leftSub, rightSub: Const(rightConst)) 52 | } 53 | 54 | /// Distance between a constant and an expression. 55 | /// - parameter leftConst: The LHS location constant. 56 | /// - parameter rightSub: The RHS location subexpression. 57 | /// - returns: The resulting number expression. 58 | public func distance(leftConst: E2.ExpressionType, rightSub: E2) -> BinaryLocationtoNumberFunctionExpression, E2> { 59 | return BinaryLocationtoNumberFunctionExpression(function: .Distance, leftSub: Const(leftConst), rightSub: rightSub) 60 | } 61 | -------------------------------------------------------------------------------- /PredicatePal/BinaryNumberExpression.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BinaryNumberExpression.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 17/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum BinaryNumberFunction { 12 | case Add 13 | case Subtract 14 | case Multiply 15 | case Divide 16 | case Modulus 17 | case Power 18 | 19 | var tag: String { 20 | switch self { 21 | case .Add: 22 | return "add:to:" 23 | case .Subtract: 24 | return "from:subtract:" 25 | case .Multiply: 26 | return "multiply:by:" 27 | case .Divide: 28 | return "divide:by:" 29 | case .Modulus: 30 | return "modulus:by:" 31 | case .Power: 32 | return "raise:toPower:" 33 | } 34 | } 35 | } 36 | 37 | /// Number expression composing two number subexpressions. 38 | /// - parameter E1: Full type of the LHS number subexpression. 39 | /// - parameter E2: Full type of the RHS number subexpression. 40 | public struct BinaryNumberExpression: Expression { 41 | public typealias ExpressionType = E1.ExpressionType 42 | 43 | let function: BinaryNumberFunction 44 | let leftSub: E1 45 | let rightSub: E2 46 | } 47 | 48 | /// Build the `NSExpression`. 49 | public prefix func*(expression: BinaryNumberExpression) -> NSExpression { 50 | return NSExpression(forFunction: expression.function.tag, arguments: [*expression.leftSub, *expression.rightSub]) 51 | } 52 | 53 | /// Add an expression to another expression. 54 | /// - parameter leftSub: The LHS number subexpression. 55 | /// - parameter rightSub: The RHS number subexpression. 56 | /// - returns: The resulting number expression. 57 | public func +(leftSub: E1, rightSub: E2) -> BinaryNumberExpression { 58 | return BinaryNumberExpression(function: .Add, leftSub: leftSub, rightSub: rightSub) 59 | } 60 | 61 | /// Add an expression to a constant. 62 | /// - parameter leftSub: The LHS number subexpression. 63 | /// - parameter rightConst: The RHS number constant. 64 | /// - returns: The resulting number expression. 65 | public func +(leftSub: E1, rightConst: E1.ExpressionType) -> BinaryNumberExpression> { 66 | return BinaryNumberExpression(function: .Add, leftSub: leftSub, rightSub: Const(rightConst)) 67 | } 68 | 69 | /// Add a constant to an expression. 70 | /// - parameter leftConst: The LHS number constant. 71 | /// - parameter rightSub: The RHS number subexpression. 72 | /// - returns: The resulting number expression. 73 | public func +(leftConst: E2.ExpressionType, rightSub: E2) -> BinaryNumberExpression, E2> { 74 | return BinaryNumberExpression(function: .Add, leftSub: Const(leftConst), rightSub: rightSub) 75 | } 76 | 77 | /// From an expression, subtract another expression. 78 | /// - parameter leftSub: The LHS number subexpression. 79 | /// - parameter rightSub: The RHS number subexpression. 80 | /// - returns: The resulting number expression. 81 | public func -(leftSub: E1, rightSub: E2) -> BinaryNumberExpression { 82 | return BinaryNumberExpression(function: .Subtract, leftSub: leftSub, rightSub: rightSub) 83 | } 84 | 85 | /// From an expression, subtract a constant. 86 | /// - parameter leftSub: The LHS number subexpression. 87 | /// - parameter rightConst: The RHS number constant. 88 | /// - returns: The resulting number expression. 89 | public func -(leftSub: E1, rightConst: E1.ExpressionType) -> BinaryNumberExpression> { 90 | return BinaryNumberExpression(function: .Subtract, leftSub: leftSub, rightSub: Const(rightConst)) 91 | } 92 | 93 | /// From a constant, subtract an expression. 94 | /// - parameter leftConst: The LHS number constant. 95 | /// - parameter rightSub: The RHS number subexpression. 96 | /// - returns: The resulting number expression. 97 | public func -(leftConst: E2.ExpressionType, rightSub: E2) -> BinaryNumberExpression, E2> { 98 | return BinaryNumberExpression(function: .Subtract, leftSub: Const(leftConst), rightSub: rightSub) 99 | } 100 | 101 | /// Multiply an expression by another expressions. 102 | /// - parameter leftSub: The LHS number subexpression. 103 | /// - parameter rightSub: The RHS number subexpression. 104 | /// - returns: The resulting number expression. 105 | public func *(leftSub: E1, rightSub: E2) -> BinaryNumberExpression { 106 | return BinaryNumberExpression(function: .Multiply, leftSub: leftSub, rightSub: rightSub) 107 | } 108 | 109 | /// Multiply an expression by a constant. 110 | /// - parameter leftSub: The LHS number subexpression. 111 | /// - parameter rightConst: The RHS number constant. 112 | /// - returns: The resulting number expression. 113 | public func *(leftSub: E1, rightConst: E1.ExpressionType) -> BinaryNumberExpression> { 114 | return BinaryNumberExpression(function: .Multiply, leftSub: leftSub, rightSub: Const(rightConst)) 115 | } 116 | 117 | /// Mulitply a constant by an expression. 118 | /// - parameter leftConst: The LHS number constant. 119 | /// - parameter rightSub: The RHS number subexpression. 120 | /// - returns: The resulting number expression. 121 | public func *(leftConst: E2.ExpressionType, rightSub: E2) -> BinaryNumberExpression, E2> { 122 | return BinaryNumberExpression(function: .Multiply, leftSub: Const(leftConst), rightSub: rightSub) 123 | } 124 | 125 | /// Divide an expression by another expressions. 126 | /// - parameter leftSub: The LHS number subexpression. 127 | /// - parameter rightSub: The RHS number subexpression. 128 | /// - returns: The resulting number expression. 129 | public func /(leftSub: E1, rightSub: E2) -> BinaryNumberExpression { 130 | return BinaryNumberExpression(function: .Divide, leftSub: leftSub, rightSub: rightSub) 131 | } 132 | 133 | /// Divide an expression by a constant. 134 | /// - parameter leftSub: The LHS number subexpression. 135 | /// - parameter rightConst: The RHS number constant. 136 | /// - returns: The resulting number expression. 137 | public func /(leftSub: E1, rightConst: E1.ExpressionType) -> BinaryNumberExpression> { 138 | return BinaryNumberExpression(function: .Divide, leftSub: leftSub, rightSub: Const(rightConst)) 139 | } 140 | 141 | /// Divide a constant by an expression. 142 | /// - parameter leftConst: The LHS number constant. 143 | /// - parameter rightSub: The RHS number subexpression. 144 | /// - returns: The resulting number expression. 145 | public func /(leftConst: E2.ExpressionType, rightSub: E2) -> BinaryNumberExpression, E2> { 146 | return BinaryNumberExpression(function: .Divide, leftSub: Const(leftConst), rightSub: rightSub) 147 | } 148 | 149 | /// Modulus an expression by another expressions. 150 | /// - parameter leftSub: The LHS number subexpression. 151 | /// - parameter rightSub: The RHS number subexpression. 152 | /// - returns: The resulting number expression. 153 | public func %(leftSub: E1, rightSub: E2) -> BinaryNumberExpression { 154 | return BinaryNumberExpression(function: .Modulus, leftSub: leftSub, rightSub: rightSub) 155 | } 156 | 157 | /// Modulus an expression by a constant. 158 | /// - parameter leftSub: The LHS number subexpression. 159 | /// - parameter rightConst: The RHS number constant. 160 | /// - returns: The resulting number expression. 161 | public func %(leftSub: E1, rightConst: E1.ExpressionType) -> BinaryNumberExpression> { 162 | return BinaryNumberExpression(function: .Modulus, leftSub: leftSub, rightSub: Const(rightConst)) 163 | } 164 | 165 | /// Modulus a constant by an expression. 166 | /// - parameter leftConst: The LHS number constant. 167 | /// - parameter rightSub: The RHS number subexpression. 168 | /// - returns: The resulting number expression. 169 | public func %(leftConst: E2.ExpressionType, rightSub: E2) -> BinaryNumberExpression, E2> { 170 | return BinaryNumberExpression(function: .Modulus, leftSub: Const(leftConst), rightSub: rightSub) 171 | } 172 | 173 | /// Raise an expression to the power of another expressions. 174 | /// - parameter leftSub: The LHS number subexpression. 175 | /// - parameter rightSub: The RHS number subexpression. 176 | /// - returns: The resulting number expression. 177 | public func **(leftSub: E1, rightSub: E2) -> BinaryNumberExpression { 178 | return BinaryNumberExpression(function: .Power, leftSub: leftSub, rightSub: rightSub) 179 | } 180 | 181 | /// Raise an expression to the power of a constant. 182 | /// - parameter leftSub: The LHS number subexpression. 183 | /// - parameter rightConst: The RHS number constant. 184 | /// - returns: The resulting number expression. 185 | public func **(leftSub: E1, rightConst: E1.ExpressionType) -> BinaryNumberExpression> { 186 | return BinaryNumberExpression(function: .Power, leftSub: leftSub, rightSub: Const(rightConst)) 187 | } 188 | 189 | /// Raise a constant to the power of an expression. 190 | /// - parameter leftConst: The LHS number constant. 191 | /// - parameter rightSub: The RHS number subexpression. 192 | /// - returns: The resulting number expression. 193 | public func **(leftConst: E2.ExpressionType, rightSub: E2) -> BinaryNumberExpression, E2> { 194 | return BinaryNumberExpression(function: .Power, leftSub: Const(leftConst), rightSub: rightSub) 195 | } 196 | 197 | -------------------------------------------------------------------------------- /PredicatePal/Block.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Block.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 18/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// This is a block 12 | public struct Block: Predicate { 13 | let block: (AnyObject, [String: AnyObject]?) -> Bool 14 | 15 | public func andSubpredicates() -> [NSPredicate] { 16 | return [*self] 17 | } 18 | 19 | public func orSubpredicates() -> [NSPredicate] { 20 | return [*self] 21 | } 22 | 23 | public init(_ block: (T, [String: AnyObject]) -> Bool) { 24 | self.block = { block($0 as! T, $1 ?? [:]) } 25 | } 26 | } 27 | 28 | public prefix func*(predicate: Block) -> NSPredicate { 29 | return NSPredicate(block: predicate.block) 30 | } 31 | 32 | -------------------------------------------------------------------------------- /PredicatePal/Boolean.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Boolean.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 10/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public struct Boolean: Predicate { 12 | let value: Bool 13 | 14 | public func andSubpredicates() -> [NSPredicate] { 15 | return [*self] 16 | } 17 | 18 | public func orSubpredicates() -> [NSPredicate] { 19 | return [*self] 20 | } 21 | 22 | public init(_ value: Bool) { 23 | self.value = value; 24 | } 25 | } 26 | 27 | public prefix func*(predicate: Boolean) -> NSPredicate { 28 | return NSPredicate(value: predicate.value) 29 | } -------------------------------------------------------------------------------- /PredicatePal/ComparisonPredicate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ComparisonPredicate.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 8/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum ComparisonFunction { 12 | case Less 13 | case LessEqual 14 | case Greater 15 | case GreaterEqual 16 | case Equal 17 | case NotEqual 18 | 19 | var tag: NSPredicateOperatorType { 20 | switch self { 21 | case .Less: 22 | return .LessThanPredicateOperatorType 23 | case .LessEqual: 24 | return .LessThanOrEqualToPredicateOperatorType 25 | case .Greater: 26 | return .GreaterThanPredicateOperatorType 27 | case .GreaterEqual: 28 | return .GreaterThanOrEqualToPredicateOperatorType 29 | case .Equal: 30 | return .EqualToPredicateOperatorType 31 | case .NotEqual: 32 | return .NotEqualToPredicateOperatorType 33 | } 34 | } 35 | } 36 | 37 | /// Predicate composing two subexpressions. 38 | /// - parameter E1: Full type of the LHS subexpression. 39 | /// - parameter E2: Full type of the RHS subexpression. 40 | public struct ComparisonPredicate: Predicate { 41 | let function: ComparisonFunction 42 | let leftSub: E1 43 | let rightSub: E2 44 | 45 | public func andSubpredicates() -> [NSPredicate] { 46 | return [*self] 47 | } 48 | 49 | public func orSubpredicates() -> [NSPredicate] { 50 | return [*self] 51 | } 52 | } 53 | 54 | /// Builds the `NSPredicate`. 55 | public prefix func*(predicate: ComparisonPredicate) -> NSPredicate { 56 | return NSComparisonPredicate( 57 | leftExpression: *predicate.leftSub, 58 | rightExpression: *predicate.rightSub, 59 | modifier: .DirectPredicateModifier, 60 | type: predicate.function.tag, 61 | options: NSComparisonPredicateOptions(rawValue: 0)) 62 | } 63 | 64 | /// Whether an expression is less than another expression. 65 | /// - parameter leftSub: The LHS subexpression. 66 | /// - parameter rightSub: The RHS subexpression. 67 | /// - returns: The resulting predicate. 68 | public func <(leftSub: E1, rightSub: E2) -> ComparisonPredicate { 69 | return ComparisonPredicate(function: .Less, leftSub: leftSub, rightSub: rightSub) 70 | } 71 | 72 | /// Whether an expression is less than a constant. 73 | /// - parameter leftSub: The LHS subexpression. 74 | /// - parameter rightConst: The RHS constant. 75 | /// - returns: The resulting predicate. 76 | public func <(leftSub: E1, rightConst: E1.ExpressionType) -> ComparisonPredicate> { 77 | return ComparisonPredicate(function: .Less, leftSub: leftSub, rightSub: Const(rightConst)) 78 | } 79 | 80 | /// Whether a constant is less than an expression. 81 | /// - parameter leftConst: The LHS constant. 82 | /// - parameter rightSub: The RHS subexpression. 83 | /// - returns: The resulting predicate. 84 | public func <(leftConst: E2.ExpressionType, rightSub: E2) -> ComparisonPredicate, E2> { 85 | return ComparisonPredicate(function: .Less, leftSub: Const(leftConst), rightSub: rightSub) 86 | } 87 | 88 | /// Whether an expression is less than or equal to another expression. 89 | /// - parameter leftSub: The LHS subexpression. 90 | /// - parameter rightSub: The RHS subexpression. 91 | /// - returns: The resulting predicate. 92 | public func <=(leftSub: E1, rightSub: E2) -> ComparisonPredicate { 93 | return ComparisonPredicate(function: .LessEqual, leftSub: leftSub, rightSub: rightSub) 94 | } 95 | 96 | /// Whether an expression is less than or equal to a constant. 97 | /// - parameter leftSub: The LHS subexpression. 98 | /// - parameter rightConst: The RHS constant. 99 | /// - returns: The resulting predicate. 100 | public func <=(leftSub: E1, rightConst: E1.ExpressionType) -> ComparisonPredicate> { 101 | return ComparisonPredicate(function: .LessEqual, leftSub: leftSub, rightSub: Const(rightConst)) 102 | } 103 | 104 | /// Whether a constant is less than or equal to an expression. 105 | /// - parameter leftConst: The LHS constant. 106 | /// - parameter rightSub: The RHS subexpression. 107 | /// - returns: The resulting predicate. 108 | public func <=(leftConst: E2.ExpressionType, rightSub: E2) -> ComparisonPredicate, E2> { 109 | return ComparisonPredicate(function: .LessEqual, leftSub: Const(leftConst), rightSub: rightSub) 110 | } 111 | 112 | /// Whether an expression is greater than another expression. 113 | /// - parameter leftSub: The LHS subexpression. 114 | /// - parameter rightSub: The RHS subexpression. 115 | /// - returns: The resulting predicate. 116 | public func >(leftSub: E1, rightSub: E2) -> ComparisonPredicate { 117 | return ComparisonPredicate(function: .Greater, leftSub: leftSub, rightSub: rightSub) 118 | } 119 | 120 | /// Whether an expression is greater than a constant. 121 | /// - parameter leftSub: The LHS subexpression. 122 | /// - parameter rightConst: The RHS constant. 123 | /// - returns: The resulting predicate. 124 | public func >(leftSub: E1, rightConst: E1.ExpressionType) -> ComparisonPredicate> { 125 | return ComparisonPredicate(function: .Greater, leftSub: leftSub, rightSub: Const(rightConst)) 126 | } 127 | 128 | /// Whether a constant is greater than an expression. 129 | /// - parameter leftConst: The LHS constant. 130 | /// - parameter rightSub: The RHS subexpression. 131 | /// - returns: The resulting predicate. 132 | public func >(leftConst: E2.ExpressionType, rightSub: E2) -> ComparisonPredicate, E2> { 133 | return ComparisonPredicate(function: .Greater, leftSub: Const(leftConst), rightSub: rightSub) 134 | } 135 | 136 | /// Whether an expression is greater than or equal to another expression. 137 | /// - parameter leftSub: The LHS subexpression. 138 | /// - parameter rightSub: The RHS subexpression. 139 | /// - returns: The resulting predicate. 140 | public func >=(leftSub: E1, rightSub: E2) -> ComparisonPredicate { 141 | return ComparisonPredicate(function: .GreaterEqual, leftSub: leftSub, rightSub: rightSub) 142 | } 143 | 144 | /// Whether an expression is greater than or equal to a constant. 145 | /// - parameter leftSub: The LHS subexpression. 146 | /// - parameter rightConst: The RHS constant. 147 | /// - returns: The resulting predicate. 148 | public func >=(leftSub: E1, rightConst: E1.ExpressionType) -> ComparisonPredicate> { 149 | return ComparisonPredicate(function: .GreaterEqual, leftSub: leftSub, rightSub: Const(rightConst)) 150 | } 151 | 152 | /// Whether a constant is greater than or equal to an expression. 153 | /// - parameter leftConst: The LHS constant. 154 | /// - parameter rightSub: The RHS subexpression. 155 | /// - returns: The resulting predicate. 156 | public func >=(leftConst: E2.ExpressionType, rightSub: E2) -> ComparisonPredicate, E2> { 157 | return ComparisonPredicate(function: .GreaterEqual, leftSub: Const(leftConst), rightSub: rightSub) 158 | } 159 | 160 | /// Whether an expression is equal to another expression. 161 | /// - parameter leftSub: The LHS subexpression. 162 | /// - parameter rightSub: The RHS subexpression. 163 | /// - returns: The resulting predicate. 164 | public func ==(leftSub: E1, rightSub: E2) -> ComparisonPredicate { 165 | return ComparisonPredicate(function: .Equal, leftSub: leftSub, rightSub: rightSub) 166 | } 167 | 168 | /// Whether an expression is equal to a constant. 169 | /// - parameter leftSub: The LHS subexpression. 170 | /// - parameter rightConst: The RHS constant. 171 | /// - returns: The resulting predicate. 172 | public func ==(leftSub: E1, rightConst: E1.ExpressionType) -> ComparisonPredicate> { 173 | return ComparisonPredicate(function: .Equal, leftSub: leftSub, rightSub: Const(rightConst)) 174 | } 175 | 176 | /// Whether a constant is equal to an expression. 177 | /// - parameter leftConst: The LHS constant. 178 | /// - parameter rightSub: The RHS subexpression. 179 | /// - returns: The resulting predicate. 180 | public func ==(leftConst: E2.ExpressionType, rightSub: E2) -> ComparisonPredicate, E2> { 181 | return ComparisonPredicate(function: .Equal, leftSub: Const(leftConst), rightSub: rightSub) 182 | } 183 | 184 | /// Whether an expression is not equal to another expression. 185 | /// - parameter leftSub: The LHS subexpression. 186 | /// - parameter rightSub: The RHS subexpression. 187 | /// - returns: The resulting predicate. 188 | public func !=(leftSub: E1, rightSub: E2) -> ComparisonPredicate { 189 | return ComparisonPredicate(function: .NotEqual, leftSub: leftSub, rightSub: rightSub) 190 | } 191 | 192 | /// Whether an expression is not equal to a constant. 193 | /// - parameter leftSub: The LHS subexpression. 194 | /// - parameter rightConst: The RHS constant. 195 | /// - returns: The resulting predicate. 196 | public func !=(leftSub: E1, rightConst: E1.ExpressionType) -> ComparisonPredicate> { 197 | return ComparisonPredicate(function: .NotEqual, leftSub: leftSub, rightSub: Const(rightConst)) 198 | } 199 | 200 | /// Whether a constant is not equal to an expression. 201 | /// - parameter leftConst: The LHS constant. 202 | /// - parameter rightSub: The RHS subexpression. 203 | /// - returns: The resulting predicate. 204 | public func !=(leftConst: E2.ExpressionType, rightSub: E2) -> ComparisonPredicate, E2> { 205 | return ComparisonPredicate(function: .NotEqual, leftSub: Const(leftConst), rightSub: rightSub) 206 | } 207 | -------------------------------------------------------------------------------- /PredicatePal/Const.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Const.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 7/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Constant term. 12 | /// - parameter T: The type of the constant. 13 | public struct Const: Expression { 14 | public typealias ExpressionType = T 15 | 16 | let value: T 17 | 18 | /// Create a constant term. 19 | /// - parameter value: The constant value. 20 | public init(_ value: T) { 21 | self.value = value 22 | } 23 | } 24 | 25 | /// Build the `NSExpression`. 26 | public prefix func*(expression: Const) -> NSExpression { 27 | return NSExpression(forConstantValue:expression.value as? AnyObject) 28 | } 29 | -------------------------------------------------------------------------------- /PredicatePal/DifferenceExpression.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DifferenceExpression.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 7/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Set difference expression composing a set subexpression and a sequence subexpression. 12 | /// - parameter E1: Full type of the LHS number subexpression. 13 | /// - parameter E2: Full type of the RHS number subexpression. 14 | public struct DifferenceExpression: Expression { 15 | public typealias ExpressionType = E1.ExpressionType 16 | 17 | let leftSub: E1 18 | let rightSub: E2 19 | } 20 | 21 | /// Build the `NSExpression`. 22 | public prefix func*(expression: DifferenceExpression) -> NSExpression { 23 | return NSExpression(forMinusSet: *expression.leftSub, with: *expression.rightSub) 24 | } 25 | 26 | /// Difference an expression with another expression. 27 | /// - parameter leftSub: The LHS set subexpression. 28 | /// - parameter rightSub: The RHS sequence subexpression. 29 | /// - returns: The resulting set expression. 30 | public func -(leftSub: E1, rightSub: E2) -> DifferenceExpression { 31 | return DifferenceExpression(leftSub: leftSub, rightSub: rightSub) 32 | } 33 | 34 | /// Difference an expression with a constant. 35 | /// - parameter leftSub: The LHS set subexpression. 36 | /// - parameter rightConst: The RHS sequence constant. 37 | /// - returns: The resulting set expression. 38 | public func -(leftSub: E1, rightConst: C) -> DifferenceExpression> { 39 | return DifferenceExpression(leftSub: leftSub, rightSub: Const(rightConst)) 40 | } 41 | 42 | /// Difference a constant with an expression. 43 | /// - parameter leftConst: The LHS set constant. 44 | /// - parameter rightSub: The RHS sequence subexpression. 45 | /// - returns: The resulting set expression. 46 | public func -(leftConst: C, rightSub: E2) -> DifferenceExpression, E2> { 47 | return DifferenceExpression(leftSub: Const(leftConst), rightSub: rightSub) 48 | } 49 | -------------------------------------------------------------------------------- /PredicatePal/Expression.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Expression.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 1/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Arbitrary expression builder. 12 | public protocol Expression { 13 | typealias ExpressionType 14 | 15 | prefix func*(expression: Self) -> NSExpression 16 | } 17 | -------------------------------------------------------------------------------- /PredicatePal/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSHumanReadableCopyright 24 | Copyright © 2015 Glen Low. All rights reserved. 25 | NSPrincipalClass 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /PredicatePal/IntersectExpression.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SetExpression.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 7/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Set intersect expression composing a set subexpression and a sequence subexpression. 12 | /// - parameter E1: Full type of the LHS set subexpression. 13 | /// - parameter E2: Full type of the RHS sequence subexpression. 14 | public struct IntersectExpression: Expression { 15 | public typealias ExpressionType = E1.ExpressionType 16 | 17 | let leftSub: E1 18 | let rightSub: E2 19 | } 20 | 21 | /// Build the `NSExpression`. 22 | public prefix func*(expression: IntersectExpression) -> NSExpression { 23 | return NSExpression(forIntersectSet: *expression.leftSub, with: *expression.rightSub) 24 | } 25 | 26 | /// Intersect an expression with another expression. 27 | /// - parameter leftSub: The LHS set subexpression. 28 | /// - parameter rightSub: The RHS sequence subexpression. 29 | /// - returns: The resulting set expression. 30 | public func &(leftSub: E1, rightSub: E2) -> IntersectExpression { 31 | return IntersectExpression(leftSub: leftSub, rightSub: rightSub) 32 | } 33 | 34 | /// Intersect an expression with a constant. 35 | /// - parameter leftSub: The LHS set subexpression. 36 | /// - parameter rightConst: The RHS sequence constant. 37 | /// - returns: The resulting set expression. 38 | public func &(leftSub: E1, rightConst: C) -> IntersectExpression> { 39 | return IntersectExpression(leftSub: leftSub, rightSub: Const(rightConst)) 40 | } 41 | 42 | /// Intersect a constant with an expression. 43 | /// - parameter leftConst: The LHS set constant. 44 | /// - parameter rightSub: The RHS sequence subexpression. 45 | /// - returns: The resulting set expression. 46 | public func &(leftConst: C, rightSub: E2) -> IntersectExpression, E2> { 47 | return IntersectExpression(leftSub: Const(leftConst), rightSub: rightSub) 48 | } 49 | -------------------------------------------------------------------------------- /PredicatePal/Key.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Key.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 7/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Keypath term. 12 | /// - parameter T: The type of the keypath value. 13 | public struct Key: Expression { 14 | public typealias ExpressionType = T 15 | 16 | let path: String 17 | 18 | /// Create a keypath term. 19 | /// - parameter path: The keypath. 20 | public init(_ path: String) { 21 | self.path = path 22 | } 23 | } 24 | 25 | /// Build the `NSExpression`. 26 | public prefix func*(expression: Key) -> NSExpression { 27 | return NSExpression(forKeyPath: expression.path) 28 | } 29 | -------------------------------------------------------------------------------- /PredicatePal/NotPredicate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NotPredicate.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 17/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// NOT predicate composing a subpredicate. 12 | /// - parameter P: Full type of the subpredicate. 13 | public struct NotPredicate: Predicate { 14 | let sub: P 15 | 16 | public func andSubpredicates() -> [NSPredicate] { 17 | return [*self] 18 | } 19 | 20 | public func orSubpredicates() -> [NSPredicate] { 21 | return [*self] 22 | } 23 | } 24 | 25 | /// Build the `NSPredicate`. 26 | public prefix func*

(predicate: NotPredicate

) -> NSPredicate { 27 | return NSCompoundPredicate(notPredicateWithSubpredicate: *predicate.sub) 28 | } 29 | 30 | /// Logical NOT of a predicate. 31 | /// - parameter sub: The subpredicate. 32 | /// - returns: The resulting predicate. 33 | public prefix func !

(sub: P) -> NotPredicate

{ 34 | return NotPredicate(sub: sub) 35 | } 36 | -------------------------------------------------------------------------------- /PredicatePal/NullaryDateExpression.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NullaryDateExpression.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 17/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum NullaryDateFunction { 12 | case Now 13 | 14 | var tag: String { 15 | switch self { 16 | case .Now: 17 | return "now" 18 | } 19 | } 20 | } 21 | 22 | /// Date expression with no subexpressions. 23 | public struct NullaryDateExpression: Expression { 24 | public typealias ExpressionType = NSDate 25 | 26 | let function: NullaryDateFunction 27 | } 28 | 29 | /// Build the `NSExpression`. 30 | public prefix func*(expression: NullaryDateExpression) -> NSExpression { 31 | return NSExpression(forFunction: expression.function.tag, arguments: []) 32 | } 33 | 34 | /// The current date. 35 | public func now() -> NullaryDateExpression { 36 | return NullaryDateExpression(function: .Now) 37 | } 38 | -------------------------------------------------------------------------------- /PredicatePal/NullaryIntegerExpression.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NullaryIntegerExpression.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 7/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum NullaryIntegerFunction { 12 | case Random 13 | 14 | var tag: String { 15 | switch self { 16 | case .Random: 17 | return "random" 18 | } 19 | } 20 | } 21 | 22 | /// Integer expression with no subexpressions. 23 | public struct NullaryIntegerExpression: Expression { 24 | public typealias ExpressionType = Int 25 | 26 | let function: NullaryIntegerFunction 27 | } 28 | 29 | /// Builds an `NSExpression` 30 | public prefix func*(expression: NullaryIntegerExpression) -> NSExpression { 31 | return NSExpression(forFunction: expression.function.tag, arguments: []) 32 | } 33 | 34 | /// A random integer. 35 | public func random() -> NullaryIntegerExpression { 36 | return NullaryIntegerExpression(function: .Random) 37 | } 38 | -------------------------------------------------------------------------------- /PredicatePal/Operators.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Operators.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 10/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | prefix operator* { } 12 | 13 | infix operator** { associativity left precedence 170 } 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /PredicatePal/OrPredicate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OrPredicate.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 17/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// OR predicate composing two subpredicates. 12 | /// - parameter P1: Full type of the LHS subpredicate. 13 | /// - parameter P2: Full type of the RHS subpredicate. 14 | public struct OrPredicate: Predicate { 15 | let leftSub: P1 16 | let rightSub: P2 17 | 18 | public func andSubpredicates() -> [NSPredicate] { 19 | return [*self] 20 | } 21 | 22 | public func orSubpredicates() -> [NSPredicate] { 23 | return leftSub.orSubpredicates() + rightSub.orSubpredicates() 24 | } 25 | } 26 | 27 | /// Build the `NSPredicate`. 28 | public prefix func*(predicate: OrPredicate) -> NSPredicate { 29 | return NSCompoundPredicate(orPredicateWithSubpredicates: predicate.orSubpredicates()) 30 | } 31 | 32 | /// Logical OR of two predicates. 33 | /// - parameter leftSub: The LHS subpredicate. 34 | /// - parameter rightSub: The RHS subpredicate. 35 | /// - returns: The resulting predicate. 36 | public func ||(leftSub: P1, rightSub: P2) -> OrPredicate { 37 | return OrPredicate(leftSub: leftSub, rightSub: rightSub) 38 | } 39 | -------------------------------------------------------------------------------- /PredicatePal/Predicate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PredicatePalicate.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 1/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Arbitrary predicate builder. 12 | public protocol Predicate { 13 | func andSubpredicates() -> [NSPredicate] 14 | func orSubpredicates() -> [NSPredicate] 15 | 16 | prefix func*(predicate: Self) -> NSPredicate 17 | } 18 | -------------------------------------------------------------------------------- /PredicatePal/PredicatePal.h: -------------------------------------------------------------------------------- 1 | // 2 | // PredicatePal.h 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 1/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Pred. 12 | FOUNDATION_EXPORT double PredVersionNumber; 13 | 14 | //! Project version string for Pred. 15 | FOUNDATION_EXPORT const unsigned char PredVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /PredicatePal/Protocols.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberType.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 1/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import CoreLocation 11 | 12 | public protocol CompareType { } 13 | public protocol LocationType { } 14 | public protocol IntegerType { } 15 | public protocol NumberType { } 16 | public protocol StringType { } 17 | 18 | public protocol IndexType { 19 | typealias Key 20 | typealias Value 21 | } 22 | 23 | public protocol SetType { 24 | typealias Element 25 | } 26 | 27 | extension Int: NumberType, IntegerType, CompareType { } 28 | extension Int8: NumberType, IntegerType, CompareType { } 29 | extension Int16: NumberType, IntegerType, CompareType { } 30 | extension Int32: NumberType, IntegerType, CompareType { } 31 | extension Int64: NumberType, IntegerType, CompareType { } 32 | 33 | extension UInt: NumberType, IntegerType, CompareType { } 34 | extension UInt8: NumberType, IntegerType, CompareType { } 35 | extension UInt16: NumberType, IntegerType, CompareType { } 36 | extension UInt32: NumberType, IntegerType, CompareType { } 37 | extension UInt64: NumberType, IntegerType, CompareType { } 38 | 39 | extension Float: NumberType, CompareType { } 40 | extension Double: NumberType, CompareType { } 41 | 42 | extension String: StringType, CompareType { } 43 | 44 | extension Array: IndexType { 45 | public typealias Key = Int 46 | public typealias Value = Element 47 | } 48 | 49 | extension Dictionary: IndexType { } 50 | 51 | extension Set: SetType { } 52 | 53 | extension CLLocation: LocationType { } 54 | 55 | extension NSDate: CompareType { } 56 | -------------------------------------------------------------------------------- /PredicatePal/QuantifiedPredicate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // QuantifiedPredicate.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 8/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum Quantifier { 12 | case All 13 | case Any 14 | 15 | var tag: NSComparisonPredicateModifier { 16 | switch self { 17 | case .All: 18 | return .AllPredicateModifier 19 | case .Any: 20 | return .AnyPredicateModifier 21 | } 22 | } 23 | } 24 | 25 | /// Quantified predicate composing a comparison subpredicate. 26 | /// - parameter E1: Full type of the LHS subexpression. 27 | /// - parameter E2: Full type of the RHS subexpression. 28 | public struct QuantifiedPredicate: Predicate { 29 | let quantifier: Quantifier 30 | let sub: ComparisonPredicate 31 | 32 | public func andSubpredicates() -> [NSPredicate] { 33 | return [*self] 34 | } 35 | 36 | public func orSubpredicates() -> [NSPredicate] { 37 | return [*self] 38 | } 39 | } 40 | 41 | /// Build the `NSPredicate`. 42 | public prefix func*(predicate: QuantifiedPredicate) -> NSPredicate { 43 | return NSComparisonPredicate( 44 | leftExpression: *predicate.sub.leftSub, 45 | rightExpression: *predicate.sub.rightSub, 46 | modifier: predicate.quantifier.tag, 47 | type: predicate.sub.function.tag, 48 | options: NSComparisonPredicateOptions(rawValue: 0)) 49 | } 50 | 51 | /// Whether a predicate holds for all elements. 52 | /// - parameter sub: The subpredicate. 53 | /// - returns: The resulting predicate. 54 | public func all(sub: ComparisonPredicate) -> QuantifiedPredicate { 55 | return QuantifiedPredicate(quantifier:.All, sub: sub) 56 | } 57 | 58 | /// Whether a predicate holds for any element. 59 | /// - parameter sub: The subpredicate. 60 | /// - returns: The resulting predicate. 61 | public func any(sub: ComparisonPredicate) -> QuantifiedPredicate { 62 | return QuantifiedPredicate(quantifier:.Any, sub: sub) 63 | } 64 | 65 | -------------------------------------------------------------------------------- /PredicatePal/SubqueryExpression.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SubqueryExpression.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 12/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Subquery expression composing a sequence subexpression, an iterator variable and a predicate. 12 | /// - parameter E: Full type of the sequence subexpression. 13 | /// - parameter P: Full type of the predicate to filter the sequence. 14 | public struct SubqueryExpression: Expression { 15 | public typealias ExpressionType = E.ExpressionType 16 | 17 | let subquery: E 18 | let iterator: Var 19 | let predicate: P 20 | } 21 | 22 | /// Build the `NSExpression`. 23 | public prefix func*(expression: SubqueryExpression) -> NSExpression { 24 | return NSExpression(forSubquery: *expression.subquery, usingIteratorVariable: expression.iterator.name, predicate: *expression.predicate) 25 | } 26 | 27 | /// Filters a sequence expression by a predicate. 28 | /// - parameter subquery: The sequence expression. 29 | /// - parameter iterator: The iterator variable. 30 | /// - parameter predicate: The predicate using `iterator` to filter `subquery`. 31 | /// - returns: The resulting sequence expression. 32 | public func subquery(subquery: E, iterator: Var, predicate: P) -> SubqueryExpression { 33 | return SubqueryExpression(subquery: subquery, iterator: iterator, predicate: predicate) 34 | } -------------------------------------------------------------------------------- /PredicatePal/This.swift: -------------------------------------------------------------------------------- 1 | // 2 | // This.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 18/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Evaluated object term. 12 | /// - parameter T: The type of the evaluated object. 13 | public struct This: Expression { 14 | public typealias ExpressionType = T 15 | 16 | /// Create an evaluated object term. 17 | public init() { } 18 | } 19 | 20 | // Build the `NSExpression`. 21 | public prefix func*(expression: This) -> NSExpression { 22 | return NSExpression.expressionForEvaluatedObject() 23 | } 24 | -------------------------------------------------------------------------------- /PredicatePal/UnaryIntegerExpression.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UnaryIntegerExpression.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 17/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum UnaryIntegerFunction { 12 | case RandomN 13 | case Complement 14 | 15 | var tag: String { 16 | switch self { 17 | case .RandomN: 18 | return "randomn:" 19 | case .Complement: 20 | return "onesComplement:" 21 | } 22 | } 23 | } 24 | 25 | /// Integer expression composing an integer subexpression. 26 | /// - parameter E: Full type of the integer subexpression. 27 | public struct UnaryIntegerExpression: Expression { 28 | public typealias ExpressionType = E.ExpressionType 29 | 30 | let function: UnaryIntegerFunction 31 | let sub: E 32 | } 33 | 34 | /// Build the `NSExpression`. 35 | public prefix func*(expression: UnaryIntegerExpression) -> NSExpression { 36 | return NSExpression(forFunction: expression.function.tag, arguments: [*expression.sub]) 37 | } 38 | 39 | /// A random integer bounded by an expression. 40 | /// - parameter sub: The integer subexpression. 41 | /// - returns: The resulting integer expression. 42 | public func randomn(sub: E) -> UnaryIntegerExpression { 43 | return UnaryIntegerExpression(function: .RandomN, sub: sub) 44 | } 45 | 46 | /// Complement an expression. 47 | /// - parameter sub: The integer subexpression. 48 | /// - returns: The resulting integer expression. 49 | prefix public func ~(sub: E) -> UnaryIntegerExpression { 50 | return UnaryIntegerExpression(function: .Complement, sub: sub) 51 | } 52 | -------------------------------------------------------------------------------- /PredicatePal/UnaryNumberExpression.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UnaryNumberExpression.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 17/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum UnaryNumberFunction { 12 | case Sqrt 13 | case Log 14 | case Ln 15 | case Exp 16 | case Floor 17 | case Ceil 18 | case Abs 19 | case Trunc 20 | 21 | var tag: String { 22 | switch self { 23 | case .Sqrt: 24 | return "sqrt:" 25 | case .Log: 26 | return "log:" 27 | case .Ln: 28 | return "ln:" 29 | case .Exp: 30 | return "exp:" 31 | case .Floor: 32 | return "floor:" 33 | case .Ceil: 34 | return "ceiling:" 35 | case .Abs: 36 | return "abs:" 37 | case .Trunc: 38 | return "trunc:" 39 | } 40 | } 41 | } 42 | 43 | /// Number expression composing a number subexpression. 44 | /// - parameter E: Full type of the number subexpression. 45 | public struct UnaryNumberExpression: Expression { 46 | public typealias ExpressionType = E.ExpressionType 47 | 48 | let function: UnaryNumberFunction 49 | let sub: E 50 | } 51 | 52 | /// Build the `NSExpression`. 53 | public prefix func*(expression: UnaryNumberExpression) -> NSExpression { 54 | return NSExpression(forFunction: expression.function.tag, arguments: [*expression.sub]) 55 | } 56 | 57 | /// Square root of an expression. 58 | /// - parameter sub: The number subexpression. 59 | /// - returns: The resulting number expression. 60 | public func sqrt(sub: E) -> UnaryNumberExpression { 61 | return UnaryNumberExpression(function: .Sqrt, sub: sub) 62 | } 63 | 64 | /// Logarithm of an expression. 65 | /// - parameter sub: The number subexpression. 66 | /// - returns: The resulting number expression. 67 | public func log(sub: E) -> UnaryNumberExpression { 68 | return UnaryNumberExpression(function: .Log, sub: sub) 69 | } 70 | 71 | /// Logarithm of an expression. 72 | /// - parameter sub: The number subexpression. 73 | /// - returns: The resulting number expression. 74 | public func ln(sub: E) -> UnaryNumberExpression { 75 | return UnaryNumberExpression(function: .Ln, sub: sub) 76 | } 77 | 78 | /// Exponential of an expression. 79 | /// - parameter sub: The number subexpression. 80 | /// - returns: The resulting number expression. 81 | public func exp(sub: E) -> UnaryNumberExpression { 82 | return UnaryNumberExpression(function: .Exp, sub: sub) 83 | } 84 | 85 | /// Floor of an expression. 86 | /// - parameter sub: The number subexpression. 87 | /// - returns: The resulting number expression. 88 | public func floor(sub: E) -> UnaryNumberExpression { 89 | return UnaryNumberExpression(function: .Floor, sub: sub) 90 | } 91 | 92 | /// Ceiling of an expression. 93 | /// - parameter sub: The number subexpression. 94 | /// - returns: The resulting number expression. 95 | public func ceil(sub: E) -> UnaryNumberExpression { 96 | return UnaryNumberExpression(function: .Ceil, sub: sub) 97 | } 98 | 99 | /// Absolute value of an expression. 100 | /// - parameter sub: The number subexpression. 101 | /// - returns: The resulting number expression. 102 | public func abs(sub: E) -> UnaryNumberExpression { 103 | return UnaryNumberExpression(function: .Abs, sub: sub) 104 | } 105 | 106 | /// Truncate an expression. 107 | /// - parameter sub: The number subexpression. 108 | /// - returns: The resulting number expression. 109 | public func trunc(sub: E) -> UnaryNumberExpression { 110 | return UnaryNumberExpression(function: .Trunc, sub: sub) 111 | } 112 | -------------------------------------------------------------------------------- /PredicatePal/UnarySequenceToNumberExpression.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UnarySequenceToNumberExpression.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 17/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum UnarySequenceToNumberFunction { 12 | case Sum 13 | case Count 14 | case Min 15 | case Max 16 | case Average 17 | case Median 18 | case Mode 19 | case Stddev 20 | 21 | var tag: String { 22 | switch self { 23 | case .Sum: 24 | return "sum:" 25 | case .Count: 26 | return "count:" 27 | case .Min: 28 | return "min:" 29 | case .Max: 30 | return "max:" 31 | case .Average: 32 | return "average:" 33 | case .Median: 34 | return "median:" 35 | case .Mode: 36 | return "mode:" 37 | case .Stddev: 38 | return "stddev:" 39 | } 40 | } 41 | } 42 | 43 | /// Number expression composing a sequence subexpression. 44 | /// - parameter E: Full type of the sequence subexpression. 45 | public struct UnarySequenceToNumberExpression: Expression { 46 | public typealias ExpressionType = E.ExpressionType.Generator.Element 47 | 48 | let function: UnarySequenceToNumberFunction 49 | let sub: E 50 | } 51 | 52 | /// Build the `NSExpression`. 53 | public prefix func*(expression: UnarySequenceToNumberExpression) -> NSExpression { 54 | return NSExpression(forFunction: expression.function.tag, arguments: [*expression.sub]) 55 | } 56 | 57 | /// Sum of an expression. 58 | /// - parameter sub: The sequence subexpression. 59 | /// - returns: The resulting number expression. 60 | public func sum(sub: E) -> UnarySequenceToNumberExpression { 61 | return UnarySequenceToNumberExpression(function: .Sum, sub: sub) 62 | } 63 | 64 | /// Count of an expression. 65 | /// - parameter sub: The sequence subexpression. 66 | /// - returns: The resulting number expression. 67 | public func count(sub: E) -> UnarySequenceToNumberExpression { 68 | return UnarySequenceToNumberExpression(function: .Count, sub: sub) 69 | } 70 | 71 | /// Minimum value of an expression. 72 | /// - parameter sub: The sequence subexpression. 73 | /// - returns: The resulting number expression. 74 | public func min(sub: E) -> UnarySequenceToNumberExpression { 75 | return UnarySequenceToNumberExpression(function: .Min, sub: sub) 76 | } 77 | 78 | /// Maximum value of an expression. 79 | /// - parameter sub: The sequence subexpression. 80 | /// - returns: The resulting number expression. 81 | public func max(sub: E) -> UnarySequenceToNumberExpression { 82 | return UnarySequenceToNumberExpression(function: .Max, sub: sub) 83 | } 84 | 85 | /// Average of an expression. 86 | /// - parameter sub: The sequence subexpression. 87 | /// - returns: The resulting number expression. 88 | public func average(sub: E) -> UnarySequenceToNumberExpression { 89 | return UnarySequenceToNumberExpression(function: .Average, sub: sub) 90 | } 91 | 92 | /// Median of an expression. 93 | /// - parameter sub: The sequence subexpression. 94 | /// - returns: The resulting number expression. 95 | public func median(sub: E) -> UnarySequenceToNumberExpression { 96 | return UnarySequenceToNumberExpression(function: .Median, sub: sub) 97 | } 98 | 99 | /// Mode of an expression. 100 | /// - parameter sub: The sequence subexpression. 101 | /// - returns: The resulting number expression. 102 | public func mode(sub: E) -> UnarySequenceToNumberExpression { 103 | return UnarySequenceToNumberExpression(function: .Mode, sub: sub) 104 | } 105 | 106 | /// Standard deviation of an expression. 107 | /// - parameter sub: The sequence subexpression. 108 | /// - returns: The resulting number expression. 109 | public func stddev(sub: E) -> UnarySequenceToNumberExpression { 110 | return UnarySequenceToNumberExpression(function: .Stddev, sub: sub) 111 | } 112 | -------------------------------------------------------------------------------- /PredicatePal/UnaryStringExpression.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UnaryStringExpression.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 17/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum UnaryStringFunction { 12 | case Uppercase 13 | case Lowercase 14 | 15 | var tag: String { 16 | switch self { 17 | case .Uppercase: 18 | return "uppercase:" 19 | case .Lowercase: 20 | return "lowercase:" 21 | } 22 | } 23 | } 24 | 25 | /// String expression composing a string subexpression. 26 | /// - parameter E: Full type of the string subexpression. 27 | public struct UnaryStringExpression: Expression { 28 | public typealias ExpressionType = E.ExpressionType 29 | 30 | let function: UnaryStringFunction 31 | let sub: E 32 | } 33 | 34 | /// Build the `NSExpression`. 35 | public prefix func*(expression: UnaryStringExpression) -> NSExpression { 36 | return NSExpression(forFunction: expression.function.tag, arguments: [*expression.sub]) 37 | } 38 | 39 | /// Uppercase the expression. 40 | /// - parameter sub: The string subexpression. 41 | /// - returns: The resulting string expression. 42 | public func uppercase(sub: E) -> UnaryStringExpression { 43 | return UnaryStringExpression(function: .Uppercase, sub: sub) 44 | } 45 | 46 | /// Lowercase the expression. 47 | /// - parameter sub: The string subexpression. 48 | /// - returns: The resulting string expression. 49 | public func lowercase(sub: E) -> UnaryStringExpression { 50 | return UnaryStringExpression(function: .Lowercase, sub: sub) 51 | } 52 | -------------------------------------------------------------------------------- /PredicatePal/UnaryStringToIntegerExpression.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UnaryStringToIntegerExpression.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 17/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum UnaryStringToIntegerFunction { 12 | case Length 13 | 14 | var tag: String { 15 | switch self { 16 | case .Length: 17 | return "length:" 18 | } 19 | } 20 | } 21 | 22 | /// Integer expression composing a string subexpression. 23 | /// - parameter E: Full type of the string subexpression. 24 | public struct UnaryStringToIntegerExpression: Expression { 25 | public typealias ExpressionType = Int 26 | 27 | let function: UnaryStringToIntegerFunction 28 | let sub: E 29 | } 30 | 31 | /// Builds the `NSExpression`. 32 | public prefix func*(expression: UnaryStringToIntegerExpression) -> NSExpression { 33 | return NSExpression(forFunction: expression.function.tag, arguments: [*expression.sub]) 34 | } 35 | 36 | /// Length of an expression. 37 | /// - parameter sub: The string subexpression. 38 | /// - returns: The resulting integer expression. 39 | public func length(sub: E) -> UnaryStringToIntegerExpression { 40 | return UnaryStringToIntegerExpression(function: .Length, sub: sub) 41 | } 42 | -------------------------------------------------------------------------------- /PredicatePal/UnionExpression.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UnionExpression.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 7/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// A set union expression composing a set subexpression and a sequence subexpression. 12 | /// - parameter E1: Full type of the LHS set subexpression. 13 | /// - parameter E2: Full type of the RHS sequence subexpression. 14 | public struct UnionExpression: Expression { 15 | public typealias ExpressionType = E1.ExpressionType 16 | 17 | let leftSub: E1 18 | let rightSub: E2 19 | } 20 | 21 | public prefix func*(expression: UnionExpression) -> NSExpression { 22 | return NSExpression(forUnionSet: *expression.leftSub, with: *expression.rightSub) 23 | } 24 | 25 | /// Union an expression with another expression. 26 | /// - parameter leftSub: The LHS set subexpression. 27 | /// - parameter rightSub: The RHS sequence subexpression. 28 | /// - returns: The resulting set expression. 29 | public func |(leftSub: E1, rightSub: E2) -> UnionExpression { 30 | return UnionExpression(leftSub: leftSub, rightSub: rightSub) 31 | } 32 | 33 | /// Union an expression with a constant. 34 | /// - parameter leftSub: The LHS set subexpression. 35 | /// - parameter rightConst: The RHS sequence constant. 36 | /// - returns: The resulting set expression. 37 | public func |(leftSub: E1, rightConst: C) -> UnionExpression> { 38 | return UnionExpression(leftSub: leftSub, rightSub: Const(rightConst)) 39 | } 40 | 41 | /// Union a constant with an expression. 42 | /// - parameter leftConst: The LHS set constant. 43 | /// - parameter rightSub: The RHS sequence subexpression. 44 | /// - returns: The resulting set expression. 45 | public func |(leftConst: C, rightSub: E2) -> UnionExpression, E2> { 46 | return UnionExpression(leftSub: Const(leftConst), rightSub: rightSub) 47 | } 48 | -------------------------------------------------------------------------------- /PredicatePal/Var.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Var.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 7/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Variable term. 12 | /// - parameter T: The type of the variable. 13 | public struct Var: Expression { 14 | public typealias ExpressionType = T 15 | 16 | let name: String 17 | 18 | /// Create a variable term. 19 | /// - parameter name: The variable name. 20 | public init(_ name: String) { 21 | self.name = name 22 | } 23 | } 24 | 25 | /// Build the `NSExpression`. 26 | public prefix func*(expression: Var) -> NSExpression { 27 | return NSExpression(forVariable: expression.name) 28 | } 29 | 30 | -------------------------------------------------------------------------------- /PredicatePalTests/ExpressionTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ExpressionTests.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 4/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import CoreLocation 10 | import XCTest 11 | 12 | import PredicatePal 13 | 14 | class ExpressionTests: XCTestCase { 15 | 16 | // BinaryIndexExpression 17 | 18 | func testArrayIndex() { 19 | let age = Key<[Int]>("age") 20 | 21 | XCTAssertEqual( 22 | *age[1], 23 | NSExpression(format: "age[1]")) 24 | } 25 | 26 | func testDictionaryIndex() { 27 | let age = Key>("age") 28 | XCTAssertEqual( 29 | *age["one"], 30 | NSExpression(format: "age[\"one\"]")) 31 | } 32 | 33 | // BinaryIntegerExpression 34 | 35 | func testBitAnd() { 36 | let age = Key("age") 37 | XCTAssertEqual( 38 | *(age & 42), 39 | NSExpression(format: "age & 42")) 40 | } 41 | 42 | func testBitOr() { 43 | let age = Key("age") 44 | XCTAssertEqual( 45 | *(age | 42), 46 | NSExpression(format: "age | 42")) 47 | } 48 | 49 | func testBitXor() { 50 | let age = Key("age") 51 | XCTAssertEqual( 52 | *(age ^ 42), 53 | NSExpression(format: "age ^ 42")) 54 | } 55 | 56 | func testLeftShift() { 57 | let age = Key("age") 58 | XCTAssertEqual( 59 | *(age << 4), 60 | NSExpression(format: "age << 4")) 61 | } 62 | 63 | func testRightShift() { 64 | let age = Key("age") 65 | XCTAssertEqual( 66 | *(age >> 4), 67 | NSExpression(format: "age >> 4")) 68 | } 69 | 70 | // BinaryLocationToNumberExpression 71 | 72 | func testDistance() { 73 | let age = Key("age") 74 | let beauty = Key("beauty") 75 | XCTAssertEqual( 76 | *distance(age, beauty), 77 | NSExpression(format: "distanceToLocation:fromLocation:(age, beauty)")) 78 | } 79 | 80 | // BinaryNumberExpression 81 | 82 | func testAdd() { 83 | let age = Key("age") 84 | XCTAssertEqual( 85 | *(age + 42), 86 | NSExpression(format: "age + 42")) 87 | } 88 | 89 | func testSubtract() { 90 | let age = Key("age") 91 | XCTAssertEqual( 92 | *(age - 42), 93 | NSExpression(format: "age - 42")) 94 | } 95 | 96 | func testMultiply() { 97 | let age = Key("age") 98 | XCTAssertEqual( 99 | *(age * 42), 100 | NSExpression(format: "age * 42")) 101 | } 102 | 103 | func testDivide() { 104 | let age = Key("age") 105 | XCTAssertEqual( 106 | *(age / 4), 107 | NSExpression(format: "age / 4")) 108 | } 109 | 110 | func testModulus() { 111 | let age = Key("age") 112 | XCTAssertEqual( 113 | *(age % 4), 114 | NSExpression(format: "modulus:by:(age, 4)")) 115 | } 116 | 117 | func testPower() { 118 | let age = Key("age") 119 | XCTAssertEqual( 120 | *(age ** 4), 121 | NSExpression(format: "age ** 4")) 122 | } 123 | 124 | // DifferenceExpression 125 | 126 | func testDifference() { 127 | let age = Key>("age") 128 | let beauty = Key>("beauty") 129 | XCTAssertEqual( 130 | *(age - beauty), 131 | NSExpression(format:"age MINUS beauty")) 132 | } 133 | 134 | // IntersectExpression 135 | 136 | func testIntersect() { 137 | let age = Key>("age") 138 | let beauty = Key>("beauty") 139 | XCTAssertEqual( 140 | *(age & beauty), 141 | NSExpression(format:"age INTERSECT beauty")) 142 | } 143 | 144 | // NullaryDateExpression 145 | 146 | func testNow() { 147 | XCTAssertEqual( 148 | *now(), 149 | NSExpression(format:"now()")) 150 | } 151 | 152 | // NullaryIntegerExpression 153 | 154 | func testRandom() { 155 | XCTAssertEqual( 156 | *random(), 157 | NSExpression(format:"random()")) 158 | } 159 | 160 | // SubqueryExpression 161 | 162 | func testSubquery() { 163 | let age = Key<[Int]>("age") 164 | let x = Var("x") 165 | XCTAssertEqual( 166 | *subquery(age, iterator: x, predicate: x > 42), 167 | NSExpression(format: "SUBQUERY(age, $x, $x > 42)")) 168 | } 169 | 170 | // UnaryIntegerExpression 171 | 172 | func testRandomN() { 173 | let age = Key("age") 174 | XCTAssertEqual( 175 | *randomn(age), 176 | NSExpression(format: "randomn(age)")) 177 | } 178 | 179 | func testComplement() { 180 | let age = Key("age") 181 | XCTAssertEqual( 182 | *(~age), 183 | NSExpression(format: "~age")) 184 | } 185 | 186 | // UnaryNumberExpression 187 | 188 | func testSqrt() { 189 | let age = Key("age") 190 | XCTAssertEqual( 191 | *sqrt(age), 192 | NSExpression(format: "sqrt(age)")) 193 | } 194 | 195 | func testLog() { 196 | let age = Key("age") 197 | XCTAssertEqual( 198 | *log(age), 199 | NSExpression(format: "log(age)")) 200 | } 201 | 202 | func testLn() { 203 | let age = Key("age") 204 | XCTAssertEqual( 205 | *ln(age), 206 | NSExpression(format: "ln(age)")) 207 | } 208 | 209 | func testExp() { 210 | let age = Key("age") 211 | XCTAssertEqual( 212 | *exp(age), 213 | NSExpression(format: "exp(age)")) 214 | } 215 | 216 | func testFloor() { 217 | let age = Key("age") 218 | XCTAssertEqual( 219 | *floor(age), 220 | NSExpression(format: "floor(age)")) 221 | } 222 | 223 | func testCeil() { 224 | let age = Key("age") 225 | XCTAssertEqual( 226 | *ceil(age), 227 | NSExpression(format: "ceiling(age)")) 228 | } 229 | 230 | func testAbs() { 231 | let age = Key("age") 232 | XCTAssertEqual( 233 | *abs(age), 234 | NSExpression(format: "abs(age)")) 235 | } 236 | 237 | func testTrunc() { 238 | let age = Key("age") 239 | XCTAssertEqual( 240 | *trunc(age), 241 | NSExpression(format: "trunc(age)")) 242 | } 243 | 244 | // UnarySequenceToNumberExpression 245 | 246 | func testSum() { 247 | let age = Key<[Int]>("age") 248 | XCTAssertEqual( 249 | *sum(age), 250 | NSExpression(format: "sum(age)")) 251 | } 252 | 253 | func testCount() { 254 | let age = Key<[Int]>("age") 255 | XCTAssertEqual( 256 | *count(age), 257 | NSExpression(format: "count(age)")) 258 | } 259 | 260 | func testMin() { 261 | let age = Key<[Int]>("age") 262 | XCTAssertEqual( 263 | *min(age), 264 | NSExpression(format: "min(age)")) 265 | } 266 | 267 | func testMax() { 268 | let age = Key<[Int]>("age") 269 | XCTAssertEqual( 270 | *max(age), 271 | NSExpression(format: "max(age)")) 272 | } 273 | 274 | func testAverage() { 275 | let age = Key<[Int]>("age") 276 | XCTAssertEqual( 277 | *average(age), 278 | NSExpression(format: "average(age)")) 279 | } 280 | 281 | func testMedian() { 282 | let age = Key<[Int]>("age") 283 | XCTAssertEqual( 284 | *median(age), 285 | NSExpression(format: "median(age)")) 286 | } 287 | 288 | func testMode() { 289 | let age = Key<[Int]>("age") 290 | XCTAssertEqual( 291 | *mode(age), 292 | NSExpression(format: "mode(age)")) 293 | } 294 | 295 | func testStddev() { 296 | let age = Key<[Int]>("age") 297 | XCTAssertEqual( 298 | *stddev(age), 299 | NSExpression(format: "stddev(age)")) 300 | } 301 | 302 | // UnaryStringExpression 303 | 304 | func testUppercase() { 305 | let age = Key("age") 306 | XCTAssertEqual( 307 | *uppercase(age), 308 | NSExpression(format: "uppercase(age)")) 309 | } 310 | 311 | func testLowercase() { 312 | let age = Key("age") 313 | XCTAssertEqual( 314 | *lowercase(age), 315 | NSExpression(format: "lowercase(age)")) 316 | } 317 | 318 | // UnaryStringToIntegerExpression 319 | 320 | func testLength() { 321 | let age = Key("age") 322 | XCTAssertEqual( 323 | *length(age), 324 | NSExpression(format: "length(age)")) 325 | } 326 | 327 | // UnionExpression 328 | 329 | func testUnion() { 330 | let age = Key>("age") 331 | let beauty = Key>("beauty") 332 | XCTAssertEqual( 333 | *(age | beauty), 334 | NSExpression(format:"age UNION beauty")) 335 | } 336 | } 337 | -------------------------------------------------------------------------------- /PredicatePalTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /PredicatePalTests/PredicateTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PredicatePalicateTests.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 8/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | import PredicatePal 12 | 13 | class PredicateTests: XCTestCase { 14 | 15 | // AndPredicate 16 | 17 | func testAnd2() { 18 | let age = Key("age") 19 | XCTAssertEqual( 20 | *(age > 21 && age < 42), 21 | NSPredicate(format: "age > 21 AND age < 42")) 22 | } 23 | 24 | func testAnd3() { 25 | let age = Key("age") 26 | XCTAssertEqual( 27 | *(age > 21 && age < 42 && age == 30), 28 | NSPredicate(format: "age > 21 AND age < 42 AND age == 30")) 29 | } 30 | 31 | 32 | // ComparisonPredicate 33 | 34 | func testLess() { 35 | let age = Key("age") 36 | XCTAssertEqual( 37 | *(age < 42), 38 | NSPredicate(format: "age < 42")) 39 | } 40 | 41 | func testLessEqual() { 42 | let age = Key("age") 43 | XCTAssertEqual( 44 | *(age <= 42), 45 | NSPredicate(format: "age <= 42")) 46 | } 47 | 48 | func testGreater() { 49 | let age = Key("age") 50 | XCTAssertEqual( 51 | *(age > 42), 52 | NSPredicate(format: "age > 42")) 53 | } 54 | 55 | func testGreaterEqual() { 56 | let age = Key("age") 57 | XCTAssertEqual( 58 | *(age >= 42), 59 | NSPredicate(format: "age >= 42")) 60 | } 61 | 62 | func testEqual() { 63 | let age = Key("age") 64 | XCTAssertEqual( 65 | *(age == 42), 66 | NSPredicate(format: "age == 42")) 67 | } 68 | 69 | func testNotEqual() { 70 | let age = Key("age") 71 | XCTAssertEqual( 72 | *(age != 42), 73 | NSPredicate(format: "age != 42")) 74 | } 75 | 76 | func testLessDate() { 77 | let age = Key("age") 78 | let now = NSDate() 79 | XCTAssertEqual( 80 | *(age < now), 81 | NSPredicate(format: "age < %@", now)) 82 | } 83 | 84 | func testLessEqualDate() { 85 | let age = Key("age") 86 | let now = NSDate() 87 | XCTAssertEqual( 88 | *(age <= now), 89 | NSPredicate(format: "age <= %@", now)) 90 | } 91 | 92 | func testGreaterDate() { 93 | let age = Key("age") 94 | let now = NSDate() 95 | XCTAssertEqual( 96 | *(age > now), 97 | NSPredicate(format: "age > %@", now)) 98 | } 99 | 100 | func testGreaterEqualDate() { 101 | let age = Key("age") 102 | let now = NSDate() 103 | XCTAssertEqual( 104 | *(age >= now), 105 | NSPredicate(format: "age >= %@", now)) 106 | } 107 | 108 | func testEqualDate() { 109 | let age = Key("age") 110 | let now = NSDate() 111 | XCTAssertEqual( 112 | *(age == now), 113 | NSPredicate(format: "age == %@", now)) 114 | } 115 | 116 | func testNotEqualDate() { 117 | let age = Key("age") 118 | let now = NSDate() 119 | XCTAssertEqual( 120 | *(age != now), 121 | NSPredicate(format: "age != %@", now)) 122 | } 123 | 124 | // NotPredicate 125 | 126 | func testNot() { 127 | let age = Key("age") 128 | XCTAssertEqual( 129 | *(!(age > 42)), 130 | NSPredicate(format: "!(age > 42)")) 131 | } 132 | 133 | // OrPredicate 134 | 135 | func testOr2() { 136 | let age = Key("age") 137 | XCTAssertEqual( 138 | *(age < 21 || age > 42), 139 | NSPredicate(format: "age < 21 OR age > 42")) 140 | } 141 | 142 | func testOr3() { 143 | let age = Key("age") 144 | XCTAssertEqual( 145 | *(age < 21 || age > 42 || age == 30), 146 | NSPredicate(format: "age < 21 OR age > 42 OR age == 30")) 147 | } 148 | 149 | // QuantifiedPredicate 150 | 151 | func testAll() { 152 | let age = Key("age") 153 | XCTAssertEqual( 154 | *all(age == 42), 155 | NSPredicate(format: "ALL age == 42")) 156 | } 157 | 158 | func testAny() { 159 | let age = Key("age") 160 | XCTAssertEqual( 161 | *any(age == 42), 162 | NSPredicate(format: "ANY age == 42")) 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /PredicatePalTests/TermTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TermTests.swift 3 | // PredicatePal 4 | // 5 | // Created by Glen Low on 21/12/2015. 6 | // Copyright © 2015 Glen Low. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | import PredicatePal 12 | 13 | class TermTests: XCTestCase { 14 | 15 | // AnyKey 16 | 17 | func testAnyKey() { 18 | let anyKey = AnyKey() 19 | 20 | XCTAssertEqual( 21 | *anyKey, 22 | NSExpression(format: "ANYKEY")) 23 | } 24 | 25 | // Block 26 | 27 | func testBlock() { 28 | let actualEvaluatedObject = "test" 29 | let actualBindings = ["a" : 1, "b" : 2] 30 | 31 | let predicate = *Block { $0 == actualEvaluatedObject && ($1 as NSDictionary).isEqual(actualBindings as NSDictionary) } 32 | 33 | XCTAssertTrue(predicate.evaluateWithObject(actualEvaluatedObject, substitutionVariables: actualBindings)) 34 | } 35 | 36 | // Boolean 37 | 38 | func testTrue() { 39 | XCTAssertEqual( 40 | *Boolean(true), 41 | NSPredicate(format: "TRUEPREDICATE")) 42 | } 43 | 44 | func testFalse() { 45 | XCTAssertEqual( 46 | *Boolean(false), 47 | NSPredicate(format: "FALSEPREDICATE")) 48 | } 49 | 50 | // Const 51 | 52 | func testConstInt() { 53 | XCTAssertEqual( 54 | *Const(42), 55 | NSExpression(format: "42")) 56 | } 57 | 58 | func testConstString() { 59 | XCTAssertEqual( 60 | *Const("hey"), 61 | NSExpression(format: "\"hey\"")) 62 | } 63 | 64 | // Key 65 | 66 | func testKey() { 67 | let age = Key("age") 68 | XCTAssertEqual( 69 | *age, 70 | NSExpression(format: "age")) 71 | } 72 | 73 | // This 74 | 75 | func testThis() { 76 | let this = This() 77 | XCTAssertEqual( 78 | *this, 79 | NSExpression(format: "SELF")); 80 | } 81 | 82 | // Var 83 | 84 | func testVar() { 85 | let age = Var("age") 86 | XCTAssertEqual( 87 | *age, 88 | NSExpression(format: "$age")) 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/pixelglow/PredicatePal.svg)](https://travis-ci.org/pixelglow/PredicatePal) 2 | 3 | **PredicatePal** is a Swift DSL for building `NSPredicate` objects. 4 | 5 | `NSPredicate` is a Foundation class that specifies how data should be fetched or filtered. The class is an integral part of many other system frameworks such as CloudKit, CoreData, Contacts, EventKit and HealthKit. Its query language is expressive and natural, but since it's typically built by a runtime parser, it can be hard to figure out and slow to build. 6 | 7 | **PredicatePal** replaces this query language with a compile-time DSL. Using the magic of Swift generics and operator overloading, this framework: 8 | 9 | * **Checks syntax at compile time.** No more crashes with query syntax errors, get Xcode autocompletion and Quick Help on your side! 10 | * **Prevents type errors.** Can't combine expressions of incompatible types. 11 | * **Plugs into the type system.** Mix and match `NSPredicate` terms with Swift constants and expressions. 12 | * **Runs fast.** 2x the speed of the runtime parser. 13 | * **Has unit tests.** 14 | 15 | Install 16 | ------- 17 | 18 | As an independent project: 19 | 20 | * In the Terminal, run `git clone https://github.com/pixelglow/PredicatePal.git`. 21 | * Within the *PredicatePal* directory, open the *PredicatePal.xcodeproj* Xcode project. 22 | * In the Xcode project, select either the *PredicatePal (iOS)*, *PredicatePal (OS X)* or *PredicatePal (tvOS)* scheme from the drop down. 23 | * You can now build, test (OS X only) or analyze with the selected scheme. 24 | * The built frameworks and test cases are in a subdirectory of *~/Library/Developer/Xcode/DerivedData*. 25 | 26 | As a project integrated with your own workspace: 27 | 28 | * In the Terminal, run `cd workspace` then `git submodule add https://github.com/pixelglow/PredicatePal.git`. 29 | * In your Xcode workspace, choose the *File > Add Files to "workspace"* menu item, then within the *PredicatePal* subdirectory pick the *PredicatePal.xcodeproj* Xcode project. 30 | * Build the *PredicatePal* project at least once. 31 | * In any project target that will use *PredicatePal*: 32 | * In *General > Embedded Binaries*, click on + and add the *PredicatePal.framework* corresponding to your target OS. The framework should appear in both *Embedded Binaries* and *Linked Frameworks and Libraries*. 33 | * You can now build, test or analyze those project targets. 34 | 35 | Using [Carthage](https://github.com/Carthage/Carthage): 36 | 37 | * In your `Cartfile`, specify `github "pixelglow/PredicatePal"`. 38 | * Run `carthage update` to build. 39 | 40 | Use 41 | --- 42 | 43 | Import: 44 | 45 | import PredicatePal 46 | 47 | Build an `NSPredicate`: 48 | 49 | let age: Key("age") 50 | let predicate = *(age < 21 || age > 42) // NSPredicate(format:"age < 21 OR age > 42") 51 | 52 | Getting started: [Tutorial](https://github.com/pixelglow/PredicatePal/wiki/Tutorial) 53 | 54 | Full syntax guide: [Syntax](https://github.com/pixelglow/PredicatePal/wiki/Syntax) 55 | 56 | Require 57 | ------- 58 | 59 | * **Build**: Xcode 7 and later. 60 | * **Link**: Only system libraries; no third-party libraries needed. 61 | * *CoreLocation.framework* 62 | * *Foundation.framework* 63 | * **Run**: Mac OS X 10.10 (Yosemite) or iOS 8.0 and later. 64 | 65 | Support 66 | ------- 67 | 68 | * Follow us on Twitter: [@pixelglow](http://twitter.com/pixelglow). 69 | * Raise an issue on [PredicatePal issues](https://github.com/pixelglow/PredicatePal/issues). 70 | 71 | License 72 | ------- 73 | 74 | *PredicatePal* is licensed with the BSD license. 75 | 76 | Donate 77 | ------ 78 | 79 | * Tip with [ChangeTip](http://pixelglow.tip.me). 80 | 81 | 82 | --------------------------------------------------------------------------------