]> err.no Git - sope/commitdiff
added key/value archiving to NSExpression
authorhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Thu, 4 Aug 2005 02:15:25 +0000 (02:15 +0000)
committerhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Thu, 4 Aug 2005 02:15:25 +0000 (02:15 +0000)
git-svn-id: http://svn.opengroupware.org/SOPE/trunk@967 e4a50df8-12e2-0310-a44c-efbce7f8a7e3

sope-core/EOCoreData/ChangeLog
sope-core/EOCoreData/NSExpression+EO.h
sope-core/EOCoreData/NSExpression+EO.m
sope-core/EOCoreData/Version

index 1bd105815e907dd9b9e6051cb8183aafceef2e59..b91af797a3c4143b6db39fa0081e46174f73f9a4 100644 (file)
@@ -1,5 +1,7 @@
 2005-08-04  Helge Hess  <helge.hess@opengroupware.org>
 
+       * NSExpression+EO.m: added EOKeyValueArchiving (v4.5.4)
+
        * NSPredicate+EO.m: added EOKeyValueArchiving to NSComparisonPredicate
          (v4.5.3)
 
index 8cf46283cbb8279a63696248267fdd5c25c9493a..3e87478bfbda49aaa3e39c73cff943b4df4dc6b9 100644 (file)
@@ -33,7 +33,7 @@
 @class NSExpression;
 @class EOQualifier;
 
-@interface NSExpression(EO)
+@interface NSExpression(EOCoreData) < EOKeyValueArchiving >
 
 - (NSPredicate *)asPredicate;
 - (NSExpression *)asExpression;
index 3f7b3b4036b72fe152024c582e091ebfdfab189c..ada802c69fcf1dab8ab0e2574309b79de74ba151 100644 (file)
   return self;
 }
 
+/* key/value archiving */
+
+- (id)initWithKeyValueUnarchiver:(EOKeyValueUnarchiver *)_unarchiver {
+  id tmp;
+
+  [self release]; self = nil;
+  
+  if ((tmp = [_unarchiver decodeObjectForKey:@"constantValue"]) != nil)
+    return [[NSExpression expressionForConstantValue:tmp] retain];
+
+  if ((tmp = [_unarchiver decodeObjectForKey:@"keyPath"]) != nil)
+    return [[NSExpression expressionForKeyPath:tmp] retain];
+  
+  if ((tmp = [_unarchiver decodeObjectForKey:@"variable"]) != nil)
+    return [[NSExpression expressionForVariable:tmp] retain];
+  
+  if ((tmp = [_unarchiver decodeObjectForKey:@"function"]) != nil) {
+    NSArray *args;
+    
+    args = [_unarchiver decodeObjectForKey:@"arguments"];
+    return [[NSExpression expressionForFunction:tmp arguments:args] retain];
+  }
+  
+  return [[NSExpression expressionForEvaluatedObject] retain];
+}
+
+- (void)encodeWithKeyValueArchiver:(EOKeyValueArchiver *)_archiver {
+  switch ([self expressionType]) {
+  case NSConstantValueExpressionType:
+    [_archiver encodeObject:[self constantValue] forKey:@"constantValue"];
+    return;
+  case NSEvaluatedObjectExpressionType:
+    /* encode no marker */
+    return;
+  case NSVariableExpressionType:
+    [_archiver encodeObject:[self variable] forKey:@"variable"];
+    return;
+  case NSKeyPathExpressionType:
+    [_archiver encodeObject:[self keyPath] forKey:@"keyPath"];
+    return;
+  case NSFunctionExpressionType:
+    [_archiver encodeObject:[self function]  forKey:@"function"];
+    [_archiver encodeObject:[self arguments] forKey:@"arguments"];
+    return;
+    
+  default:
+      NSLog(@"WARNING(%s): could not encode NSExpression: %@!",
+           __PRETTY_FUNCTION__, self);
+  }
+}
+
 @end /* NSPredicate(EOCoreData) */
index 81d0f5a4cff3edc3be75e404954d4eed90c1bd38..9d93031b2c14602d3af70ada8fe43b6eda356ce9 100644 (file)
@@ -1,3 +1,3 @@
 # version file
 
-SUBMINOR_VERSION:=3
+SUBMINOR_VERSION:=4