home *** CD-ROM | disk | FTP | other *** search
- // EOExpressionArray.h
- // Copyright (c) 1994, NeXT Computer, Inc. All rights reserved.
-
- #import <foundation/NSArray.h>
- #import <foundation/NSData.h>
- #import <foundation/NSDictionary.h>
- #import <foundation/NSObject.h>
- #import <foundation/NSString.h>
-
- #import <objc/Object.h>
-
- @class EOAttribute;
- @class EOExpressionArray;
-
-
- @protocol EOExpressionContext <NSObject>
-
- - (NSString *)expressionValueForAttribute:(EOAttribute *)anAttribute;
- // Does the appropriate aliasing and name generation for an attribute in
- // the context of this particular query.
-
- - (NSString *)expressionValueForAttributePath:(EOExpressionArray *)path;
- // Returns an attribute name complete with alias for an attribute path.
- // An attribute path is an array that consists of any number of
- // relationships followed by an attribute.
-
- @end
-
- // An EOExpressionArray is an array that composes query expressions from
- // the expression values of its elements, prepending its prefix, inserting
- // its infix between values and appending its suffix. For example, if an
- // array contains the string objects "toAuthor", "toPublisher", "address",
- // and has "(", ".", and ")" as its prefix, infix, and suffix, its
- // expression value would be "(toAuthor.toPublisher.address)".
- //
- // This class is used internally by the Framework; you should never need to
- // create or use one yourself.
-
- @interface EOExpressionArray:NSMutableArray <NSCopying>
- {
- NSString *_prefix;
- NSString *_infix;
- NSString *_suffix;
- NSMutableArray *_array;
- }
-
- - initWithPrefix:(NSString *)prefix
- infix:(NSString *)infix
- suffix:(NSString *)suffix;
- // Initializes a newly allocated EOExpressionArray to contain no objects and to use the given prefix, infix, and suffix.
-
- - (void)setPrefix:(NSString *)prefix;
- - (NSString *)prefix;
- - (void)setInfix:(NSString *)infix;
- - (NSString *)infix;
- - (void)setSuffix:(NSString *)suffix;
- - (NSString *)suffix;
- // These methods set/return the prefix, infix, or suffix string.
-
- - (BOOL)referencesObject:object;
- // Returns YES if the receiver contains object or if any EOExpressionArray
- // contained by the receiver contains object. Pointer equality, NOT
- // -isEqual: is used to compare objects.
-
- @end
-
-
- // This category defaults expressionValue to -stringValue for all objects.
- // This allows the use of many standard Application Kit objects with
- // EOExpressionArray.
- @interface Object (EOExpression)
-
- - (NSString *)expressionValueForContext:(id <EOExpressionContext>)context;
- // If the receiver responds to -stringValue, returns that as an NSString;
- // otherwise returns nil.
-
- @end
-
-
- // This category provides the same defaulting for foundation objects.
-
- @interface NSObject(EOExpression)
-
- - (NSString *)expressionValueForContext:(id <EOExpressionContext>)context;
- // If the receiver responds to -stringValue, returns that as an NSString;
- // otherwise returns nil.
-
- @end
-
-
- // This category allows strings to conform to the EOExpression protocol
-
- @interface NSString(EOExpression)
-
- - (NSString *)expressionValueForContext:(id <EOExpressionContext>)context;
- // Returns an immutable version of the receiver.
-
- @end
-