1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
45
46
47
48
49
50
51
52
53
54
55
56
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
45
46
47
48
49
50
51
52
53
54
55
56
|
-
+
-
+
-
+
-
+
-
+
|
#import "PGResultRow.h"
@interface PGResultRowEnumerator: OFEnumerator
{
PGResult *result;
PGresult *res;
size_t row, pos, count;
int row, pos, count;
}
- initWithResult: (PGResult*)result
row: (size_t)row;
row: (int)row;
@end
@interface PGResultRowKeyEnumerator: PGResultRowEnumerator
@end
@interface PGResultRowObjectEnumerator: PGResultRowEnumerator
@end
@implementation PGResultRow
+ rowWithResult: (PGResult*)result
row: (size_t)row
row: (int)row
{
return [[[self alloc] initWithResult: result
row: row] autorelease];
}
- initWithResult: (PGResult*)result_
row: (size_t)row_
row: (int)row_
{
self = [super init];
result = [result_ retain];
res = [result PG_result];
row = row_;
return self;
}
- (void)dealloc
{
[result release];
[super dealloc];
}
- (size_t)count
{
size_t i, count, fields = PQnfields(res);
int i, count, fields = PQnfields(res);
for (i = count = 0; i < fields; i++)
if (!PQgetisnull(res, row, i))
count++;
return count;
}
|
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
-
+
|
initWithResult: result
row: row] autorelease];
}
@end
@implementation PGResultRowEnumerator
- initWithResult: (PGResult*)result_
row: (size_t)row_
row: (int)row_
{
self = [super init];
result = [result_ retain];
res = [result PG_result];
row = row_;
count = PQnfields(res);
|