ObjPgSQL  Check-in [491b090606]

Overview
Comment:Modernize coding style
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 491b090606ca0dcbd65e6abcf2020f8af9342b8c6bd90dc1596bed3f72e6009d
User & Date: js on 2018-11-06 21:45:03
Other Links: manifest | tags
Context
2019-03-16
22:58
Use dot syntax check-in: dfb0336763 user: js tags: trunk
2018-11-06
21:45
Modernize coding style check-in: 491b090606 user: js tags: trunk
21:29
Adjust to ObjFW changes check-in: 5d46842834 user: js tags: trunk
Changes

Modified src/PGConnection+Private.h from [78c2e023e3] to [84c2eea1b1].

22
23
24
25
26
27
28
29
30
31
32
 */

#import "PGConnection.h"

OF_ASSUME_NONNULL_BEGIN

@interface PGConnection ()
- (PGconn *)PG_connection;
@end

OF_ASSUME_NONNULL_END







|



22
23
24
25
26
27
28
29
30
31
32
 */

#import "PGConnection.h"

OF_ASSUME_NONNULL_BEGIN

@interface PGConnection ()
@property (readonly, nonatomic) PGconn *pg_connection;
@end

OF_ASSUME_NONNULL_END

Modified src/PGConnection.m from [2b5931631c] to [1ce8286c7a].

26
27
28
29
30
31
32

33
34
35
36
37
38
39
#import "PGResult.h"
#import "PGResult+Private.h"

#import "PGConnectionFailedException.h"
#import "PGCommandFailedException.h"

@implementation PGConnection

@synthesize parameters = _parameters;

- (void)dealloc
{
	[_parameters release];

	[self close];







>







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#import "PGResult.h"
#import "PGResult+Private.h"

#import "PGConnectionFailedException.h"
#import "PGCommandFailedException.h"

@implementation PGConnection
@synthesize pg_connection = _connection;
@synthesize parameters = _parameters;

- (void)dealloc
{
	[_parameters release];

	[self close];
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
		@throw [PGCommandFailedException
		    exceptionWithConnection: self
				    command: command];
	}

	switch (PQresultStatus(result)) {
	case PGRES_TUPLES_OK:
		return [PGResult PG_resultWithResult: result];
	case PGRES_COMMAND_OK:
		PQclear(result);
		return nil;
	default:
		PQclear(result);
		@throw [PGCommandFailedException
		    exceptionWithConnection: self







|







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
		@throw [PGCommandFailedException
		    exceptionWithConnection: self
				    command: command];
	}

	switch (PQresultStatus(result)) {
	case PGRES_TUPLES_OK:
		return [PGResult pg_resultWithResult: result];
	case PGRES_COMMAND_OK:
		PQclear(result);
		return nil;
	default:
		PQclear(result);
		@throw [PGCommandFailedException
		    exceptionWithConnection: self
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
		[self freeMemory: values];
	}

	objc_autoreleasePoolPop(pool);

	switch (PQresultStatus(result)) {
	case PGRES_TUPLES_OK:
		return [PGResult PG_resultWithResult: result];
	case PGRES_COMMAND_OK:
		PQclear(result);
		return nil;
	default:
		PQclear(result);
		@throw [PGCommandFailedException
		    exceptionWithConnection: self







|







159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
		[self freeMemory: values];
	}

	objc_autoreleasePoolPop(pool);

	switch (PQresultStatus(result)) {
	case PGRES_TUPLES_OK:
		return [PGResult pg_resultWithResult: result];
	case PGRES_COMMAND_OK:
		PQclear(result);
		return nil;
	default:
		PQclear(result);
		@throw [PGCommandFailedException
		    exceptionWithConnection: self
241
242
243
244
245
246
247
248
249
250
251
252
253
- (void)insertRows: (OFArray OF_GENERIC(OFDictionary *) *)rows
	 intoTable: (OFString *)table
{
	for (OFDictionary *row in rows)
		[self insertRow: row
		      intoTable: table];
}

- (PGconn *)PG_connection
{
	return _connection;
}
@end







<
<
<
<
<

242
243
244
245
246
247
248





249
- (void)insertRows: (OFArray OF_GENERIC(OFDictionary *) *)rows
	 intoTable: (OFString *)table
{
	for (OFDictionary *row in rows)
		[self insertRow: row
		      intoTable: table];
}





@end

Modified src/PGResult+Private.h from [e9cdf4b915] to [159fb60c68].

22
23
24
25
26
27
28


29
30
31

32
33
34
 */

#import "PGResult.h"

OF_ASSUME_NONNULL_BEGIN

@interface PGResult ()


+ (instancetype)PG_resultWithResult: (PGresult *)result;
- PG_initWithResult: (PGresult *)result OF_METHOD_FAMILY(init);
- (PGresult *)PG_result;

@end

OF_ASSUME_NONNULL_END







>
>
|
|
<
>



22
23
24
25
26
27
28
29
30
31
32

33
34
35
36
 */

#import "PGResult.h"

OF_ASSUME_NONNULL_BEGIN

@interface PGResult ()
@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

Modified src/PGResult.m from [31133d2ea7] to [879f970757].

18
19
20
21
22
23
24

25
26
27
28


29
30
31
32
33
34
35
36
37
38
39
40
41
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import "PGResult.h"

#import "PGResultRow.h"
#import "PGResultRow+Private.h"

@implementation PGResult


+ (instancetype)PG_resultWithResult: (PGresult *)result
{
	return [[[self alloc] PG_initWithResult: result] autorelease];
}

- (instancetype)PG_initWithResult: (PGresult *)result
{
	self = [super init];

	_result = result;

	return self;
}







>




>
>
|

|


|







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import "PGResult.h"
#import "PGResult+Private.h"
#import "PGResultRow.h"
#import "PGResultRow+Private.h"

@implementation PGResult
@synthesize pg_result = _result;

+ (instancetype)pg_resultWithResult: (PGresult *)result
{
	return [[[self alloc] pg_initWithResult: result] autorelease];
}

- (instancetype)pg_initWithResult: (PGresult *)result
{
	self = [super init];

	_result = result;

	return self;
}
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
}

- (id)objectAtIndex: (size_t)index
{
	if (index > PQntuples(_result))
		@throw [OFOutOfRangeException exception];

	return [PGResultRow PG_rowWithResult: self
					 row: (int)index];
}

- (PGresult *)PG_result
{
	return _result;
}
@end







|


<
<
<
<
<

57
58
59
60
61
62
63
64
65
66





67
}

- (id)objectAtIndex: (size_t)index
{
	if (index > PQntuples(_result))
		@throw [OFOutOfRangeException exception];

	return [PGResultRow pg_rowWithResult: self
					 row: (int)index];
}





@end

Modified src/PGResultRow+Private.h from [2dc226ea0b] to [54a71cebbe].

22
23
24
25
26
27
28
29
30
31
32

33
34
35
 */

#import "PGResultRow.h"

OF_ASSUME_NONNULL_BEGIN

@interface PGResultRow ()
+ (instancetype)PG_rowWithResult: (PGResult *)result
			     row: (int)row;
- PG_initWithResult: (PGResult *)result
		row: (int)row OF_METHOD_FAMILY(init);

@end

OF_ASSUME_NONNULL_END







|

|
|
>



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 */

#import "PGResultRow.h"

OF_ASSUME_NONNULL_BEGIN

@interface PGResultRow ()
+ (instancetype)pg_rowWithResult: (PGResult *)result
			     row: (int)row;
- (instancetype)pg_initWithResult: (PGResult *)result
			      row: (int)row OF_METHOD_FAMILY(init)
    OF_DESIGNATED_INITIALIZER;
@end

OF_ASSUME_NONNULL_END

Modified src/PGResultRow.m from [0a37255b98] to [80d17b4c5e].

78
79
80
81
82
83
84
85
86
87
88
89
90
91
92

- initWithResult: (PGResult *)result
	     row: (int)row
{
	self = [super init];

	_result = [result retain];
	_res = [result PG_result];
	_row = row;

	return self;
}

- (void)dealloc
{







|







78
79
80
81
82
83
84
85
86
87
88
89
90
91
92

- initWithResult: (PGResult *)result
	     row: (int)row
{
	self = [super init];

	_result = [result retain];
	_res = [result pg_result];
	_row = row;

	return self;
}

- (void)dealloc
{
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186

		objects[j++] = [OFString stringWithUTF8String:
		    PQfname(_res, state->state + i)];
	}

	state->state += count;
	state->itemsPtr = objects;
	state->mutationsPtr = (unsigned long*)self;

	return j;
}
@end

@implementation PGResultRowEnumerator
- initWithResult: (PGResult *)result
	     row: (int)row
{
	self = [super init];

	_result = [result retain];
	_res = [result PG_result];
	_row = row;
	_count = PQnfields(_res);

	return self;
}

- (void)dealloc







|












|







159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186

		objects[j++] = [OFString stringWithUTF8String:
		    PQfname(_res, state->state + i)];
	}

	state->state += count;
	state->itemsPtr = objects;
	state->mutationsPtr = (unsigned long *)self;

	return j;
}
@end

@implementation PGResultRowEnumerator
- initWithResult: (PGResult *)result
	     row: (int)row
{
	self = [super init];

	_result = [result retain];
	_res = [result pg_result];
	_row = row;
	_count = PQnfields(_res);

	return self;
}

- (void)dealloc

Modified src/exceptions/PGCommandFailedException.h from [764f2a0c2b] to [f143fc5e8c].

28
29
30
31
32
33
34
35


36

37
38

39
40
41
@interface PGCommandFailedException: PGException
{
	OFString *_command;
}

@property (readonly, nonatomic) OFString *command;

+ (instancetype)exceptionWithConnection: (PGConnection *)connection


				command: (OFString *)command;

- initWithConnection: (PGConnection *)connection
	     command: (OFString *)command;

@end

OF_ASSUME_NONNULL_END








>
>

>
|
|
>



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
@interface PGCommandFailedException: PGException
{
	OFString *_command;
}

@property (readonly, nonatomic) OFString *command;

+ (instancetype)exceptionWithConnection: (PGConnection *)connection
    OF_UNAVAILABLE;
+ (instancetype)exceptionWithConnection: (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

Modified src/exceptions/PGCommandFailedException.m from [e985f3486f] to [4da1ac931d].

21
22
23
24
25
26
27





28
29
30
31
32
33
34
35
36





37
38
39
40
41
42
43
44
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import "PGCommandFailedException.h"

@implementation PGCommandFailedException
@synthesize command = _command;






+ (instancetype)exceptionWithConnection: (PGConnection *)connection
				command: (OFString *)command
{
	return [[[self alloc] initWithConnection: connection
					 command: command] autorelease];
}

- initWithConnection: (PGConnection *)connection





	     command: (OFString *)command
{
	self = [super initWithConnection: connection];

	@try {
		_command = [command copy];
	} @catch (id e) {
		[self release];







>
>
>
>
>








|
>
>
>
>
>
|







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import "PGCommandFailedException.h"

@implementation PGCommandFailedException
@synthesize command = _command;

+ (instancetype)exceptionWithConnection: (PGConnection *)connection
{
	OF_UNRECOGNIZED_SELECTOR
}

+ (instancetype)exceptionWithConnection: (PGConnection *)connection
				command: (OFString *)command
{
	return [[[self alloc] initWithConnection: connection
					 command: command] autorelease];
}

- (instancetype)initWithConnection: (PGConnection *)connection
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithConnection: (PGConnection *)connection
			   command: (OFString *)command
{
	self = [super initWithConnection: connection];

	@try {
		_command = [command copy];
	} @catch (id e) {
		[self release];

Modified src/exceptions/PGException.h from [9dd47748a5] to [9661557133].

32
33
34
35
36
37
38
39

40
41
42
	PGConnection *_connection;
	OFString *_error;
}

@property (readonly, nonatomic) PGConnection *connection;

+ (instancetype)exceptionWithConnection: (PGConnection *)connection;
- initWithConnection: (PGConnection *)connection;

@end

OF_ASSUME_NONNULL_END







|
>



32
33
34
35
36
37
38
39
40
41
42
43
	PGConnection *_connection;
	OFString *_error;
}

@property (readonly, nonatomic) PGConnection *connection;

+ (instancetype)exceptionWithConnection: (PGConnection *)connection;
- (instancetype)initWithConnection: (PGConnection *)connection
    OF_DESIGNATED_INITIALIZER;
@end

OF_ASSUME_NONNULL_END

Modified src/exceptions/PGException.m from [6b0ae0eb82] to [ed6fbdfed3].

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
- initWithConnection: (PGConnection *)connection
{
	self = [super init];

	@try {
		_connection = [connection retain];
		_error = [[OFString alloc]
		    initWithCString: PQerrorMessage([_connection PG_connection])
			   encoding: [OFLocale encoding]];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;







|







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
- initWithConnection: (PGConnection *)connection
{
	self = [super init];

	@try {
		_connection = [connection retain];
		_error = [[OFString alloc]
		    initWithCString: PQerrorMessage([_connection pg_connection])
			   encoding: [OFLocale encoding]];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;