GNUstep Core Data  0.1
CoreDataUtilities.h
1 /* Declarations of utility functions for the GNUstep Core Data framework.
2  Copyright (C) 2005 Free Software Foundation, Inc.
3 
4  Written by: Saso Kiselkov <diablos@manga.sk>
5  Date: August 2005
6 
7  This file is part of the GNUstep Core Data framework.
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free
21  Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
22 */
23 
24 #ifndef _CoreDataUtilities_h_
25 #define _CoreDataUtilities_h_
26 
27 @class NSError, NSString;
28 
35 static inline void
36 SetNonNullError (NSError ** ptr, NSError * error)
37 {
38  if (ptr != NULL)
39  {
40  *ptr = error;
41  }
42 }
43 
53 static inline BOOL
54 ObjectMatchedByFetchRequest (NSManagedObject * object,
55  NSFetchRequest * fetchRequest)
56 {
57  NSEntityDescription * entity = [fetchRequest entity];
58  NSPredicate * predicate = [fetchRequest predicate];
59  NSArray * affectedStores = [fetchRequest affectedStores];
60 
61  if (entity != nil)
62  {
63  if ([[object entity] isEqual: entity] == NO)
64  {
65  return NO;
66  }
67  }
68 
69  if (predicate != nil)
70  {
71  if ([predicate evaluateWithObject: object] == NO)
72  {
73  return NO;
74  }
75  }
76 
77  if (affectedStores != nil)
78  {
79  if ([affectedStores containsObject: [[object objectID]
80  persistentStore]] == NO)
81  {
82  return NO;
83  }
84  }
85 
86  return YES;
87 }
88 
89 #endif // _CoreDataUtilities_h_
An object for storing details about managed object fetches.
Validates whether value'' is a valid value forattribute'', returning YES if it is,...