aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks
diff options
context:
space:
mode:
Diffstat (limited to 'Frameworks')
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m5
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresTypeHandlerProtocol.h11
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.m149
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.m7
4 files changed, 3 insertions, 169 deletions
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m b/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m
index 130d6590..861e1727 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m
+++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m
@@ -70,11 +70,6 @@ static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] =
return nil;
}
-- (NSData *)remoteDataFromObject:(id)object type:(FLXPostgresOid *)type
-{
- return nil;
-}
-
- (id)objectFromRemoteData:(const void *)bytes length:(NSUInteger)length type:(FLXPostgresOid)type
{
if (!bytes || !type) return nil;
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeHandlerProtocol.h b/Frameworks/PostgresKit/Source/FLXPostgresTypeHandlerProtocol.h
index 2402bc56..05b3acef 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresTypeHandlerProtocol.h
+++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeHandlerProtocol.h
@@ -51,17 +51,6 @@
- (NSArray *)classAliases;
/**
- * Return a transmittable data representation from the supplied object,
- * and set the remote type for the data.
- *
- * @param object The object to produce the data for.
- * @param type The type of object we're supplying.
- *
- * @return The data represenation as an NSData instance.
- */
-- (NSData *)remoteDataFromObject:(id)object type:(FLXPostgresOid *)type;
-
-/**
* Convert the supplied remote data into an object.
*
* @param bytes The remote data to convert.
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.m b/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.m
index d6cd7934..0a4ad011 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.m
+++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.m
@@ -60,27 +60,6 @@ static FLXPostgresOid FLXPostgresTypeNumberTypes[] =
return EndianS64_BtoN(*((SInt64 *)bytes));
}
-- (UInt16)unsignedInt16FromBytes:(const void *)bytes
-{
- if (!bytes) return 0;
-
- return EndianU16_BtoN(*((UInt16 *)bytes));
-}
-
-- (UInt32)unsignedInt32FromBytes:(const void *)bytes
-{
- if (!bytes) return 0;
-
- return EndianU32_BtoN(*((UInt32 *)bytes));
-}
-
-- (UInt64)unsignedInt64FromBytes:(const void *)bytes
-{
- if (!bytes) return 0;
-
- return EndianU64_BtoN(*((UInt64 *)bytes));
-}
-
- (NSNumber *)integerObjectFromBytes:(const void *)bytes length:(NSUInteger)length
{
if (!bytes) return nil;
@@ -98,50 +77,6 @@ static FLXPostgresOid FLXPostgresTypeNumberTypes[] =
return nil;
}
-- (NSNumber *)unsignedIntegerObjectFromBytes:(const void *)bytes length:(NSUInteger)length
-{
- if (!bytes) return nil;
-
- switch (length)
- {
- case 2:
- return [NSNumber numberWithUnsignedShort:[self unsignedInt16FromBytes:bytes]];
- case 4:
- return [NSNumber numberWithUnsignedInteger:[self unsignedInt32FromBytes:bytes]];
- case 8:
- return [NSNumber numberWithUnsignedLongLong:[self unsignedInt64FromBytes:bytes]];
- }
-
- return nil;
-}
-
-- (NSData *)remoteDataFromInt64:(SInt64)value
-{
- if (sizeof(SInt64) != 8) return nil;
-
- value = EndianS64_NtoB(value);
-
- return [NSData dataWithBytes:&value length:sizeof(value)];
-}
-
-- (NSData *)remoteDataFromInt32:(SInt32)value
-{
- if (sizeof(SInt32) != 4) return nil;
-
- value = EndianS32_NtoB(value);
-
- return [NSData dataWithBytes:&value length:sizeof(value)];
-}
-
-- (NSData *)remoteDataFromInt16:(SInt16)value
-{
- if (sizeof(SInt16) != 2) return nil;
-
- value = EndianS16_NtoB(value);
-
- return [NSData dataWithBytes:&value length:sizeof(value)];
-}
-
#pragma mark -
#pragma mark Floating Point
@@ -169,7 +104,7 @@ static FLXPostgresOid FLXPostgresTypeNumberTypes[] =
return u64.r;
}
-- (NSNumber *)realObjectFromBytes:(const void *)bytes length:(NSUInteger)length
+- (NSNumber *)floatObjectFromBytes:(const void *)bytes length:(NSUInteger)length
{
switch (length)
{
@@ -182,52 +117,14 @@ static FLXPostgresOid FLXPostgresTypeNumberTypes[] =
return nil;
}
-
-- (NSData *)remoteDataFromFloat32:(Float32)value
-{
- if (sizeof(Float32) != 4) return nil;
-
- union { Float32 r; UInt32 i; } u32;
-
- u32.r = value;
- u32.i = CFSwapInt32HostToBig(u32.i);
-
- return [NSData dataWithBytes:&u32 length:sizeof(u32)];
-}
-
-- (NSData *)remoteDataFromFloat64:(Float64)value
-{
- if (sizeof(Float64) != 8) return nil;
-
- union { Float64 r; UInt64 i; } u64;
-
- u64.r = value;
- u64.i = CFSwapInt64HostToBig(u64.i);
-
- return [NSData dataWithBytes:&u64 length:sizeof(u64)];
-}
-
#pragma mark -
#pragma mark Boolean
-- (BOOL)booleanFromBytes:(const void *)bytes
-{
- if (!bytes) return NO;
-
- return (*((const int8_t *)bytes) ? YES : NO);
-}
-
- (NSNumber *)booleanObjectFromBytes:(const void *)bytes length:(NSUInteger)length
{
if (!bytes || length != 1) return nil;
- return [NSNumber numberWithBool:[self booleanFromBytes:bytes]];
-}
-
-
-- (NSData *)remoteDataFromBoolean:(BOOL)value
-{
- return [NSData dataWithBytes:&value length:1];
+ return [NSNumber numberWithBool:*((const int8_t *)bytes) ? YES : NO];
}
#pragma mark -
@@ -248,46 +145,6 @@ static FLXPostgresOid FLXPostgresTypeNumberTypes[] =
return nil;
}
-- (NSData *)remoteDataFromObject:(id)object type:(FLXPostgresOid *)type
-{
- if (!object || !type || ![object isKindOfClass:[NSNumber class]]) return nil;
-
- NSNumber *number = (NSNumber *)object;
-
- const char *objectType = [number objCType];
-
- switch (objectType[0])
- {
- case 'c':
- case 'C':
- case 'B': // Boolean
- (*type) = FLXPostgresOidBool;
- return [self remoteDataFromBoolean:[(NSNumber *)object boolValue]];
- case 'i': // Integer
- case 'l': // Long
- case 'S': // Unsigned short
- (*type) = FLXPostgresOidInt4;
- return [self remoteDataFromInt32:[(NSNumber *)object shortValue]];
- case 's':
- (*type) = FLXPostgresOidInt2;
- return [self remoteDataFromInt16:[(NSNumber *)object shortValue]];
- case 'q': // Long long
- case 'Q': // Unsigned long long
- case 'I': // Unsigned integer
- case 'L': // Unsigned long
- (*type) = FLXPostgresOidInt8;
- return [self remoteDataFromInt64:[(NSNumber *)object longLongValue]];
- case 'f': // Float
- (*type) = FLXPostgresOidFloat4;
- return [self remoteDataFromFloat32:[(NSNumber *)object floatValue]];
- case 'd': // Double
- (*type) = FLXPostgresOidFloat8;
- return [self remoteDataFromFloat64:[(NSNumber *)object doubleValue]];
- default:
- return nil;
- }
-}
-
- (id)objectFromRemoteData:(const void *)bytes length:(NSUInteger)length type:(FLXPostgresOid)type
{
if (!bytes || !length || !type) return nil;
@@ -300,7 +157,7 @@ static FLXPostgresOid FLXPostgresTypeNumberTypes[] =
return [self integerObjectFromBytes:bytes length:length];
case FLXPostgresOidFloat4:
case FLXPostgresOidFloat8:
- return [self realObjectFromBytes:bytes length:length];
+ return [self floatObjectFromBytes:bytes length:length];
case FLXPostgresOidBool:
return [self booleanObjectFromBytes:bytes length:length];
default:
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.m b/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.m
index 4e45ec40..3e72163e 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.m
+++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.m
@@ -54,13 +54,6 @@ static FLXPostgresOid FLXPostgresTypeStringTypes[] =
return [NSArray arrayWithObject:@"NSCFString"];
}
-- (NSData *)remoteDataFromObject:(id)object type:(FLXPostgresOid *)type
-{
- if (!object || !type || ![object isKindOfClass:[NSString class]]) return nil;
-
- return [(NSString *)object dataUsingEncoding:[_connection stringEncoding]];
-}
-
- (id)objectFromRemoteData:(const void *)bytes length:(NSUInteger)length type:(FLXPostgresOid)type
{
if (!bytes || !type) return nil;