From 7a001c0aa03a388d050e6a06b60e189fab3842af Mon Sep 17 00:00:00 2001 From: helge Date: Thu, 4 Aug 2005 13:21:22 +0000 Subject: [PATCH] added EOKeyValueArchiving to fetch-spec and qualifier classes git-svn-id: http://svn.opengroupware.org/SOPE/trunk@968 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-core/EOControl/ChangeLog | 10 ++++++ sope-core/EOControl/EOAndQualifier.m | 14 ++++++++ sope-core/EOControl/EOFetchSpecification.m | 34 +++++++++++++++++++ .../EOControl/EOKeyComparisonQualifier.m | 31 +++++++++++++++++ sope-core/EOControl/EOKeyValueQualifier.m | 31 +++++++++++++++++ sope-core/EOControl/EONotQualifier.m | 13 +++++++ sope-core/EOControl/EOOrQualifier.m | 14 ++++++++ sope-core/EOControl/EOQualifier.h | 7 ++-- sope-core/EOControl/EOQualifier.m | 14 +++++--- sope-core/EOControl/EOQualifierVariable.m | 12 +++++++ sope-core/EOControl/EOSortOrdering.h | 3 +- sope-core/EOControl/EOSortOrdering.m | 16 +++++++++ sope-core/EOControl/NSObject+EOQualifierOps.m | 4 +-- sope-core/EOControl/Version | 2 +- 14 files changed, 194 insertions(+), 11 deletions(-) diff --git a/sope-core/EOControl/ChangeLog b/sope-core/EOControl/ChangeLog index dcfcc871..8b94d3a0 100644 --- a/sope-core/EOControl/ChangeLog +++ b/sope-core/EOControl/ChangeLog @@ -1,3 +1,13 @@ +2005-08-04 Helge Hess + + * v4.5.55 + + * EOSortOrdering.m, EOFetchSpecification.m: added EOKeyValueArchiving + + * EO*Qualifier.m: added EOKeyValueArchiving to EOQualifier classes + + * NSObject+EOQualifierOps.m: fixed gcc 4.0 warnings + 2005-08-04 Helge Hess * EOKeyValueArchiver.m: process class names containing a dot by diff --git a/sope-core/EOControl/EOAndQualifier.m b/sope-core/EOControl/EOAndQualifier.m index f56b1af4..558b5cf0 100644 --- a/sope-core/EOControl/EOAndQualifier.m +++ b/sope-core/EOControl/EOAndQualifier.m @@ -264,6 +264,20 @@ static BOOL debugTransform = NO; return [aq autorelease]; } +/* key/value archiving */ + +- (id)initWithKeyValueUnarchiver:(EOKeyValueUnarchiver *)_unarchiver { + if ((self = [super initWithKeyValueUnarchiver:_unarchiver]) != nil) { + self->qualifiers = [[_unarchiver decodeObjectForKey:@"qualifiers"] copy]; + self->count = [self->qualifiers count]; + } + return self; +} +- (void)encodeWithKeyValueArchiver:(EOKeyValueArchiver *)_archiver { + [super encodeWithKeyValueArchiver:_archiver]; + [_archiver encodeObject:[self qualifiers] forKey:@"qualifiers"]; +} + /* description */ - (NSString *)description { diff --git a/sope-core/EOControl/EOFetchSpecification.m b/sope-core/EOControl/EOFetchSpecification.m index b4e3fcc6..78614c1f 100644 --- a/sope-core/EOControl/EOFetchSpecification.m +++ b/sope-core/EOControl/EOFetchSpecification.m @@ -333,6 +333,40 @@ return [fs autorelease]; } +/* key/value archiving */ + +- (id)initWithKeyValueUnarchiver:(EOKeyValueUnarchiver *)_unarchiver { + if ((self = [super init]) != nil) { + self->entityName = [[_unarchiver decodeObjectForKey:@"entityName"] copy]; + self->qualifier = [[_unarchiver decodeObjectForKey:@"qualifier"] retain]; + self->hints = [[_unarchiver decodeObjectForKey:@"hints"] copy]; + self->sortOrderings = + [[_unarchiver decodeObjectForKey:@"sortOrderings"] retain]; + + self->fetchLimit = [_unarchiver decodeIntForKey:@"fetchLimit"]; + + self->fsFlags.usesDistinct = + [_unarchiver decodeBoolForKey:@"usesDistinct"] ? 1 : 0; + self->fsFlags.locksObjects = + [_unarchiver decodeBoolForKey:@"locksObjects"] ? 1 : 0; + self->fsFlags.deep = + [_unarchiver decodeBoolForKey:@"deep"] ? 1 : 0; + } + return self; +} +- (void)encodeWithKeyValueArchiver:(EOKeyValueArchiver *)_archiver { + [_archiver encodeObject:[self entityName] forKey:@"entityName"]; + [_archiver encodeObject:[self qualifier] forKey:@"qualifier"]; + [_archiver encodeObject:[self hints] forKey:@"hints"]; + [_archiver encodeObject:[self sortOrderings] forKey:@"sortOrderings"]; + + [_archiver encodeInt:[self fetchLimit] forKey:@"fetchLimit"]; + + [_archiver encodeBool:self->fsFlags.usesDistinct forKey:@"usesDistinct"]; + [_archiver encodeBool:self->fsFlags.locksObjects forKey:@"locksObjects"]; + [_archiver encodeBool:self->fsFlags.deep forKey:@"deep"]; +} + /* description */ - (NSString *)description { diff --git a/sope-core/EOControl/EOKeyComparisonQualifier.m b/sope-core/EOControl/EOKeyComparisonQualifier.m index 1c6ba9e8..91e5af88 100644 --- a/sope-core/EOControl/EOKeyComparisonQualifier.m +++ b/sope-core/EOControl/EOKeyComparisonQualifier.m @@ -232,6 +232,37 @@ static EONull *null = nil; return [kcq autorelease]; } +/* key/value archiving */ + +- (id)initWithKeyValueUnarchiver:(EOKeyValueUnarchiver *)_unarchiver { + if ((self = [super initWithKeyValueUnarchiver:_unarchiver]) != nil) { + NSString *s; + + self->leftKey = [[_unarchiver decodeObjectForKey:@"leftKey"] retain]; + self->rightKey = [[_unarchiver decodeObjectForKey:@"rightKey"] retain]; + + if ((s = [_unarchiver decodeObjectForKey:@"selectorName"]) != nil) { + if (![s hasSuffix:@":"]) s = [s stringByAppendingString:@":"]; + self->operator = NSSelectorFromString(s); + } + else if ((s = [_unarchiver decodeObjectForKey:@"selector"]) != nil) + self->operator = NSSelectorFromString(s); + } + return self; +} +- (void)encodeWithKeyValueArchiver:(EOKeyValueArchiver *)_archiver { + NSString *s; + + [super encodeWithKeyValueArchiver:_archiver]; + + [_archiver encodeObject:[self leftKey] forKey:@"leftKey"]; + [_archiver encodeObject:[self rightKey] forKey:@"rightKey"]; + + s = NSStringFromSelector([self selector]); + if ([s hasSuffix:@":"]) s = [s substringToIndex:[s length] - 1]; + [_archiver encodeObject:s forKey:@"selectorName"]; +} + /* description */ - (NSString *)description { diff --git a/sope-core/EOControl/EOKeyValueQualifier.m b/sope-core/EOControl/EOKeyValueQualifier.m index 93d3aac8..fd19cf62 100644 --- a/sope-core/EOControl/EOKeyValueQualifier.m +++ b/sope-core/EOControl/EOKeyValueQualifier.m @@ -246,6 +246,37 @@ static EONull *null = nil; return [kvq autorelease]; } +/* key/value archiving */ + +- (id)initWithKeyValueUnarchiver:(EOKeyValueUnarchiver *)_unarchiver { + if ((self = [super initWithKeyValueUnarchiver:_unarchiver]) != nil) { + NSString *s; + + self->key = [[_unarchiver decodeObjectForKey:@"key"] copy]; + self->value = [[_unarchiver decodeObjectForKey:@"value"] retain]; + + if ((s = [_unarchiver decodeObjectForKey:@"selectorName"]) != nil) { + if (![s hasSuffix:@":"]) s = [s stringByAppendingString:@":"]; + self->operator = NSSelectorFromString(s); + } + else if ((s = [_unarchiver decodeObjectForKey:@"selector"]) != nil) + self->operator = NSSelectorFromString(s); + } + return self; +} +- (void)encodeWithKeyValueArchiver:(EOKeyValueArchiver *)_archiver { + NSString *s; + + [super encodeWithKeyValueArchiver:_archiver]; + + [_archiver encodeObject:[self key] forKey:@"key"]; + [_archiver encodeObject:[self value] forKey:@"value"]; + + s = NSStringFromSelector([self selector]); + if ([s hasSuffix:@":"]) s = [s substringToIndex:[s length] - 1]; + [_archiver encodeObject:s forKey:@"selectorName"]; +} + /* description */ - (NSString *)description { diff --git a/sope-core/EOControl/EONotQualifier.m b/sope-core/EOControl/EONotQualifier.m index a33d8d6a..b56b54b0 100644 --- a/sope-core/EOControl/EONotQualifier.m +++ b/sope-core/EOControl/EONotQualifier.m @@ -141,6 +141,19 @@ return [nq autorelease]; } +/* key/value archiving */ + +- (id)initWithKeyValueUnarchiver:(EOKeyValueUnarchiver *)_unarchiver { + if ((self = [super initWithKeyValueUnarchiver:_unarchiver]) != nil) { + self->qualifier = [[_unarchiver decodeObjectForKey:@"qualifier"] copy]; + } + return self; +} +- (void)encodeWithKeyValueArchiver:(EOKeyValueArchiver *)_archiver { + [super encodeWithKeyValueArchiver:_archiver]; + [_archiver encodeObject:[self qualifier] forKey:@"qualifier"]; +} + /* description */ - (NSString *)description { diff --git a/sope-core/EOControl/EOOrQualifier.m b/sope-core/EOControl/EOOrQualifier.m index d8e96a3b..8cb1b70c 100644 --- a/sope-core/EOControl/EOOrQualifier.m +++ b/sope-core/EOControl/EOOrQualifier.m @@ -251,6 +251,20 @@ static BOOL debugTransform = NO; return [aq autorelease]; } +/* key/value archiving */ + +- (id)initWithKeyValueUnarchiver:(EOKeyValueUnarchiver *)_unarchiver { + if ((self = [super initWithKeyValueUnarchiver:_unarchiver]) != nil) { + self->qualifiers = [[_unarchiver decodeObjectForKey:@"qualifiers"] copy]; + self->count = [self->qualifiers count]; + } + return self; +} +- (void)encodeWithKeyValueArchiver:(EOKeyValueArchiver *)_archiver { + [super encodeWithKeyValueArchiver:_archiver]; + [_archiver encodeObject:[self qualifiers] forKey:@"qualifiers"]; +} + /* description */ - (NSString *)description { diff --git a/sope-core/EOControl/EOQualifier.h b/sope-core/EOControl/EOQualifier.h index 6581999d..de5f12a3 100644 --- a/sope-core/EOControl/EOQualifier.h +++ b/sope-core/EOControl/EOQualifier.h @@ -22,7 +22,8 @@ #ifndef __EOQualifier_h__ #define __EOQualifier_h__ -#import +#import +#include /* EOQualifier @@ -53,7 +54,7 @@ - (BOOL)evaluateWithObject:(id)_object; @end -@interface EOQualifier : NSObject +@interface EOQualifier : NSObject < EOKeyValueArchiving > + (EOQualifier *)qualifierToMatchAnyValue:(NSDictionary *)_values; + (EOQualifier *)qualifierToMatchAllValues:(NSDictionary *)_values; @@ -199,7 +200,7 @@ extern SEL EOQualifierOperatorCaseInsensitiveLike; /* variable qualifier content */ -@interface EOQualifierVariable : NSObject < NSCoding > +@interface EOQualifierVariable : NSObject < NSCoding, EOKeyValueArchiving > { NSString *varKey; } diff --git a/sope-core/EOControl/EOQualifier.m b/sope-core/EOControl/EOQualifier.m index 7f352053..23c96daf 100644 --- a/sope-core/EOControl/EOQualifier.m +++ b/sope-core/EOControl/EOQualifier.m @@ -244,12 +244,18 @@ static EONull *null = nil; return evalDebug ? YES : NO; } -@end /* EOQualifier */ - -@implementation EOQualifier(QuickEval) +/* QuickEval */ - (BOOL)evaluateWithObject:(id)_object inEvalContext:(id)_ctx { return [(id)self evaluateWithObject:_object]; } -@end /* EOQualifier(QuickEval) */ +/* key/value archiving */ + +- (id)initWithKeyValueUnarchiver:(EOKeyValueUnarchiver *)_unarchiver { + return [super init]; +} +- (void)encodeWithKeyValueArchiver:(EOKeyValueArchiver *)_archiver { +} + +@end /* EOQualifier */ diff --git a/sope-core/EOControl/EOQualifierVariable.m b/sope-core/EOControl/EOQualifierVariable.m index 71d1dd59..fe5a69d5 100644 --- a/sope-core/EOControl/EOQualifierVariable.m +++ b/sope-core/EOControl/EOQualifierVariable.m @@ -70,6 +70,18 @@ return [self->varKey isEqual:[_obj key]]; } +/* key/value archiving */ + +- (id)initWithKeyValueUnarchiver:(EOKeyValueUnarchiver *)_unarchiver { + if ((self = [super init]) != nil) { + self->varKey = [[_unarchiver decodeObjectForKey:@"key"] copy]; + } + return self; +} +- (void)encodeWithKeyValueArchiver:(EOKeyValueArchiver *)_archiver { + [_archiver encodeObject:[self key] forKey:@"key"]; +} + /* description */ - (NSString *)qualifierDescription { diff --git a/sope-core/EOControl/EOSortOrdering.h b/sope-core/EOControl/EOSortOrdering.h index 97eeb0f6..a2ba4f71 100644 --- a/sope-core/EOControl/EOSortOrdering.h +++ b/sope-core/EOControl/EOSortOrdering.h @@ -24,6 +24,7 @@ #import #include +#include @class NSDictionary, NSString; @@ -42,7 +43,7 @@ EOControl_EXPORT SEL EOCompareCaseInsensitiveAscending; EOControl_EXPORT SEL EOCompareCaseInsensitiveDescending; #endif -@interface EOSortOrdering : NSObject +@interface EOSortOrdering : NSObject < EOKeyValueArchiving > { NSString *key; SEL selector; diff --git a/sope-core/EOControl/EOSortOrdering.m b/sope-core/EOControl/EOSortOrdering.m index 909d188e..93d2c01d 100644 --- a/sope-core/EOControl/EOSortOrdering.m +++ b/sope-core/EOControl/EOSortOrdering.m @@ -117,6 +117,22 @@ EOControl_DECLARE SEL EOCompareCaseInsensitiveDescending = selector:self->selector]; } +/* key/value archiving */ + +- (id)initWithKeyValueUnarchiver:(EOKeyValueUnarchiver *)_unarchiver { + if ((self = [super init]) != nil) { + self->key = [[_unarchiver decodeObjectForKey:@"key"] copy]; + self->selector = + NSSelectorFromString([_unarchiver decodeObjectForKey:@"selector"]); + } + return self; +} +- (void)encodeWithKeyValueArchiver:(EOKeyValueArchiver *)_archiver { + [_archiver encodeObject:[self key] forKey:@"key"]; + [_archiver encodeObject:NSStringFromSelector([self selector]) + forKey:@"selector"]; +} + /* description */ - (NSString *)description { diff --git a/sope-core/EOControl/NSObject+EOQualifierOps.m b/sope-core/EOControl/NSObject+EOQualifierOps.m index 378fa10f..82702466 100644 --- a/sope-core/EOControl/NSObject+EOQualifierOps.m +++ b/sope-core/EOControl/NSObject+EOQualifierOps.m @@ -76,7 +76,7 @@ static EONull *null = nil; @implementation NSString(ImplementedQualifierComparisons) -- (BOOL)isLike:(id)_pattern { +- (BOOL)isLike:(NSString *)_pattern { NSArray *cs; unsigned count; #if 0 @@ -154,7 +154,7 @@ static EONull *null = nil; return NO; } -- (BOOL)isCaseInsensitiveLike:(id)_pattern { +- (BOOL)isCaseInsensitiveLike:(NSString *)_pattern { return [[self lowercaseString] isLike:[_pattern lowercaseString]]; } diff --git a/sope-core/EOControl/Version b/sope-core/EOControl/Version index 5a9103fb..1e1b1b4f 100644 --- a/sope-core/EOControl/Version +++ b/sope-core/EOControl/Version @@ -1,3 +1,3 @@ # version file -SUBMINOR_VERSION:=54 +SUBMINOR_VERSION:=55 -- 2.39.5