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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
switch (PQftype(res, column)) {
case 16: /* BOOLOID */
if ([string isEqual: @"t"])
return [OFNumber numberWithBool: YES];
else
return [OFNumber numberWithBool: NO];
case 21: /* INT2OID */
return [OFNumber numberWithInt16:
(int16_t)string.decimalValue];
case 23: /* INT4OID */
return [OFNumber numberWithInt32:
(int32_t)string.decimalValue];
case 20: /* INT8OID */
return [OFNumber numberWithInt64:
(int64_t)string.decimalValue];
case 700: /* FLOAT4OID */
return [OFNumber numberWithFloat: string.floatValue];
case 701: /* FLOAT8OID */
return [OFNumber numberWithDouble: string.doubleValue];
}
return string;
}
@interface PGResultRowEnumerator: OFEnumerator
{
PGResult *_result;
PGresult *_res;
int _row, _pos, _count;
}
- initWithResult: (PGResult*)result
row: (int)row;
@end
@interface PGResultRowKeyEnumerator: PGResultRowEnumerator
@end
@interface PGResultRowObjectEnumerator: PGResultRowEnumerator
@end
@implementation PGResultRow
+ (instancetype)rowWithResult: (PGResult *)result
row: (int)row
{
return [[[self alloc] initWithResult: result
row: row] autorelease];
}
- (instancetype)initWithResult: (PGResult *)result
row: (int)row
{
self = [super init];
_result = [result retain];
_res = result.pg_result;
_row = row;
|
|
|
|
|
|
|
|
<
|
<
|
<
|
<
|
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
switch (PQftype(res, column)) {
case 16: /* BOOLOID */
if ([string isEqual: @"t"])
return [OFNumber numberWithBool: YES];
else
return [OFNumber numberWithBool: NO];
case 21: /* INT2OID */
return [OFNumber numberWithShort:
(short)[string longLongValueWithBase: 10]];
case 23: /* INT4OID */
return [OFNumber numberWithLong:
(long)[string longLongValueWithBase: 10]];
case 20: /* INT8OID */
return [OFNumber numberWithLongLong:
[string longLongValueWithBase: 10]];
case 700: /* FLOAT4OID */
return [OFNumber numberWithFloat: string.floatValue];
case 701: /* FLOAT8OID */
return [OFNumber numberWithDouble: string.doubleValue];
}
return string;
}
@interface PGResultRowEnumerator: OFEnumerator
{
PGResult *_result;
PGresult *_res;
int _row, _pos, _count;
}
- initWithResult: (PGResult*)result row: (int)row;
@end
@interface PGResultRowKeyEnumerator: PGResultRowEnumerator
@end
@interface PGResultRowObjectEnumerator: PGResultRowEnumerator
@end
@implementation PGResultRow
+ (instancetype)rowWithResult: (PGResult *)result row: (int)row
{
return [[[self alloc] initWithResult: result row: row] autorelease];
}
- (instancetype)initWithResult: (PGResult *)result row: (int)row
{
self = [super init];
_result = [result retain];
_res = result.pg_result;
_row = row;
|
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
- (OFEnumerator *)objectEnumerator
{
return [[[PGResultRowObjectEnumerator alloc]
initWithResult: _result
row: _row] autorelease];
}
- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
objects: (id *)objects
count: (int)count
{
int i, j;
if (state->extra[0] == 0) {
state->extra[0] = 1;
|
|
|
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
- (OFEnumerator *)objectEnumerator
{
return [[[PGResultRowObjectEnumerator alloc]
initWithResult: _result
row: _row] autorelease];
}
- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state
objects: (id *)objects
count: (int)count
{
int i, j;
if (state->extra[0] == 0) {
state->extra[0] = 1;
|
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
state->mutationsPtr = (unsigned long *)self;
return j;
}
@end
@implementation PGResultRowEnumerator
- (instancetype)initWithResult: (PGResult *)result
row: (int)row
{
self = [super init];
_result = [result retain];
_res = result.pg_result;
_row = row;
_count = PQnfields(_res);
|
|
<
|
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
state->mutationsPtr = (unsigned long *)self;
return j;
}
@end
@implementation PGResultRowEnumerator
- (instancetype)initWithResult: (PGResult *)result row: (int)row
{
self = [super init];
_result = [result retain];
_res = result.pg_result;
_row = row;
_count = PQnfields(_res);
|