diff --git a/doc/error_handling.md b/doc/error_handling.md new file mode 100644 index 0000000000..ac876eb6ee --- /dev/null +++ b/doc/error_handling.md @@ -0,0 +1,29 @@ +Category 1: NSError for "expected" problems +=========================================== +Characterized by: File access problem, network access problems.... User should be informed. Problems which cannot be eliminated during development. + +- Writing a group to a file, with file access problems. + + +Category 2: NSException for "unexpected" problems - no recovery +=============================================================== +Characterized by: Fatal errors. Wrong use of API. Application should rightfully crash. These problems should be eliminated during development. Feedback should be fast and direct in the form of an exception. The +application should not attempt to catch the exception. + +- Indexing out of bounds. +- Passing illegal parameter type. +- Writing to read only table (working assumption). +- Core library exceptions. + + +Category 3: NSException for "unexpected" problems - with recovery +================================================================= +Technically possible with ARC safe exceptions flag. Leads to excessive release code (automatically inserted). Should not be needed. + + + + + + + + diff --git a/doc/ref/examples/ex_objc_group_intro.m b/doc/ref/examples/ex_objc_group_intro.m index f4393fe80d..ac8fd23bcd 100644 --- a/doc/ref/examples/ex_objc_group_intro.m +++ b/doc/ref/examples/ex_objc_group_intro.m @@ -20,8 +20,8 @@ int main() /* Creates a group and uses it to create a new table. */ - TightdbGroup *group = [TightdbGroup group]; - PeopleTable *table = [group getTable:@"people" withClass:[PeopleTable class]]; + TightdbGroup* group = [TightdbGroup group]; + PeopleTable* table = [group getTable:@"people" withClass:[PeopleTable class] error:nil]; /* Adds values to the table. */ @@ -31,7 +31,7 @@ int main() /* Write the group (and the contained table) to a specified file. */ [[NSFileManager defaultManager] removeItemAtPath:@"filename.tightdb" error:nil]; - [group write:@"filename.tightdb"]; + [group writeToFile:@"filename.tightdb" withError:nil]; /* Adds another row to the table. Note the update is NOT persisted automatically (delete the old file and use write again). */ @@ -39,18 +39,17 @@ int main() [table addName:@"Sam" Age:17]; [[NSFileManager defaultManager] removeItemAtPath:@"filename.tightdb" error:nil]; - [group write:@"filename.tightdb"]; + [group writeToFile:@"filename.tightdb" withError:nil]; /* Retrieves an in memory buffer from the group. */ - size_t size; - const char *buffer = [group writeToMem:&size]; + TightdbBinary* buffer = [group writeToBuffer]; - TightdbGroup *groupFromMemory = [TightdbGroup groupWithBuffer:buffer size:size]; - PeopleTable *tableFromMemery = [groupFromMemory getTable:@"people" withClass:[PeopleTable class] error:nil]; + /* Creates a group from an im memory buffer */ + TightdbGroup* groupFromMemory = [TightdbGroup groupWithBuffer:buffer withError:nil]; + PeopleTable* tableFromMemery = [groupFromMemory getTable:@"people" withClass:[PeopleTable class] error:nil]; - for (PeopleTable_Cursor *cursor in tableFromMemery) - { + for (PeopleTable_Cursor* cursor in tableFromMemery) { NSLog(@"Name: %@", cursor.Name); } diff --git a/doc/ref/examples/ex_objc_sharedgroup_intro.m b/doc/ref/examples/ex_objc_sharedgroup_intro.m index f4985a738d..2045cb5da0 100644 --- a/doc/ref/examples/ex_objc_sharedgroup_intro.m +++ b/doc/ref/examples/ex_objc_sharedgroup_intro.m @@ -5,52 +5,94 @@ #import #import + TIGHTDB_TABLE_3(PeopleTable, Name, String, Age, Int, Hired, Bool); + + + int main() { @autoreleasepool { /* Creates a group and uses it to create a new table. */ - TightdbSharedGroup *shared = [TightdbSharedGroup groupWithFilename:@"sharedgroup.tightdb"]; + NSFileManager *fm = [NSFileManager defaultManager]; + [fm removeItemAtPath:@"sharedgrouptest.tightdb" error:nil]; + [fm removeItemAtPath:@"sharedgrouptest.tightdb.lock" error:nil]; + + TightdbSharedGroup *shared = [TightdbSharedGroup sharedGroupWithFile:@"sharedgrouptest.tightdb" withError:nil]; + if (!shared) { + NSLog(@"Error"); + } + else { + NSLog(@"%@", shared); + } - /* A write transaction (with rollback if not first writer to employees table). */ + /* A write transaction (with commit). */ - [shared writeTransaction:^(TightdbGroup *group) { + NSError *error = nil; + BOOL success; + + success = [shared writeTransactionWithError:&error withBlock:^(TightdbGroup *group) { /* Write transactions with the shared group are possible via the provided variable binding named group. */ - PeopleTable *table = [group getTable:@"employees" withClass:[PeopleTable class]]; + PeopleTable *table = [group getTable:@"employees" withClass:[PeopleTable class] error:nil]; + if ([table count] > 0) { NSLog(@"Not empty!"); return NO; /* Rollback */ } [table addName:@"Bill" Age:53 Hired:YES]; - NSLog(@"Row added!"); + NSLog(@"Commit!"); return YES; /* Commit */ + } ]; + + if(!success) + NSLog(@"Error : %@", [error localizedDescription]); + + /* A write transaction (with rollback). */ + + success = [shared writeTransactionWithError:&error withBlock:^(TightdbGroup *group) { + + /* Write transactions with the shared group are possible via the provided variable binding named group. */ + + PeopleTable *table = [group getTable:@"employees" withClass:[PeopleTable class] error:nil]; + + if ([table count] > 0) { + NSLog(@"Roll back!"); + return NO; /* Rollback */ + } + + [table addName:@"Bill" Age:53 Hired:YES]; + NSLog(@"Commit!"); + return YES; /* Commit */ + }]; + + if(!success) + NSLog(@"Error : %@", [error localizedDescription]); - }]; /* A read transaction */ - [shared readTransaction:^(TightdbGroup *group) { + [shared readTransactionWithBlock:^(TightdbGroup *group) { /* Read transactions with the shared group are possible via the provided variable binding named group. */ - PeopleTable *table = [group getTable:@"employees" withClass:[PeopleTable class]]; + PeopleTable *table = [group getTable:@"employees" withClass:[PeopleTable class] error:nil]; for (PeopleTable_Cursor *curser in table) { NSLog(@"Name: %@", [curser Name]); } }]; - } } + /* @@EndExample@@ */ diff --git a/doc/ref/examples/ex_objc_table_dynamic_intro.m b/doc/ref/examples/ex_objc_table_dynamic_intro.m index b015ba9705..3ee1a3d4c6 100644 --- a/doc/ref/examples/ex_objc_table_dynamic_intro.m +++ b/doc/ref/examples/ex_objc_table_dynamic_intro.m @@ -85,8 +85,6 @@ int main() TightdbCursor *c2 = [table cursorAtIndex:[table count]]; if (c2 != nil) NSLog(@"Should not get here."); - - } } diff --git a/doc/ref/examples/ex_objc_table_typed_intro.m b/doc/ref/examples/ex_objc_table_typed_intro.m index e80e094bd8..01a960425a 100644 --- a/doc/ref/examples/ex_objc_table_typed_intro.m +++ b/doc/ref/examples/ex_objc_table_typed_intro.m @@ -1,6 +1,5 @@ /* @@Example: ex_objc_table_typed_intro @@ */ - #import #import @@ -28,6 +27,15 @@ int main() cursor.Name = @"Sofie"; cursor.Age = 40; +/* + [table addOrInsertRowAtIndex:[table count] + Name:@"Jesper" + Age:200]; +*/ + cursor = [table addRow]; + cursor.Name = @"Jesper"; + cursor.Age = 200; + NSLog(@"The size of the table is now %zd", [table count]); for (PeopleTable_Cursor *ite in table) { @@ -50,12 +58,7 @@ int main() TightdbCursor *c3 = [table cursorAtIndex:[table count]]; if (c3 != nil) NSLog(@"Should not get here."); - - } } - - - /* @@EndExample@@ */ diff --git a/doc/ref/examples/ex_objc_table_typed_intro_with_many_comments.m b/doc/ref/examples/ex_objc_table_typed_intro_with_many_comments.m index 335fdcb026..e99f1cd3c7 100644 --- a/doc/ref/examples/ex_objc_table_typed_intro_with_many_comments.m +++ b/doc/ref/examples/ex_objc_table_typed_intro_with_many_comments.m @@ -48,7 +48,7 @@ int main() for (PeopleTable_Cursor *curser in query) NSLog(@"Name: %lld", [curser Age]); - /* To avoid repeating the same quiry, the result may be stored in + /* To avoid repeating the same query, the result may be stored in * a table view for multiple access. The following code executes the * query once and saves the result in a table view. */ diff --git a/src/tightdb/objc/cursor.h b/src/tightdb/objc/cursor.h index 7ccf8b3b1e..e42ec14d81 100644 --- a/src/tightdb/objc/cursor.h +++ b/src/tightdb/objc/cursor.h @@ -29,22 +29,15 @@ -(void)setNdx:(size_t)ndx; -(size_t)index; --(BOOL)setInt:(int64_t)value inColumn:(size_t)colNdx; --(BOOL)setInt:(int64_t)value inColumn:(size_t)colNdx error:(NSError *__autoreleasing *)error; --(BOOL)setString:(NSString *)value inColumn:(size_t)colNdx; --(BOOL)setString:(NSString *)value inColumn:(size_t)colNdx error:(NSError *__autoreleasing *)error; --(BOOL)setBool:(BOOL)value inColumn:(size_t)colNdx; --(BOOL)setBool:(BOOL)value inColumn:(size_t)colNdx error:(NSError *__autoreleasing *)error; --(BOOL)setFloat:(float)value inColumn:(size_t)colNdx; --(BOOL)setFloat:(float)value inColumn:(size_t)colNdx error:(NSError *__autoreleasing *)error; --(BOOL)setDouble:(double)value inColumn:(size_t)colNdx; --(BOOL)setDouble:(double)value inColumn:(size_t)colNdx error:(NSError *__autoreleasing *)error; --(BOOL)setDate:(time_t)value inColumn:(size_t)colNdx; --(BOOL)setBinary:(TightdbBinary *)value inColumn:(size_t)colNdx; --(BOOL)setBinary:(TightdbBinary *)value inColumn:(size_t)colNdx error:(NSError *__autoreleasing *)error; --(BOOL)setMixed:(TightdbMixed *)value inColumn:(size_t)colNdx; --(BOOL)setMixed:(TightdbMixed *)value inColumn:(size_t)colNdx error:(NSError *__autoreleasing *)error; --(BOOL)setTable:(TightdbTable *)value inColumn:(size_t)colNdx; +-(void)setInt:(int64_t)value inColumn:(size_t)colNdx; +-(void)setString:(NSString *)value inColumn:(size_t)colNdx; +-(void)setBool:(BOOL)value inColumn:(size_t)colNdx; +-(void)setFloat:(float)value inColumn:(size_t)colNdx; +-(void)setDouble:(double)value inColumn:(size_t)colNdx; +-(void)setDate:(time_t)value inColumn:(size_t)colNdx; +-(void)setBinary:(TightdbBinary *)value inColumn:(size_t)colNdx; +-(void)setMixed:(TightdbMixed *)value inColumn:(size_t)colNdx; +-(void)setTable:(TightdbTable *)value inColumn:(size_t)colNdx; -(int64_t)getIntInColumn:(size_t)colNdx; -(NSString *)getStringInColumn:(size_t)colNdx; @@ -66,31 +59,21 @@ @interface TightdbAccessor: NSObject -(id)initWithCursor:(TightdbCursor *)cursor columnId:(size_t)columnId; -(BOOL)getBool; --(BOOL)setBool:(BOOL)value; --(BOOL)setBool:(BOOL)value error:(NSError *__autoreleasing *)error; +-(void)setBool:(BOOL)value; -(int64_t)getInt; --(BOOL)setInt:(int64_t)value; --(BOOL)setInt:(int64_t)value error:(NSError *__autoreleasing *)error; +-(void)setInt:(int64_t)value; -(float)getFloat; --(BOOL)setFloat:(float)value; --(BOOL)setFloat:(float)value error:(NSError *__autoreleasing *)error; +-(void)setFloat:(float)value; -(double)getDouble; --(BOOL)setDouble:(double)value; --(BOOL)setDouble:(double)value error:(NSError *__autoreleasing *)error; +-(void)setDouble:(double)value; -(NSString *)getString; --(BOOL)setString:(NSString *)value; --(BOOL)setString:(NSString *)value error:(NSError *__autoreleasing *)error; +-(void)setString:(NSString *)value; -(TightdbBinary *)getBinary; --(BOOL)setBinary:(TightdbBinary *)value; --(BOOL)setBinary:(TightdbBinary *)value error:(NSError *__autoreleasing *)error; --(BOOL)setBinary:(const char *)data size:(size_t)size; --(BOOL)setBinary:(const char *)data size:(size_t)size error:(NSError *__autoreleasing *)error; +-(void)setBinary:(TightdbBinary *)value; -(time_t)getDate; --(BOOL)setDate:(time_t)value; --(BOOL)setDate:(time_t)value error:(NSError *__autoreleasing *)error; --(BOOL)setSubtable:(TightdbTable *)subtable; +-(void)setDate:(time_t)value; +-(void)setSubtable:(TightdbTable *)value; -(id)getSubtable:(Class)obj; -(TightdbMixed *)getMixed; --(BOOL)setMixed:(TightdbMixed *)value; --(BOOL)setMixed:(TightdbMixed *)value error:(NSError *__autoreleasing *)error; +-(void)setMixed:(TightdbMixed *)value; @end diff --git a/src/tightdb/objc/cursor_objc.mm b/src/tightdb/objc/cursor_objc.mm index c3bdf9c4ac..d6a2032cae 100644 --- a/src/tightdb/objc/cursor_objc.mm +++ b/src/tightdb/objc/cursor_objc.mm @@ -52,128 +52,92 @@ -(void)dealloc -(int64_t)getIntInColumn:(size_t)colNdx { - return [_table get:colNdx ndx:_ndx]; + return [_table getIntInColumn:colNdx atRow:_ndx]; } -(NSString *)getStringInColumn:(size_t)colNdx { - return [_table getString:colNdx ndx:_ndx]; + return [_table getStringInColumn:colNdx atRow:_ndx]; +} + +-(TightdbBinary *)getBinaryInColumn:(size_t)colNdx +{ + return [_table getBinaryInColumn:colNdx atRow:_ndx]; } -(BOOL)getBoolInColumn:(size_t)colNdx { - return [_table getBool:colNdx ndx:_ndx]; + return [_table getBoolInColumn:colNdx atRow:_ndx]; } -(float)getFloatInColumn:(size_t)colNdx { - return [_table getFloat:colNdx ndx:_ndx]; + return [_table getFloatInColumn:colNdx atRow:_ndx]; } -(double)getDoubleInColumn:(size_t)colNdx { - return [_table getDouble:colNdx ndx:_ndx]; + return [_table getDoubleInColumn:colNdx atRow:_ndx]; } -(time_t)getDateInColumn:(size_t)colNdx { - return [_table getDate:colNdx ndx:_ndx]; -} - --(TightdbBinary *)getBinaryInColumn:(size_t)colNdx -{ - return [_table getBinary:colNdx ndx:_ndx]; -} - --(TightdbMixed *)getMixedInColumn:(size_t)colNdx -{ - return [_table getMixed:colNdx ndx:_ndx]; + return [_table getDateInColumn:colNdx atRow:_ndx]; } -(TightdbTable *)getTableInColumn:(size_t)colNdx { - return [_table getSubtable:colNdx ndx:_ndx]; -} - - --(BOOL)setInt:(int64_t)value inColumn:(size_t)colNdx -{ - return [self setInt:value inColumn:colNdx error:nil]; + return [_table getTableInColumn:colNdx atRow:_ndx]; } --(BOOL)setInt:(int64_t)value inColumn:(size_t)colNdx error:(NSError *__autoreleasing *)error -{ - return [_table set:colNdx ndx:_ndx value:value error:error]; -} - --(BOOL)setString:(NSString *)value inColumn:(size_t)colNdx -{ - return [self setString:value inColumn:colNdx error:nil]; -} - --(BOOL)setString:(NSString *)value inColumn:(size_t)colNdx error:(NSError *__autoreleasing *)error -{ - return [_table setString:colNdx ndx:_ndx value:value error:error]; -} - --(BOOL)setBool:(BOOL)value inColumn:(size_t)colNdx -{ - return [self setBool:value inColumn:colNdx error:nil]; -} - --(BOOL)setBool:(BOOL)value inColumn:(size_t)colNdx error:(NSError *__autoreleasing *)error -{ - return [_table setBool:colNdx ndx:_ndx value:value error:error]; -} - --(BOOL)setFloat:(float)value inColumn:(size_t)colNdx +-(TightdbMixed *)getMixedInColumn:(size_t)colNdx { - return [self setFloat:value inColumn:colNdx error:nil]; + return [_table getMixedInColumn:colNdx atRow:_ndx]; } --(BOOL)setFloat:(float)value inColumn:(size_t)colNdx error:(NSError *__autoreleasing *)error +-(void)setInt:(int64_t)value inColumn:(size_t)colNdx { - return [_table setFloat:colNdx ndx:_ndx value:value error:error]; + [_table setInt:value inColumn:colNdx atRow:_ndx]; } --(BOOL)setDouble:(double)value inColumn:(size_t)colNdx +-(void)setString:(NSString *)value inColumn:(size_t)colNdx { - return [self setDouble:value inColumn:colNdx error:nil]; + [_table setString:value inColumn:colNdx atRow:_ndx]; } --(BOOL)setDouble:(double)value inColumn:(size_t)colNdx error:(NSError *__autoreleasing *)error +-(void)setBinary:(TightdbBinary *)value inColumn:(size_t)colNdx { - return [_table setDouble:colNdx ndx:_ndx value:value error:error]; + [_table setBinary:value inColumn:colNdx atRow:_ndx]; } --(BOOL)setDate:(time_t)value inColumn:(size_t)colNdx +-(void)setBool:(BOOL)value inColumn:(size_t)colNdx { - return [_table setDate:colNdx ndx:_ndx value:value]; + [_table setBool:value inColumn:colNdx atRow:_ndx]; } --(BOOL)setBinary:(TightdbBinary *)value inColumn:(size_t)colNdx +-(void)setFloat:(float)value inColumn:(size_t)colNdx { - return [self setBinary:value inColumn:colNdx error:nil]; + [_table setFloat:value inColumn:colNdx atRow:_ndx]; } --(BOOL)setBinary:(TightdbBinary *)value inColumn:(size_t)colNdx error:(NSError *__autoreleasing *)error +-(void)setDouble:(double)value inColumn:(size_t)colNdx { - return [_table setBinary:colNdx ndx:_ndx value:value error:error]; + [_table setDouble:value inColumn:colNdx atRow:_ndx]; } --(BOOL)setMixed:(TightdbMixed *)value inColumn:(size_t)colNdx +-(void)setDate:(time_t)value inColumn:(size_t)colNdx { - return [self setMixed:value inColumn:colNdx error:nil]; + [_table setDate:value inColumn:colNdx atRow:_ndx]; } --(BOOL)setMixed:(TightdbMixed *)value inColumn:(size_t)colNdx error:(NSError *__autoreleasing *)error +-(void)setTable:(TightdbTable *)value inColumn:(size_t)colNdx { - return [_table setMixed:colNdx ndx:_ndx value:value error:error]; + [_table setTable:value inColumn:colNdx atRow:_ndx]; } --(BOOL)setTable:(TightdbTable *)value inColumn:(size_t)colNdx +-(void)setMixed:(TightdbMixed *)value inColumn:(size_t)colNdx { - return [_table setSubtable:colNdx ndx:_ndx withTable:value]; + [_table setMixed:value inColumn:colNdx atRow:_ndx]; } @end @@ -195,145 +159,99 @@ -(id)initWithCursor:(TightdbCursor *)cursor columnId:(size_t)columnId return self; } - -(BOOL)getBool { - return [_cursor.table getBool:_columnId ndx:_cursor.ndx]; -} - --(BOOL)setBool:(BOOL)value -{ - return [self setBool:value error:nil]; + return [_cursor.table getBoolInColumn:_columnId atRow:_cursor.ndx]; } --(BOOL)setBool:(BOOL)value error:(NSError *__autoreleasing *)error +-(void)setBool:(BOOL)value { - return [_cursor.table setBool:_columnId ndx:_cursor.ndx value:value error:error]; + [_cursor.table setBool:value inColumn:_columnId atRow:_cursor.ndx]; } -(int64_t)getInt { - return [_cursor.table get:_columnId ndx:_cursor.ndx]; + return [_cursor.table getIntInColumn:_columnId atRow:_cursor.ndx]; } --(BOOL)setInt:(int64_t)value +-(void)setInt:(int64_t)value { - return [self setInt:value error:nil]; -} - --(BOOL)setInt:(int64_t)value error:(NSError *__autoreleasing *)error -{ - return [_cursor.table set:_columnId ndx:_cursor.ndx value:value error:error]; + [_cursor.table setInt:value inColumn:_columnId atRow:_cursor.ndx]; } -(float)getFloat { - return [_cursor.table getFloat:_columnId ndx:_cursor.ndx]; -} - --(BOOL)setFloat:(float)value -{ - return [self setFloat:value error:nil]; + return [_cursor.table getFloatInColumn:_columnId atRow:_cursor.ndx]; } --(BOOL)setFloat:(float)value error:(NSError *__autoreleasing *)error +-(void)setFloat:(float)value { - return [_cursor.table setFloat:_columnId ndx:_cursor.ndx value:value error:error]; + [_cursor.table setFloat:value inColumn:_columnId atRow:_cursor.ndx]; } -(double)getDouble { - return [_cursor.table getDouble:_columnId ndx:_cursor.ndx]; -} - --(BOOL)setDouble:(double)value -{ - return [self setDouble:value error:nil]; + return [_cursor.table getDoubleInColumn:_columnId atRow:_cursor.ndx]; } --(BOOL)setDouble:(double)value error:(NSError *__autoreleasing *)error +-(void)setDouble:(double)value { - return [_cursor.table setDouble:_columnId ndx:_cursor.ndx value:value error:error]; + [_cursor.table setDouble:value inColumn:_columnId atRow:_cursor.ndx]; } -(NSString *)getString { - return [_cursor.table getString:_columnId ndx:_cursor.ndx]; -} - --(BOOL)setString:(NSString *)value -{ - return [self setString:value error:nil]; + return [_cursor.table getStringInColumn:_columnId atRow:_cursor.ndx]; } --(BOOL)setString:(NSString *)value error:(NSError *__autoreleasing *)error +-(void)setString:(NSString *)value { - return [_cursor.table setString:_columnId ndx:_cursor.ndx value:value error:error]; + [_cursor.table setString:value inColumn:_columnId atRow:_cursor.ndx]; } -(TightdbBinary *)getBinary { - return [_cursor.table getBinary:_columnId ndx:_cursor.ndx]; + return [_cursor.table getBinaryInColumn:_columnId atRow:_cursor.ndx]; } --(BOOL)setBinary:(TightdbBinary *)value +-(void)setBinary:(TightdbBinary *)value { - return [self setBinary:value error:nil]; -} - --(BOOL)setBinary:(TightdbBinary *)value error:(NSError *__autoreleasing *)error -{ - return [_cursor.table setBinary:_columnId ndx:_cursor.ndx value:value error:error]; -} - --(BOOL)setBinary:(const char *)data size:(size_t)size -{ - return [self setBinary:data size:size error:nil]; -} - --(BOOL)setBinary:(const char *)data size:(size_t)size error:(NSError *__autoreleasing *)error -{ - return [_cursor.table setBinary:_columnId ndx:_cursor.ndx data:data size:size error:error]; + [_cursor.table setBinary:value inColumn:_columnId atRow:_cursor.ndx]; } +// FIXME: should it be setBinaryWithBuffer / setBinaryWithBinary ? +// -(BOOL)setBinary:(const char *)data size:(size_t)size +// { +// return [_cursor.table setBinary:_columnId ndx:_cursor.ndx data:data size:size error:error]; +// } -(time_t)getDate { - return [_cursor.table getDate:_columnId ndx:_cursor.ndx]; -} - --(BOOL)setDate:(time_t)value -{ - return [self setDate:value error:nil]; + return [_cursor.table getDateInColumn:_columnId atRow:_cursor.ndx]; } --(BOOL)setDate:(time_t)value error:(NSError *__autoreleasing *)error +-(void)setDate:(time_t)value { - return [_cursor.table setDate:_columnId ndx:_cursor.ndx value:value error:error]; + [_cursor.table setDate:value inColumn:_columnId atRow:_cursor.ndx]; } -(id)getSubtable:(Class)obj { - return [_cursor.table getSubtable:_columnId ndx:_cursor.ndx withClass:obj]; + return [_cursor.table getTableInColumn:_columnId atRow:_cursor.ndx withClass:obj]; } --(BOOL)setSubtable:(TightdbTable *)subtable +-(void)setSubtable:(TightdbTable *)value { - return [_cursor.table setSubtable:_columnId ndx:_cursor.ndx withTable:subtable]; + [_cursor.table setTable:value inColumn:_columnId atRow:_cursor.ndx]; } -(TightdbMixed *)getMixed { - return [_cursor.table getMixed:_columnId ndx:_cursor.ndx]; -} - --(BOOL)setMixed:(TightdbMixed *)value -{ - return [self setMixed:value error:nil]; + return [_cursor.table getMixedInColumn:_columnId atRow:_cursor.ndx]; } --(BOOL)setMixed:(TightdbMixed *)value error:(NSError *__autoreleasing *)error +-(void)setMixed:(TightdbMixed *)value { - return [_cursor.table setMixed:_columnId ndx:_cursor.ndx value:value error:error]; + [_cursor.table setMixed:value inColumn:_columnId atRow:_cursor.ndx]; } @end diff --git a/src/tightdb/objc/group.h b/src/tightdb/objc/group.h index 4e240a4aa2..90db81f151 100644 --- a/src/tightdb/objc/group.h +++ b/src/tightdb/objc/group.h @@ -20,16 +20,23 @@ #import +@class TightdbBinary; @class TightdbTable; @interface TightdbGroup: NSObject -+(TightdbGroup *)groupWithFilename:(NSString *)filename; -+(TightdbGroup *)groupWithFilename:(NSString *)filename error:(NSError *__autoreleasing *)error; -+(TightdbGroup *)groupWithBuffer:(const char*)data size:(size_t)size; -+(TightdbGroup *)groupWithBuffer:(const char*)data size:(size_t)size error:(NSError *__autoreleasing *)error; + ++(TightdbGroup *)groupWithFile:(NSString *)filename withError:(NSError *__autoreleasing *)error; + +/** + * You pass the ownership of the specified buffer to the group. The + * buffer will eventually be freed using the C function free(), so + * the buffer you pass, must have been allocated using C function + * malloc(). + */ ++(TightdbGroup *)groupWithBuffer:(TightdbBinary *)buffer withError:(NSError *__autoreleasing *)error; + +(TightdbGroup *)group; -+(TightdbGroup *)groupWithError:(NSError *__autoreleasing *)error; -(size_t)getTableCount; -(NSString *)getTableName:(size_t)table_ndx; @@ -49,7 +56,6 @@ * This method returns nil if it encounters a memory allocation error * (out of memory). */ --(TightdbTable *)getTable:(NSString *)name; -(TightdbTable *)getTable:(NSString *)name error:(NSError *__autoreleasing *)error; /** @@ -61,13 +67,18 @@ * The specified table class must be one that is declared by using * one of the table macros TIGHTDB_TABLE_*. */ --(id)getTable:(NSString *)name withClass:(Class)obj; -(id)getTable:(NSString *)name withClass:(Class)obj error:(NSError *__autoreleasing *)error; /* Serialization */ --(BOOL)write:(NSString *)filePath; --(BOOL)write:(NSString *)filePath error:(NSError *__autoreleasing *)error; --(const char*)writeToMem:(size_t*)size; --(const char*)writeToMem:(size_t*)size error:(NSError *__autoreleasing *)error; +-(BOOL)writeToFile:(NSString *)filePath withError:(NSError *__autoreleasing *)error; + +/** + * The ownership of the returned buffer is transferred to the + * caller. The buffer will have been allocated using C function + * malloc(), and it is the responsibility of the caller that C + * function free() is eventually called to free the buffer. + */ +-(TightdbBinary *)writeToBuffer; + @end diff --git a/src/tightdb/objc/group_objc.mm b/src/tightdb/objc/group_objc.mm index 8ae95ba099..eaee867048 100644 --- a/src/tightdb/objc/group_objc.mm +++ b/src/tightdb/objc/group_objc.mm @@ -22,20 +22,26 @@ @implementation TightdbGroup BOOL m_read_only; } -+(TightdbGroup*)group -{ - return [self groupWithError:nil]; -} -+(TightdbGroup*)groupWithError:(NSError* __autoreleasing*)error ++(TightdbGroup*)group { TightdbGroup* group = [[TightdbGroup alloc] init]; - TIGHTDB_EXCEPTION_ERRHANDLER(group->m_group = new tightdb::Group;, nil); + try { + group->m_group = new tightdb::Group; + } + catch (std::exception& ex) { + NSException *exception = [NSException exceptionWithName:@"tightdb:core_exception" + reason:[NSString stringWithUTF8String:ex.what()] + userInfo:[NSMutableDictionary dictionary]]; // IMPORTANT: cannot not be nil !! + [exception raise]; + } group->m_is_owned = YES; group->m_read_only = NO; return group; } + +// Private. // Careful with this one - Remember that group will be deleted on dealloc. +(TightdbGroup*)groupWithNativeGroup:(tightdb::Group*)group isOwned:(BOOL)is_owned readOnly:(BOOL)read_only { @@ -47,42 +53,71 @@ +(TightdbGroup*)groupWithNativeGroup:(tightdb::Group*)group isOwned:(BOOL)is_own } -+(TightdbGroup*)groupWithFilename:(NSString*)filename -{ - return [self groupWithFilename:filename error:nil]; -} - -+(TightdbGroup*)groupWithFilename:(NSString*)filename error:(NSError**)error ++(TightdbGroup *)groupWithFile:(NSString *)filename withError:(NSError **)error { TightdbGroup* group = [[TightdbGroup alloc] init]; if (!group) return nil; - TIGHTDB_EXCEPTION_ERRHANDLER( - group->m_group = new tightdb::Group(tightdb::StringData(ObjcStringAccessor(filename)));, - nil); + try { + group->m_group = new tightdb::Group(tightdb::StringData(ObjcStringAccessor(filename))); + } + // TODO: capture this in a macro or function, shared group constructor uses the same pattern. + catch (tightdb::util::File::PermissionDenied& ex) { + if (error) // allow nil as the error argument + *error = make_tightdb_error(tdb_err_File_PermissionDenied, [NSString stringWithUTF8String:ex.what()]); + return nil; + + } + catch (tightdb::util::File::Exists& ex) { + if(error) // allow nil as the error argument + *error = make_tightdb_error(tdb_err_File_Exists, [NSString stringWithUTF8String:ex.what()]); + return nil; + + } + catch (tightdb::util::File::AccessError& ex) { + if (error) // allow nil as the error argument + *error = make_tightdb_error(tdb_err_File_AccessError, [NSString stringWithUTF8String:ex.what()]); + return nil; + + } + catch (std::exception& ex) { + if (error) // allow nil as the error argument + *error = make_tightdb_error(tdb_err_Fail, [NSString stringWithUTF8String:ex.what()]); + return nil; + } group->m_is_owned = YES; group->m_read_only = NO; return group; } -+(TightdbGroup*)groupWithBuffer:(const char*)data size:(size_t)size -{ - return [self groupWithBuffer:data size:size error:nil]; -} -+(TightdbGroup*)groupWithBuffer:(const char*)data size:(size_t)size error:(NSError* __autoreleasing*)error ++(TightdbGroup*)groupWithBuffer:(TightdbBinary*)buffer withError:(NSError**)error { TightdbGroup* group = [[TightdbGroup alloc] init]; if (!group) return nil; - TIGHTDB_EXCEPTION_ERRHANDLER( - group->m_group = new tightdb::Group(tightdb::BinaryData(data, size));, - nil); + try { + const tightdb::BinaryData& buffer_2 = [buffer getNativeBinary]; + bool take_ownership = true; + group->m_group = new tightdb::Group(buffer_2, take_ownership); + } + catch (tightdb::InvalidDatabase& ex) { + if (error) // allow nil as the error argument + *error = make_tightdb_error(tdb_err_InvalidDatabase, [NSString stringWithUTF8String:ex.what()]); + return nil; + } + catch (std::exception& ex) { + NSException *exception = [NSException exceptionWithName:@"tightdb:core_exception" + reason:[NSString stringWithUTF8String:ex.what()] + userInfo:[NSMutableDictionary dictionary]]; // IMPORTANT: cannot not be nil !! + [exception raise]; + } group->m_is_owned = YES; group->m_read_only = NO; return group; } + -(void)dealloc { #ifdef TIGHTDB_DEBUG @@ -102,33 +137,59 @@ -(NSString*)getTableName:(size_t)table_ndx return to_objc_string(m_group->get_table_name(table_ndx)); } --(BOOL)write:(NSString*)file_path -{ - return [self write:file_path error:nil]; -} --(BOOL)write:(NSString*)file_path error:(NSError* __autoreleasing*)error +-(BOOL)writeToFile:(NSString*)path withError:(NSError* __autoreleasing*)error { - TIGHTDB_EXCEPTION_ERRHANDLER( - m_group->write(tightdb::StringData(ObjcStringAccessor(file_path)));, - NO); + try { + m_group->write(tightdb::StringData(ObjcStringAccessor(path))); + } + // TODO: capture this in a macro or function, shared group constructor uses the same pattern. + // Except, here, we return no instead of nil. + catch (tightdb::util::File::PermissionDenied& ex) { + if (error) // allow nil as the error argument + *error = make_tightdb_error(tdb_err_File_PermissionDenied, [NSString stringWithUTF8String:ex.what()]); + return NO; + + } + catch (tightdb::util::File::Exists& ex) { + if (error) // allow nil as the error argument + *error = make_tightdb_error(tdb_err_File_Exists, [NSString stringWithUTF8String:ex.what()]); + return NO; + + } + catch (tightdb::util::File::AccessError& ex) { + if (error) // allow nil as the error argument + *error = make_tightdb_error(tdb_err_File_AccessError, [NSString stringWithUTF8String:ex.what()]); + return NO; + + } + catch (std::exception& ex) { + if (error) // allow nil as the error argument + *error = make_tightdb_error(tdb_err_Fail, [NSString stringWithUTF8String:ex.what()]); + return NO; + } return YES; } --(const char*)writeToMem:(size_t*)size -{ - return [self writeToMem:size error:nil]; -} --(const char*)writeToMem:(size_t*)size error:(NSError* __autoreleasing*)error +-(TightdbBinary*)writeToBuffer { - TIGHTDB_EXCEPTION_ERRHANDLER( - tightdb::BinaryData buffer = m_group->write_to_mem(); - *size = buffer.size(); - return buffer.data();, - nil); + TightdbBinary* buffer = [[TightdbBinary alloc] init]; + if (!buffer) + return nil; + try { + [buffer getNativeBinary] = m_group->write_to_mem(); + } + catch (std::exception& ex) { + NSException *exception = [NSException exceptionWithName:@"tightdb:core_exception" + reason:[NSString stringWithUTF8String:ex.what()] + userInfo:[NSMutableDictionary dictionary]]; // IMPORTANT: cannot not be nil !! + [exception raise]; + } + return buffer; } + -(BOOL)hasTable:(NSString*)name { return m_group->has_table(ObjcStringAccessor(name)); @@ -141,44 +202,61 @@ -(BOOL)hasTable:(NSString*)name withClass:(__unsafe_unretained Class)class_obj { if (!m_group->has_table(ObjcStringAccessor(name))) return NO; - TightdbTable* table = [self getTable:name withClass:class_obj]; + TightdbTable* table = [self getTable:name withClass:class_obj error:nil]; return table != nil; } --(id)getTable:(NSString*)name +-(id)getTable:(NSString*)name error:(NSError**)error { - return [self getTable:name error:nil]; -} + // FIXME: Read-only errors should probably be handled by throwing + // an exception. That is what is done in other places in this + // binding, and it also seems like the right thing to do. This + // method should also not take an error argument. + if (m_read_only) { + // A group is readonly when it has been extracted from a shared group in a read transaction. + // In this case, getTable should return nil for non-existing tables. + if (![self hasTable:name]) { + if (error) // allow nil as the error argument + *error = make_tightdb_error(tdb_err_TableNotFound, @"The table was not found. Cannot create the table in read only mode."); + return nil; + } + } --(id)getTable:(NSString*)name error:(NSError* __autoreleasing*)error -{ TightdbTable* table = [[TightdbTable alloc] _initRaw]; if (TIGHTDB_UNLIKELY(!table)) return nil; - TIGHTDB_EXCEPTION_ERRHANDLER( + TIGHTDB_EXCEPTION_HANDLER_CORE_EXCEPTION( tightdb::TableRef table_2 = m_group->get_table(ObjcStringAccessor(name)); - [table setNativeTable:table_2.get()];, - nil); + [table setNativeTable:table_2.get()];) [table setParent:self]; [table setReadOnly:m_read_only]; return table; } --(id)getTable:(NSString*)name withClass:(__unsafe_unretained Class)class_obj -{ - return [self getTable:name withClass:class_obj error:nil]; -} // FIXME: Check that the specified class derives from Table. -(id)getTable:(NSString*)name withClass:(__unsafe_unretained Class)class_obj error:(NSError* __autoreleasing*)error { + // FIXME: Read-only errors should probably be handled by throwing + // an exception. That is what is done in other places in this + // binding, and it also seems like the right thing to do. This + // method should also not take an error argument. + if (m_read_only) { + // A group is readonly when it has been extracted from a shared group in a read transaction. + // In this case, getTable should return nil for non-existing tables. + if (![self hasTable:name]) { + if (error) // allow nil as the error argument + *error = make_tightdb_error(tdb_err_TableNotFound, @"The table was not found. Cannot create the table in read only mode."); + return nil; + } + } + TightdbTable* table = [[class_obj alloc] _initRaw]; if (TIGHTDB_UNLIKELY(!table)) return nil; bool was_created; - TIGHTDB_EXCEPTION_ERRHANDLER( + TIGHTDB_EXCEPTION_HANDLER_CORE_EXCEPTION( tightdb::TableRef table_2 = m_group->get_table(ObjcStringAccessor(name), was_created); - [table setNativeTable:table_2.get()];, - nil); + [table setNativeTable:table_2.get()];) [table setParent:self]; [table setReadOnly:m_read_only]; if (was_created) { diff --git a/src/tightdb/objc/group_shared.h b/src/tightdb/objc/group_shared.h index 61f6f5b555..db9683a75d 100644 --- a/src/tightdb/objc/group_shared.h +++ b/src/tightdb/objc/group_shared.h @@ -21,13 +21,13 @@ #import #import -typedef void(^TightdbSharedGroupReadTransactionBlock)(TightdbGroup *group); -typedef BOOL(^TightdbSharedGroupWriteTransactionBlock)(TightdbGroup *group); +typedef void(^TightdbReadBlock)(TightdbGroup *group); +typedef BOOL(^TightdbWriteBlock)(TightdbGroup *group); @interface TightdbSharedGroup: NSObject -+(TightdbSharedGroup *)groupWithFilename:(NSString *)filename; ++(TightdbSharedGroup *)sharedGroupWithFile:(NSString *)path withError:(NSError **)error; --(void)readTransaction:(TightdbSharedGroupReadTransactionBlock)block; --(void)writeTransaction:(TightdbSharedGroupWriteTransactionBlock)block; +-(void)readWithBlock:(TightdbReadBlock)block; +-(BOOL)writeWithBlock:(TightdbWriteBlock)block withError:(NSError **)error; @end diff --git a/src/tightdb/objc/group_shared_objc.mm b/src/tightdb/objc/group_shared_objc.mm index 7a22a6fe79..8b92f69b7d 100644 --- a/src/tightdb/objc/group_shared_objc.mm +++ b/src/tightdb/objc/group_shared_objc.mm @@ -14,23 +14,36 @@ @implementation TightdbSharedGroup tightdb::util::UniquePtr m_shared_group; } -+(TightdbSharedGroup*)groupWithFilename:(NSString*)filename ++(TightdbSharedGroup*)sharedGroupWithFile:(NSString*)path withError:(NSError**)error // FIXME: Confirm __autoreleasing is not needed with ARC { TightdbSharedGroup* shared_group = [[TightdbSharedGroup alloc] init]; if (!shared_group) return nil; try { - shared_group->m_shared_group.reset(new tightdb::SharedGroup(tightdb::StringData(ObjcStringAccessor(filename)))); + shared_group->m_shared_group.reset(new tightdb::SharedGroup(tightdb::StringData(ObjcStringAccessor(path)))); } - catch (...) { - // FIXME: Diffrent exception types mean different things. More - // details must be made available. We should proably have - // special catches for at least these: - // tightdb::File::AccessError (and various derivatives), - // tightdb::ResourceAllocError, std::bad_alloc. In general, - // any core library function or operator that is not declared - // 'noexcept' must be considered as being able to throw - // anything derived from std::exception. + // TODO: capture this in a macro or function, group constructor uses the same pattern. + catch (tightdb::util::File::PermissionDenied& ex) { + if (error) // allow nil as the error argument + *error = make_tightdb_error(tdb_err_File_PermissionDenied, [NSString stringWithUTF8String:ex.what()]); + return nil; + + } + catch (tightdb::util::File::Exists& ex) { + if (error) // allow nil as the error argument + *error = make_tightdb_error(tdb_err_File_Exists, [NSString stringWithUTF8String:ex.what()]); + return nil; + + } + catch (tightdb::util::File::AccessError& ex) { + if (error) // allow nil as the error argument + *error = make_tightdb_error(tdb_err_File_AccessError, [NSString stringWithUTF8String:ex.what()]); + return nil; + + } + catch (std::exception& ex) { + if (error) // allow nil as the error argument + *error = make_tightdb_error(tdb_err_Fail, [NSString stringWithUTF8String:ex.what()]); return nil; } return shared_group; @@ -43,39 +56,85 @@ -(void)dealloc #endif } - --(void)readTransaction:(TightdbSharedGroupReadTransactionBlock)block +-(void)readWithBlock:(TightdbReadBlock)block { + const tightdb::Group* group; + try { + group = &m_shared_group->begin_read(); + } + catch (std::exception& ex) { + NSException* exception = [NSException exceptionWithName:@"tightdb:core_exception" + reason:[NSString stringWithUTF8String:ex.what()] + userInfo:[NSMutableDictionary dictionary]]; // IMPORTANT: cannot not be nil !! + [exception raise]; + } + @try { - const tightdb::Group& group = m_shared_group->begin_read(); - TightdbGroup* group_2 = [TightdbGroup groupWithNativeGroup:const_cast(&group) isOwned:NO readOnly:YES]; + // No TightDB Obj-C methods used in the block + // should throw anything but NSException or derivatives. Note: if the client calls other libraries + // throwing other kinds of exceptions they will leak back to the client code, if he does not + // catch them within the block. + TightdbGroup* group_2 = [TightdbGroup groupWithNativeGroup:const_cast(group) isOwned:NO readOnly:YES]; block(group_2); - } - @catch (NSException* exception) { - @throw exception; + } @finally { m_shared_group->end_read(); } } --(void)writeTransaction:(TightdbSharedGroupWriteTransactionBlock)block + +-(BOOL)writeWithBlock:(TightdbWriteBlock)block withError:(NSError**)error { + tightdb::Group* group; + try { + group = &m_shared_group->begin_write(); + } + catch (std::exception& ex) { + // File access errors are treated as exceptions here since they should not occur after the shared + // group has already beenn successfully opened on the file and memeory mapped. The shared group constructor handles + // the excepted error related to file access. + NSException* exception = [NSException exceptionWithName:@"tightdb:core_exception" + reason:[NSString stringWithUTF8String:ex.what()] + userInfo:[NSMutableDictionary dictionary]]; + [exception raise]; + } + + BOOL confirmation = NO; @try { - tightdb::Group& group = m_shared_group->begin_write(); - TightdbGroup* group_2 = [TightdbGroup groupWithNativeGroup:&group isOwned:NO readOnly:NO]; - if (block(group_2)) { - m_shared_group->commit(); - } - else { - m_shared_group->rollback(); - } + TightdbGroup* group_2 = [TightdbGroup groupWithNativeGroup:group isOwned:NO readOnly:NO]; + confirmation = block(group_2); } @catch (NSException* exception) { m_shared_group->rollback(); - @throw exception; + @throw; } -} + if (confirmation) { + // Required to avoid leaking of core exceptions. + try { + m_shared_group->commit(); + } + catch (std::exception& ex) { + NSException* exception = [NSException exceptionWithName:@"tightdb:core_exception" + reason:@"" + userInfo:[NSMutableDictionary dictionary]]; + [exception raise]; + } + return YES; + } + + // As of now the only kind of error is when the block decides to rollback. + // In the future, other kinds may be relevant (network error etc).. + // It could be discussed if rollback is an error at all. But, if the method is + // returning NO it makes sense the user can check the error an see that it + // was caused by a decision of the block to roll back. + + if (error) // allow nil as the error argument + *error = make_tightdb_error(tdb_err_Rollback, @"The block code requested a rollback"); + + m_shared_group->rollback(); + return NO; +} @end diff --git a/src/tightdb/objc/helper_macros.h b/src/tightdb/objc/helper_macros.h index a04abc442b..c4a178bfc4 100644 --- a/src/tightdb/objc/helper_macros.h +++ b/src/tightdb/objc/helper_macros.h @@ -146,14 +146,6 @@ #define TIGHTDB_COLUMN_INSERT_4_Y(table, col, _row, value, type) [table _insertSubtableCopy:col row:_row subtable:value] #define TIGHTDB_COLUMN_INSERT_4_N(table, col, row, _value, type) [table insert##type:col ndx:row value:_value] -/* TIGHTDB_COLUMN_INSERT_ERROR */ - -#define TIGHTDB_COLUMN_INSERT_ERROR(table, col, row, value, type, error) TIGHTDB_COLUMN_INSERT_ERROR_2(TIGHTDB_IS_SUBTABLE(type), table, col, row, value, type, error) -#define TIGHTDB_COLUMN_INSERT_ERROR_2(is_subtable, table, col, row, value, type, error) TIGHTDB_COLUMN_INSERT_ERROR_3(is_subtable, table, col, row, value, type, error) -#define TIGHTDB_COLUMN_INSERT_ERROR_3(is_subtable, table, col, row, value, type, error) TIGHTDB_COLUMN_INSERT_ERROR_4_##is_subtable(table, col, row, value, type, error) -#define TIGHTDB_COLUMN_INSERT_ERROR_4_Y(table, col, _row, value, type, error) [table _insertSubtableCopy:col row:_row subtable:value error:error] -#define TIGHTDB_COLUMN_INSERT_ERROR_4_N(table, col, row, _value, type, error) [table insert##type:col ndx:row value:_value error:error] - /* TIGHTDB_CURSOR_PROPERTY */ @@ -174,8 +166,7 @@ #define TIGHTDB_CURSOR_PROPERTY_DEF_SIMPLE(name, type) \ @property TIGHTDB_TYPE_##type name; \ -(TIGHTDB_TYPE_##type)name; \ --(void)set##name:(TIGHTDB_TYPE_##type)value; \ --(BOOL)set##name:(TIGHTDB_TYPE_##type)value error:(NSError* __autoreleasing*)error; +-(void)set##name:(TIGHTDB_TYPE_##type)value; #define TIGHTDB_CURSOR_PROPERTY_IMPL_SIMPLE(name, type) \ -(TIGHTDB_TYPE_##type)name \ @@ -185,13 +176,8 @@ -(void)set##name:(TIGHTDB_TYPE_##type)value \ { \ [_##name set##type:value]; \ -} \ --(BOOL)set##name:(TIGHTDB_TYPE_##type)value error:(NSError* __autoreleasing*)error \ -{ \ - return [_##name set##type:value error:error]; \ } - #define TIGHTDB_CURSOR_PROPERTY_DEF_SUBTABLE(name, type) \ @property type* name; \ -(type*)name; \ diff --git a/src/tightdb/objc/table.h b/src/tightdb/objc/table.h index 66a970844a..1b74206f25 100644 --- a/src/tightdb/objc/table.h +++ b/src/tightdb/objc/table.h @@ -88,23 +88,8 @@ -(BOOL)isEqual:(TightdbTable *)other; -/** - * @{ - * - * If the specified column is neither a subtable column, nor a mixed - * column, then these methods return nil. They also return nil for a - * mixed column, if the mixed value at the specified row is not a - * subtable. The second method also returns nil if the type of the - * subtable is not compatible with the specified table - * class. Finally, these methods return nil if they encounter a - * memory allocation error (out of memory). - * - * The specified table class must be one that is declared by using - * one of the table macros TIGHTDB_TABLE_*. - */ --(TightdbTable *)getSubtable:(size_t)colNdx ndx:(size_t)ndx; --(id)getSubtable:(size_t)colNdx ndx:(size_t)ndx withClass:(Class)obj; -/** @} */ +-(BOOL)isReadOnly; + /** * This method will return NO if it encounters a memory allocation @@ -139,9 +124,7 @@ /* Only curser based add should be public. This is just a temporaray way to hide the methods. */ /* TODO: Move to class extension. */ -(size_t)_addRow; --(size_t)_addRowWithError:(NSError *__autoreleasing *)error; -(size_t)_addRows:(size_t)rowCount; --(size_t)_addRows:(size_t)rowCount error:(NSError *__autoreleasing *)error; -(BOOL)clear; -(BOOL)clearWithError:(NSError *__autoreleasing *)error; @@ -158,27 +141,34 @@ -(BOOL)insertRow:(size_t)ndx; -(BOOL)insertRow:(size_t)ndx error:(NSError *__autoreleasing *)error; -/* Adaptive ints. */ -/* FIXME: Should be getInt:(int64_t)value inColumn:(size_t)colNdx andRow:(size_t)rowNdx; */ --(int64_t)get:(size_t)colNdx ndx:(size_t)ndx; --(BOOL)set:(size_t)colNdx ndx:(size_t)ndx value:(int64_t)value; --(BOOL)set:(size_t)colNdx ndx:(size_t)ndx value:(int64_t)value error:(NSError *__autoreleasing *)error; --(BOOL)getBool:(size_t)colNdx ndx:(size_t)ndx; --(BOOL)setBool:(size_t)colNdx ndx:(size_t)ndx value:(BOOL)value; --(BOOL)setBool:(size_t)colNdx ndx:(size_t)ndx value:(BOOL)value error:(NSError *__autoreleasing *)error; --(float)getFloat:(size_t)colNdx ndx:(size_t)ndx; --(BOOL)setFloat:(size_t)colNdx ndx:(size_t)ndx value:(float)value; --(BOOL)setFloat:(size_t)colNdx ndx:(size_t)ndx value:(float)value error:(NSError *__autoreleasing *)error; --(double)getDouble:(size_t)colNdx ndx:(size_t)ndx; --(BOOL)setDouble:(size_t)colNdx ndx:(size_t)ndx value:(double)value; --(BOOL)setDouble:(size_t)colNdx ndx:(size_t)ndx value:(double)value error:(NSError *__autoreleasing *)error; --(time_t)getDate:(size_t)colNdx ndx:(size_t)ndx; --(BOOL)setDate:(size_t)colNdx ndx:(size_t)ndx value:(time_t)value; --(BOOL)setDate:(size_t)colNdx ndx:(size_t)ndx value:(time_t)value error:(NSError *__autoreleasing *)error; - -/* NOTE: Low-level insert functions. Always insert in all columns at once - and call InsertDone after to avoid table getting un-balanced. */ -/* FIXME: Should be insertBool:(BOOL)value inColumn:(size_t)colNdx andRow:(size_t)rowNdx; */ +-(BOOL)getBoolInColumn:(size_t)colNdx atRow:(size_t)ndx; +-(int64_t)getIntInColumn:(size_t)colNdx atRow:(size_t)ndx; +-(float)getFloatInColumn:(size_t)colNdx atRow:(size_t)ndx; +-(double)getDoubleInColumn:(size_t)colNdx atRow:(size_t)ndx; +-(time_t)getDateInColumn:(size_t)colNdx atRow:(size_t)ndx; +-(NSString *)getStringInColumn:(size_t)colNdx atRow:(size_t)ndx; +-(TightdbBinary *)getBinaryInColumn:(size_t)colNdx atRow:(size_t)ndx; +-(TightdbTable *)getTableInColumn:(size_t)colNdx atRow:(size_t)ndx; +-(id)getTableInColumn:(size_t)colNdx atRow:(size_t)ndx withClass:(Class)obj; +-(TightdbMixed *)getMixedInColumn:(size_t)colNdx atRow:(size_t)ndx; + +-(void)setInt:(int64_t)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx; +-(void)setBool:(BOOL)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx; +-(void)setFloat:(float)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx; +-(void)setDouble:(double)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx; +-(void)setDate:(time_t)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx; +-(void)setString:(NSString *)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx; +-(void)setBinary:(TightdbBinary *)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx; +-(void)setTable:(TightdbTable *)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx; +-(void)setMixed:(TightdbMixed *)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx; + + +/* FIXME: It has been decided that the insert methods must not be a + * part of the public Obj-C API. All row insertion must happen by + * inserting a complete rows. This must occur either by calling + * `addRow` and then setting each column value afterwards, or possibly + * by calling a method that takes all column values as arguments at + * once. */ -(BOOL)insertBool:(size_t)colNdx ndx:(size_t)ndx value:(BOOL)value; -(BOOL)insertBool:(size_t)colNdx ndx:(size_t)ndx value:(BOOL)value error:(NSError *__autoreleasing *)error; -(BOOL)insertInt:(size_t)colNdx ndx:(size_t)ndx value:(int64_t)value; @@ -198,17 +188,6 @@ -(BOOL)insertDone; -(BOOL)insertDoneWithError:(NSError *__autoreleasing *)error; -/* Strings */ --(NSString *)getString:(size_t)colNdx ndx:(size_t)ndx; --(BOOL)setString:(size_t)colNdx ndx:(size_t)ndx value:(NSString *)value; --(BOOL)setString:(size_t)colNdx ndx:(size_t)ndx value:(NSString *)value error:(NSError *__autoreleasing *)error; - -/* Binary */ --(TightdbBinary *)getBinary:(size_t)colNdx ndx:(size_t)ndx; --(BOOL)setBinary:(size_t)colNdx ndx:(size_t)ndx value:(TightdbBinary *)value; --(BOOL)setBinary:(size_t)colNdx ndx:(size_t)ndx value:(TightdbBinary *)value error:(NSError *__autoreleasing *)error; --(BOOL)setBinary:(size_t)colNdx ndx:(size_t)ndx data:(const char *)data size:(size_t)size; --(BOOL)setBinary:(size_t)colNdx ndx:(size_t)ndx data:(const char *)data size:(size_t)size error:(NSError *__autoreleasing *)error; /* Subtables */ -(size_t)getTableSize:(size_t)colNdx ndx:(size_t)ndx; @@ -216,15 +195,12 @@ -(BOOL)insertSubtable:(size_t)colNdx ndx:(size_t)ndx error:(NSError *__autoreleasing *)error; -(BOOL)clearSubtable:(size_t)colNdx ndx:(size_t)ndx; -(BOOL)clearSubtable:(size_t)colNdx ndx:(size_t)ndx error:(NSError *__autoreleasing *)error; --(BOOL)setSubtable:(size_t)col_ndx ndx:(size_t)ndx withTable:(TightdbTable *)subtable; /* Mixed */ --(TightdbMixed *)getMixed:(size_t)colNdx ndx:(size_t)ndx; + -(TightdbType)getMixedType:(size_t)colNdx ndx:(size_t)ndx; -(BOOL)insertMixed:(size_t)colNdx ndx:(size_t)ndx value:(TightdbMixed *)value; -(BOOL)insertMixed:(size_t)colNdx ndx:(size_t)ndx value:(TightdbMixed *)value error:(NSError *__autoreleasing *)error; --(BOOL)setMixed:(size_t)colNdx ndx:(size_t)ndx value:(TightdbMixed *)value; --(BOOL)setMixed:(size_t)colNdx ndx:(size_t)ndx value:(TightdbMixed *)value error:(NSError *__autoreleasing *)error; -(size_t)addColumnWithType:(TightdbType)type andName:(NSString *)name; -(size_t)addColumnWithType:(TightdbType)type andName:(NSString *)name error:(NSError *__autoreleasing *)error; diff --git a/src/tightdb/objc/table_objc.mm b/src/tightdb/objc/table_objc.mm index adec5a7721..6a548e1ec8 100644 --- a/src/tightdb/objc/table_objc.mm +++ b/src/tightdb/objc/table_objc.mm @@ -51,7 +51,7 @@ -(BOOL)isEqual:(TightdbBinary*)bin { return m_data == bin->m_data; } --(tightdb::BinaryData)getNativeBinary +-(tightdb::BinaryData&)getNativeBinary { return m_data; } @@ -457,6 +457,8 @@ @implementation TightdbTable TightdbCursor* m_tmp_cursor; } + + -(id)init { self = [super init]; @@ -535,60 +537,14 @@ -(void)setReadOnly:(BOOL)read_only m_read_only = read_only; } --(BOOL)isEqual:(TightdbTable*)other -{ - return *m_table == *other->m_table; -} - --(BOOL)setSubtable:(size_t)col_ndx ndx:(size_t)ndx withTable:(TightdbTable*)subtable +-(BOOL)isReadOnly { - // TODO: Use core method for checking the equality of two table specs. Even in the typed interface - // the user might add columns (_checkType for typed and spec against spec for dynamic). - - tightdb::DataType t = m_table->get_column_type(col_ndx); - if (t == tightdb::type_Table) { - // TODO: Handle any exeptions from core lib. - m_table->set_subtable(col_ndx, ndx, &subtable.getNativeTable); - return YES; - } - return NO; + return m_read_only; } --(TightdbTable*)getSubtable:(size_t)col_ndx ndx:(size_t)ndx -{ - tightdb::DataType type = m_table->get_column_type(col_ndx); - if (type != tightdb::type_Table) - return nil; - tightdb::TableRef table = m_table->get_subtable(col_ndx, ndx); - if (!table) - return nil; - TightdbTable* table_2 = [[TightdbTable alloc] _initRaw]; - if (TIGHTDB_UNLIKELY(!table_2)) - return nil; - [table_2 setNativeTable:table.get()]; - [table_2 setParent:self]; - [table_2 setReadOnly:m_read_only]; - return table_2; -} - -// FIXME: Check that the specified class derives from TightdbTable. --(id)getSubtable:(size_t)col_ndx ndx:(size_t)ndx withClass:(__unsafe_unretained Class)class_obj +-(BOOL)isEqual:(TightdbTable*)other { - tightdb::DataType type = m_table->get_column_type(col_ndx); - if (type != tightdb::type_Table) - return nil; - tightdb::TableRef table = m_table->get_subtable(col_ndx, ndx); - if (!table) - return nil; - TightdbTable* table_2 = [[class_obj alloc] _initRaw]; - if (TIGHTDB_UNLIKELY(!table_2)) - return nil; - [table_2 setNativeTable:table.get()]; - [table_2 setParent:self]; - [table_2 setReadOnly:m_read_only]; - if (![table_2 _checkType]) - return nil; - return table_2; + return *m_table == *other->m_table; } // FIXME: Check that the specified class derives from TightdbTable. @@ -667,35 +623,38 @@ -(TightdbCursor*)addRow return [[TightdbCursor alloc] initWithTable:self ndx:[self _addRow]]; } + -(size_t)_addRow { - return [self _addRowWithError:nil]; -} --(size_t)_addRowWithError:(NSError* __autoreleasing*)error -{ - if (m_read_only) { - if (error) - *error = make_tightdb_error(tdb_err_FailRdOnly, @"Tried to add row while read-only."); - return NO; - } - TIGHTDB_EXCEPTION_ERRHANDLER(return m_table->add_empty_row();, 0); + return [self _addRows:1]; } -(size_t)_addRows:(size_t)num_rows { - return [self _addRows:num_rows error:nil]; -} + // TODO: Use a macro or a function for error handling --(size_t)_addRows:(size_t)num_rows error:(NSError* __autoreleasing*)error -{ - if (m_read_only) { - if (error) - *error = make_tightdb_error(tdb_err_FailRdOnly, @"Tried to add row while read-only."); - return NO; + if(m_read_only) { + NSException* exception = [NSException exceptionWithName:@"tightdb:table_is_read_only" + reason:@"You tried to modify a table in read only mode" + userInfo:[NSMutableDictionary dictionary]]; + [exception raise]; + } + + size_t index; + try { + index = m_table->add_empty_row(num_rows); + } + catch(std::exception& ex) { + NSException *exception = [NSException exceptionWithName:@"tightdb:core_exception" + reason:[NSString stringWithUTF8String:ex.what()] + userInfo:[NSMutableDictionary dictionary]]; + [exception raise]; } - TIGHTDB_EXCEPTION_ERRHANDLER(return m_table->add_empty_row(num_rows);, 0); + + return index; } + -(TightdbCursor*)cursorAtIndex:(size_t)ndx { // initWithTable checks for illegal index. @@ -777,111 +736,177 @@ -(BOOL)removeLastRowWithError:(NSError* __autoreleasing*)error TIGHTDB_EXCEPTION_ERRHANDLER(m_table->remove_last();, NO); return YES; } --(int64_t)get:(size_t)col_ndx ndx:(size_t)ndx + + +-(BOOL)getBoolInColumn:(size_t)col_ndx atRow:(size_t)row_ndx { - return m_table->get_int(col_ndx, ndx); + return m_table->get_bool(col_ndx, row_ndx); } --(BOOL)set:(size_t)col_ndx ndx:(size_t)ndx value:(int64_t)value +-(int64_t)getIntInColumn:(size_t)col_ndx atRow:(size_t)row_ndx { - return [self set:col_ndx ndx:ndx value:value error:nil]; + return m_table->get_int(col_ndx, row_ndx); } --(BOOL)set:(size_t)col_ndx ndx:(size_t)ndx value:(int64_t)value error:(NSError* __autoreleasing*)error +-(float)getFloatInColumn:(size_t)col_ndx atRow:(size_t)row_ndx { - if (m_read_only) { - if (error) - *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]); - return NO; - } - TIGHTDB_EXCEPTION_ERRHANDLER(m_table->set_int(col_ndx, ndx, value);, NO); - return YES; + return m_table->get_float(col_ndx, row_ndx); } --(BOOL)getBool:(size_t)col_ndx ndx:(size_t)ndx +-(double)getDoubleInColumn:(size_t)col_ndx atRow:(size_t)row_ndx { - return m_table->get_bool(col_ndx, ndx); + return m_table->get_double(col_ndx, row_ndx); } --(BOOL)setBool:(size_t)col_ndx ndx:(size_t)ndx value:(BOOL)value +-(NSString*)getStringInColumn:(size_t)col_ndx atRow:(size_t)row_ndx { - return [self setBool:col_ndx ndx:ndx value:value error:nil]; + return to_objc_string(m_table->get_string(col_ndx, row_ndx)); } --(BOOL)setBool:(size_t)col_ndx ndx:(size_t)ndx value:(BOOL)value error:(NSError* __autoreleasing*)error +-(TightdbBinary*)getBinaryInColumn:(size_t)col_ndx atRow:(size_t)row_ndx { - if (m_read_only) { - if (error) - *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]); - return NO; - } - TIGHTDB_EXCEPTION_ERRHANDLER(m_table->set_bool(col_ndx, ndx, value);, NO); - return YES; + return [[TightdbBinary alloc] initWithBinary:m_table->get_binary(col_ndx, row_ndx)]; } --(float)getFloat:(size_t)col_ndx ndx:(size_t)ndx +-(time_t)getDateInColumn:(size_t)col_ndx atRow:(size_t)row_ndx { - return m_table->get_float(col_ndx, ndx); + return m_table->get_datetime(col_ndx, row_ndx).get_datetime(); } --(BOOL)setFloat:(size_t)col_ndx ndx:(size_t)ndx value:(float)value +-(TightdbTable*)getTableInColumn:(size_t)col_ndx atRow:(size_t)row_ndx { - return [self setFloat:col_ndx ndx:ndx value:value error:nil]; + tightdb::DataType type = m_table->get_column_type(col_ndx); + if (type != tightdb::type_Table) + return nil; + tightdb::TableRef table = m_table->get_subtable(col_ndx, row_ndx); + if (!table) + return nil; + TightdbTable* table_2 = [[TightdbTable alloc] _initRaw]; + if (TIGHTDB_UNLIKELY(!table_2)) + return nil; + [table_2 setNativeTable:table.get()]; + [table_2 setParent:self]; + [table_2 setReadOnly:m_read_only]; + return table_2; } --(BOOL)setFloat:(size_t)col_ndx ndx:(size_t)ndx value:(float)value error:(NSError* __autoreleasing*)error +// FIXME: Check that the specified class derives from TightdbTable. +-(id)getTableInColumn:(size_t)col_ndx atRow:(size_t)row_ndx withClass:(__unsafe_unretained Class)class_obj { - if (m_read_only) { - if (error) - *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]); - return NO; - } - TIGHTDB_EXCEPTION_ERRHANDLER(m_table->set_float(col_ndx, ndx, value);, NO); - return YES; + tightdb::DataType type = m_table->get_column_type(col_ndx); + if (type != tightdb::type_Table) + return nil; + tightdb::TableRef table = m_table->get_subtable(col_ndx, row_ndx); + if (!table) + return nil; + TightdbTable* table_2 = [[class_obj alloc] _initRaw]; + if (TIGHTDB_UNLIKELY(!table)) + return nil; + [table_2 setNativeTable:table.get()]; + [table_2 setParent:self]; + [table_2 setReadOnly:m_read_only]; + if (![table_2 _checkType]) + return nil; + return table_2; +} + +-(TightdbMixed*)getMixedInColumn:(size_t)col_ndx atRow:(size_t)row_ndx +{ + tightdb::Mixed mixed = m_table->get_mixed(col_ndx, row_ndx); + if (mixed.get_type() != tightdb::type_Table) + return [TightdbMixed mixedWithNativeMixed:mixed]; + + tightdb::TableRef table = m_table->get_subtable(col_ndx, row_ndx); + if (!table) + return nil; + TightdbTable* table_2 = [[TightdbTable alloc] _initRaw]; + if (TIGHTDB_UNLIKELY(!table_2)) + return nil; + [table_2 setNativeTable:table.get()]; + [table_2 setParent:self]; + [table_2 setReadOnly:m_read_only]; + if (![table_2 _checkType]) + return nil; + + return [TightdbMixed mixedWithTable:table_2]; } --(double)getDouble:(size_t)col_ndx ndx:(size_t)ndx + +-(void)setBool:(BOOL)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx { - return m_table->get_double(col_ndx, ndx); + TIGHTDB_EXCEPTION_HANDLER_SETTERS( + m_table->set_bool(col_ndx, row_ndx, value);, + tightdb_Bool); } --(BOOL)setDouble:(size_t)col_ndx ndx:(size_t)ndx value:(double)value +-(void)setInt:(int64_t)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx { - return [self setDouble:col_ndx ndx:ndx value:value error:nil]; + TIGHTDB_EXCEPTION_HANDLER_SETTERS( + m_table->set_int(col_ndx, row_ndx, value);, + tightdb_Int); } --(BOOL)setDouble:(size_t)col_ndx ndx:(size_t)ndx value:(double)value error:(NSError* __autoreleasing*)error +-(void)setFloat:(float)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx { - if (m_read_only) { - if (error) - *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]); - return NO; - } - TIGHTDB_EXCEPTION_ERRHANDLER(m_table->set_double(col_ndx, ndx, value);, NO); - return YES; + TIGHTDB_EXCEPTION_HANDLER_SETTERS( + m_table->set_float(col_ndx, row_ndx, value);, + tightdb_Float); } --(time_t)getDate:(size_t)col_ndx ndx:(size_t)ndx +-(void)setDouble:(double)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx { - return m_table->get_datetime(col_ndx, ndx).get_datetime(); + TIGHTDB_EXCEPTION_HANDLER_SETTERS( + m_table->set_double(col_ndx, row_ndx, value);, + tightdb_Double); } --(BOOL)setDate:(size_t)col_ndx ndx:(size_t)ndx value:(time_t)value +-(void)setString:(NSString*)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx { - return [self setDate:col_ndx ndx:ndx value:value error:nil]; + TIGHTDB_EXCEPTION_HANDLER_SETTERS( + m_table->set_string(col_ndx, row_ndx, ObjcStringAccessor(value));, + tightdb_String); } --(BOOL)setDate:(size_t)col_ndx ndx:(size_t)ndx value:(time_t)value error:(NSError* __autoreleasing*)error +-(void)setBinary:(TightdbBinary*)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx { - if (m_read_only) { - if (error) - *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]); - return NO; - } - TIGHTDB_EXCEPTION_ERRHANDLER(m_table->set_datetime(col_ndx, ndx, value);, NO); - return YES; + TIGHTDB_EXCEPTION_HANDLER_SETTERS( + m_table->set_binary(col_ndx, row_ndx, [value getNativeBinary]);, + tightdb_Binary); +} + +-(void)setDate:(time_t)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx +{ + TIGHTDB_EXCEPTION_HANDLER_SETTERS( + m_table->set_datetime(col_ndx, row_ndx, value);, + tightdb_Date); +} + +-(void)setTable:(TightdbTable*)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx +{ + // TODO: Use core method for checking the equality of two table specs. Even in the typed interface + // the user might add columns (_checkType for typed and spec against spec for dynamic). + + TIGHTDB_EXCEPTION_HANDLER_SETTERS( + m_table->set_subtable(col_ndx, row_ndx, &[value getNativeTable]);, + tightdb_Table); +} + +-(void)setMixed:(TightdbMixed*)value inColumn:(size_t)col_ndx atRow:(size_t)row_ndx +{ + const tightdb::Mixed& mixed = [value getNativeMixed]; + TightdbTable* subtable = mixed.get_type() == tightdb::type_Table ? [value getTable] : nil; + TIGHTDB_EXCEPTION_HANDLER_SETTERS( + if (subtable) { + tightdb::LangBindHelper::set_mixed_subtable(*m_table, col_ndx, row_ndx, + [subtable getNativeTable]); + } + else { + m_table->set_mixed(col_ndx, row_ndx, mixed); + }, + tightdb_Mixed); } + -(BOOL)insertBool:(size_t)col_ndx ndx:(size_t)ndx value:(BOOL)value { return [self insertBool:col_ndx ndx:ndx value:value error:nil]; @@ -889,6 +914,10 @@ -(BOOL)insertBool:(size_t)col_ndx ndx:(size_t)ndx value:(BOOL)value -(BOOL)insertBool:(size_t)col_ndx ndx:(size_t)ndx value:(BOOL)value error:(NSError* __autoreleasing*)error { + // FIXME: Read-only errors should probably be handled by throwing + // an exception. That is what is done in other places in this + // binding, and it also seems like the right thing to do. This + // method should also not take an error argument. if (m_read_only) { if (error) *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); @@ -906,6 +935,10 @@ -(BOOL)insertInt:(size_t)col_ndx ndx:(size_t)ndx value:(int64_t)value -(BOOL)insertInt:(size_t)col_ndx ndx:(size_t)ndx value:(int64_t)value error:(NSError* __autoreleasing*)error { + // FIXME: Read-only errors should probably be handled by throwing + // an exception. That is what is done in other places in this + // binding, and it also seems like the right thing to do. This + // method should also not take an error argument. if (m_read_only) { if (error) *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); @@ -922,6 +955,10 @@ -(BOOL)insertFloat:(size_t)col_ndx ndx:(size_t)ndx value:(float)value -(BOOL)insertFloat:(size_t)col_ndx ndx:(size_t)ndx value:(float)value error:(NSError* __autoreleasing*)error { + // FIXME: Read-only errors should probably be handled by throwing + // an exception. That is what is done in other places in this + // binding, and it also seems like the right thing to do. This + // method should also not take an error argument. if (m_read_only) { if (error) *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); @@ -938,6 +975,10 @@ -(BOOL)insertDouble:(size_t)col_ndx ndx:(size_t)ndx value:(double)value -(BOOL)insertDouble:(size_t)col_ndx ndx:(size_t)ndx value:(double)value error:(NSError* __autoreleasing*)error { + // FIXME: Read-only errors should probably be handled by throwing + // an exception. That is what is done in other places in this + // binding, and it also seems like the right thing to do. This + // method should also not take an error argument. if (m_read_only) { if (error) *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); @@ -954,6 +995,10 @@ -(BOOL)insertString:(size_t)col_ndx ndx:(size_t)ndx value:(NSString*)value -(BOOL)insertString:(size_t)col_ndx ndx:(size_t)ndx value:(NSString*)value error:(NSError* __autoreleasing*)error { + // FIXME: Read-only errors should probably be handled by throwing + // an exception. That is what is done in other places in this + // binding, and it also seems like the right thing to do. This + // method should also not take an error argument. if (m_read_only) { if (error) *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); @@ -972,6 +1017,10 @@ -(BOOL)insertBinary:(size_t)col_ndx ndx:(size_t)ndx value:(TightdbBinary*)value -(BOOL)insertBinary:(size_t)col_ndx ndx:(size_t)ndx value:(TightdbBinary*)value error:(NSError* __autoreleasing*)error { + // FIXME: Read-only errors should probably be handled by throwing + // an exception. That is what is done in other places in this + // binding, and it also seems like the right thing to do. This + // method should also not take an error argument. if (m_read_only) { if (error) *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); @@ -990,6 +1039,10 @@ -(BOOL)insertBinary:(size_t)col_ndx ndx:(size_t)ndx data:(const char*)data size: -(BOOL)insertBinary:(size_t)col_ndx ndx:(size_t)ndx data:(const char*)data size:(size_t)size error:(NSError* __autoreleasing*)error { + // FIXME: Read-only errors should probably be handled by throwing + // an exception. That is what is done in other places in this + // binding, and it also seems like the right thing to do. This + // method should also not take an error argument. if (m_read_only) { if (error) *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); @@ -1008,6 +1061,10 @@ -(BOOL)insertDate:(size_t)col_ndx ndx:(size_t)ndx value:(time_t)value -(BOOL)insertDate:(size_t)col_ndx ndx:(size_t)ndx value:(time_t)value error:(NSError* __autoreleasing*)error { + // FIXME: Read-only errors should probably be handled by throwing + // an exception. That is what is done in other places in this + // binding, and it also seems like the right thing to do. This + // method should also not take an error argument. if (m_read_only) { if (error) *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); @@ -1024,72 +1081,11 @@ -(BOOL)insertDone -(BOOL)insertDoneWithError:(NSError* __autoreleasing*)error { + // FIXME: This method should probably not take an error argument. TIGHTDB_EXCEPTION_ERRHANDLER(m_table->insert_done();, NO); return YES; } --(NSString*)getString:(size_t)col_ndx ndx:(size_t)ndx -{ - return to_objc_string(m_table->get_string(col_ndx, ndx)); -} - --(BOOL)setString:(size_t)col_ndx ndx:(size_t)ndx value:(NSString*)value -{ - return [self setString:col_ndx ndx:ndx value:value error:nil]; -} --(BOOL)setString:(size_t)col_ndx ndx:(size_t)ndx value:(NSString*)value error:(NSError* __autoreleasing*)error -{ - if (m_read_only) { - if (error) - *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]); - return NO; - } - TIGHTDB_EXCEPTION_ERRHANDLER( - m_table->set_string(col_ndx, ndx, ObjcStringAccessor(value));, - NO); - return YES; -} - --(TightdbBinary*)getBinary:(size_t)col_ndx ndx:(size_t)ndx -{ - return [[TightdbBinary alloc] initWithBinary:m_table->get_binary(col_ndx, ndx)]; -} - --(BOOL)setBinary:(size_t)col_ndx ndx:(size_t)ndx value:(TightdbBinary*)value -{ - return [self setBinary:col_ndx ndx:ndx value:value error:nil]; -} - --(BOOL)setBinary:(size_t)col_ndx ndx:(size_t)ndx value:(TightdbBinary*)value error:(NSError* __autoreleasing*)error -{ - if (m_read_only) { - if (error) - *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]); - return NO; - } - TIGHTDB_EXCEPTION_ERRHANDLER( - m_table->set_binary(col_ndx, ndx, [value getNativeBinary]);, - NO); - return YES; -} - --(BOOL)setBinary:(size_t)col_ndx ndx:(size_t)ndx data:(const char*)data size:(size_t)size -{ - return [self setBinary:col_ndx ndx:ndx data:data size:size error:nil]; -} - --(BOOL)setBinary:(size_t)col_ndx ndx:(size_t)ndx data:(const char*)data size:(size_t)size error:(NSError* __autoreleasing*)error -{ - if (m_read_only) { - if (error) - *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]); - return NO; - } - TIGHTDB_EXCEPTION_ERRHANDLER( - m_table->set_binary(col_ndx, ndx, tightdb::BinaryData(data, size));, - NO); - return YES; -} -(size_t)getTableSize:(size_t)col_ndx ndx:(size_t)row_ndx { @@ -1103,6 +1099,10 @@ -(BOOL)insertSubtable:(size_t)col_ndx ndx:(size_t)row_ndx -(BOOL)insertSubtable:(size_t)col_ndx ndx:(size_t)row_ndx error:(NSError* __autoreleasing*)error { + // FIXME: Read-only errors should probably be handled by throwing + // an exception. That is what is done in other places in this + // binding, and it also seems like the right thing to do. This + // method should also not take an error argument. if (m_read_only) { if (error) *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); @@ -1120,6 +1120,10 @@ -(BOOL)_insertSubtableCopy:(size_t)col_ndx row:(size_t)row_ndx subtable:(Tightdb -(BOOL)_insertSubtableCopy:(size_t)col_ndx row:(size_t)row_ndx subtable:(TightdbTable*)subtable error:(NSError* __autoreleasing*)error { + // FIXME: Read-only errors should probably be handled by throwing + // an exception. That is what is done in other places in this + // binding, and it also seems like the right thing to do. This + // method should also not take an error argument. if (m_read_only) { if (error) *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); @@ -1137,6 +1141,10 @@ -(BOOL)clearSubtable:(size_t)col_ndx ndx:(size_t)row_ndx } -(BOOL)clearSubtable:(size_t)col_ndx ndx:(size_t)row_ndx error:(NSError* __autoreleasing*)error { + // FIXME: Read-only errors should probably be handled by throwing + // an exception. That is what is done in other places in this + // binding, and it also seems like the right thing to do. This + // method should also not take an error argument. if (m_read_only) { if (error) *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to clear while read only ColumnId: %llu", (unsigned long long)col_ndx]); @@ -1146,27 +1154,6 @@ -(BOOL)clearSubtable:(size_t)col_ndx ndx:(size_t)row_ndx error:(NSError* __autor return YES; } --(TightdbMixed*)getMixed:(size_t)col_ndx ndx:(size_t)row_ndx -{ - tightdb::Mixed mixed = m_table->get_mixed(col_ndx, row_ndx); - if (mixed.get_type() != tightdb::type_Table) { - return [TightdbMixed mixedWithNativeMixed:mixed]; - } - - tightdb::TableRef table = m_table->get_subtable(col_ndx, row_ndx); - if (!table) - return nil; - TightdbTable* table_2 = [[TightdbTable alloc] _initRaw]; - if (TIGHTDB_UNLIKELY(!table_2)) - return nil; - [table_2 setNativeTable:table.get()]; - [table_2 setParent:self]; - [table_2 setReadOnly:m_read_only]; - if (![table_2 _checkType]) - return nil; - - return [TightdbMixed mixedWithTable:table_2]; -} -(TightdbType)getMixedType:(size_t)col_ndx ndx:(size_t)row_ndx { @@ -1199,31 +1186,6 @@ -(BOOL)insertMixed:(size_t)col_ndx ndx:(size_t)row_ndx value:(TightdbMixed*)valu return YES; } --(BOOL)setMixed:(size_t)col_ndx ndx:(size_t)row_ndx value:(TightdbMixed*)value -{ - return [self setMixed:col_ndx ndx:row_ndx value:value error:nil]; -} - --(BOOL)setMixed:(size_t)col_ndx ndx:(size_t)row_ndx value:(TightdbMixed*)value error:(NSError* __autoreleasing*)error -{ - if (m_read_only) { - if (error) - *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]); - return NO; - } - const tightdb::Mixed& mixed = [value getNativeMixed]; - TightdbTable* subtable = mixed.get_type() == tightdb::type_Table ? [value getTable] : nil; - TIGHTDB_EXCEPTION_ERRHANDLER( - if (subtable) { - tightdb::LangBindHelper::set_mixed_subtable(*m_table, col_ndx, row_ndx, - [subtable getNativeTable]); - } - else { - m_table->set_mixed(col_ndx, row_ndx, mixed); - }, - NO); - return YES; -} -(size_t)addColumnWithType:(TightdbType)type andName:(NSString*)name { @@ -1237,6 +1199,7 @@ -(size_t)addColumnWithType:(TightdbType)type andName:(NSString*)name error:(NSEr 0); } + -(size_t)findBool:(size_t)col_ndx value:(BOOL)value { return m_table->find_first_bool(col_ndx, value); diff --git a/src/tightdb/objc/table_priv.h b/src/tightdb/objc/table_priv.h index e6433736cb..2e21cda947 100644 --- a/src/tightdb/objc/table_priv.h +++ b/src/tightdb/objc/table_priv.h @@ -8,7 +8,7 @@ @interface TightdbBinary() --(tightdb::BinaryData)getNativeBinary; +-(tightdb::BinaryData&)getNativeBinary; @end diff --git a/src/tightdb/objc/test/Makefile b/src/tightdb/objc/test/Makefile index 29273624e3..3fb25cf64d 100644 --- a/src/tightdb/objc/test/Makefile +++ b/src/tightdb/objc/test/Makefile @@ -2,7 +2,7 @@ check_PROGRAMS = unit-tests unit_tests_SOURCES = \ data_type.mm table.m group.m group_misc_2.m table_delete_all.m tutorial.m enumerator.m \ -get_subtable.m subtable.m mixed.m query.m shared_group.m err_handling.mm functional.m +get_subtable.m subtable.m mixed.m query.m err_handling.mm functional.m shared_group.m #unit_tests_SOURCES = functional.m diff --git a/src/tightdb/objc/test/enumerator.m b/src/tightdb/objc/test/enumerator.m index 073eda301b..2a1c08f187 100644 --- a/src/tightdb/objc/test/enumerator.m +++ b/src/tightdb/objc/test/enumerator.m @@ -31,7 +31,7 @@ - (void)testTutorial //------------------------------------------------------ TightdbGroup *group = [TightdbGroup group]; // Create new table in group - EnumPeopleTable *people = [group getTable:@"employees" withClass:[EnumPeopleTable class]]; + EnumPeopleTable *people = [group getTable:@"employees" withClass:[EnumPeopleTable class] error:nil]; // Add some rows [people addName:@"John" Age:20 Hired:YES]; diff --git a/src/tightdb/objc/test/err_handling.mm b/src/tightdb/objc/test/err_handling.mm index ca8f406c41..0c2a2ece06 100644 --- a/src/tightdb/objc/test/err_handling.mm +++ b/src/tightdb/objc/test/err_handling.mm @@ -62,36 +62,21 @@ - (void)testErrHandling TightdbGroup* group = [TightdbGroup group]; // Create new table in group - PeopleErrTable* people = [group getTable:@"employees" withClass:[PeopleErrTable class]]; + PeopleErrTable* people = [group getTable:@"employees" withClass:[PeopleErrTable class] error:nil]; + // No longer supports errors, the tes may be redundant // Add some rows - error = nil; - if (![people addName:@"John" Age:20 Hired:YES error:&error]) { - NSLog(@"%@", [error localizedDescription]); - STFail(@"This should have worked"); - } - error = nil; - if (![people addName:@"Mary" Age:21 Hired:NO error:&error]) { - NSLog(@"%@", [error localizedDescription]); - STFail(@"This should have worked"); - } - if (![people addName:@"Lars" Age:21 Hired:YES error:&error]) { - NSLog(@"%@", [error localizedDescription]); - STFail(@"This should have worked"); - } - error = nil; - if (![people addName:@"Phil" Age:43 Hired:NO error:&error]) { - NSLog(@"%@", [error localizedDescription]); - STFail(@"This should have worked"); - } - error = nil; - if (![people addName:@"Anni" Age:54 Hired:YES error:&error]) { - NSLog(@"%@", [error localizedDescription]); - STFail(@"This should have worked"); - } + + [people addName:@"John" Age:20 Hired:YES]; + [people addName:@"Mary" Age:21 Hired:NO]; + [people addName:@"Lars" Age:21 Hired:YES]; + [people addName:@"Phil" Age:43 Hired:NO]; + [people addName:@"Anni" Age:54 Hired:YES]; + + // Insert at specific position - [people insertAtIndex:2 Name:@"Frank" Age:34 Hired:YES]; + [people insertRowAtIndex:2 Name:@"Frank" Age:34 Hired:YES]; // Getting the size of the table NSLog(@"PeopleErrTable Size: %lu - is %@. [6 - not empty]", [people count], @@ -102,7 +87,7 @@ - (void)testErrHandling // Write the group to disk [fm removeItemAtPath:@"peopleErr.tightdb" error:NULL]; error = nil; - if (![group write:@"peopleErr.tightdb" error:&error]) { + if (![group writeToFile:@"peopleErr.tightdb" withError:&error]) { NSLog(@"%@", [error localizedDescription]); STFail(@"No error expected"); } @@ -126,10 +111,11 @@ - (void)testErrHandling // Load a group from disk (and try to update, even though it is readonly) error = nil; - TightdbGroup* fromDisk = [TightdbGroup groupWithFilename:@"peopleErr.tightdb" error:&error]; + TightdbGroup* fromDisk = [TightdbGroup groupWithFile:@"peopleErr.tightdb" withError:&error]; if (error) { NSLog(@"%@", [error localizedDescription]); - } else { + } + else { // This is no longer an error, becuase read/write mode is no longer required per default. // STFail(@"Since file cannot be opened, we should have gotten an error here."); } @@ -147,25 +133,26 @@ - (void)testErrHandling } error = nil; - fromDisk = [TightdbGroup groupWithFilename:@"peopleErr.tightdb" error:&error]; + fromDisk = [TightdbGroup groupWithFile:@"peopleErr.tightdb" withError:&error]; if (error) { NSLog(@"%@", [error localizedDescription]); STFail(@"File should have been possible to open"); } - PeopleErrTable* diskTable = [fromDisk getTable:@"employees" withClass:[PeopleErrTable class]]; + PeopleErrTable* diskTable = [fromDisk getTable:@"employees" withClass:[PeopleErrTable class] error:nil]; // Fake readonly. [((TightdbTable*)diskTable) setReadOnly:true]; NSLog(@"Disktable size: %zu", [diskTable count]); + /* No longer support for errors here error = nil; if (![diskTable addName:@"Anni" Age:54 Hired:YES error:&error]) { NSLog(@"%@", [error localizedDescription]); } else { STFail(@"addName to readonly should have failed."); - } + }*/ NSLog(@"Disktable size: %zu", [diskTable count]); } @@ -308,7 +295,7 @@ -(void)testErrorInsert // Add sub-tables if (i == 2) { - TightdbTable* subtable = [table getSubtable:8 ndx:i]; + TightdbTable* subtable = [table getTableInColumn:8 atRow:i]; if (![subtable insertInt:0 ndx:0 value:42 error:&error]) { NSLog(@"%@", [error localizedDescription]); STFail(@"Insert failed."); diff --git a/src/tightdb/objc/test/get_subtable.m b/src/tightdb/objc/test/get_subtable.m index 50ce5094cb..7ebd96a6e3 100644 --- a/src/tightdb/objc/test/get_subtable.m +++ b/src/tightdb/objc/test/get_subtable.m @@ -45,18 +45,18 @@ - (void)testGetSubtable [table insertSubtable:2 ndx:0]; [table insertDone]; - TightdbTable* subtable = [table getSubtable:2 ndx:0]; + TightdbTable* subtable = [table getTableInColumn:2 atRow:0]; [subtable insertBool:0 ndx:0 value:YES]; [subtable insertInt:1 ndx:0 value:42]; [subtable insertDone]; - GetSubtable* testTable = [table getSubtable:2 ndx:0 withClass:[GetSubtable class]]; + GetSubtable* testTable = [table getTableInColumn:2 atRow:0 withClass:[GetSubtable class]]; GetSubtable_Cursor* cursor = [testTable cursorAtIndex:0]; NSLog(@"Age in subtable: %lld", cursor.Age); STAssertEquals(cursor.Age, (int64_t)42, @"Sub table row should be 42"); - STAssertNil([table getSubtable:2 ndx:0 withClass:[WrongNameTable class]], @"should return nil because wrong name"); - STAssertNil([table getSubtable:2 ndx:0 withClass:[WrongTypeTable class]], @"should return nil because wrong type"); + STAssertNil([table getTableInColumn:2 atRow:0 withClass:[WrongNameTable class]], @"should return nil because wrong name"); + STAssertNil([table getTableInColumn:2 atRow:0 withClass:[WrongTypeTable class]], @"should return nil because wrong type"); } diff --git a/src/tightdb/objc/test/group.m b/src/tightdb/objc/test/group.m index 036097fe03..663c41403d 100644 --- a/src/tightdb/objc/test/group.m +++ b/src/tightdb/objc/test/group.m @@ -45,15 +45,15 @@ - (void)testGroup // Create empty group and serialize to disk TightdbGroup *toDisk = [TightdbGroup group]; [fm removeItemAtPath:@"table_test.tightdb" error:NULL]; - [toDisk write:@"table_test.tightdb"]; + [toDisk writeToFile:@"table_test.tightdb" withError:nil]; // Load the group - TightdbGroup *fromDisk = [TightdbGroup groupWithFilename:@"table_test.tightdb"]; + TightdbGroup *fromDisk = [TightdbGroup groupWithFile:@"table_test.tightdb" withError:nil]; if (!fromDisk) STFail(@"From disk not valid"); // Create new table in group - TestTableGroup *t = (TestTableGroup *)[fromDisk getTable:@"test" withClass:[TestTableGroup class]]; + TestTableGroup *t = (TestTableGroup *)[fromDisk getTable:@"test" withClass:[TestTableGroup class] error:nil]; // Verify NSLog(@"Columns: %zu", [t getColumnCount]); diff --git a/src/tightdb/objc/test/group_misc_2.m b/src/tightdb/objc/test/group_misc_2.m index 98e1d745dd..24c0715d4f 100644 --- a/src/tightdb/objc/test/group_misc_2.m +++ b/src/tightdb/objc/test/group_misc_2.m @@ -44,7 +44,7 @@ - (void)testGroup_Misc2 TightdbGroup* group = [TightdbGroup group]; NSLog(@"HasTable: %i", [group hasTable:@"employees" withClass:[MyTable class]] ); // Create new table in group - MyTable* table = [group getTable:@"employees" withClass:[MyTable class]]; + MyTable* table = [group getTable:@"employees" withClass:[MyTable class] error:nil]; NSLog(@"Table: %@", table); NSLog(@"HasTable: %i", [group hasTable:@"employees" withClass:[MyTable class]] ); @@ -105,12 +105,12 @@ - (void)testGroup_Misc2 NSFileManager* fm = [NSFileManager defaultManager]; // Write to disk - [fm removeItemAtPath:@"employees.tightdb" error:NULL]; - [group write:@"employees.tightdb"]; + [fm removeItemAtPath:@"employees.tightdb" error:nil]; + [group writeToFile:@"employees.tightdb" withError:nil]; // Load a group from disk (and print contents) - TightdbGroup* fromDisk = [TightdbGroup groupWithFilename:@"employees.tightdb"]; - MyTable* diskTable = [fromDisk getTable:@"employees" withClass:[MyTable class]]; + TightdbGroup* fromDisk = [TightdbGroup groupWithFile:@"employees.tightdb" withError:nil]; + MyTable* diskTable = [fromDisk getTable:@"employees" withClass:[MyTable class] error:nil]; [diskTable addName:@"Anni" Age:54 Hired:YES Spare:0]; // [diskTable insertAtIndex:2 Name:@"Thomas" Age:41 Hired:NO Spare:1]; @@ -119,16 +119,15 @@ - (void)testGroup_Misc2 MyTable_Cursor* cursor = [diskTable cursorAtIndex:i]; NSLog(@"%zu: %@", i, [cursor Name]); NSLog(@"%zu: %@", i, cursor.Name); - NSLog(@"%zu: %@", i, [diskTable getString:0 ndx:i]); + NSLog(@"%zu: %@", i, [diskTable getStringInColumn:0 atRow:i]); } // Write same group to memory buffer - size_t size; - const char* data = [group writeToMem:&size]; + TightdbBinary* buffer = [group writeToBuffer]; // Load a group from memory (and print contents) - TightdbGroup* fromMem = [TightdbGroup groupWithBuffer:data size:size]; - MyTable* memTable = [fromMem getTable:@"employees" withClass:[MyTable class]]; + TightdbGroup* fromMem = [TightdbGroup groupWithBuffer:buffer withError:nil]; + MyTable* memTable = [fromMem getTable:@"employees" withClass:[MyTable class] error:nil]; for (size_t i = 0; i < [memTable count]; i++) { // ??? cursor NSLog(@"%zu: %@", i, memTable.Name); @@ -139,7 +138,7 @@ - (void)testGroup_Misc2 - (void)testQuery { TightdbGroup* group = [TightdbGroup group]; - QueryTable* table = [group getTable:@"Query table" withClass:[QueryTable class]]; + QueryTable* table = [group getTable:@"Query table" withClass:[QueryTable class] error:nil]; // Add some rows [table addFirst:2 Second:@"a"]; @@ -196,7 +195,7 @@ - (void)testQuery - (void)testSubtables { TightdbGroup* group = [TightdbGroup group]; - TightdbTable* table = [group getTable:@"table" withClass:[TightdbTable class]]; + TightdbTable* table = [group getTable:@"table" withClass:[TightdbTable class] error:nil]; // Specify the table type { @@ -216,17 +215,18 @@ - (void)testSubtables // Add a row to the top level table [table addRow]; - [table set:COL_TABLE_INT ndx:0 value:700]; + [table setInt:700 inColumn:COL_TABLE_INT atRow:0]; // Add two rows to the subtable - TightdbTable* subtable = [table getSubtable:COL_TABLE_TAB ndx:0]; + TightdbTable* subtable = [table getTableInColumn:COL_TABLE_TAB atRow:0]; [subtable addRow]; - [subtable set:COL_SUBTABLE_INT ndx:0 value:800]; + + [subtable setInt:800 inColumn:COL_SUBTABLE_INT atRow:0]; [subtable addRow]; - [subtable set:COL_SUBTABLE_INT ndx:1 value:801]; + [subtable setInt:801 inColumn:COL_SUBTABLE_INT atRow:1]; // Make the mixed values column contain another subtable - [table setMixed:COL_TABLE_MIX ndx:0 value: [TightdbMixed mixedWithTable:nil]]; + [table setMixed:[TightdbMixed mixedWithTable:nil] inColumn:COL_TABLE_MIX atRow:0]; /* Fails!!! // Specify its type diff --git a/src/tightdb/objc/test/mixed.m b/src/tightdb/objc/test/mixed.m index 6b33d8cdd1..5452fd47d2 100644 --- a/src/tightdb/objc/test/mixed.m +++ b/src/tightdb/objc/test/mixed.m @@ -142,7 +142,7 @@ - (void)testMixed TightdbGroup *group = [TightdbGroup group]; // Create new table in group - MixedTable *table = [group getTable:@"MixedValues" withClass:[MixedTable class]]; + MixedTable *table = [group getTable:@"MixedValues" withClass:[MixedTable class] error:nil]; NSLog(@"Table: %@", table); // Add some rows TightdbMixed *mixedTable = [TightdbMixed mixedWithTable:tableSub]; diff --git a/src/tightdb/objc/test/query.m b/src/tightdb/objc/test/query.m index 1a7b5be0fd..3d99b85a32 100644 --- a/src/tightdb/objc/test/query.m +++ b/src/tightdb/objc/test/query.m @@ -167,32 +167,32 @@ - (void) testDynamic TightdbBinary *bin1 = [[TightdbBinary alloc] initWithData:bin size:sizeof bin / 2]; TightdbBinary *bin2 = [[TightdbBinary alloc] initWithData:bin size:sizeof bin]; - // TODO: Rewrite test for cursor based add. + // Using private method just for the sake of testing the setters below. [table _addRows:2]; - [table setBool:BOOL_COL ndx:0 value:YES]; - [table setBool:BOOL_COL ndx:1 value:NO]; + [table setBool:YES inColumn:BOOL_COL atRow:0]; + [table setBool:NO inColumn:BOOL_COL atRow:1]; - [table set:INT_COL ndx:0 value:0]; - [table set:INT_COL ndx:1 value:860]; + [table setInt:0 inColumn:INT_COL atRow:0]; + [table setInt:860 inColumn:INT_COL atRow:1]; - [table setFloat:FLOAT_COL ndx:0 value:0]; - [table setFloat:FLOAT_COL ndx:1 value:5.6]; + [table setFloat:0 inColumn:FLOAT_COL atRow:0]; + [table setFloat:5.6 inColumn:FLOAT_COL atRow:1]; - [table setDouble:DOUBLE_COL ndx:0 value:0]; - [table setDouble:DOUBLE_COL ndx:1 value:5.6]; + [table setDouble:0 inColumn:DOUBLE_COL atRow:0]; + [table setDouble:5.6 inColumn:DOUBLE_COL atRow:1]; - [table setString:STRING_COL ndx:0 value:@""]; - [table setString:STRING_COL ndx:1 value:@"foo"]; + [table setString:@"" inColumn:STRING_COL atRow:0]; + [table setString:@"foo" inColumn:STRING_COL atRow:1]; - [table setBinary:BINARY_COL ndx:0 value:bin1]; - [table setBinary:BINARY_COL ndx:1 value:bin2]; + [table setBinary:bin1 inColumn:BINARY_COL atRow:0]; + [table setBinary:bin2 inColumn:BINARY_COL atRow:1]; - [table setDate:DATE_COL ndx:0 value:0]; - [table setDate:DATE_COL ndx:1 value:timeNow]; + [table setDate:0 inColumn:DATE_COL atRow:0]; + [table setDate:timeNow inColumn:DATE_COL atRow:1]; - [table setMixed:MIXED_COL ndx:0 value:mixInt1]; - [table setMixed:MIXED_COL ndx:1 value:mixString]; + [table setMixed:mixInt1 inColumn:MIXED_COL atRow:0]; + [table setMixed:mixString inColumn:MIXED_COL atRow:1]; // Conditions (note that count is invoked to get the number of matches) @@ -253,21 +253,22 @@ - (void) testDynamic - (void)testFind { - TightdbTable *table = [[TightdbTable alloc]init]; + TightdbTable* table = [[TightdbTable alloc]init]; [table addColumnWithType:tightdb_Int andName:@"IntCol"]; [table _addRows:6]; - [table set:0 ndx:0 value:10]; - [table set:0 ndx:1 value:42]; - [table set:0 ndx:2 value:27]; - [table set:0 ndx:3 value:31]; - [table set:0 ndx:4 value:8]; - [table set:0 ndx:5 value:39]; - - STAssertEquals([[[table where] column:0 isBetweenInt:20 and_:40] find:0], (size_t)2, @"find"); - STAssertEquals([[[table where] column:0 isBetweenInt:20 and_:40] find:3], (size_t)3, @"find"); - STAssertEquals([[[table where] column:0 isBetweenInt:20 and_:40] find:4], (size_t)5, @"find"); + + [table setInt:10 inColumn:0 atRow:0]; + [table setInt:42 inColumn:0 atRow:1]; + [table setInt:27 inColumn:0 atRow:2]; + [table setInt:31 inColumn:0 atRow:3]; + [table setInt:8 inColumn:0 atRow:4]; + [table setInt:39 inColumn:0 atRow:5]; + + STAssertEquals([[[table where] column:0 isBetweenInt:20 and_:40] find:0], (size_t)2, @"find"); + STAssertEquals([[[table where] column:0 isBetweenInt:20 and_:40] find:3], (size_t)3, @"find"); + STAssertEquals([[[table where] column:0 isBetweenInt:20 and_:40] find:4], (size_t)5, @"find"); STAssertEquals([[[table where] column:0 isBetweenInt:20 and_:40] find:6], (size_t)-1, @"find"); - STAssertEquals([[[table where] column:0 isBetweenInt:20 and_:40] find:3], (size_t)3, @"find"); + STAssertEquals([[[table where] column:0 isBetweenInt:20 and_:40] find:3], (size_t)3, @"find"); // jjepsen: disabled this test, perhaps it's not relevant after query sematics update. //STAssertEquals([[[table where] column:0 isBetweenInt:20 and_:40] find:-1], (size_t)-1, @"find"); } diff --git a/src/tightdb/objc/test/shared_group.m b/src/tightdb/objc/test/shared_group.m index 0c0d5d0014..73d6a8fe48 100644 --- a/src/tightdb/objc/test/shared_group.m +++ b/src/tightdb/objc/test/shared_group.m @@ -11,13 +11,9 @@ #import #import -TIGHTDB_TABLE_DEF_2(SharedTable2, - Hired, Bool, - Age, Int) - -TIGHTDB_TABLE_IMPL_2(SharedTable2, - Hired, Bool, - Age, Int) +TIGHTDB_TABLE_2(SharedTable2, + Hired, Bool, + Age, Int) @interface MACTestSharedGroup: SenTestCase @@ -26,9 +22,13 @@ @implementation MACTestSharedGroup - (void)testSharedGroup { - TightdbGroup *group = [TightdbGroup group]; + + // TODO: Update test to include more ASSERTS + + + TightdbGroup* group = [TightdbGroup group]; // Create new table in group - SharedTable2 *table = [group getTable:@"employees" withClass:[SharedTable2 class]]; + SharedTable2 *table = [group getTable:@"employees" withClass:[SharedTable2 class] error:nil]; NSLog(@"Table: %@", table); // Add some rows [table addHired:YES Age:50]; @@ -39,76 +39,62 @@ - (void)testSharedGroup NSLog(@"MyTable Size: %lu", [table count]); - NSFileManager *fm = [NSFileManager defaultManager]; + NSFileManager* fm = [NSFileManager defaultManager]; // Write to disk - [fm removeItemAtPath:@"employees.tightdb" error:NULL]; - [group write:@"employees.tightdb"]; + [fm removeItemAtPath:@"employees.tightdb" error:nil]; + [fm removeItemAtPath:@"employees.tightdb.lock" error:nil]; + [group writeToFile:@"employees.tightdb" withError:nil]; // Read only shared group - TightdbSharedGroup *fromDisk = [TightdbSharedGroup groupWithFilename:@"employees.tightdb"]; - @try { - [fromDisk readTransaction:^(TightdbGroup *group) { - SharedTable2 *diskTable = [group getTable:@"employees" withClass:[SharedTable2 class]]; + TightdbSharedGroup* fromDisk = [TightdbSharedGroup sharedGroupWithFile:@"employees.tightdb" withError:nil]; + + [fromDisk readWithBlock:^(TightdbGroup* group) { + SharedTable2* diskTable = [group getTable:@"employees" withClass:[SharedTable2 class] error:nil]; NSLog(@"Disktable size: %zu", [diskTable count]); for (size_t i = 0; i < [diskTable count]; i++) { SharedTable2_Cursor *cursor = [diskTable cursorAtIndex:i]; NSLog(@"%zu: %lld", i, [cursor Age]); NSLog(@"%zu: %lld", i, cursor.Age); - NSLog(@"%zu: %i", i, [diskTable getBool:0 ndx:i]); + NSLog(@"%zu: %i", i, [diskTable getBoolInColumn:0 atRow:i]); } - [diskTable addHired:YES Age:54]; }]; - } - @catch (NSException *exception) { - NSLog(@"Exception caught: %@", exception); - } - - // Write shared group and commit -// TightdbSharedGroup *fromDisk = [TightdbSharedGroup groupWithFilename:@"employees.tightdb"]; - [fromDisk writeTransaction:^(TightdbGroup *group) { - SharedTable2 *diskTable = [group getTable:@"employees" withClass:[SharedTable2 class]]; - NSLog(@"Disktable size: %zu", [diskTable count]); - for (size_t i = 0; i < 50; i++) { - [diskTable addHired:YES Age:i]; - } - return YES; // Commit - }]; - // Write shared group and rollback -// TightdbSharedGroup *fromDisk = [TightdbSharedGroup groupWithFilename:@"employees.tightdb"]; - [fromDisk writeTransaction:^(TightdbGroup *group) { - SharedTable2 *diskTable = [group getTable:@"employees" withClass:[SharedTable2 class]]; - NSLog(@"Disktable size: %zu", [diskTable count]); - for (size_t i = 0; i < 50; i++) { - [diskTable addHired:YES Age:i]; - } - return NO; // rollback - }]; - // Write and fail with exception in block (Should rollback) -// TightdbSharedGroup *fromDisk = [TightdbSharedGroup groupWithFilename:@"employees.tightdb"]; - @try { - [fromDisk writeTransaction:^(TightdbGroup *group) { - SharedTable2 *diskTable = [group getTable:@"employees" withClass:[SharedTable2 class]]; + + + [fromDisk writeWithBlock:^(TightdbGroup* group) { + SharedTable2* diskTable = [group getTable:@"employees" withClass:[SharedTable2 class] error:nil]; NSLog(@"Disktable size: %zu", [diskTable count]); for (size_t i = 0; i < 50; i++) { [diskTable addHired:YES Age:i]; } - [NSException raise:@"Test exception" format:@"Program went ballistic"]; - return YES; // commit - }]; - } - @catch (NSException *exception) { - NSLog(@"Exception caught: %@", exception); - } + return YES; // Commit + } withError:nil]; - [fromDisk readTransaction:^(TightdbGroup *group) { - SharedTable2 *diskTable = [group getTable:@"employees" withClass:[SharedTable2 class]]; - NSLog(@"Disktable size: %zu", [diskTable count]); - }]; + [fromDisk writeWithBlock:^(TightdbGroup* group) { + SharedTable2* diskTable = [group getTable:@"employees" withClass:[SharedTable2 class] error:nil]; + NSLog(@"Disktable size: %zu", [diskTable count]); + for (size_t i = 0; i < 50; i++) { + [diskTable addHired:YES Age:i]; + } + return NO; // rollback + } withError:nil]; -} + [fromDisk writeWithBlock:^(TightdbGroup* group) { + SharedTable2* diskTable = [group getTable:@"employees" withClass:[SharedTable2 class] error:nil]; + NSLog(@"Disktable size: %zu", [diskTable count]); + for (size_t i = 0; i < 50; i++) { + [diskTable addHired:YES Age:i]; + } + return YES; // commit + } withError:nil]; + + [fromDisk readWithBlock:^(TightdbGroup* group) { + SharedTable2* diskTable = [group getTable:@"employees" withClass:[SharedTable2 class] error:nil]; + NSLog(@"Disktable size: %zu", [diskTable count]); + }]; +} @end diff --git a/src/tightdb/objc/test/subtable.m b/src/tightdb/objc/test/subtable.m index eeac81e001..eed569b82e 100644 --- a/src/tightdb/objc/test/subtable.m +++ b/src/tightdb/objc/test/subtable.m @@ -45,7 +45,7 @@ - (void)testSubtable TightdbGroup *group = [TightdbGroup group]; /* Create new table in group */ - TestSubtableMain *people = [group getTable:@"employees" withClass:[TestSubtableMain class]]; + TestSubtableMain *people = [group getTable:@"employees" withClass:[TestSubtableMain class] error:nil]; /* FIXME: Add support for specifying a subtable to the 'add' method. The subtable must then be copied into the parent diff --git a/src/tightdb/objc/test/table.m b/src/tightdb/objc/test/table.m index a560d65c12..64ba4f550b 100644 --- a/src/tightdb/objc/test/table.m +++ b/src/tightdb/objc/test/table.m @@ -56,9 +56,9 @@ - (void)testTable // Verify - if ([_table get:0 ndx:ndx] != 0) + if ([_table getIntInColumn:0 atRow:ndx] != 0) STFail(@"First not zero"); - if ([_table get:1 ndx:ndx] != 10) + if ([_table getIntInColumn:1 atRow:ndx] != 10) STFail(@"Second not 10"); diff --git a/src/tightdb/objc/test/table_delete_all.m b/src/tightdb/objc/test/table_delete_all.m index 577b275d93..47f1a35a56 100644 --- a/src/tightdb/objc/test/table_delete_all.m +++ b/src/tightdb/objc/test/table_delete_all.m @@ -65,7 +65,7 @@ -(void)testTableDeleteAll // Add sub-tables if (i == 2) { - TightdbTable* subtable = [table getSubtable:8 ndx:i]; + TightdbTable* subtable = [table getTableInColumn:8 atRow:i]; [subtable insertInt:0 ndx:0 value:42]; [subtable insertString:1 ndx:0 value:@"meaning"]; [subtable insertDone]; diff --git a/src/tightdb/objc/test/tutorial.m b/src/tightdb/objc/test/tutorial.m index d28481e74e..1253492db5 100644 --- a/src/tightdb/objc/test/tutorial.m +++ b/src/tightdb/objc/test/tutorial.m @@ -40,7 +40,7 @@ - (void)testTutorial TightdbGroup *group = [TightdbGroup group]; // Create new table in group - PeopleTable *people = [group getTable:@"employees" withClass:[PeopleTable class]]; + PeopleTable *people = [group getTable:@"employees" withClass:[PeopleTable class] error:nil]; // Add some rows [people addName:@"John" Age:20 Hired:YES]; @@ -50,7 +50,7 @@ - (void)testTutorial [people addName:@"Anni" Age:54 Hired:YES]; // Insert at specific position - [people insertAtIndex:2 Name:@"Frank" Age:34 Hired:YES]; + [people insertRowAtIndex:2 Name:@"Frank" Age:34 Hired:YES]; // Getting the size of the table NSLog(@"PeopleTable Size: %lu - is %@. [6 - not empty]", [people count], @@ -69,12 +69,9 @@ - (void)testTutorial NSLog(@"%@ is %lld years old.", name, age); if (hired) NSLog(@"is hired."); - // Setting values - NSError *error; - if (![[people cursorAtIndex:5] setAge:43 error:&error]) { // Getting younger - NSLog(@"%@", [error localizedDescription]); - STFail(@"This action should not fail"); - } + // Setting values (note: setter access will be made obsolete, use dot notation) + [[people cursorAtIndex:5] setAge:43]; // Getting younger + // or with dot-syntax: myRow.Age += 1; // Happy birthday! NSLog(@"%@ age is now %lld. [44]", myRow.Name, myRow.Age); @@ -146,12 +143,12 @@ - (void)testTutorial NSFileManager *fm = [NSFileManager defaultManager]; // Write the group to disk - [fm removeItemAtPath:@"employees.tightdb" error:NULL]; - [group write:@"employees.tightdb"]; + [fm removeItemAtPath:@"employees.tightdb" error:nil]; + [group writeToFile:@"employees.tightdb" withError:nil]; // Load a group from disk (and print contents) - TightdbGroup *fromDisk = [TightdbGroup groupWithFilename:@"employees.tightdb"]; - PeopleTable *diskTable = [fromDisk getTable:@"employees" withClass:[PeopleTable class]]; + TightdbGroup *fromDisk = [TightdbGroup groupWithFile:@"employees.tightdb" withError:nil]; + PeopleTable *diskTable = [fromDisk getTable:@"employees" withClass:[PeopleTable class] error:nil]; [diskTable addName:@"Anni" Age:54 Hired:YES]; @@ -164,12 +161,11 @@ - (void)testTutorial } // Write same group to memory buffer - size_t size; - const char* const data = [group writeToMem:&size]; + TightdbBinary* buffer = [group writeToBuffer]; // Load a group from memory (and print contents) - TightdbGroup *fromMem = [TightdbGroup groupWithBuffer:data size:size]; - PeopleTable *memTable = [fromMem getTable:@"employees" withClass:[PeopleTable class]]; + TightdbGroup *fromMem = [TightdbGroup groupWithBuffer:buffer withError:nil]; + PeopleTable *memTable = [fromMem getTable:@"employees" withClass:[PeopleTable class] error:nil]; for (size_t i = 0; i < [memTable count]; i++) { PeopleTable_Cursor *cursor = [memTable cursorAtIndex:i]; NSLog(@"%zu: %@", i, cursor.Name); diff --git a/src/tightdb/objc/tightdb.h b/src/tightdb/objc/tightdb.h index 994d770c3c..f0b7111f5e 100644 --- a/src/tightdb/objc/tightdb.h +++ b/src/tightdb/objc/tightdb.h @@ -52,9 +52,8 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName1, CType1) \ @end \ @interface TableName: TightdbTable \ TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1; \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 error:(NSError**)error; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1; \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1; \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1; \ -(TableName##_Query*)where; \ -(TableName##_Cursor*)addRow; \ -(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @@ -161,18 +160,13 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ return self; \ } \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 \ -{ \ - return [self add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 error:nil]; \ -} \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 error:(NSError**)error\ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 \ { \ size_t ndx = [self count]; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 0, ndx, CName1, CType1, error)) \ - return NO; \ - return [self insertDoneWithError:error]; \ + TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ + [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ [self insertDone]; \ @@ -272,9 +266,8 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName2, CType2) \ @interface TableName: TightdbTable \ TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ TIGHTDB_COLUMN_PROXY_DEF(CName2, CType2) \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2; \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 error:(NSError**)error; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2; \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2; \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2; \ -(TableName##_Query*)where; \ -(TableName##_Cursor*)addRow; \ -(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @@ -390,20 +383,14 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ return self; \ } \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 \ -{ \ - return [self add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 error:nil]; \ -} \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 error:(NSError**)error\ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 \ { \ size_t ndx = [self count]; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 0, ndx, CName1, CType1, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 1, ndx, CName2, CType2, error)) \ - return NO; \ - return [self insertDoneWithError:error]; \ + TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ + TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ + [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -510,9 +497,8 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName3, CType3) \ TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ TIGHTDB_COLUMN_PROXY_DEF(CName2, CType2) \ TIGHTDB_COLUMN_PROXY_DEF(CName3, CType3) \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3; \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 error:(NSError**)error; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3; \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3; \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3; \ -(TableName##_Query*)where; \ -(TableName##_Cursor*)addRow; \ -(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @@ -637,22 +623,15 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName3, CType3) \ TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ return self; \ } \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 \ -{ \ - return [self add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 error:nil]; \ -} \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 error:(NSError**)error\ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 \ { \ size_t ndx = [self count]; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 0, ndx, CName1, CType1, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 1, ndx, CName2, CType2, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 2, ndx, CName3, CType3, error)) \ - return NO; \ - return [self insertDoneWithError:error]; \ + TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ + TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ + TIGHTDB_COLUMN_INSERT(self, 2, ndx, CName3, CType3); \ + [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -766,9 +745,8 @@ TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ TIGHTDB_COLUMN_PROXY_DEF(CName2, CType2) \ TIGHTDB_COLUMN_PROXY_DEF(CName3, CType3) \ TIGHTDB_COLUMN_PROXY_DEF(CName4, CType4) \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4; \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 error:(NSError**)error; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4; \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4; \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4; \ -(TableName##_Query*)where; \ -(TableName##_Cursor*)addRow; \ -(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @@ -902,24 +880,16 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName4, CType4) \ TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ return self; \ } \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 \ -{ \ - return [self add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 error:nil]; \ -} \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 error:(NSError**)error\ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 \ { \ size_t ndx = [self count]; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 0, ndx, CName1, CType1, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 1, ndx, CName2, CType2, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 2, ndx, CName3, CType3, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 3, ndx, CName4, CType4, error)) \ - return NO; \ - return [self insertDoneWithError:error]; \ + TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ + TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ + TIGHTDB_COLUMN_INSERT(self, 2, ndx, CName3, CType3); \ + TIGHTDB_COLUMN_INSERT(self, 3, ndx, CName4, CType4); \ + [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -1040,9 +1010,8 @@ TIGHTDB_COLUMN_PROXY_DEF(CName2, CType2) \ TIGHTDB_COLUMN_PROXY_DEF(CName3, CType3) \ TIGHTDB_COLUMN_PROXY_DEF(CName4, CType4) \ TIGHTDB_COLUMN_PROXY_DEF(CName5, CType5) \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5; \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 error:(NSError**)error; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5; \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5; \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5; \ -(TableName##_Query*)where; \ -(TableName##_Cursor*)addRow; \ -(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @@ -1185,26 +1154,17 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName5, CType5) \ TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ return self; \ } \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 \ -{ \ - return [self add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 error:nil]; \ -} \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 error:(NSError**)error\ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 \ { \ size_t ndx = [self count]; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 0, ndx, CName1, CType1, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 1, ndx, CName2, CType2, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 2, ndx, CName3, CType3, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 3, ndx, CName4, CType4, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 4, ndx, CName5, CType5, error)) \ - return NO; \ - return [self insertDoneWithError:error]; \ + TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ + TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ + TIGHTDB_COLUMN_INSERT(self, 2, ndx, CName3, CType3); \ + TIGHTDB_COLUMN_INSERT(self, 3, ndx, CName4, CType4); \ + TIGHTDB_COLUMN_INSERT(self, 4, ndx, CName5, CType5); \ + [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -1332,9 +1292,8 @@ TIGHTDB_COLUMN_PROXY_DEF(CName3, CType3) \ TIGHTDB_COLUMN_PROXY_DEF(CName4, CType4) \ TIGHTDB_COLUMN_PROXY_DEF(CName5, CType5) \ TIGHTDB_COLUMN_PROXY_DEF(CName6, CType6) \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6; \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 error:(NSError**)error; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6; \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6; \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6; \ -(TableName##_Query*)where; \ -(TableName##_Cursor*)addRow; \ -(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @@ -1486,28 +1445,18 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName6, CType6) \ TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ return self; \ } \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 \ -{ \ - return [self add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 error:nil]; \ -} \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 error:(NSError**)error\ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 \ { \ size_t ndx = [self count]; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 0, ndx, CName1, CType1, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 1, ndx, CName2, CType2, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 2, ndx, CName3, CType3, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 3, ndx, CName4, CType4, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 4, ndx, CName5, CType5, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 5, ndx, CName6, CType6, error)) \ - return NO; \ - return [self insertDoneWithError:error]; \ + TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ + TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ + TIGHTDB_COLUMN_INSERT(self, 2, ndx, CName3, CType3); \ + TIGHTDB_COLUMN_INSERT(self, 3, ndx, CName4, CType4); \ + TIGHTDB_COLUMN_INSERT(self, 4, ndx, CName5, CType5); \ + TIGHTDB_COLUMN_INSERT(self, 5, ndx, CName6, CType6); \ + [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -1642,9 +1591,8 @@ TIGHTDB_COLUMN_PROXY_DEF(CName4, CType4) \ TIGHTDB_COLUMN_PROXY_DEF(CName5, CType5) \ TIGHTDB_COLUMN_PROXY_DEF(CName6, CType6) \ TIGHTDB_COLUMN_PROXY_DEF(CName7, CType7) \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7; \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 error:(NSError**)error; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7; \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7; \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7; \ -(TableName##_Query*)where; \ -(TableName##_Cursor*)addRow; \ -(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @@ -1805,30 +1753,19 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName7, CType7) \ TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ return self; \ } \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 \ -{ \ - return [self add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 error:nil]; \ -} \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 error:(NSError**)error\ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 \ { \ size_t ndx = [self count]; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 0, ndx, CName1, CType1, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 1, ndx, CName2, CType2, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 2, ndx, CName3, CType3, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 3, ndx, CName4, CType4, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 4, ndx, CName5, CType5, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 5, ndx, CName6, CType6, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 6, ndx, CName7, CType7, error)) \ - return NO; \ - return [self insertDoneWithError:error]; \ + TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ + TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ + TIGHTDB_COLUMN_INSERT(self, 2, ndx, CName3, CType3); \ + TIGHTDB_COLUMN_INSERT(self, 3, ndx, CName4, CType4); \ + TIGHTDB_COLUMN_INSERT(self, 4, ndx, CName5, CType5); \ + TIGHTDB_COLUMN_INSERT(self, 5, ndx, CName6, CType6); \ + TIGHTDB_COLUMN_INSERT(self, 6, ndx, CName7, CType7); \ + [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -1970,9 +1907,8 @@ TIGHTDB_COLUMN_PROXY_DEF(CName5, CType5) \ TIGHTDB_COLUMN_PROXY_DEF(CName6, CType6) \ TIGHTDB_COLUMN_PROXY_DEF(CName7, CType7) \ TIGHTDB_COLUMN_PROXY_DEF(CName8, CType8) \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8; \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 error:(NSError**)error; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8; \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8; \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8; \ -(TableName##_Query*)where; \ -(TableName##_Cursor*)addRow; \ -(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @@ -2142,32 +2078,20 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName8, CType8) \ TIGHTDB_COLUMN_PROXY_INIT(self, 7, CName8, CType8); \ return self; \ } \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 \ -{ \ - return [self add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 error:nil]; \ -} \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 error:(NSError**)error\ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 \ { \ size_t ndx = [self count]; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 0, ndx, CName1, CType1, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 1, ndx, CName2, CType2, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 2, ndx, CName3, CType3, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 3, ndx, CName4, CType4, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 4, ndx, CName5, CType5, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 5, ndx, CName6, CType6, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 6, ndx, CName7, CType7, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 7, ndx, CName8, CType8, error)) \ - return NO; \ - return [self insertDoneWithError:error]; \ + TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ + TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ + TIGHTDB_COLUMN_INSERT(self, 2, ndx, CName3, CType3); \ + TIGHTDB_COLUMN_INSERT(self, 3, ndx, CName4, CType4); \ + TIGHTDB_COLUMN_INSERT(self, 4, ndx, CName5, CType5); \ + TIGHTDB_COLUMN_INSERT(self, 5, ndx, CName6, CType6); \ + TIGHTDB_COLUMN_INSERT(self, 6, ndx, CName7, CType7); \ + TIGHTDB_COLUMN_INSERT(self, 7, ndx, CName8, CType8); \ + [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -2316,9 +2240,8 @@ TIGHTDB_COLUMN_PROXY_DEF(CName6, CType6) \ TIGHTDB_COLUMN_PROXY_DEF(CName7, CType7) \ TIGHTDB_COLUMN_PROXY_DEF(CName8, CType8) \ TIGHTDB_COLUMN_PROXY_DEF(CName9, CType9) \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9; \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 error:(NSError**)error; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9; \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9; \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9; \ -(TableName##_Query*)where; \ -(TableName##_Cursor*)addRow; \ -(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @@ -2497,34 +2420,21 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName9, CType9) \ TIGHTDB_COLUMN_PROXY_INIT(self, 8, CName9, CType9); \ return self; \ } \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 \ -{ \ - return [self add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 error:nil]; \ -} \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 error:(NSError**)error\ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 \ { \ size_t ndx = [self count]; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 0, ndx, CName1, CType1, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 1, ndx, CName2, CType2, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 2, ndx, CName3, CType3, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 3, ndx, CName4, CType4, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 4, ndx, CName5, CType5, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 5, ndx, CName6, CType6, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 6, ndx, CName7, CType7, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 7, ndx, CName8, CType8, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 8, ndx, CName9, CType9, error)) \ - return NO; \ - return [self insertDoneWithError:error]; \ + TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ + TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ + TIGHTDB_COLUMN_INSERT(self, 2, ndx, CName3, CType3); \ + TIGHTDB_COLUMN_INSERT(self, 3, ndx, CName4, CType4); \ + TIGHTDB_COLUMN_INSERT(self, 4, ndx, CName5, CType5); \ + TIGHTDB_COLUMN_INSERT(self, 5, ndx, CName6, CType6); \ + TIGHTDB_COLUMN_INSERT(self, 6, ndx, CName7, CType7); \ + TIGHTDB_COLUMN_INSERT(self, 7, ndx, CName8, CType8); \ + TIGHTDB_COLUMN_INSERT(self, 8, ndx, CName9, CType9); \ + [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -2680,9 +2590,8 @@ TIGHTDB_COLUMN_PROXY_DEF(CName7, CType7) \ TIGHTDB_COLUMN_PROXY_DEF(CName8, CType8) \ TIGHTDB_COLUMN_PROXY_DEF(CName9, CType9) \ TIGHTDB_COLUMN_PROXY_DEF(CName10, CType10) \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10; \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 error:(NSError**)error; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10; \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10; \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10; \ -(TableName##_Query*)where; \ -(TableName##_Cursor*)addRow; \ -(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @@ -2870,36 +2779,22 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName10, CType10) \ TIGHTDB_COLUMN_PROXY_INIT(self, 9, CName10, CType10); \ return self; \ } \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 \ -{ \ - return [self add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 error:nil]; \ -} \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 error:(NSError**)error\ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 \ { \ size_t ndx = [self count]; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 0, ndx, CName1, CType1, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 1, ndx, CName2, CType2, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 2, ndx, CName3, CType3, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 3, ndx, CName4, CType4, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 4, ndx, CName5, CType5, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 5, ndx, CName6, CType6, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 6, ndx, CName7, CType7, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 7, ndx, CName8, CType8, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 8, ndx, CName9, CType9, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 9, ndx, CName10, CType10, error)) \ - return NO; \ - return [self insertDoneWithError:error]; \ + TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ + TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ + TIGHTDB_COLUMN_INSERT(self, 2, ndx, CName3, CType3); \ + TIGHTDB_COLUMN_INSERT(self, 3, ndx, CName4, CType4); \ + TIGHTDB_COLUMN_INSERT(self, 4, ndx, CName5, CType5); \ + TIGHTDB_COLUMN_INSERT(self, 5, ndx, CName6, CType6); \ + TIGHTDB_COLUMN_INSERT(self, 6, ndx, CName7, CType7); \ + TIGHTDB_COLUMN_INSERT(self, 7, ndx, CName8, CType8); \ + TIGHTDB_COLUMN_INSERT(self, 8, ndx, CName9, CType9); \ + TIGHTDB_COLUMN_INSERT(self, 9, ndx, CName10, CType10); \ + [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -3062,9 +2957,8 @@ TIGHTDB_COLUMN_PROXY_DEF(CName8, CType8) \ TIGHTDB_COLUMN_PROXY_DEF(CName9, CType9) \ TIGHTDB_COLUMN_PROXY_DEF(CName10, CType10) \ TIGHTDB_COLUMN_PROXY_DEF(CName11, CType11) \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11; \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 error:(NSError**)error; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11; \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11; \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11; \ -(TableName##_Query*)where; \ -(TableName##_Cursor*)addRow; \ -(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @@ -3261,38 +3155,23 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName11, CType11) \ TIGHTDB_COLUMN_PROXY_INIT(self, 10, CName11, CType11); \ return self; \ } \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 \ -{ \ - return [self add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 error:nil]; \ -} \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 error:(NSError**)error\ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 \ { \ size_t ndx = [self count]; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 0, ndx, CName1, CType1, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 1, ndx, CName2, CType2, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 2, ndx, CName3, CType3, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 3, ndx, CName4, CType4, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 4, ndx, CName5, CType5, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 5, ndx, CName6, CType6, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 6, ndx, CName7, CType7, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 7, ndx, CName8, CType8, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 8, ndx, CName9, CType9, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 9, ndx, CName10, CType10, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 10, ndx, CName11, CType11, error)) \ - return NO; \ - return [self insertDoneWithError:error]; \ + TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ + TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ + TIGHTDB_COLUMN_INSERT(self, 2, ndx, CName3, CType3); \ + TIGHTDB_COLUMN_INSERT(self, 3, ndx, CName4, CType4); \ + TIGHTDB_COLUMN_INSERT(self, 4, ndx, CName5, CType5); \ + TIGHTDB_COLUMN_INSERT(self, 5, ndx, CName6, CType6); \ + TIGHTDB_COLUMN_INSERT(self, 6, ndx, CName7, CType7); \ + TIGHTDB_COLUMN_INSERT(self, 7, ndx, CName8, CType8); \ + TIGHTDB_COLUMN_INSERT(self, 8, ndx, CName9, CType9); \ + TIGHTDB_COLUMN_INSERT(self, 9, ndx, CName10, CType10); \ + TIGHTDB_COLUMN_INSERT(self, 10, ndx, CName11, CType11); \ + [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -3462,9 +3341,8 @@ TIGHTDB_COLUMN_PROXY_DEF(CName9, CType9) \ TIGHTDB_COLUMN_PROXY_DEF(CName10, CType10) \ TIGHTDB_COLUMN_PROXY_DEF(CName11, CType11) \ TIGHTDB_COLUMN_PROXY_DEF(CName12, CType12) \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12; \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 error:(NSError**)error; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12; \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12; \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12; \ -(TableName##_Query*)where; \ -(TableName##_Cursor*)addRow; \ -(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @@ -3670,40 +3548,24 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName12, CType12) \ TIGHTDB_COLUMN_PROXY_INIT(self, 11, CName12, CType12); \ return self; \ } \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 \ -{ \ - return [self add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 error:nil]; \ -} \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 error:(NSError**)error\ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 \ { \ size_t ndx = [self count]; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 0, ndx, CName1, CType1, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 1, ndx, CName2, CType2, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 2, ndx, CName3, CType3, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 3, ndx, CName4, CType4, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 4, ndx, CName5, CType5, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 5, ndx, CName6, CType6, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 6, ndx, CName7, CType7, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 7, ndx, CName8, CType8, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 8, ndx, CName9, CType9, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 9, ndx, CName10, CType10, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 10, ndx, CName11, CType11, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 11, ndx, CName12, CType12, error)) \ - return NO; \ - return [self insertDoneWithError:error]; \ + TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ + TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ + TIGHTDB_COLUMN_INSERT(self, 2, ndx, CName3, CType3); \ + TIGHTDB_COLUMN_INSERT(self, 3, ndx, CName4, CType4); \ + TIGHTDB_COLUMN_INSERT(self, 4, ndx, CName5, CType5); \ + TIGHTDB_COLUMN_INSERT(self, 5, ndx, CName6, CType6); \ + TIGHTDB_COLUMN_INSERT(self, 6, ndx, CName7, CType7); \ + TIGHTDB_COLUMN_INSERT(self, 7, ndx, CName8, CType8); \ + TIGHTDB_COLUMN_INSERT(self, 8, ndx, CName9, CType9); \ + TIGHTDB_COLUMN_INSERT(self, 9, ndx, CName10, CType10); \ + TIGHTDB_COLUMN_INSERT(self, 10, ndx, CName11, CType11); \ + TIGHTDB_COLUMN_INSERT(self, 11, ndx, CName12, CType12); \ + [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -3880,9 +3742,8 @@ TIGHTDB_COLUMN_PROXY_DEF(CName10, CType10) \ TIGHTDB_COLUMN_PROXY_DEF(CName11, CType11) \ TIGHTDB_COLUMN_PROXY_DEF(CName12, CType12) \ TIGHTDB_COLUMN_PROXY_DEF(CName13, CType13) \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13; \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 error:(NSError**)error; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13; \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13; \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13; \ -(TableName##_Query*)where; \ -(TableName##_Cursor*)addRow; \ -(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @@ -4097,42 +3958,25 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName13, CType13) \ TIGHTDB_COLUMN_PROXY_INIT(self, 12, CName13, CType13); \ return self; \ } \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 \ -{ \ - return [self add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 error:nil]; \ -} \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 error:(NSError**)error\ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 \ { \ size_t ndx = [self count]; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 0, ndx, CName1, CType1, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 1, ndx, CName2, CType2, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 2, ndx, CName3, CType3, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 3, ndx, CName4, CType4, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 4, ndx, CName5, CType5, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 5, ndx, CName6, CType6, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 6, ndx, CName7, CType7, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 7, ndx, CName8, CType8, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 8, ndx, CName9, CType9, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 9, ndx, CName10, CType10, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 10, ndx, CName11, CType11, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 11, ndx, CName12, CType12, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 12, ndx, CName13, CType13, error)) \ - return NO; \ - return [self insertDoneWithError:error]; \ + TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ + TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ + TIGHTDB_COLUMN_INSERT(self, 2, ndx, CName3, CType3); \ + TIGHTDB_COLUMN_INSERT(self, 3, ndx, CName4, CType4); \ + TIGHTDB_COLUMN_INSERT(self, 4, ndx, CName5, CType5); \ + TIGHTDB_COLUMN_INSERT(self, 5, ndx, CName6, CType6); \ + TIGHTDB_COLUMN_INSERT(self, 6, ndx, CName7, CType7); \ + TIGHTDB_COLUMN_INSERT(self, 7, ndx, CName8, CType8); \ + TIGHTDB_COLUMN_INSERT(self, 8, ndx, CName9, CType9); \ + TIGHTDB_COLUMN_INSERT(self, 9, ndx, CName10, CType10); \ + TIGHTDB_COLUMN_INSERT(self, 10, ndx, CName11, CType11); \ + TIGHTDB_COLUMN_INSERT(self, 11, ndx, CName12, CType12); \ + TIGHTDB_COLUMN_INSERT(self, 12, ndx, CName13, CType13); \ + [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -4316,9 +4160,8 @@ TIGHTDB_COLUMN_PROXY_DEF(CName11, CType11) \ TIGHTDB_COLUMN_PROXY_DEF(CName12, CType12) \ TIGHTDB_COLUMN_PROXY_DEF(CName13, CType13) \ TIGHTDB_COLUMN_PROXY_DEF(CName14, CType14) \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14; \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 error:(NSError**)error; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14; \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14; \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14; \ -(TableName##_Query*)where; \ -(TableName##_Cursor*)addRow; \ -(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @@ -4542,44 +4385,26 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName14, CType14) \ TIGHTDB_COLUMN_PROXY_INIT(self, 13, CName14, CType14); \ return self; \ } \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 \ -{ \ - return [self add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 error:nil]; \ -} \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 error:(NSError**)error\ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 \ { \ size_t ndx = [self count]; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 0, ndx, CName1, CType1, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 1, ndx, CName2, CType2, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 2, ndx, CName3, CType3, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 3, ndx, CName4, CType4, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 4, ndx, CName5, CType5, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 5, ndx, CName6, CType6, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 6, ndx, CName7, CType7, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 7, ndx, CName8, CType8, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 8, ndx, CName9, CType9, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 9, ndx, CName10, CType10, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 10, ndx, CName11, CType11, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 11, ndx, CName12, CType12, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 12, ndx, CName13, CType13, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 13, ndx, CName14, CType14, error)) \ - return NO; \ - return [self insertDoneWithError:error]; \ + TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ + TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ + TIGHTDB_COLUMN_INSERT(self, 2, ndx, CName3, CType3); \ + TIGHTDB_COLUMN_INSERT(self, 3, ndx, CName4, CType4); \ + TIGHTDB_COLUMN_INSERT(self, 4, ndx, CName5, CType5); \ + TIGHTDB_COLUMN_INSERT(self, 5, ndx, CName6, CType6); \ + TIGHTDB_COLUMN_INSERT(self, 6, ndx, CName7, CType7); \ + TIGHTDB_COLUMN_INSERT(self, 7, ndx, CName8, CType8); \ + TIGHTDB_COLUMN_INSERT(self, 8, ndx, CName9, CType9); \ + TIGHTDB_COLUMN_INSERT(self, 9, ndx, CName10, CType10); \ + TIGHTDB_COLUMN_INSERT(self, 10, ndx, CName11, CType11); \ + TIGHTDB_COLUMN_INSERT(self, 11, ndx, CName12, CType12); \ + TIGHTDB_COLUMN_INSERT(self, 12, ndx, CName13, CType13); \ + TIGHTDB_COLUMN_INSERT(self, 13, ndx, CName14, CType14); \ + [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -4770,9 +4595,8 @@ TIGHTDB_COLUMN_PROXY_DEF(CName12, CType12) \ TIGHTDB_COLUMN_PROXY_DEF(CName13, CType13) \ TIGHTDB_COLUMN_PROXY_DEF(CName14, CType14) \ TIGHTDB_COLUMN_PROXY_DEF(CName15, CType15) \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 CName15:(TIGHTDB_ARG_TYPE(CType15))CName15; \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 CName15:(TIGHTDB_ARG_TYPE(CType15))CName15 error:(NSError**)error; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 CName15:(TIGHTDB_ARG_TYPE(CType15))CName15; \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 CName15:(TIGHTDB_ARG_TYPE(CType15))CName15; \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 CName15:(TIGHTDB_ARG_TYPE(CType15))CName15; \ -(TableName##_Query*)where; \ -(TableName##_Cursor*)addRow; \ -(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @@ -5005,46 +4829,27 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName15, CType15) \ TIGHTDB_COLUMN_PROXY_INIT(self, 14, CName15, CType15); \ return self; \ } \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 CName15:(TIGHTDB_ARG_TYPE(CType15))CName15 \ -{ \ - return [self add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 CName15:(TIGHTDB_ARG_TYPE(CType15))CName15 error:nil]; \ -} \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 CName15:(TIGHTDB_ARG_TYPE(CType15))CName15 error:(NSError**)error\ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 CName15:(TIGHTDB_ARG_TYPE(CType15))CName15 \ { \ size_t ndx = [self count]; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 0, ndx, CName1, CType1, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 1, ndx, CName2, CType2, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 2, ndx, CName3, CType3, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 3, ndx, CName4, CType4, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 4, ndx, CName5, CType5, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 5, ndx, CName6, CType6, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 6, ndx, CName7, CType7, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 7, ndx, CName8, CType8, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 8, ndx, CName9, CType9, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 9, ndx, CName10, CType10, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 10, ndx, CName11, CType11, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 11, ndx, CName12, CType12, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 12, ndx, CName13, CType13, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 13, ndx, CName14, CType14, error)) \ - return NO; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 14, ndx, CName15, CType15, error)) \ - return NO; \ - return [self insertDoneWithError:error]; \ + TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ + TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ + TIGHTDB_COLUMN_INSERT(self, 2, ndx, CName3, CType3); \ + TIGHTDB_COLUMN_INSERT(self, 3, ndx, CName4, CType4); \ + TIGHTDB_COLUMN_INSERT(self, 4, ndx, CName5, CType5); \ + TIGHTDB_COLUMN_INSERT(self, 5, ndx, CName6, CType6); \ + TIGHTDB_COLUMN_INSERT(self, 6, ndx, CName7, CType7); \ + TIGHTDB_COLUMN_INSERT(self, 7, ndx, CName8, CType8); \ + TIGHTDB_COLUMN_INSERT(self, 8, ndx, CName9, CType9); \ + TIGHTDB_COLUMN_INSERT(self, 9, ndx, CName10, CType10); \ + TIGHTDB_COLUMN_INSERT(self, 10, ndx, CName11, CType11); \ + TIGHTDB_COLUMN_INSERT(self, 11, ndx, CName12, CType12); \ + TIGHTDB_COLUMN_INSERT(self, 12, ndx, CName13, CType13); \ + TIGHTDB_COLUMN_INSERT(self, 13, ndx, CName14, CType14); \ + TIGHTDB_COLUMN_INSERT(self, 14, ndx, CName15, CType15); \ + [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 CName15:(TIGHTDB_ARG_TYPE(CType15))CName15 \ +-(void)insertRowAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 CName15:(TIGHTDB_ARG_TYPE(CType15))CName15 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ diff --git a/src/tightdb/objc/tightdb.h.cheetah b/src/tightdb/objc/tightdb.h.cheetah index b9153b4b8b..109feea189 100644 --- a/src/tightdb/objc/tightdb.h.cheetah +++ b/src/tightdb/objc/tightdb.h.cheetah @@ -76,7 +76,7 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName${j+1}, CType${j+1}) \ %for $j in range($num_cols) TIGHTDB_COLUMN_PROXY_DEF(CName${j+1}, CType${j+1}) \ %end for --(BOOL)add##%slurp +-(void)add##%slurp %for $j in range($num_cols) %if 0 < $j %echo ' ' @@ -84,15 +84,7 @@ TIGHTDB_COLUMN_PROXY_DEF(CName${j+1}, CType${j+1}) \ CName${j+1}:(TIGHTDB_ARG_TYPE(CType${j+1}))CName${j+1}%slurp %end for ; \ --(BOOL)add##%slurp -%for $j in range($num_cols) -%if 0 < $j -%echo ' ' -%end if -CName${j+1}:(TIGHTDB_ARG_TYPE(CType${j+1}))CName${j+1}%slurp -%end for - error:(NSError**)error; \ --(void)insertAtIndex:(size_t)ndx%slurp +-(void)insertRowAtIndex:(size_t)ndx%slurp %for $j in range($num_cols) CName${j+1}:(TIGHTDB_ARG_TYPE(CType${j+1}))CName${j+1}%slurp %end for @@ -225,32 +217,19 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName${j+1}, CType${j+1}) \ %end for return self; \ } \ --(BOOL)add##%slurp +-(void)add##%slurp %for $j in range($num_cols) CName${j+1}:(TIGHTDB_ARG_TYPE(CType${j+1}))CName${j+1} %slurp %end for \ -{ \ - return [self add##%slurp -%for $j in range($num_cols) -CName${j+1}:(TIGHTDB_ARG_TYPE(CType${j+1}))CName${j+1} %slurp -%end for -error:nil]; \ -} \ --(BOOL)add##%slurp -%for $j in range($num_cols) -CName${j+1}:(TIGHTDB_ARG_TYPE(CType${j+1}))CName${j+1} %slurp -%end for -error:(NSError**)error\ { \ size_t ndx = [self count]; \ %for $j in range($num_cols) - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, ${j}, ndx, CName${j+1}, CType${j+1}, error)) \ - return NO; \ + TIGHTDB_COLUMN_INSERT(self, ${j}, ndx, CName${j+1}, CType${j+1}); \ %end for - return [self insertDoneWithError:error]; \ + [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx %slurp +-(void)insertRowAtIndex:(size_t)ndx %slurp %for $j in range($num_cols) CName${j+1}:(TIGHTDB_ARG_TYPE(CType${j+1}))CName${j+1} %slurp %end for diff --git a/src/tightdb/objc/util.hpp b/src/tightdb/objc/util.hpp index b1ea5c121c..c717a71206 100644 --- a/src/tightdb/objc/util.hpp +++ b/src/tightdb/objc/util.hpp @@ -47,15 +47,33 @@ struct ObjcStringAccessor { std::size_t m_size; }; +inline NSString* to_objc_string(tightdb::StringData s) +{ + using namespace std; + using namespace tightdb; + const char* data = s.data(); + NSUInteger size; + if (util::int_cast_with_overflow_detect(s.size(), size)) + throw runtime_error("String size overflow"); + return [[NSString alloc] initWithBytes:data length:size encoding:NSUTF8StringEncoding]; +} + + +// Still used in the new error strategy. Perhaps it should be public? enum TightdbErr { - tdb_err_Ok = 0, - tdb_err_Fail = 1, - tdb_err_FailRdOnly = 2, - tdb_err_FileAccess = 3, - tdb_err_Resource = 4, + tdb_err_Ok = 0, + tdb_err_Fail = 1, + tdb_err_FailRdOnly = 2, + tdb_err_File_AccessError = 3, + tdb_err_File_PermissionDenied = 4, + tdb_err_File_Exists = 5, + tdb_err_File_NotFound = 6, + tdb_err_Rollback = 7, + tdb_err_InvalidDatabase = 8, + tdb_err_TableNotFound = 9 }; -inline NSError* make_tightdb_error(TightdbErr code, NSString *desc) +inline NSError* make_tightdb_error(TightdbErr code, NSString* desc) { NSMutableDictionary* details = [NSMutableDictionary dictionary]; [details setValue:desc forKey:NSLocalizedDescriptionKey]; @@ -65,34 +83,64 @@ inline NSError* make_tightdb_error(TightdbErr code, NSString *desc) #define TIGHTDB_OBJC_SIZE_T_NUMBER_IN numberWithUnsignedLong #define TIGHTDB_OBJC_SIZE_T_NUMBER_OUT unsignedLongValue -#define TIGHTDB_EXCEPTION_ERRHANDLER(action, failReturnValue) TIGHTDB_EXCEPTION_ERRHANDLER_EX(action, failReturnValue, error) -#define TIGHTDB_EXCEPTION_ERRHANDLER_EX(action, failReturnValue, errVar) try { action } \ -catch(tightdb::util::File::AccessError &ex) { \ - if (errVar) \ - *errVar = make_tightdb_error(tdb_err_FileAccess, [NSString stringWithUTF8String:ex.what()]); \ - return failReturnValue; \ -} \ -catch(tightdb::ResourceAllocError &ex) { \ - if (errVar) \ - *errVar = make_tightdb_error(tdb_err_Resource, [NSString stringWithUTF8String:ex.what()]); \ - return failReturnValue; \ +#define TIGHTDB_EXCEPTION_ERRHANDLER(action, fail_return_value) \ +TIGHTDB_EXCEPTION_ERRHANDLER_EX(action, fail_return_value, error) + +// This is the old macro, which should be phased out. +#define TIGHTDB_EXCEPTION_ERRHANDLER_EX(action, fail_return_value, err_var) \ +try { action } \ +catch (tightdb::util::File::AccessError& ex) { \ + if (err_var) \ + *err_var = make_tightdb_error(tdb_err_File_AccessError, [NSString stringWithUTF8String:ex.what()]); \ + return fail_return_value; \ } \ -catch (std::exception &ex) { \ - if (errVar) \ - *errVar = make_tightdb_error(tdb_err_Fail, [NSString stringWithUTF8String:ex.what()]); \ - return failReturnValue; \ +catch (std::exception& ex) { \ + if (err_var) \ + *err_var = make_tightdb_error(tdb_err_Fail, [NSString stringWithUTF8String:ex.what()]); \ + return fail_return_value; \ } +// This macro is part of the new error strategy, specifically for table value setters. +#define TIGHTDB_EXCEPTION_HANDLER_SETTERS(action, datatype) \ +if (m_read_only) { \ + NSException* exception = [NSException exceptionWithName:@"tightdb:table_is_read_only" \ + reason:@"You tried to modify an immutable table" \ + userInfo:[NSMutableDictionary dictionary]]; \ + [exception raise]; \ +} \ +if (col_ndx >= [self getColumnCount]) { \ + NSException* exception = [NSException exceptionWithName:@"tightdb:column_index_out_of_bounds" \ + reason:@"The specified column index is not within the table bounds" \ + userInfo:[NSMutableDictionary dictionary]]; \ + [exception raise]; \ +} \ +if ([self getColumnType:col_ndx] != datatype) { \ + NSException* exception = [NSException exceptionWithName:@"tightdb:illegal_type" \ + reason:@"The supplied type is not compatible with the column type" \ + userInfo:[NSMutableDictionary dictionary]]; \ + [exception raise]; \ +} \ +if (row_ndx >= [self count]) { \ + NSException* exception = [NSException exceptionWithName:@"tightdb:row_index_out_of_bounds" \ + reason:@"The specified row index is not within the table bounds" \ + userInfo:[NSMutableDictionary dictionary]]; \ + [exception raise]; \ +} \ +try { action } \ +catch(std::exception& ex) { \ + NSException* exception = [NSException exceptionWithName:@"tightdb:core_exception" \ + reason:[NSString stringWithUTF8String:ex.what()] \ + userInfo:[NSMutableDictionary dictionary]]; \ + [exception raise]; \ +} -inline NSString* to_objc_string(tightdb::StringData s) -{ - using namespace std; - using namespace tightdb; - const char* data = s.data(); - NSUInteger size; - if (util::int_cast_with_overflow_detect(s.size(), size)) - throw runtime_error("String size overflow"); - return [[NSString alloc] initWithBytes:data length:size encoding:NSUTF8StringEncoding]; +#define TIGHTDB_EXCEPTION_HANDLER_CORE_EXCEPTION(action) \ +try { action } \ +catch(std::exception& ex) { \ + NSException* exception = [NSException exceptionWithName:@"tightdb:core_exception" \ + reason:[NSString stringWithUTF8String:ex.what()] \ + userInfo:[NSMutableDictionary dictionary]]; \ + [exception raise]; \ } #endif // TIGHTDB_OBJC_UTIL_HPP diff --git a/test-iphone/TightDbExample/Performance.m b/test-iphone/TightDbExample/Performance.m index 17fd5f3493..0491789652 100644 --- a/test-iphone/TightDbExample/Performance.m +++ b/test-iphone/TightDbExample/Performance.m @@ -57,7 +57,7 @@ - (void)testInsert { TightdbGroup *group = [TightdbGroup group]; // Create new table in group - PerfTable *table = [group getTable:@"employees"withClass:[PerfTable class]]; + PerfTable *table = [group getTable:@"employees"withClass:[PerfTable class] error:nil]; // Add some rows NSUInteger count = _size; @@ -67,7 +67,7 @@ - (void)testInsert { } [table addName:@"Sparse" Age:41 Hired:NO Spare:2]; - NSLog(@"Age verify: %lld", [table get:1 ndx:1000]); + NSLog(@"Age verify: %lld", [table getIntInColumn:1 atRow:1000]); NSTimeInterval stop = [NSDate timeIntervalSinceReferenceDate]; dispatch_async(dispatch_get_main_queue(), ^{ [_utils OutGroup:GROUP_RUN msg:[NSString stringWithFormat:@"Inserted %i records in %.2f s",_size, stop-start]]; @@ -75,11 +75,11 @@ - (void)testInsert { // Write to disk [[NSFileManager defaultManager] removeItemAtPath:[_utils pathForDataFile:@"bigperfemployees.tightdb"] error:nil]; - [group write:[_utils pathForDataFile:@"bigperfemployees.tightdb"]]; + [group writeToFile:[_utils pathForDataFile:@"bigperfemployees.tightdb"] withError:nil]; [self reportSizeForFile:[_utils pathForDataFile:@"bigperfemployees.tightdb"] msg:@"Normal filesize"]; [table optimize]; [[NSFileManager defaultManager] removeItemAtPath:[_utils pathForDataFile:@"perfemployees.tightdb"] error:nil]; - [group write:[_utils pathForDataFile:@"perfemployees.tightdb"]]; + [group writeToFile:[_utils pathForDataFile:@"perfemployees.tightdb"] withError:nil]; [self reportSizeForFile:[_utils pathForDataFile:@"perfemployees.tightdb"] msg:@"Optimized filesize"]; @@ -139,8 +139,8 @@ - (void)testFetch { NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate]; - TightdbGroup *fromDisk = [TightdbGroup groupWithFilename:[_utils pathForDataFile:@"perfemployees.tightdb"]]; - PerfTable *diskTable = [fromDisk getTable:@"employees" withClass:[PerfTable class]]; + TightdbGroup *fromDisk = [TightdbGroup groupWithFile:[_utils pathForDataFile:@"perfemployees.tightdb"]withError:nil]; + PerfTable *diskTable = [fromDisk getTable:@"employees" withClass:[PerfTable class] error:nil]; if ([diskTable count] != _size+1) { dispatch_async(dispatch_get_main_queue(), ^{ @@ -196,8 +196,8 @@ - (void)testFetchSparse { NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate]; - TightdbGroup *fromDisk = [TightdbGroup groupWithFilename:[_utils pathForDataFile:@"perfemployees.tightdb"]]; - PerfTable *diskTable = [fromDisk getTable:@"employees" withClass:[PerfTable class]]; + TightdbGroup *fromDisk = [TightdbGroup groupWithFile:[_utils pathForDataFile:@"perfemployees.tightdb"]withError:nil]; + PerfTable *diskTable = [fromDisk getTable:@"employees" withClass:[PerfTable class] error:nil]; // Create query (current employees between 20 and 30 years old) PerfTable_Query *q = [[diskTable where].Age columnIsBetween:40 and_:50]; @@ -252,8 +252,8 @@ - (void)testFetchAndIterate int counter = 0; NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate]; - TightdbGroup *fromDisk = [TightdbGroup groupWithFilename:[_utils pathForDataFile:@"perfemployees.tightdb"]]; - PerfTable *diskTable = [fromDisk getTable:@"employees" withClass:[PerfTable class]]; + TightdbGroup *fromDisk = [TightdbGroup groupWithFile:[_utils pathForDataFile:@"perfemployees.tightdb"]withError:nil]; + PerfTable *diskTable = [fromDisk getTable:@"employees" withClass:[PerfTable class] error:nil]; // Create query (current employees between 20 and 30 years old) @@ -275,8 +275,8 @@ - (void)testUnqualifiedFetchAndIterate { NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate]; - TightdbGroup *fromDisk = [TightdbGroup groupWithFilename:[_utils pathForDataFile:@"perfemployees.tightdb"]]; - PerfTable *diskTable = [fromDisk getTable:@"employees" withClass:[PerfTable class]]; + TightdbGroup *fromDisk = [TightdbGroup groupWithFile:[_utils pathForDataFile:@"perfemployees.tightdb"]withError:nil]; + PerfTable *diskTable = [fromDisk getTable:@"employees" withClass:[PerfTable class] error:nil]; int agesum = 0; for (PerfTable_Cursor *cur in diskTable) { @@ -292,11 +292,11 @@ - (void)testWriteToDisk { NSString *tightDBPath = [_utils pathForDataFile:@"testemployees.tightdb"]; - TightdbGroup *fromDisk = [TightdbGroup groupWithFilename:[_utils pathForDataFile:@"perfemployees.tightdb"]]; + TightdbGroup *fromDisk = [TightdbGroup groupWithFile:[_utils pathForDataFile:@"perfemployees.tightdb"]withError:nil]; NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate]; [[NSFileManager defaultManager] removeItemAtPath:tightDBPath error:nil]; - [fromDisk write:tightDBPath]; + [fromDisk writeToFile:tightDBPath withError:nil]; NSTimeInterval stop = [NSDate timeIntervalSinceReferenceDate]; dispatch_async(dispatch_get_main_queue(), ^{ @@ -308,9 +308,9 @@ - (void)testWriteToDisk -(void)testReadTransaction { NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate]; - TightdbSharedGroup *fromDisk = [TightdbSharedGroup groupWithFilename:[_utils pathForDataFile:@"perfemployees.tightdb"]]; - [fromDisk readTransaction:^(TightdbGroup *group) { - PerfTable *diskTable = [group getTable:@"employees" withClass:[PerfTable class]]; + TightdbSharedGroup *fromDisk = [TightdbSharedGroup sharedGroupWithFile:[_utils pathForDataFile:@"perfemployees.tightdb"] withError:nil]; + [fromDisk readWithBlock:^(TightdbGroup *group) { + PerfTable *diskTable = [group getTable:@"employees" withClass:[PerfTable class] error:nil]; // Create query (current employees between 20 and 30 years old) PerfTable_Query *q = [[[diskTable where].Hired columnIsEqualTo:YES].Age columnIsBetween:20 and_:30]; @@ -332,9 +332,9 @@ -(void)testReadTransaction -(void)testWriteTransaction { NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate]; - TightdbSharedGroup *fromDisk = [TightdbSharedGroup groupWithFilename:[_utils pathForDataFile:@"perfemployees.tightdb"]]; - [fromDisk writeTransaction:^(TightdbGroup *group) { - PerfTable *diskTable = [group getTable:@"employees" withClass:[PerfTable class]]; + TightdbSharedGroup *fromDisk = [TightdbSharedGroup sharedGroupWithFile:[_utils pathForDataFile:@"perfemployees.tightdb"] withError:nil]; + [fromDisk writeWithBlock:^(TightdbGroup *group) { + PerfTable *diskTable = [group getTable:@"employees" withClass:[PerfTable class] error:nil]; // Add some rows NSUInteger count = _size; @@ -344,7 +344,7 @@ -(void)testWriteTransaction [diskTable addName:@"Sparse" Age:41 Hired:NO Spare:2]; return YES; // Commit transaction - }]; + } withError:nil]; NSTimeInterval stop = [NSDate timeIntervalSinceReferenceDate]; dispatch_async(dispatch_get_main_queue(), ^{ diff --git a/test-iphone/TightDbExample/ViewController.m b/test-iphone/TightDbExample/ViewController.m index c7fa2ba9b0..57b672b394 100644 --- a/test-iphone/TightDbExample/ViewController.m +++ b/test-iphone/TightDbExample/ViewController.m @@ -69,7 +69,7 @@ - (void)testGroup { TightdbGroup *group = [TightdbGroup group]; // Create new table in group - MyTable *table = [group getTable:@"employees" withClass:[MyTable class]]; + MyTable *table = [group getTable:@"employees" withClass:[MyTable class] error:nil]; // Add some rows [table addName:@"John" Age:20 Hired:YES Spare:0]; @@ -132,29 +132,28 @@ - (void)testGroup [manager removeItemAtPath:[_utils pathForDataFile:@"employees.tightdb"] error:nil]; // Write to disk - [group write:[_utils pathForDataFile:@"employees.tightdb"]]; + [group writeToFile:[_utils pathForDataFile:@"employees.tightdb"] withError:nil]; // Load a group from disk (and print contents) - TightdbGroup *fromDisk = [TightdbGroup groupWithFilename:[_utils pathForDataFile:@"employees.tightdb"]]; - MyTable *diskTable = [fromDisk getTable:@"employees" withClass:[MyTable class]]; + TightdbGroup *fromDisk = [TightdbGroup groupWithFile:[_utils pathForDataFile:@"employees.tightdb"] withError:nil]; + MyTable *diskTable = [fromDisk getTable:@"employees" withClass:[MyTable class] error:nil]; [diskTable addName:@"Anni" Age:54 Hired:YES Spare:0]; - [diskTable insertAtIndex:2 Name:@"Thomas" Age:41 Hired:NO Spare:1]; + [diskTable insertRowAtIndex:2 Name:@"Thomas" Age:41 Hired:NO Spare:1]; NSLog(@"Disktable size: %zu", [diskTable count]); for (size_t i = 0; i < [diskTable count]; i++) { MyTable_Cursor *cursor = [diskTable cursorAtIndex:i]; NSLog(@"%zu: %@", i, [cursor Name]); NSLog(@"%zu: %@", i, cursor.Name); - NSLog(@"%zu: %@", i, [diskTable getString:0 ndx:i]); + NSLog(@"%zu: %@", i, [diskTable getStringInColumn:0 atRow:i]); } // Write same group to memory buffer - size_t size; - const char* data = [group writeToMem:&size]; + TightdbBinary* buffer = [group writeToBuffer]; // Load a group from memory (and print contents) - TightdbGroup *fromMem = [TightdbGroup groupWithBuffer:data size:size]; - MyTable *memTable = [fromMem getTable:@"employees" withClass:[MyTable class]]; + TightdbGroup *fromMem = [TightdbGroup groupWithBuffer:buffer withError:nil]; + MyTable *memTable = [fromMem getTable:@"employees" withClass:[MyTable class] error:nil]; for (MyTable_Cursor *row in memTable) {