mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Basic implementation of NSPredicate and related classes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22880 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
490475dd98
commit
43e4029a29
9 changed files with 2149 additions and 1 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2006-05-09 Dr. H. Nikolaus Schaller
|
||||
|
||||
* Source/GNUmakefile:
|
||||
* Source/NSPredicate.m:
|
||||
* Headers/Foundation/NSCompoundPredicate.h:
|
||||
* Headers/Foundation/NSComparisonPredicate.h:
|
||||
* Headers/Foundation/NSPredicate.h:
|
||||
* Headers/Foundation/NSExpression.h:
|
||||
* Headers/Foundation/Foundation.h:
|
||||
Basic implementation of NSPredicate and related classes.
|
||||
|
||||
2006-05-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* configure.ac: Check for bfd stuff for stacktrace support.
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this library; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02111 USA
|
||||
#
|
||||
|
||||
# This usually happens when you source GNUstep.sh, then run ./configure,
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
#include <Foundation/NSCharacterSet.h>
|
||||
#include <Foundation/NSClassDescription.h>
|
||||
#include <Foundation/NSCoder.h>
|
||||
#include <Foundation/NSComparisonPredicate.h>
|
||||
#include <Foundation/NSCompoundPredicate.h>
|
||||
#include <Foundation/NSConnection.h>
|
||||
#include <Foundation/NSDate.h>
|
||||
#include <Foundation/NSDateFormatter.h>
|
||||
|
@ -53,6 +55,7 @@
|
|||
#include <Foundation/NSEnumerator.h>
|
||||
#include <Foundation/NSError.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSExpression.h>
|
||||
#include <Foundation/NSFileHandle.h>
|
||||
#include <Foundation/NSFileManager.h>
|
||||
#include <Foundation/NSFormatter.h>
|
||||
|
@ -75,6 +78,7 @@
|
|||
#include <Foundation/NSPortCoder.h>
|
||||
#include <Foundation/NSPortMessage.h>
|
||||
#include <Foundation/NSPortNameServer.h>
|
||||
#include <Foundation/NSPredicate.h>
|
||||
#include <Foundation/NSProcessInfo.h>
|
||||
#include <Foundation/NSProtocolChecker.h>
|
||||
#include <Foundation/NSProxy.h>
|
||||
|
|
97
Headers/Foundation/NSComparisonPredicate.h
Normal file
97
Headers/Foundation/NSComparisonPredicate.h
Normal file
|
@ -0,0 +1,97 @@
|
|||
/* Interface for NSComparisonPredicate for GNUStep
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Dr. H. Nikolaus Schaller
|
||||
Created: 2005
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef __NSComparisonPredicate_h_GNUSTEP_BASE_INCLUDE
|
||||
#define __NSComparisonPredicate_h_GNUSTEP_BASE_INCLUDE
|
||||
|
||||
#include <Foundation/NSExpression.h>
|
||||
#include <Foundation/NSPredicate.h>
|
||||
|
||||
typedef enum _NSComparisonPredicateModifier
|
||||
{
|
||||
NSDirectPredicateModifier=0,
|
||||
NSAllPredicateModifier,
|
||||
NSAnyPredicateModifier,
|
||||
} NSComparisonPredicateModifier;
|
||||
|
||||
typedef enum _NSComparisonPredicateOptions
|
||||
{
|
||||
NSCaseInsensitivePredicateOption=0x01,
|
||||
NSDiacriticInsensitivePredicateOption=0x02,
|
||||
} NSComparisonPredicateOptions;
|
||||
|
||||
typedef enum _NSPredicateOperatorType
|
||||
{
|
||||
NSLessThanPredicateOperatorType = 0,
|
||||
NSLessThanOrEqualToPredicateOperatorType,
|
||||
NSGreaterThanPredicateOperatorType,
|
||||
NSGreaterThanOrEqualToPredicateOperatorType,
|
||||
NSEqualToPredicateOperatorType,
|
||||
NSNotEqualToPredicateOperatorType,
|
||||
NSMatchesPredicateOperatorType,
|
||||
NSLikePredicateOperatorType,
|
||||
NSBeginsWithPredicateOperatorType,
|
||||
NSEndsWithPredicateOperatorType,
|
||||
NSInPredicateOperatorType,
|
||||
NSCustomSelectorPredicateOperatorType
|
||||
} NSPredicateOperatorType;
|
||||
|
||||
@interface NSComparisonPredicate : NSPredicate
|
||||
{
|
||||
NSComparisonPredicateModifier _modifier;
|
||||
SEL _selector;
|
||||
unsigned _options;
|
||||
NSPredicateOperatorType _type;
|
||||
@public
|
||||
NSExpression *_left;
|
||||
NSExpression *_right;
|
||||
}
|
||||
|
||||
+ (NSPredicate *) predicateWithLeftExpression: (NSExpression *)left
|
||||
rightExpression: (NSExpression *)right
|
||||
customSelector: (SEL)sel;
|
||||
+ (NSPredicate *) predicateWithLeftExpression: (NSExpression *)left
|
||||
rightExpression: (NSExpression *)right
|
||||
modifier: (NSComparisonPredicateModifier)modifier
|
||||
type: (NSPredicateOperatorType)type
|
||||
options: (unsigned) opts;
|
||||
|
||||
- (NSComparisonPredicateModifier) comparisonPredicateModifier;
|
||||
- (SEL) customSelector;
|
||||
- (NSPredicate *) initWithLeftExpression: (NSExpression *)left
|
||||
rightExpression: (NSExpression *)right
|
||||
customSelector: (SEL)sel;
|
||||
- (id) initWithLeftExpression: (NSExpression *)left
|
||||
rightExpression: (NSExpression *)right
|
||||
modifier: (NSComparisonPredicateModifier)modifier
|
||||
type: (NSPredicateOperatorType)type
|
||||
options: (unsigned) opts;
|
||||
- (NSExpression *) leftExpression;
|
||||
- (unsigned) options;
|
||||
- (NSPredicateOperatorType) predicateOperatorType;
|
||||
- (NSExpression *) rightExpression;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
50
Headers/Foundation/NSCompoundPredicate.h
Normal file
50
Headers/Foundation/NSCompoundPredicate.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* Interface for NSCompoundPredicate for GNUStep
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Dr. H. Nikolaus Schaller
|
||||
Created: 2005
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef __NSCompoundPredicate_h_GNUSTEP_BASE_INCLUDE
|
||||
#define __NSCompoundPredicate_h_GNUSTEP_BASE_INCLUDE
|
||||
|
||||
#include <Foundation/NSPredicate.h>
|
||||
|
||||
typedef enum _NSCompoundPredicateType
|
||||
{
|
||||
NSNotPredicateType = 0,
|
||||
NSAndPredicateType,
|
||||
NSOrPredicateType
|
||||
} NSCompoundPredicateType;
|
||||
|
||||
@interface NSCompoundPredicate : NSPredicate
|
||||
|
||||
+ (NSPredicate *) andPredicateWithSubpredicates: (NSArray *)list;
|
||||
+ (NSPredicate *) notPredicateWithSubpredicate: (NSPredicate *)predicate;
|
||||
+ (NSPredicate *) orPredicateWithSubpredicates: (NSArray *)list;
|
||||
|
||||
- (NSCompoundPredicateType) compoundPredicateType;
|
||||
- (id) initWithType: (NSCompoundPredicateType)type
|
||||
subpredicates: (NSArray *)list;
|
||||
- (NSArray *) subpredicates;
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
63
Headers/Foundation/NSExpression.h
Normal file
63
Headers/Foundation/NSExpression.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* Interface for NSExpression for GNUStep
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Dr. H. Nikolaus Schaller
|
||||
Created: 2005
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef __NSExpression_h_GNUSTEP_BASE_INCLUDE
|
||||
#define __NSExpression_h_GNUSTEP_BASE_INCLUDE
|
||||
|
||||
#include <Foundation/NSPredicate.h>
|
||||
|
||||
@class NSMutableDictionary;
|
||||
|
||||
typedef enum _NSExpressionType
|
||||
{
|
||||
NSConstantValueExpressionType=0,
|
||||
NSEvaluatedObjectExpressionType,
|
||||
NSVariableExpressionType,
|
||||
NSKeyPathExpressionType,
|
||||
NSFunctionExpressionType
|
||||
} NSExpressionType;
|
||||
|
||||
@interface NSExpression : NSObject <NSCoding, NSCopying>
|
||||
|
||||
+ (NSExpression *) expressionForConstantValue: (id)obj;
|
||||
+ (NSExpression *) expressionForEvaluatedObject;
|
||||
+ (NSExpression *) expressionForFunction: (NSString *)name
|
||||
arguments: (NSArray *)args;
|
||||
+ (NSExpression *) expressionForKeyPath: (NSString *)path;
|
||||
+ (NSExpression *) expressionForVariable: (NSString *)string;
|
||||
|
||||
- (NSArray *) arguments;
|
||||
- (id) constantValue;
|
||||
- (NSExpressionType) expressionType;
|
||||
- (id) expressionValueWithObject: (id)object
|
||||
context: (NSMutableDictionary *)context;
|
||||
- (NSString *) function;
|
||||
- (id) initWithExpressionType: (NSExpressionType) type;
|
||||
- (NSString *) keyPath;
|
||||
- (NSExpression *) operand;
|
||||
- (NSString *) variable;
|
||||
|
||||
@end
|
||||
#endif /* __NSExpression_h_GNUSTEP_BASE_INCLUDE */
|
||||
|
50
Headers/Foundation/NSPredicate.h
Normal file
50
Headers/Foundation/NSPredicate.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* Interface for NSPredicate for GNUStep
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Dr. H. Nikolaus Schaller
|
||||
Created: 2005
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef __NSPredicate_h_GNUSTEP_BASE_INCLUDE
|
||||
#define __NSPredicate_h_GNUSTEP_BASE_INCLUDE
|
||||
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
|
||||
@interface NSPredicate : NSObject <NSCoding, NSCopying>
|
||||
|
||||
+ (NSPredicate *) predicateWithFormat: (NSString *)format, ...;
|
||||
+ (NSPredicate *) predicateWithFormat: (NSString *)format
|
||||
argumentArray: (NSArray *)args;
|
||||
+ (NSPredicate *) predicateWithFormat: (NSString *)format
|
||||
arguments: (va_list)args;
|
||||
+ (NSPredicate *) predicateWithValue: (BOOL)value;
|
||||
|
||||
- (BOOL) evaluateWithObject: (id)object;
|
||||
- (NSString *) predicateFormat;
|
||||
- (NSPredicate *) predicateWithSubstitutionVariables: (NSDictionary *)variables;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSArray (NSPredicate)
|
||||
- (NSArray *) filteredArrayUsingPredicate: (NSPredicate *)predicate;
|
||||
@end
|
||||
|
||||
#endif /* __NSPredicate_h_GNUSTEP_BASE_INCLUDE */
|
|
@ -202,6 +202,7 @@ NSPort.m \
|
|||
NSPortCoder.m \
|
||||
NSPortMessage.m \
|
||||
NSPortNameServer.m \
|
||||
NSPredicate.m \
|
||||
NSProcessInfo.m \
|
||||
NSPropertyList.m \
|
||||
NSProtocolChecker.m \
|
||||
|
@ -279,6 +280,8 @@ NSCalendarDate.h \
|
|||
NSCharacterSet.h \
|
||||
NSClassDescription.h \
|
||||
NSCoder.h \
|
||||
NSComparisonPredicate.h \
|
||||
NSCompoundPredicate.h \
|
||||
NSConnection.h \
|
||||
NSData.h \
|
||||
NSDate.h \
|
||||
|
@ -293,6 +296,7 @@ NSDistributedNotificationCenter.h \
|
|||
NSEnumerator.h \
|
||||
NSError.h \
|
||||
NSException.h \
|
||||
NSExpression.h \
|
||||
NSFileHandle.h \
|
||||
NSFileManager.h \
|
||||
NSFormatter.h \
|
||||
|
@ -319,6 +323,7 @@ NSPort.h \
|
|||
NSPortCoder.h \
|
||||
NSPortMessage.h \
|
||||
NSPortNameServer.h \
|
||||
NSPredicate.h \
|
||||
NSProcessInfo.h \
|
||||
NSPropertyList.h \
|
||||
NSProtocolChecker.h \
|
||||
|
|
1867
Source/NSPredicate.m
Normal file
1867
Source/NSPredicate.m
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue