diff --git a/src/PGConnection+Private.h b/src/PGConnection+Private.h index 883c27d..cd6bb84 100644 --- a/src/PGConnection+Private.h +++ b/src/PGConnection+Private.h @@ -26,7 +26,7 @@ OF_ASSUME_NONNULL_BEGIN @interface PGConnection () -- (PGconn *)PG_connection; +@property (readonly, nonatomic) PGconn *pg_connection; @end OF_ASSUME_NONNULL_END diff --git a/src/PGConnection.m b/src/PGConnection.m index b0a3bf1..a94d0ce 100644 --- a/src/PGConnection.m +++ b/src/PGConnection.m @@ -30,6 +30,7 @@ #import "PGCommandFailedException.h" @implementation PGConnection +@synthesize pg_connection = _connection; @synthesize parameters = _parameters; - (void)dealloc @@ -96,7 +97,7 @@ switch (PQresultStatus(result)) { case PGRES_TUPLES_OK: - return [PGResult PG_resultWithResult: result]; + return [PGResult pg_resultWithResult: result]; case PGRES_COMMAND_OK: PQclear(result); return nil; @@ -162,7 +163,7 @@ switch (PQresultStatus(result)) { case PGRES_TUPLES_OK: - return [PGResult PG_resultWithResult: result]; + return [PGResult pg_resultWithResult: result]; case PGRES_COMMAND_OK: PQclear(result); return nil; @@ -245,9 +246,4 @@ [self insertRow: row intoTable: table]; } - -- (PGconn *)PG_connection -{ - return _connection; -} @end diff --git a/src/PGResult+Private.h b/src/PGResult+Private.h index 313465a..2833a5f 100644 --- a/src/PGResult+Private.h +++ b/src/PGResult+Private.h @@ -26,9 +26,11 @@ OF_ASSUME_NONNULL_BEGIN @interface PGResult () -+ (instancetype)PG_resultWithResult: (PGresult *)result; -- PG_initWithResult: (PGresult *)result OF_METHOD_FAMILY(init); -- (PGresult *)PG_result; +@property (readonly, nonatomic) PGresult *pg_result; + ++ (instancetype)pg_resultWithResult: (PGresult *)result; +- (instancetype)pg_initWithResult: (PGresult *)result OF_METHOD_FAMILY(init) + OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END diff --git a/src/PGResult.m b/src/PGResult.m index fceb6b8..bd55779 100644 --- a/src/PGResult.m +++ b/src/PGResult.m @@ -22,16 +22,19 @@ */ #import "PGResult.h" +#import "PGResult+Private.h" #import "PGResultRow.h" #import "PGResultRow+Private.h" @implementation PGResult -+ (instancetype)PG_resultWithResult: (PGresult *)result +@synthesize pg_result = _result; + ++ (instancetype)pg_resultWithResult: (PGresult *)result { - return [[[self alloc] PG_initWithResult: result] autorelease]; + return [[[self alloc] pg_initWithResult: result] autorelease]; } -- (instancetype)PG_initWithResult: (PGresult *)result +- (instancetype)pg_initWithResult: (PGresult *)result { self = [super init]; @@ -58,12 +61,7 @@ if (index > PQntuples(_result)) @throw [OFOutOfRangeException exception]; - return [PGResultRow PG_rowWithResult: self + return [PGResultRow pg_rowWithResult: self row: (int)index]; } - -- (PGresult *)PG_result -{ - return _result; -} @end diff --git a/src/PGResultRow+Private.h b/src/PGResultRow+Private.h index 91fa0ad..00a257c 100644 --- a/src/PGResultRow+Private.h +++ b/src/PGResultRow+Private.h @@ -26,10 +26,11 @@ OF_ASSUME_NONNULL_BEGIN @interface PGResultRow () -+ (instancetype)PG_rowWithResult: (PGResult *)result ++ (instancetype)pg_rowWithResult: (PGResult *)result row: (int)row; -- PG_initWithResult: (PGResult *)result - row: (int)row OF_METHOD_FAMILY(init); +- (instancetype)pg_initWithResult: (PGResult *)result + row: (int)row OF_METHOD_FAMILY(init) + OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END diff --git a/src/PGResultRow.m b/src/PGResultRow.m index 134c589..6b3a1aa 100644 --- a/src/PGResultRow.m +++ b/src/PGResultRow.m @@ -82,7 +82,7 @@ convertType(PGresult *res, int column, OFString *string) self = [super init]; _result = [result retain]; - _res = [result PG_result]; + _res = [result pg_result]; _row = row; return self; @@ -163,7 +163,7 @@ convertType(PGresult *res, int column, OFString *string) state->state += count; state->itemsPtr = objects; - state->mutationsPtr = (unsigned long*)self; + state->mutationsPtr = (unsigned long *)self; return j; } @@ -176,7 +176,7 @@ convertType(PGresult *res, int column, OFString *string) self = [super init]; _result = [result retain]; - _res = [result PG_result]; + _res = [result pg_result]; _row = row; _count = PQnfields(_res); diff --git a/src/exceptions/PGCommandFailedException.h b/src/exceptions/PGCommandFailedException.h index 62d3bed..b4b5bd6 100644 --- a/src/exceptions/PGCommandFailedException.h +++ b/src/exceptions/PGCommandFailedException.h @@ -32,10 +32,14 @@ OF_ASSUME_NONNULL_BEGIN @property (readonly, nonatomic) OFString *command; ++ (instancetype)exceptionWithConnection: (PGConnection *)connection + OF_UNAVAILABLE; + (instancetype)exceptionWithConnection: (PGConnection *)connection command: (OFString *)command; -- initWithConnection: (PGConnection *)connection - command: (OFString *)command; +- (instancetype)initWithConnection: (PGConnection *)connection OF_UNAVAILABLE; +- (instancetype)initWithConnection: (PGConnection *)connection + command: (OFString *)command + OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END diff --git a/src/exceptions/PGCommandFailedException.m b/src/exceptions/PGCommandFailedException.m index c77752c..484da9b 100644 --- a/src/exceptions/PGCommandFailedException.m +++ b/src/exceptions/PGCommandFailedException.m @@ -26,6 +26,11 @@ @implementation PGCommandFailedException @synthesize command = _command; ++ (instancetype)exceptionWithConnection: (PGConnection *)connection +{ + OF_UNRECOGNIZED_SELECTOR +} + + (instancetype)exceptionWithConnection: (PGConnection *)connection command: (OFString *)command { @@ -33,8 +38,13 @@ command: command] autorelease]; } -- initWithConnection: (PGConnection *)connection - command: (OFString *)command +- (instancetype)initWithConnection: (PGConnection *)connection +{ + OF_INVALID_INIT_METHOD +} + +- (instancetype)initWithConnection: (PGConnection *)connection + command: (OFString *)command { self = [super initWithConnection: connection]; diff --git a/src/exceptions/PGException.h b/src/exceptions/PGException.h index dbc680c..f69777d 100644 --- a/src/exceptions/PGException.h +++ b/src/exceptions/PGException.h @@ -36,7 +36,8 @@ OF_ASSUME_NONNULL_BEGIN @property (readonly, nonatomic) PGConnection *connection; + (instancetype)exceptionWithConnection: (PGConnection *)connection; -- initWithConnection: (PGConnection *)connection; +- (instancetype)initWithConnection: (PGConnection *)connection + OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END diff --git a/src/exceptions/PGException.m b/src/exceptions/PGException.m index 95ad0f2..94e6955 100644 --- a/src/exceptions/PGException.m +++ b/src/exceptions/PGException.m @@ -39,7 +39,7 @@ @try { _connection = [connection retain]; _error = [[OFString alloc] - initWithCString: PQerrorMessage([_connection PG_connection]) + initWithCString: PQerrorMessage([_connection pg_connection]) encoding: [OFLocale encoding]]; } @catch (id e) { [self release];