Modernize coding style
FossilOrigin-Name: 491b090606ca0dcbd65e6abcf2020f8af9342b8c6bd90dc1596bed3f72e6009d
This commit is contained in:
parent
dd11eb6c25
commit
6120fa8fea
10 changed files with 44 additions and 32 deletions
|
@ -26,7 +26,7 @@
|
|||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface PGConnection ()
|
||||
- (PGconn *)PG_connection;
|
||||
@property (readonly, nonatomic) PGconn *pg_connection;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -26,6 +26,11 @@
|
|||
@implementation PGCommandFailedException
|
||||
@synthesize command = _command;
|
||||
|
||||
+ (instancetype)exceptionWithConnection: (PGConnection *)connection
|
||||
{
|
||||
OF_UNRECOGNIZED_SELECTOR
|
||||
}
|
||||
|
||||
+ (instancetype)exceptionWithConnection: (PGConnection *)connection
|
||||
command: (OFString *)command
|
||||
{
|
||||
|
@ -33,7 +38,12 @@
|
|||
command: command] autorelease];
|
||||
}
|
||||
|
||||
- initWithConnection: (PGConnection *)connection
|
||||
- (instancetype)initWithConnection: (PGConnection *)connection
|
||||
{
|
||||
OF_INVALID_INIT_METHOD
|
||||
}
|
||||
|
||||
- (instancetype)initWithConnection: (PGConnection *)connection
|
||||
command: (OFString *)command
|
||||
{
|
||||
self = [super initWithConnection: connection];
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue