diff options
Diffstat (limited to 'Frameworks')
-rw-r--r-- | Frameworks/PostgresKit/Source/FLXPostgresResult.h | 9 | ||||
-rw-r--r-- | Frameworks/PostgresKit/Source/FLXPostgresResult.m | 16 |
2 files changed, 21 insertions, 4 deletions
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresResult.h b/Frameworks/PostgresKit/Source/FLXPostgresResult.h index 4148ba3d..168f8f15 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresResult.h +++ b/Frameworks/PostgresKit/Source/FLXPostgresResult.h @@ -30,7 +30,7 @@ typedef enum } FLXPostgresResultRowType; -@interface FLXPostgresResult : NSObject +@interface FLXPostgresResult : NSObject { void *_result; void **_typeHandlers; @@ -43,6 +43,7 @@ FLXPostgresResultRowType; NSString **_fields; NSStringEncoding _stringEncoding; + FLXPostgresResultRowType _defaultRowType; FLXPostgresConnection *_connection; } @@ -62,6 +63,11 @@ FLXPostgresResultRowType; */ @property (readonly) NSStringEncoding stringEncoding; +/** + * @property defaultRowType The row type that should be used when calling -row. + */ +@property (readwrite, assign) FLXPostgresResultRowType defaultRowType; + - (id)initWithResult:(void *)result connection:(FLXPostgresConnection *)connection; - (NSUInteger)numberOfFields; @@ -70,6 +76,7 @@ FLXPostgresResultRowType; - (NSArray *)fields; +- (id)row; - (NSArray *)rowAsArray; - (NSDictionary *)rowAsDictionary; - (id)rowAsType:(FLXPostgresResultRowType)type; diff --git a/Frameworks/PostgresKit/Source/FLXPostgresResult.m b/Frameworks/PostgresKit/Source/FLXPostgresResult.m index 57a26268..06950a3b 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresResult.m +++ b/Frameworks/PostgresKit/Source/FLXPostgresResult.m @@ -38,6 +38,7 @@ @synthesize numberOfRows = _numberOfRows; @synthesize numberOfFields = _numberOfFields; @synthesize stringEncoding = _stringEncoding; +@synthesize defaultRowType = _defaultRowType; #pragma mark - #pragma mark Initialisation @@ -73,6 +74,7 @@ _connection = [connection retain]; _stringEncoding = [_connection stringEncoding]; + _defaultRowType = FLXPostgresResultRowAsDictionary; _typeHandlers = (void **)calloc(sizeof(void *), _numberOfFields); @@ -115,6 +117,16 @@ #pragma mark Data Retrieval /** + * Return the current row in the type of the currently set default (defaults to dictionary). + * + * @return The row of data. + */ +- (id)row +{ + return [self rowAsType:_defaultRowType]; +} + +/** * Return the current row as an array. * * @return The array of data. @@ -143,9 +155,7 @@ { if (_row >= _numberOfRows) return nil; - id data; - - data = (type == FLXPostgresResultRowAsArray) ? [NSMutableArray arrayWithCapacity:_numberOfFields] : [NSMutableDictionary dictionaryWithCapacity:_numberOfFields]; + id data = (type == FLXPostgresResultRowAsArray) ? [NSMutableArray arrayWithCapacity:_numberOfFields] : [NSMutableDictionary dictionaryWithCapacity:_numberOfFields]; for (NSUInteger i = 0; i < _numberOfFields; i++) { |