From 12ad4fae862bc157cd133b42ed8f204bc273058a Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Mon, 10 Sep 2012 10:23:44 +0000 Subject: Tidy up data types. --- .../Source/FLXPostgresTypeDateTimeHandler.m | 2 +- .../PostgresKit/Source/FLXPostgresTypeHandler.h | 5 +++++ .../PostgresKit/Source/FLXPostgresTypeHandler.m | 3 +++ .../Source/FLXPostgresTypeHandlerProtocol.h | 2 +- .../Source/FLXPostgresTypeNumberHandler.m | 2 +- .../Source/FLXPostgresTypeStringHandler.m | 20 ++++++++++++-------- 6 files changed, 23 insertions(+), 11 deletions(-) (limited to 'Frameworks') diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m b/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m index 2dbd6c28..25b74b4c 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m +++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m @@ -73,7 +73,7 @@ static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] = return nil; } -- (id)objectFromResult:(const PGresult *)result atRow:(unsigned int)row column:(unsigned int)column +- (id)objectFromResult:(const PGresult *)result atRow:(NSUInteger)row column:(NSUInteger)column { FLXPostgresOid type = PQftype(result, column); diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeHandler.h b/Frameworks/PostgresKit/Source/FLXPostgresTypeHandler.h index f2808d52..1b3146b8 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresTypeHandler.h +++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeHandler.h @@ -25,6 +25,11 @@ @interface FLXPostgresTypeHandler : NSObject { + NSUInteger _row; + NSUInteger _column; + + const PGresult *_result; + FLXPostgresConnection *_connection; } diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeHandler.m b/Frameworks/PostgresKit/Source/FLXPostgresTypeHandler.m index a1b5fac6..a7b98909 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresTypeHandler.m +++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeHandler.m @@ -25,9 +25,12 @@ @synthesize connection = _connection; +#pragma mark - + - (id)initWithConnection:(FLXPostgresConnection *)connection { if ((self = [super init])) { + _result = nil; _connection = [connection retain]; } diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeHandlerProtocol.h b/Frameworks/PostgresKit/Source/FLXPostgresTypeHandlerProtocol.h index 5c05af63..a0c04c26 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresTypeHandlerProtocol.h +++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeHandlerProtocol.h @@ -57,6 +57,6 @@ * * @return An object represenation of the data. */ -- (id)objectFromResult:(const PGresult *)result atRow:(unsigned int)row column:(unsigned int)column; +- (id)objectFromResult:(const PGresult *)result atRow:(NSUInteger)row column:(NSUInteger)column; @end diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.m b/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.m index 42db1b33..467a8821 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.m +++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.m @@ -145,7 +145,7 @@ static FLXPostgresOid FLXPostgresTypeNumberTypes[] = return nil; } -- (id)objectFromResult:(const PGresult *)result atRow:(unsigned int)row column:(unsigned int)column +- (id)objectFromResult:(const PGresult *)result atRow:(NSUInteger)row column:(NSUInteger)column { FLXPostgresOid type = PQftype(result, column); NSUInteger length = PQgetlength(result, row, column); diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.m b/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.m index aa7adf2a..2c49ee64 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.m +++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.m @@ -45,9 +45,9 @@ static FLXPostgresOid FLXPostgresTypeStringTypes[] = @interface FLXPostgresTypeStringHandler () -- (id)_stringFromResult:(const PGresult *)result atRow:(unsigned int)row column:(unsigned int)column; -- (id)_macAddressFromResult:(const PGresult *)result atRow:(unsigned int)row column:(unsigned int)column; -- (id)_inetAddressFromResult:(const PGresult *)result atRow:(unsigned int)row column:(unsigned int)column type:(FLXPostgresOid)type; +- (id)_stringFromResult:(const PGresult *)result atRow:(NSUInteger)row column:(NSUInteger)column; +- (id)_macAddressFromResult:(const PGresult *)result atRow:(NSUInteger)row column:(NSUInteger)column; +- (id)_inetAddressFromResult:(const PGresult *)result atRow:(NSUInteger)row column:(NSUInteger)column type:(FLXPostgresOid)type; @end @@ -72,10 +72,14 @@ static FLXPostgresOid FLXPostgresTypeStringTypes[] = return [NSArray arrayWithObject:@"NSCFString"]; } -- (id)objectFromResult:(const PGresult *)result atRow:(unsigned int)row column:(unsigned int)column +- (id)objectFromResult:(const PGresult *)result atRow:(NSUInteger)row column:(NSUInteger)column { FLXPostgresOid type = PQftype(result, column); + _row = row; + _column = column; + _result = result; + switch (type) { case FLXPostgresOidMacAddr: @@ -111,7 +115,7 @@ static FLXPostgresOid FLXPostgresTypeStringTypes[] = * * @return A string representation of the value. */ -- (id)_stringFromResult:(const PGresult *)result atRow:(unsigned int)row column:(unsigned int)column +- (id)_stringFromResult:(const PGresult *)result atRow:(NSUInteger)row column:(NSUInteger)column { const void *bytes = PQgetvalue(result, row, column); NSUInteger length = PQgetlength(result, row, column); @@ -130,7 +134,7 @@ static FLXPostgresOid FLXPostgresTypeStringTypes[] = * * @return A string representation of the MAC address. */ -- (id)_macAddressFromResult:(const PGresult *)result atRow:(unsigned int)row column:(unsigned int)column +- (id)_macAddressFromResult:(const PGresult *)result atRow:(NSUInteger)row column:(NSUInteger)column { PGmacaddr address; @@ -149,10 +153,10 @@ static FLXPostgresOid FLXPostgresTypeStringTypes[] = * * @return A string representation of the network address. */ -- (id)_inetAddressFromResult:(const PGresult *)result atRow:(unsigned int)row column:(unsigned int)column type:(FLXPostgresOid)type +- (id)_inetAddressFromResult:(const PGresult *)result atRow:(NSUInteger)row column:(NSUInteger)column type:(FLXPostgresOid)type { PGinet inet; - + if (!PQgetf(result, row, type == FLXPostgresOidInetAddr ? "%inet" : "%cidr", column, &inet)) return [NSNull null]; char ip[80]; -- cgit v1.2.3