]> err.no Git - sope/blob - sope-gdl1/GDLAccess/EOQuotedExpression.m
added missing inline pathes
[sope] / sope-gdl1 / GDLAccess / EOQuotedExpression.m
1 /* 
2    EOQuotedExpression.m
3
4    Copyright (C) 1996 Free Software Foundation, Inc.
5
6    Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro>
7    Date: 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
27 #import <Foundation/NSString.h>
28 #import <Foundation/NSArray.h>
29 #import "common.h"
30 #import "EOQuotedExpression.h"
31
32 @implementation EOQuotedExpression
33
34 - (id)expressionValueForContext:(id<EOExpressionContext>)_context {
35   NSMutableString *result;
36   NSArray         *components;
37   id              expr;
38
39   expr       = [(EOExpressionArray *)self->expression 
40                                      expressionValueForContext:_context];
41   components = [expr componentsSeparatedByString:quote];
42   result     = [NSMutableString stringWithCapacity:[expr length] + 10];
43
44   [result appendString:quote];
45   [result appendString:[components componentsJoinedByString:escape]];
46   [result appendString:quote];
47   
48   return result;
49 }
50
51 - (id)initWithExpression:(id)_expression
52   quote:(NSString *)_quote
53   escape:(NSString *)_escape
54 {
55   if ((self = [super init])) {
56     ASSIGN(self->expression, _expression);
57     ASSIGN(self->quote, _quote);
58     ASSIGN(self->escape, _escape);
59   }
60
61   return self;
62 }
63
64 - (void)dealloc {
65   RELEASE(self->expression);
66   RELEASE(self->quote);
67   RELEASE(self->escape);
68   [super dealloc];
69 }
70
71 // NSCopying
72
73 - (id)copyWithZone:(NSZone*)zone {
74     return [[[self class]
75                    allocWithZone:zone]
76                    initWithExpression:expression quote:quote escape:escape];
77 }
78 - (id)copy {
79     return [self copyWithZone:NSDefaultMallocZone()];
80 }
81
82 @end /* EOQuotedExpression */