Deprecated: Assigning the return value of new by reference is deprecated in /home/bluestat/public_html/source/index.php on line 477
/*
* Tindex
* Copyright ©2002 - 2006, Blue Static
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program; if not,
* write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
* $Id: SQLiteResult.m 467 2006-08-19 20:32:11Z rsesek $
* $HeadURL: file:///Users/rsesek/SVN/macosx/Tindex/trunk/SQLiteResult.m $
*/
#import "SQLiteResult.h"
@implementation SQLiteResult
/**
* Initializes a result set with a given prepared VM SQLite statement
*
* @param sqlite3_stmt Prepared SQLite statement
*
* @return id Created object
*/
- (id)initWithStatement: (sqlite3_stmt *)aStatement
{
SQLiteRecord *currentRecord;
records = [[NSMutableArray alloc] init];
int index = 0;
int columnCount;
columnCount = sqlite3_column_count(aStatement);
while (sqlite3_step(aStatement) == SQLITE_ROW)
{
currentRecord = [[SQLiteRecord alloc] init];
for (index = 0; index < columnCount; index++)
{
[currentRecord insertColumn: [NSString stringWithCString: sqlite3_column_name(aStatement, index)]
withValue: [NSString stringWithCString: sqlite3_column_text(aStatement, index)]];
}
[records addObject: currentRecord];
[currentRecord release];
}
return self;
}
/**
* Returns all of the records as an enumerated object
*
* @return NSEnumerator Enumerated record objects
*/
- (NSEnumerator *)objectEnumerator
{
return [records objectEnumerator];
}
/**
* Returns a given record at the specified index
*
* @param integer Numbered index
*
* @return SQLiteRecord Record at the given index
*/
- (SQLiteRecord *)objectAtIndex: (int)index
{
if ([records count] >= (index + 1))
{
return [records objectAtIndex: index];
}
else
{
return nil;
}
}
/**
* Deallocates class and releases objects
*/
- (void)dealloc
{
[records release];
[super dealloc];
}
@end