Adjust to recent ObjFW changes
FossilOrigin-Name: fc8e42990e7f6476b8b806521222620bbac0496c61a91b20f9e3787fc20fdbb4
This commit is contained in:
parent
6d64ce5a68
commit
ae918f26c4
12 changed files with 88 additions and 65 deletions
|
@ -4,13 +4,16 @@
|
||||||
|
|
||||||
#import "PGResult.h"
|
#import "PGResult.h"
|
||||||
|
|
||||||
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface PGConnection: OFObject
|
@interface PGConnection: OFObject
|
||||||
{
|
{
|
||||||
PGconn *_connnection;
|
PGconn *_connnection;
|
||||||
OFDictionary *_parameters;
|
OFDictionary OF_GENERIC(OFString *, OFString *) *_parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (copy) OFDictionary *parameters;
|
@property (nonatomic, copy)
|
||||||
|
OFDictionary OF_GENERIC(OFString *, OFString *) *parameters;
|
||||||
|
|
||||||
- (void)connect;
|
- (void)connect;
|
||||||
- (void)reset;
|
- (void)reset;
|
||||||
|
@ -21,6 +24,8 @@
|
||||||
- (PGconn *)PG_connection;
|
- (PGconn *)PG_connection;
|
||||||
- (void)insertRow: (OFDictionary *)row
|
- (void)insertRow: (OFDictionary *)row
|
||||||
intoTable: (OFString *)table;
|
intoTable: (OFString *)table;
|
||||||
- (void)insertRows: (OFArray*)rows
|
- (void)insertRows: (OFArray OF_GENERIC(OFDictionary *) *)rows
|
||||||
intoTable: (OFString *)table;
|
intoTable: (OFString *)table;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -17,9 +17,11 @@
|
||||||
|
|
||||||
- (void)connect
|
- (void)connect
|
||||||
{
|
{
|
||||||
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
void *pool = objc_autoreleasePoolPush();
|
||||||
OFEnumerator *keyEnumerator = [_parameters keyEnumerator];
|
OFEnumerator OF_GENERIC(OFString *) *keyEnumerator =
|
||||||
OFEnumerator *objectEnumerator = [_parameters objectEnumerator];
|
[_parameters keyEnumerator];
|
||||||
|
OFEnumerator OF_GENERIC(OFString *) *objectEnumerator =
|
||||||
|
[_parameters objectEnumerator];
|
||||||
OFMutableString *connectionInfo = nil;
|
OFMutableString *connectionInfo = nil;
|
||||||
OFString *key, *object;
|
OFString *key, *object;
|
||||||
|
|
||||||
|
@ -39,7 +41,7 @@
|
||||||
@throw [PGConnectionFailedException
|
@throw [PGConnectionFailedException
|
||||||
exceptionWithConnection: self];
|
exceptionWithConnection: self];
|
||||||
|
|
||||||
[pool release];
|
objc_autoreleasePoolPop(pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)reset
|
- (void)reset
|
||||||
|
@ -83,7 +85,7 @@
|
||||||
- (PGResult *)executeCommand: (OFConstantString *)command
|
- (PGResult *)executeCommand: (OFConstantString *)command
|
||||||
parameters: (id)parameter, ...
|
parameters: (id)parameter, ...
|
||||||
{
|
{
|
||||||
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
void *pool = objc_autoreleasePoolPush();
|
||||||
PGresult *result;
|
PGresult *result;
|
||||||
const char **values;
|
const char **values;
|
||||||
va_list args, args2;
|
va_list args, args2;
|
||||||
|
@ -130,7 +132,7 @@
|
||||||
[self freeMemory: values];
|
[self freeMemory: values];
|
||||||
}
|
}
|
||||||
|
|
||||||
[pool release];
|
objc_autoreleasePoolPop(pool);
|
||||||
|
|
||||||
switch (PQresultStatus(result)) {
|
switch (PQresultStatus(result)) {
|
||||||
case PGRES_TUPLES_OK:
|
case PGRES_TUPLES_OK:
|
||||||
|
@ -149,7 +151,7 @@
|
||||||
- (void)insertRow: (OFDictionary *)row
|
- (void)insertRow: (OFDictionary *)row
|
||||||
intoTable: (OFString *)table
|
intoTable: (OFString *)table
|
||||||
{
|
{
|
||||||
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
void *pool = objc_autoreleasePoolPush();
|
||||||
OFMutableString *command;
|
OFMutableString *command;
|
||||||
OFEnumerator *enumerator;
|
OFEnumerator *enumerator;
|
||||||
const char **values;
|
const char **values;
|
||||||
|
@ -198,7 +200,7 @@
|
||||||
[self freeMemory: values];
|
[self freeMemory: values];
|
||||||
}
|
}
|
||||||
|
|
||||||
[pool release];
|
objc_autoreleasePoolPop(pool);
|
||||||
|
|
||||||
if (PQresultStatus(result) != PGRES_COMMAND_OK) {
|
if (PQresultStatus(result) != PGRES_COMMAND_OK) {
|
||||||
PQclear(result);
|
PQclear(result);
|
||||||
|
@ -210,18 +212,12 @@
|
||||||
PQclear(result);
|
PQclear(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)insertRows: (OFArray*)rows
|
- (void)insertRows: (OFArray OF_GENERIC(OFDictionary *) *)rows
|
||||||
intoTable: (OFString *)table
|
intoTable: (OFString *)table
|
||||||
{
|
{
|
||||||
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
for (OFDictionary *row in rows)
|
||||||
OFEnumerator *enumerator = [rows objectEnumerator];
|
|
||||||
OFDictionary *row;
|
|
||||||
|
|
||||||
while ((row = [enumerator nextObject]) != nil)
|
|
||||||
[self insertRow: row
|
[self insertRow: row
|
||||||
intoTable: table];
|
intoTable: table];
|
||||||
|
|
||||||
[pool release];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (PGconn *)PG_connection
|
- (PGconn *)PG_connection
|
||||||
|
|
|
@ -2,12 +2,18 @@
|
||||||
|
|
||||||
#import <ObjFW/ObjFW.h>
|
#import <ObjFW/ObjFW.h>
|
||||||
|
|
||||||
@interface PGResult: OFArray
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@class PGResultRow;
|
||||||
|
|
||||||
|
@interface PGResult: OFArray OF_GENERIC(PGResultRow *)
|
||||||
{
|
{
|
||||||
PGresult *_result;
|
PGresult *_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ PG_resultWithResult: (PGresult*)result;
|
+ (instancetype)PG_resultWithResult: (PGresult *)result;
|
||||||
- PG_initWithResult: (PGresult*)result;
|
- PG_initWithResult: (PGresult *)result OF_METHOD_FAMILY(init);
|
||||||
- (PGresult *)PG_result;
|
- (PGresult *)PG_result;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
#import "PGResult.h"
|
#import "PGResult.h"
|
||||||
|
|
||||||
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface PGResultRow: OFDictionary
|
@interface PGResultRow: OFDictionary
|
||||||
{
|
{
|
||||||
PGResult *_result;
|
PGResult *_result;
|
||||||
|
@ -16,3 +18,5 @@
|
||||||
- initWithResult: (PGResult *)result
|
- initWithResult: (PGResult *)result
|
||||||
row: (int)row;
|
row: (int)row;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
#import "PGException.h"
|
#import "PGException.h"
|
||||||
|
|
||||||
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface PGCommandFailedException: PGException
|
@interface PGCommandFailedException: PGException
|
||||||
{
|
{
|
||||||
OFString *_command;
|
OFString *_command;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (readonly, copy) OFString *command;
|
@property (readonly, nonatomic) OFString *command;
|
||||||
|
|
||||||
+ (instancetype)exceptionWithConnection: (PGConnection *)connection
|
+ (instancetype)exceptionWithConnection: (PGConnection *)connection
|
||||||
command: (OFString *)command;
|
command: (OFString *)command;
|
||||||
- initWithConnection: (PGConnection *)connection
|
- initWithConnection: (PGConnection *)connection
|
||||||
command: (OFString *)command;
|
command: (OFString *)command;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
#import "PGException.h"
|
#import "PGException.h"
|
||||||
|
|
||||||
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface PGConnectionFailedException: PGException
|
@interface PGConnectionFailedException: PGException
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -2,14 +2,18 @@
|
||||||
|
|
||||||
#import "PGConnection.h"
|
#import "PGConnection.h"
|
||||||
|
|
||||||
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface PGException: OFException
|
@interface PGException: OFException
|
||||||
{
|
{
|
||||||
PGConnection *_connection;
|
PGConnection *_connection;
|
||||||
OFString *_error;
|
OFString *_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (readonly, retain) PGConnection *connection;
|
@property (readonly, nonatomic) PGConnection *connection;
|
||||||
|
|
||||||
+ (instancetype)exceptionWithConnection: (PGConnection *)connection;
|
+ (instancetype)exceptionWithConnection: (PGConnection *)connection;
|
||||||
- initWithConnection: (PGConnection *)connection;
|
- initWithConnection: (PGConnection *)connection;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue