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
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface PGConnection ()
|
@interface PGConnection ()
|
||||||
- (PGconn *)PG_connection;
|
@property (readonly, nonatomic) PGconn *pg_connection;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#import "PGCommandFailedException.h"
|
#import "PGCommandFailedException.h"
|
||||||
|
|
||||||
@implementation PGConnection
|
@implementation PGConnection
|
||||||
|
@synthesize pg_connection = _connection;
|
||||||
@synthesize parameters = _parameters;
|
@synthesize parameters = _parameters;
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
|
@ -96,7 +97,7 @@
|
||||||
|
|
||||||
switch (PQresultStatus(result)) {
|
switch (PQresultStatus(result)) {
|
||||||
case PGRES_TUPLES_OK:
|
case PGRES_TUPLES_OK:
|
||||||
return [PGResult PG_resultWithResult: result];
|
return [PGResult pg_resultWithResult: result];
|
||||||
case PGRES_COMMAND_OK:
|
case PGRES_COMMAND_OK:
|
||||||
PQclear(result);
|
PQclear(result);
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -162,7 +163,7 @@
|
||||||
|
|
||||||
switch (PQresultStatus(result)) {
|
switch (PQresultStatus(result)) {
|
||||||
case PGRES_TUPLES_OK:
|
case PGRES_TUPLES_OK:
|
||||||
return [PGResult PG_resultWithResult: result];
|
return [PGResult pg_resultWithResult: result];
|
||||||
case PGRES_COMMAND_OK:
|
case PGRES_COMMAND_OK:
|
||||||
PQclear(result);
|
PQclear(result);
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -245,9 +246,4 @@
|
||||||
[self insertRow: row
|
[self insertRow: row
|
||||||
intoTable: table];
|
intoTable: table];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (PGconn *)PG_connection
|
|
||||||
{
|
|
||||||
return _connection;
|
|
||||||
}
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -26,9 +26,11 @@
|
||||||
OF_ASSUME_NONNULL_BEGIN
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface PGResult ()
|
@interface PGResult ()
|
||||||
+ (instancetype)PG_resultWithResult: (PGresult *)result;
|
@property (readonly, nonatomic) PGresult *pg_result;
|
||||||
- PG_initWithResult: (PGresult *)result OF_METHOD_FAMILY(init);
|
|
||||||
- (PGresult *)PG_result;
|
+ (instancetype)pg_resultWithResult: (PGresult *)result;
|
||||||
|
- (instancetype)pg_initWithResult: (PGresult *)result OF_METHOD_FAMILY(init)
|
||||||
|
OF_DESIGNATED_INITIALIZER;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -22,16 +22,19 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "PGResult.h"
|
#import "PGResult.h"
|
||||||
|
#import "PGResult+Private.h"
|
||||||
#import "PGResultRow.h"
|
#import "PGResultRow.h"
|
||||||
#import "PGResultRow+Private.h"
|
#import "PGResultRow+Private.h"
|
||||||
|
|
||||||
@implementation PGResult
|
@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];
|
self = [super init];
|
||||||
|
|
||||||
|
@ -58,12 +61,7 @@
|
||||||
if (index > PQntuples(_result))
|
if (index > PQntuples(_result))
|
||||||
@throw [OFOutOfRangeException exception];
|
@throw [OFOutOfRangeException exception];
|
||||||
|
|
||||||
return [PGResultRow PG_rowWithResult: self
|
return [PGResultRow pg_rowWithResult: self
|
||||||
row: (int)index];
|
row: (int)index];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (PGresult *)PG_result
|
|
||||||
{
|
|
||||||
return _result;
|
|
||||||
}
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -26,10 +26,11 @@
|
||||||
OF_ASSUME_NONNULL_BEGIN
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface PGResultRow ()
|
@interface PGResultRow ()
|
||||||
+ (instancetype)PG_rowWithResult: (PGResult *)result
|
+ (instancetype)pg_rowWithResult: (PGResult *)result
|
||||||
row: (int)row;
|
row: (int)row;
|
||||||
- PG_initWithResult: (PGResult *)result
|
- (instancetype)pg_initWithResult: (PGResult *)result
|
||||||
row: (int)row OF_METHOD_FAMILY(init);
|
row: (int)row OF_METHOD_FAMILY(init)
|
||||||
|
OF_DESIGNATED_INITIALIZER;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -82,7 +82,7 @@ convertType(PGresult *res, int column, OFString *string)
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
_result = [result retain];
|
_result = [result retain];
|
||||||
_res = [result PG_result];
|
_res = [result pg_result];
|
||||||
_row = row;
|
_row = row;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -176,7 +176,7 @@ convertType(PGresult *res, int column, OFString *string)
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
_result = [result retain];
|
_result = [result retain];
|
||||||
_res = [result PG_result];
|
_res = [result pg_result];
|
||||||
_row = row;
|
_row = row;
|
||||||
_count = PQnfields(_res);
|
_count = PQnfields(_res);
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,14 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@property (readonly, nonatomic) OFString *command;
|
@property (readonly, nonatomic) OFString *command;
|
||||||
|
|
||||||
|
+ (instancetype)exceptionWithConnection: (PGConnection *)connection
|
||||||
|
OF_UNAVAILABLE;
|
||||||
+ (instancetype)exceptionWithConnection: (PGConnection *)connection
|
+ (instancetype)exceptionWithConnection: (PGConnection *)connection
|
||||||
command: (OFString *)command;
|
command: (OFString *)command;
|
||||||
- initWithConnection: (PGConnection *)connection
|
- (instancetype)initWithConnection: (PGConnection *)connection OF_UNAVAILABLE;
|
||||||
command: (OFString *)command;
|
- (instancetype)initWithConnection: (PGConnection *)connection
|
||||||
|
command: (OFString *)command
|
||||||
|
OF_DESIGNATED_INITIALIZER;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -26,6 +26,11 @@
|
||||||
@implementation PGCommandFailedException
|
@implementation PGCommandFailedException
|
||||||
@synthesize command = _command;
|
@synthesize command = _command;
|
||||||
|
|
||||||
|
+ (instancetype)exceptionWithConnection: (PGConnection *)connection
|
||||||
|
{
|
||||||
|
OF_UNRECOGNIZED_SELECTOR
|
||||||
|
}
|
||||||
|
|
||||||
+ (instancetype)exceptionWithConnection: (PGConnection *)connection
|
+ (instancetype)exceptionWithConnection: (PGConnection *)connection
|
||||||
command: (OFString *)command
|
command: (OFString *)command
|
||||||
{
|
{
|
||||||
|
@ -33,7 +38,12 @@
|
||||||
command: command] autorelease];
|
command: command] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithConnection: (PGConnection *)connection
|
- (instancetype)initWithConnection: (PGConnection *)connection
|
||||||
|
{
|
||||||
|
OF_INVALID_INIT_METHOD
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithConnection: (PGConnection *)connection
|
||||||
command: (OFString *)command
|
command: (OFString *)command
|
||||||
{
|
{
|
||||||
self = [super initWithConnection: connection];
|
self = [super initWithConnection: connection];
|
||||||
|
|
|
@ -36,7 +36,8 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
@property (readonly, nonatomic) PGConnection *connection;
|
@property (readonly, nonatomic) PGConnection *connection;
|
||||||
|
|
||||||
+ (instancetype)exceptionWithConnection: (PGConnection *)connection;
|
+ (instancetype)exceptionWithConnection: (PGConnection *)connection;
|
||||||
- initWithConnection: (PGConnection *)connection;
|
- (instancetype)initWithConnection: (PGConnection *)connection
|
||||||
|
OF_DESIGNATED_INITIALIZER;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
@try {
|
@try {
|
||||||
_connection = [connection retain];
|
_connection = [connection retain];
|
||||||
_error = [[OFString alloc]
|
_error = [[OFString alloc]
|
||||||
initWithCString: PQerrorMessage([_connection PG_connection])
|
initWithCString: PQerrorMessage([_connection pg_connection])
|
||||||
encoding: [OFLocale encoding]];
|
encoding: [OFLocale encoding]];
|
||||||
} @catch (id e) {
|
} @catch (id e) {
|
||||||
[self release];
|
[self release];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue