Support quoting of NSArray and NSSet objects

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@22542 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2006-02-22 11:15:16 +00:00
parent f4bf045efc
commit e965604e5b
2 changed files with 18 additions and 11 deletions

View file

@ -1,3 +1,7 @@
2005-02-22 Richard Frith-Macdonald <rfm@gnu.org>
* SQLClient.m: Support quoting of NSArray and NSSet objects.
2006-01-11 Nicola Pero <nicola@brainstorm.co.uk> 2006-01-11 Nicola Pero <nicola@brainstorm.co.uk>
* configure.ac: Do not source GNUSTEP_CONFIG_FILE if it doesn't * configure.ac: Do not source GNUSTEP_CONFIG_FILE if it doesn't

View file

@ -62,6 +62,7 @@ static NSNull *null = nil;
static Class NSStringClass = 0; static Class NSStringClass = 0;
static Class NSArrayClass = 0; static Class NSArrayClass = 0;
static Class NSDateClass = 0; static Class NSDateClass = 0;
static Class NSSetClass = 0;
@implementation SQLRecord @implementation SQLRecord
+ (id) allocWithZone: (NSZone*)aZone + (id) allocWithZone: (NSZone*)aZone
@ -440,6 +441,7 @@ static unsigned int maxConnections = 8;
rollbackStatement = RETAIN([NSArray arrayWithObject: rollbackString]); rollbackStatement = RETAIN([NSArray arrayWithObject: rollbackString]);
NSStringClass = [NSString class]; NSStringClass = [NSString class];
NSArrayClass = [NSArray class]; NSArrayClass = [NSArray class];
NSSetClass = [NSSet class];
[NSTimer scheduledTimerWithTimeInterval: 1.0 [NSTimer scheduledTimerWithTimeInterval: 1.0
target: self target: self
selector: @selector(_tick:) selector: @selector(_tick:)
@ -918,24 +920,25 @@ static void quoteString(NSMutableString *s)
} }
/** /**
* For an NSArray object, we produce a bracketed list of the * For an NSArray or NSSet, we produce a bracketed list of the
* (quoted) objects in the array. * (quoted) objects in the array.
*/ */
if ([obj isKindOfClass: NSArrayClass] == YES) if ([obj isKindOfClass: NSArrayClass] == YES ||
[obj isKindOfClass: NSSetClass] == YES)
{ {
NSMutableString *ms = [NSMutableString stringWithCapacity: 100]; NSMutableString *ms = [NSMutableString stringWithCapacity: 100];
unsigned count = [obj count]; NSEnumerator *enumerator = [obj objectEnumerator];
unsigned i; id value = [enumerator nextObject];
[ms appendString: @"("]; [ms appendString: @"("];
if (count > 0) if (value != nil)
{ {
[ms appendString: [self quote: [obj objectAtIndex: 0]]]; [ms appendString: [self quote: value]];
for (i = 1; i < count; i++) }
{ while ((value = [enumerator nextObject]) != nil)
[ms appendString: @","]; {
[ms appendString: [self quote: [obj objectAtIndex: i]]]; [ms appendString: @","];
} [ms appendString: [self quote: value]];
} }
[ms appendString: @")"]; [ms appendString: @")"];
return ms; return ms;