]> err.no Git - sope/blob - sope-gdl1/GDLAccess/EOQualifier+SQL.m
added missing inline pathes
[sope] / sope-gdl1 / GDLAccess / EOQualifier+SQL.m
1 /* 
2    EOAdaptorChannel.m
3
4    Copyright (C) 1996 Free Software Foundation, Inc.
5
6    Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro>
7    Date: October 1996
8
9    This file is part of the GNUstep Database Library.
10
11    This library is free software; you can redistribute it and/or
12    modify it under the terms of the GNU Library General Public
13    License as published by the Free Software Foundation; either
14    version 2 of the License, or (at your option) any later version.
15
16    This library is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19    Library General Public License for more details.
20
21    You should have received a copy of the GNU Library General Public
22    License along with this library; see the file COPYING.LIB.
23    If not, write to the Free Software Foundation,
24    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 */
26 // $Id: EOQualifier+SQL.m 1 2004-08-20 10:38:46Z znek $
27
28 #include "EOSQLExpression.h"
29 #include "EOSQLQualifier.h"
30 #include <EOControl/EOQualifier.h>
31 #include "common.h"
32
33 @implementation EOAndQualifier(SQLGeneration)
34
35 - (NSString *)sqlStringForSQLExpression:(EOSQLExpression *)_sqlExpr {
36   return [_sqlExpr sqlStringForConjoinedQualifiers:[self qualifiers]];
37 }
38
39 - (EOQualifier *)schemaBasedQualifierWithRootEntity:(EOEntity *)_entity {
40   NSArray  *array;
41   id       objects[self->count + 1];
42   unsigned i;
43
44   IMP objAtIdx;
45
46   objAtIdx = [self->qualifiers methodForSelector:@selector(objectAtIndex:)];
47   
48   for (i = 0; i < self->count; i++) {
49     id q, newq;
50
51     q = objAtIdx(self->qualifiers, @selector(objectAtIndex:), i);
52     newq = [q schemaBasedQualifierWithRootEntity:_entity];
53     if (newq == nil) newq = q;
54     
55     objects[i] = newq;
56   }
57
58   array = [NSArray arrayWithObjects:objects count:self->count];
59   return [[[[self class] alloc] initWithQualifierArray:array] autorelease];
60 }
61
62 @end /* EOAndQualifier(SQLGeneration) */
63
64 @implementation EOOrQualifier(SQLGeneration)
65
66 - (NSString *)sqlStringForSQLExpression:(EOSQLExpression *)_sqlExpr {
67   return [_sqlExpr sqlStringForDisjoinedQualifiers:[self qualifiers]];
68 }
69
70 - (EOQualifier *)schemaBasedQualifierWithRootEntity:(EOEntity *)_entity {
71   NSArray  *array;
72   id       objects[self->count + 1];
73   unsigned i;
74
75   IMP objAtIdx;
76
77   objAtIdx = [self->qualifiers methodForSelector:@selector(objectAtIndex:)];
78   
79   for (i = 0; i < self->count; i++) {
80     id q, newq;
81
82     q = objAtIdx(self->qualifiers, @selector(objectAtIndex:), i);
83     newq = [q schemaBasedQualifierWithRootEntity:_entity];
84     if (newq == nil) newq = q;
85     
86     objects[i] = newq;
87   }
88
89   array = [NSArray arrayWithObjects:objects count:self->count];
90   return [[[[self class] alloc] initWithQualifierArray:array] autorelease];
91 }
92
93 @end /* EOOrQualifier(SQLGeneration) */
94
95 @implementation EONotQualifier(SQLGeneration)
96
97 - (NSString *)sqlStringForSQLExpression:(EOSQLExpression *)_sqlExpr {
98   return [_sqlExpr sqlStringForNegatedQualifier:[self qualifier]];
99 }
100
101 - (EOQualifier *)schemaBasedQualifierWithRootEntity:(EOEntity *)_entity {
102   EOQualifier *sq;
103
104   sq = [(id<EOQualifierSQLGeneration>)self->qualifier
105            schemaBasedQualifierWithRootEntity:_entity];
106   if (sq == self->qualifier)
107     return self;
108
109   sq = [[EONotQualifier alloc] initWithQualifier:sq];
110   return [sq autorelease];
111 }
112
113 @end /* EONotQualifier(SQLGeneration) */
114
115 @implementation EOKeyValueQualifier(SQLGeneration)
116
117 - (NSString *)sqlStringForSQLExpression:(EOSQLExpression *)_sqlExpr {
118   return [_sqlExpr sqlStringForKeyValueQualifier:self];
119 }
120
121 - (EOQualifier *)schemaBasedQualifierWithRootEntity:(EOEntity *)_entity {
122   NSLog(@"ERROR(%s): subclasses need to override this method!",
123         __PRETTY_FUNCTION__);
124   return nil;
125 }
126
127 @end /* EOKeyValueQualifier(SQLGeneration) */
128
129 @implementation EOKeyComparisonQualifier(SQLGeneration)
130
131 - (NSString *)sqlStringForSQLExpression:(EOSQLExpression *)_sqlExpr {
132   return [_sqlExpr sqlStringForKeyComparisonQualifier:self];
133 }
134
135 - (EOQualifier *)schemaBasedQualifierWithRootEntity:(EOEntity *)_entity {
136   NSLog(@"ERROR(%s): subclasses need to override this method!",
137         __PRETTY_FUNCTION__);
138   return nil;
139 }
140
141 @end /* EOKeyComparisonQualifier(SQLGeneration) */