/* NSComparisonPredicate.h Copyright (c) 2004-2012, Apple Inc. All rights reserved. */ #import // Flags(s) that can be passed to the factory to indicate that a operator operating on strings should do so in a case insensitive fashion. typedef NS_OPTIONS(NSUInteger, NSComparisonPredicateOptions) { NSCaseInsensitivePredicateOption = 0x01, NSDiacriticInsensitivePredicateOption = 0x02, NSNormalizedPredicateOption NS_ENUM_AVAILABLE(10_6, 4_0) = 0x04, /* Indicate that the strings to be compared have been preprocessed; this supersedes other options and is intended as a performance optimization option */ }; // Describes how the operator is modified: can be direct, ALL, or ANY typedef NS_ENUM(NSUInteger, NSComparisonPredicateModifier) { NSDirectPredicateModifier = 0, // Do a direct comparison NSAllPredicateModifier, // ALL toMany.x = y NSAnyPredicateModifier // ANY toMany.x = y }; // Type basic set of operators defined. Most are obvious; NSCustomSelectorPredicateOperatorType allows a developer to create an operator which uses the custom selector specified in the constructor to do the evaluation. typedef NS_ENUM(NSUInteger, NSPredicateOperatorType) { NSLessThanPredicateOperatorType = 0, // compare: returns NSOrderedAscending NSLessThanOrEqualToPredicateOperatorType, // compare: returns NSOrderedAscending || NSOrderedSame NSGreaterThanPredicateOperatorType, // compare: returns NSOrderedDescending NSGreaterThanOrEqualToPredicateOperatorType, // compare: returns NSOrderedDescending || NSOrderedSame NSEqualToPredicateOperatorType, // isEqual: returns true NSNotEqualToPredicateOperatorType, // isEqual: returns false NSMatchesPredicateOperatorType, NSLikePredicateOperatorType, NSBeginsWithPredicateOperatorType, NSEndsWithPredicateOperatorType, NSInPredicateOperatorType, // rhs contains lhs returns true NSCustomSelectorPredicateOperatorType, NSContainsPredicateOperatorType NS_ENUM_AVAILABLE(10_5, 3_0) = 99, // lhs contains rhs returns true NSBetweenPredicateOperatorType NS_ENUM_AVAILABLE(10_5, 3_0) }; @class NSPredicateOperator; @class NSExpression; // Comparison predicates are predicates which do some form of comparison between the results of two expressions and return a BOOL. They take an operator, a left expression, and a right expression, and return the result of invoking the operator with the results of evaluating the expressions. NS_CLASS_AVAILABLE(10_4, 3_0) @interface NSComparisonPredicate : NSPredicate { @private void *_reserved2; NSPredicateOperator *_predicateOperator; NSExpression *_lhs; NSExpression *_rhs; } + (NSPredicate *)predicateWithLeftExpression:(NSExpression *)lhs rightExpression:(NSExpression *)rhs modifier:(NSComparisonPredicateModifier)modifier type:(NSPredicateOperatorType)type options:(NSComparisonPredicateOptions)options; + (NSPredicate *)predicateWithLeftExpression:(NSExpression *)lhs rightExpression:(NSExpression *)rhs customSelector:(SEL)selector; - (id)initWithLeftExpression:(NSExpression *)lhs rightExpression:(NSExpression *)rhs modifier:(NSComparisonPredicateModifier)modifier type:(NSPredicateOperatorType)type options:(NSComparisonPredicateOptions)options; - (id)initWithLeftExpression:(NSExpression *)lhs rightExpression:(NSExpression *)rhs customSelector:(SEL)selector; - (NSPredicateOperatorType)predicateOperatorType; - (NSComparisonPredicateModifier)comparisonPredicateModifier; - (NSExpression *)leftExpression; - (NSExpression *)rightExpression; - (SEL)customSelector; - (NSComparisonPredicateOptions)options; @end