From 89be090fcdd697967afc577b9d8e1948219b0d01 Mon Sep 17 00:00:00 2001 From: Kristian Spangsege Date: Mon, 3 Feb 2014 14:10:10 +0100 Subject: [PATCH 1/2] Now using new Descriptor based API (Spec is no longer a public class) --- src/tightdb/objc/group_objc.mm | 34 +- src/tightdb/objc/helper_macros.h | 353 +-- src/tightdb/objc/query_objc.mm | 104 +- src/tightdb/objc/table.h | 16 +- src/tightdb/objc/table_objc.mm | 657 +++-- src/tightdb/objc/table_priv.h | 2 +- src/tightdb/objc/test/err_handling.mm | 70 +- src/tightdb/objc/test/get_subtable.m | 21 +- src/tightdb/objc/test/group_misc_2.m | 74 +- src/tightdb/objc/test/table.m | 71 +- src/tightdb/objc/test/table_delete_all.m | 29 +- src/tightdb/objc/tightdb.h | 2880 ++++++++++++---------- src/tightdb/objc/tightdb.h.cheetah | 111 +- src/tightdb/objc/util.hpp | 14 +- 14 files changed, 2296 insertions(+), 2140 deletions(-) diff --git a/src/tightdb/objc/group_objc.mm b/src/tightdb/objc/group_objc.mm index 4ce2568cb0..166253c9e7 100644 --- a/src/tightdb/objc/group_objc.mm +++ b/src/tightdb/objc/group_objc.mm @@ -32,9 +32,7 @@ +(TightdbGroup *)group +(TightdbGroup *)groupWithError:(NSError *__autoreleasing *)error { TightdbGroup *group = [[TightdbGroup alloc] init]; - TIGHTDB_EXCEPTION_ERRHANDLER( - group.group = new tightdb::Group(); - , @"com.tightdb.group", nil); + TIGHTDB_EXCEPTION_ERRHANDLER(group.group = new tightdb::Group();, nil); group.readOnly = NO; return group; } @@ -58,8 +56,8 @@ +(TightdbGroup *)groupWithFilename:(NSString *)filename error:(NSError **)error { tightdb::Group* group; TIGHTDB_EXCEPTION_ERRHANDLER( - group = new tightdb::Group(tightdb::StringData(ObjcStringAccessor(filename))); - , @"com.tightdb.group", nil); + group = new tightdb::Group(tightdb::StringData(ObjcStringAccessor(filename)));, + nil); TightdbGroup* group2 = [[TightdbGroup alloc] init]; if (group2) { group2.group = group; @@ -77,8 +75,8 @@ +(TightdbGroup *)groupWithBuffer:(const char *)data size:(size_t)size error:(NSE { tightdb::Group* group; TIGHTDB_EXCEPTION_ERRHANDLER( - group = new tightdb::Group(tightdb::BinaryData(data, size)); - , @"com.tightdb.group", nil); + group = new tightdb::Group(tightdb::BinaryData(data, size));, + nil); TightdbGroup* group2 = [[TightdbGroup alloc] init]; group2.group = group; group2.readOnly = NO; @@ -116,8 +114,8 @@ -(BOOL)write:(NSString *)filePath -(BOOL)write:(NSString *)filePath error:(NSError *__autoreleasing *)error { TIGHTDB_EXCEPTION_ERRHANDLER( - _group->write(tightdb::StringData(ObjcStringAccessor(filePath))); - , @"com.tightdb.group", NO); + _group->write(tightdb::StringData(ObjcStringAccessor(filePath)));, + NO); return YES; } @@ -129,10 +127,10 @@ -(const char*)writeToMem:(size_t*)size -(const char*)writeToMem:(size_t*)size error:(NSError *__autoreleasing *)error { TIGHTDB_EXCEPTION_ERRHANDLER( - tightdb::BinaryData buffer = _group->write_to_mem(); - *size = buffer.size(); - return buffer.data(); - , @"com.tightdb.group", nil); + tightdb::BinaryData buffer = _group->write_to_mem(); + *size = buffer.size(); + return buffer.data();, + nil); } -(BOOL)hasTable:(NSString *)name @@ -140,7 +138,7 @@ -(BOOL)hasTable:(NSString *)name return _group->has_table(ObjcStringAccessor(name)); } -// FIXME: Avoid creating a table instance. It should be enough to create an TightdbSpec and then check that. +// FIXME: Avoid creating a table instance. It should be enough to create an TightdbDescriptor and then check that. // FIXME: Check that the specified class derives from Table. // FIXME: Find a way to avoid having to transcode the table name twice -(BOOL)hasTable:(NSString *)name withClass:(__unsafe_unretained Class)classObj @@ -160,8 +158,8 @@ -(id)getTable:(NSString *)name error:(NSError *__autoreleasing *)error TightdbTable *table = [[TightdbTable alloc] _initRaw]; if (TIGHTDB_UNLIKELY(!table)) return nil; TIGHTDB_EXCEPTION_ERRHANDLER( - [table setTable:_group->get_table(ObjcStringAccessor(name))]; - , @"com.tightdb.group", nil); + [table setTable:_group->get_table(ObjcStringAccessor(name))];, + nil); [table setParent:self]; [table setReadOnly:_readOnly]; return table; @@ -178,8 +176,8 @@ -(id)getTable:(NSString *)name withClass:(__unsafe_unretained Class)classObj err if (TIGHTDB_UNLIKELY(!table)) return nil; bool was_created; TIGHTDB_EXCEPTION_ERRHANDLER( - [table setTable:_group->get_table(ObjcStringAccessor(name), was_created)]; - , @"com.tightdb.group", nil); + [table setTable:_group->get_table(ObjcStringAccessor(name), was_created)];, + nil); [table setParent:self]; [table setReadOnly:_readOnly]; if (was_created) { diff --git a/src/tightdb/objc/helper_macros.h b/src/tightdb/objc/helper_macros.h index 6e3b637c3a..d2fdbc6667 100644 --- a/src/tightdb/objc/helper_macros.h +++ b/src/tightdb/objc/helper_macros.h @@ -40,10 +40,10 @@ #define TIGHTDB_TYPE_Int int64_t #define TIGHTDB_TYPE_Float float #define TIGHTDB_TYPE_Double double -#define TIGHTDB_TYPE_String NSString * -#define TIGHTDB_TYPE_Binary TightdbBinary * +#define TIGHTDB_TYPE_String NSString* +#define TIGHTDB_TYPE_Binary TightdbBinary* #define TIGHTDB_TYPE_Date time_t -#define TIGHTDB_TYPE_Mixed TightdbMixed * +#define TIGHTDB_TYPE_Mixed TightdbMixed* #define TIGHTDB_TYPE_ID_Bool tightdb_Bool #define TIGHTDB_TYPE_ID_Int tightdb_Int @@ -61,7 +61,7 @@ #define TIGHTDB_ARG_TYPE(type) TIGHTDB_ARG_TYPE_2(TIGHTDB_IS_SUBTABLE(type), type) #define TIGHTDB_ARG_TYPE_2(is_subtable, type) TIGHTDB_ARG_TYPE_3(is_subtable, type) #define TIGHTDB_ARG_TYPE_3(is_subtable, type) TIGHTDB_ARG_TYPE_4_##is_subtable(type) -#define TIGHTDB_ARG_TYPE_4_Y(type) type * +#define TIGHTDB_ARG_TYPE_4_Y(type) type* #define TIGHTDB_ARG_TYPE_4_N(type) TIGHTDB_TYPE_##type @@ -71,8 +71,8 @@ #define TIGHTDB_COLUMN_PROXY_DEF(name, type) TIGHTDB_COLUMN_PROXY_DEF_2(TIGHTDB_IS_SUBTABLE(type), name, type) #define TIGHTDB_COLUMN_PROXY_DEF_2(is_subtable, name, type) TIGHTDB_COLUMN_PROXY_DEF_3(is_subtable, name, type) #define TIGHTDB_COLUMN_PROXY_DEF_3(is_subtable, name, type) TIGHTDB_COLUMN_PROXY_DEF_4_##is_subtable(name, type) -#define TIGHTDB_COLUMN_PROXY_DEF_4_Y(name, type) @property(nonatomic, strong) TightdbColumnProxy_Subtable *name; -#define TIGHTDB_COLUMN_PROXY_DEF_4_N(name, type) @property(nonatomic, strong) TightdbColumnProxy_##type *name; +#define TIGHTDB_COLUMN_PROXY_DEF_4_Y(name, type) @property(nonatomic, strong) TightdbColumnProxy_Subtable* name; +#define TIGHTDB_COLUMN_PROXY_DEF_4_N(name, type) @property(nonatomic, strong) TightdbColumnProxy_##type* name; #define TIGHTDB_COLUMN_PROXY_IMPL(name, type) @synthesize name = _##name; @@ -86,43 +86,54 @@ // TIGHTDB_ADD_COLUMN -#define TIGHTDB_ADD_COLUMN(spec, name, type) TIGHTDB_ADD_COLUMN_2(TIGHTDB_IS_SUBTABLE(type), spec, name, type) -#define TIGHTDB_ADD_COLUMN_2(is_subtable, spec, name, type) TIGHTDB_ADD_COLUMN_3(is_subtable, spec, name, type) -#define TIGHTDB_ADD_COLUMN_3(is_subtable, spec, name, type) TIGHTDB_ADD_COLUMN_4_##is_subtable(spec, name, type) -#define TIGHTDB_ADD_COLUMN_4_Y(spec, _name, type) \ -{ \ - NSString *name = [NSString stringWithUTF8String:#_name]; \ - if (!name) return NO; \ - TightdbSpec *subspec = [spec addColumnTable:name]; \ - if (!subspec) return NO; \ - if (![type _addColumns:subspec]) return NO; \ +#define TIGHTDB_ADD_COLUMN(desc, name, type) TIGHTDB_ADD_COLUMN_2(TIGHTDB_IS_SUBTABLE(type), desc, name, type) +#define TIGHTDB_ADD_COLUMN_2(is_subtable, desc, name, type) TIGHTDB_ADD_COLUMN_3(is_subtable, desc, name, type) +#define TIGHTDB_ADD_COLUMN_3(is_subtable, desc, name, type) TIGHTDB_ADD_COLUMN_4_##is_subtable(desc, name, type) +#define TIGHTDB_ADD_COLUMN_4_Y(desc, _name, type) \ +{ \ + NSString* name = [NSString stringWithUTF8String:#_name]; \ + if (!name) \ + return NO; \ + TightdbDescriptor* subdesc = [desc addColumnTable:name]; \ + if (!subdesc) \ + return NO; \ + if (![type _addColumns:subdesc]) \ + return NO; \ } -#define TIGHTDB_ADD_COLUMN_4_N(spec, _name, type) \ +#define TIGHTDB_ADD_COLUMN_4_N(desc, _name, type) \ { \ - NSString *name = [NSString stringWithUTF8String:#_name]; \ - if (!name) return NO; \ - if (![spec addColumnWithType:TIGHTDB_TYPE_ID_##type andName:name]) return NO; \ + NSString* name = [NSString stringWithUTF8String:#_name]; \ + if (!name) \ + return NO; \ + if (![desc addColumnWithType:TIGHTDB_TYPE_ID_##type andName:name]) \ + return NO; \ } // TIGHTDB_CHECK_COLUMN_TYPE -#define TIGHTDB_CHECK_COLUMN_TYPE(spec, col, name, type) TIGHTDB_CHECK_COLUMN_TYPE_2(TIGHTDB_IS_SUBTABLE(type), spec, col, name, type) -#define TIGHTDB_CHECK_COLUMN_TYPE_2(is_subtable, spec, col, name, type) TIGHTDB_CHECK_COLUMN_TYPE_3(is_subtable, spec, col, name, type) -#define TIGHTDB_CHECK_COLUMN_TYPE_3(is_subtable, spec, col, name, type) TIGHTDB_CHECK_COLUMN_TYPE_4_##is_subtable(spec, col, name, type) -#define TIGHTDB_CHECK_COLUMN_TYPE_4_Y(spec, col, name, type) \ -{ \ - if ([spec getColumnType:col] != tightdb_Table) return NO; \ - if (![[spec getColumnName:col] isEqualToString:@#name]) return NO; \ - TightdbSpec *subspec = [spec getSubspec:col]; \ - if (!subspec) return NO; \ - if (![type _checkType:subspec]) return NO; \ +#define TIGHTDB_CHECK_COLUMN_TYPE(desc, col, name, type) TIGHTDB_CHECK_COLUMN_TYPE_2(TIGHTDB_IS_SUBTABLE(type), desc, col, name, type) +#define TIGHTDB_CHECK_COLUMN_TYPE_2(is_subtable, desc, col, name, type) TIGHTDB_CHECK_COLUMN_TYPE_3(is_subtable, desc, col, name, type) +#define TIGHTDB_CHECK_COLUMN_TYPE_3(is_subtable, desc, col, name, type) TIGHTDB_CHECK_COLUMN_TYPE_4_##is_subtable(desc, col, name, type) +#define TIGHTDB_CHECK_COLUMN_TYPE_4_Y(desc, col, name, type) \ +{ \ + if ([desc getColumnType:col] != tightdb_Table) \ + return NO; \ + if (![[desc getColumnName:col] isEqualToString:@#name]) \ + return NO; \ + TightdbDescriptor* subdesc = [desc getSubdescriptor:col]; \ + if (!subdesc) \ + return NO; \ + if (![type _checkType:subdesc]) \ + return NO; \ } -#define TIGHTDB_CHECK_COLUMN_TYPE_4_N(spec, col, name, type) \ +#define TIGHTDB_CHECK_COLUMN_TYPE_4_N(desc, col, name, type) \ { \ - if ([spec getColumnType:col] != TIGHTDB_TYPE_ID_##type) return NO; \ - if (![[spec getColumnName:col] isEqualToString:@#name]) return NO; \ + if ([desc getColumnType:col] != TIGHTDB_TYPE_ID_##type) \ + return NO; \ + if (![[desc getColumnName:col] isEqualToString:@#name]) \ + return NO; \ } @@ -164,7 +175,7 @@ @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; +-(BOOL)set##name:(TIGHTDB_TYPE_##type)value error:(NSError* __autoreleasing*)error; #define TIGHTDB_CURSOR_PROPERTY_IMPL_SIMPLE(name, type) \ -(TIGHTDB_TYPE_##type)name \ @@ -175,22 +186,22 @@ { \ [_##name set##type:value]; \ } \ --(BOOL)set##name:(TIGHTDB_TYPE_##type)value error:(NSError *__autoreleasing *)error \ +-(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; \ +@property type* name; \ +-(type*)name; \ #define TIGHTDB_CURSOR_PROPERTY_IMPL_SUBTABLE(name, type) \ --(type *)name \ +-(type*)name \ { \ return [_##name getSubtable:[type class]]; \ } \ --(void)set##name:(type *)subtable \ +-(void)set##name:(type*)subtable \ { \ [_##name setSubtable:subtable]; \ } \ @@ -214,14 +225,14 @@ #define TIGHTDB_QUERY_ACCESSOR_DEF_Bool(table, col_name) \ @interface table##_QueryAccessor_##col_name : TightdbQueryAccessorBool \ --(table##_Query *)columnIsEqualTo:(BOOL)value; \ +-(table##_Query*)columnIsEqualTo:(BOOL)value; \ @end #define TIGHTDB_QUERY_ACCESSOR_IMPL_Bool(table, col_name) \ @implementation table##_QueryAccessor_##col_name \ --(table##_Query *)columnIsEqualTo:(BOOL)value \ +-(table##_Query*)columnIsEqualTo:(BOOL)value \ { \ - return (table##_Query *)[super columnIsEqualTo:value]; \ + return (table##_Query*)[super columnIsEqualTo:value]; \ } \ @end @@ -230,44 +241,44 @@ #define TIGHTDB_QUERY_ACCESSOR_DEF_Int(table, col_name) \ @interface table##_QueryAccessor_##col_name : TightdbQueryAccessorInt \ --(table##_Query *)columnIsEqualTo:(int64_t)value; \ --(table##_Query *)columnIsNotEqualTo:(int64_t)value; \ --(table##_Query *)columnIsGreaterThan:(int64_t)value; \ --(table##_Query *)columnIsGreaterThanOrEqualTo:(int64_t)value; \ --(table##_Query *)columnIsLessThan:(int64_t)value; \ --(table##_Query *)columnIsLessThanOrEqualTo:(int64_t)value; \ --(table##_Query *)columnIsBetween:(int64_t)from and_:(int64_t)to; \ +-(table##_Query*)columnIsEqualTo:(int64_t)value; \ +-(table##_Query*)columnIsNotEqualTo:(int64_t)value; \ +-(table##_Query*)columnIsGreaterThan:(int64_t)value; \ +-(table##_Query*)columnIsGreaterThanOrEqualTo:(int64_t)value; \ +-(table##_Query*)columnIsLessThan:(int64_t)value; \ +-(table##_Query*)columnIsLessThanOrEqualTo:(int64_t)value; \ +-(table##_Query*)columnIsBetween:(int64_t)from and_:(int64_t)to; \ @end #define TIGHTDB_QUERY_ACCESSOR_IMPL_Int(table, col_name) \ @implementation table##_QueryAccessor_##col_name \ --(table##_Query *)columnIsEqualTo:(int64_t)value \ +-(table##_Query*)columnIsEqualTo:(int64_t)value \ { \ - return (table##_Query *)[super columnIsEqualTo:value]; \ + return (table##_Query*)[super columnIsEqualTo:value]; \ } \ --(table##_Query *)columnIsNotEqualTo:(int64_t)value \ +-(table##_Query*)columnIsNotEqualTo:(int64_t)value \ { \ - return (table##_Query *)[super columnIsNotEqualTo:value]; \ + return (table##_Query*)[super columnIsNotEqualTo:value]; \ } \ --(table##_Query *)columnIsGreaterThan:(int64_t)value \ +-(table##_Query*)columnIsGreaterThan:(int64_t)value \ { \ - return (table##_Query *)[super columnIsGreaterThan:value]; \ + return (table##_Query*)[super columnIsGreaterThan:value]; \ } \ --(table##_Query *)columnIsGreaterThanOrEqualTo:(int64_t)value \ +-(table##_Query*)columnIsGreaterThanOrEqualTo:(int64_t)value \ { \ - return (table##_Query *)[super columnIsGreaterThanOrEqualTo:value]; \ + return (table##_Query*)[super columnIsGreaterThanOrEqualTo:value]; \ } \ --(table##_Query *)columnIsLessThan:(int64_t)value \ +-(table##_Query*)columnIsLessThan:(int64_t)value \ { \ - return (table##_Query *)[super columnIsLessThan:value]; \ + return (table##_Query*)[super columnIsLessThan:value]; \ } \ --(table##_Query *)columnIsLessThanOrEqualTo:(int64_t)value \ +-(table##_Query*)columnIsLessThanOrEqualTo:(int64_t)value \ { \ - return (table##_Query *)[super columnIsLessThanOrEqualTo:value]; \ + return (table##_Query*)[super columnIsLessThanOrEqualTo:value]; \ } \ --(table##_Query *)columnIsBetween:(int64_t)from and_:(int64_t)to \ +-(table##_Query*)columnIsBetween:(int64_t)from and_:(int64_t)to \ { \ - return (table##_Query *)[super columnIsBetween:from and_:to]; \ + return (table##_Query*)[super columnIsBetween:from and_:to]; \ } \ @end @@ -276,44 +287,44 @@ #define TIGHTDB_QUERY_ACCESSOR_DEF_Float(table, col_name) \ @interface table##_QueryAccessor_##col_name : TightdbQueryAccessorFloat \ --(table##_Query *)columnIsEqualTo:(float)value; \ --(table##_Query *)columnIsNotEqualTo:(float)value; \ --(table##_Query *)columnIsGreaterThan:(float)value; \ --(table##_Query *)columnIsGreaterThanOrEqualTo:(float)value; \ --(table##_Query *)columnIsLessThan:(float)value; \ --(table##_Query *)columnIsLessThanOrEqualTo:(float)value; \ --(table##_Query *)columnIsBetween:(float)from and_:(float)to; \ +-(table##_Query*)columnIsEqualTo:(float)value; \ +-(table##_Query*)columnIsNotEqualTo:(float)value; \ +-(table##_Query*)columnIsGreaterThan:(float)value; \ +-(table##_Query*)columnIsGreaterThanOrEqualTo:(float)value; \ +-(table##_Query*)columnIsLessThan:(float)value; \ +-(table##_Query*)columnIsLessThanOrEqualTo:(float)value; \ +-(table##_Query*)columnIsBetween:(float)from and_:(float)to; \ @end #define TIGHTDB_QUERY_ACCESSOR_IMPL_Float(table, col_name) \ @implementation table##_QueryAccessor_##col_name \ --(table##_Query *)columnIsEqualTo:(float)value \ +-(table##_Query*)columnIsEqualTo:(float)value \ { \ - return (table##_Query *)[super columnIsEqualTo:value]; \ + return (table##_Query*)[super columnIsEqualTo:value]; \ } \ --(table##_Query *)columnIsNotEqualTo:(float)value \ +-(table##_Query*)columnIsNotEqualTo:(float)value \ { \ - return (table##_Query *)[super columnIsNotEqualTo:value]; \ + return (table##_Query*)[super columnIsNotEqualTo:value]; \ } \ --(table##_Query *)columnIsGreaterThan:(float)value \ +-(table##_Query*)columnIsGreaterThan:(float)value \ { \ - return (table##_Query *)[super columnIsGreaterThan:value]; \ + return (table##_Query*)[super columnIsGreaterThan:value]; \ } \ --(table##_Query *)columnIsGreaterThanOrEqualTo:(float)value \ +-(table##_Query*)columnIsGreaterThanOrEqualTo:(float)value \ { \ - return (table##_Query *)[super columnIsGreaterThanOrEqualTo:value]; \ + return (table##_Query*)[super columnIsGreaterThanOrEqualTo:value]; \ } \ --(table##_Query *)columnIsLessThan:(float)value \ +-(table##_Query*)columnIsLessThan:(float)value \ { \ - return (table##_Query *)[super columnIsLessThan:value]; \ + return (table##_Query*)[super columnIsLessThan:value]; \ } \ --(table##_Query *)columnIsLessThanOrEqualTo:(float)value \ +-(table##_Query*)columnIsLessThanOrEqualTo:(float)value \ { \ - return (table##_Query *)[super columnIsLessThanOrEqualTo:value]; \ + return (table##_Query*)[super columnIsLessThanOrEqualTo:value]; \ } \ --(table##_Query *)columnIsBetween:(float)from and_:(float)to \ +-(table##_Query*)columnIsBetween:(float)from and_:(float)to \ { \ - return (table##_Query *)[super columnIsBetween:from and_:to]; \ + return (table##_Query*)[super columnIsBetween:from and_:to]; \ } \ @end @@ -322,44 +333,44 @@ #define TIGHTDB_QUERY_ACCESSOR_DEF_Double(table, col_name) \ @interface table##_QueryAccessor_##col_name : TightdbQueryAccessorDouble \ --(table##_Query *)columnIsEqualTo:(double)value; \ --(table##_Query *)columnIsNotEqualTo:(double)value; \ --(table##_Query *)columnIsGreaterThan:(double)value; \ --(table##_Query *)columnIsGreaterThanOrEqualTo:(double)value; \ --(table##_Query *)columnIsLessThan:(double)value; \ --(table##_Query *)columnIsLessThanOrEqualTo:(double)value; \ --(table##_Query *)columnIsBetween:(double)from and_:(double)to; \ +-(table##_Query*)columnIsEqualTo:(double)value; \ +-(table##_Query*)columnIsNotEqualTo:(double)value; \ +-(table##_Query*)columnIsGreaterThan:(double)value; \ +-(table##_Query*)columnIsGreaterThanOrEqualTo:(double)value; \ +-(table##_Query*)columnIsLessThan:(double)value; \ +-(table##_Query*)columnIsLessThanOrEqualTo:(double)value; \ +-(table##_Query*)columnIsBetween:(double)from and_:(double)to; \ @end #define TIGHTDB_QUERY_ACCESSOR_IMPL_Double(table, col_name) \ @implementation table##_QueryAccessor_##col_name \ --(table##_Query *)columnIsEqualTo:(double)value \ +-(table##_Query*)columnIsEqualTo:(double)value \ { \ - return (table##_Query *)[super columnIsEqualTo:value]; \ + return (table##_Query*)[super columnIsEqualTo:value]; \ } \ --(table##_Query *)columnIsNotEqualTo:(double)value \ +-(table##_Query*)columnIsNotEqualTo:(double)value \ { \ - return (table##_Query *)[super columnIsNotEqualTo:value]; \ + return (table##_Query*)[super columnIsNotEqualTo:value]; \ } \ --(table##_Query *)columnIsGreaterThan:(double)value \ +-(table##_Query*)columnIsGreaterThan:(double)value \ { \ - return (table##_Query *)[super columnIsGreaterThan:value]; \ + return (table##_Query*)[super columnIsGreaterThan:value]; \ } \ --(table##_Query *)columnIsGreaterThanOrEqualTo:(double)value \ +-(table##_Query*)columnIsGreaterThanOrEqualTo:(double)value \ { \ - return (table##_Query *)[super columnIsGreaterThanOrEqualTo:value]; \ + return (table##_Query*)[super columnIsGreaterThanOrEqualTo:value]; \ } \ --(table##_Query *)columnIsLessThan:(double)value \ +-(table##_Query*)columnIsLessThan:(double)value \ { \ - return (table##_Query *)[super columnIsLessThan:value]; \ + return (table##_Query*)[super columnIsLessThan:value]; \ } \ --(table##_Query *)columnIsLessThanOrEqualTo:(double)value \ +-(table##_Query*)columnIsLessThanOrEqualTo:(double)value \ { \ - return (table##_Query *)[super columnIsLessThanOrEqualTo:value]; \ + return (table##_Query*)[super columnIsLessThanOrEqualTo:value]; \ } \ --(table##_Query *)columnIsBetween:(double)from and_:(double)to \ +-(table##_Query*)columnIsBetween:(double)from and_:(double)to \ { \ - return (table##_Query *)[super columnIsBetween:from and_:to]; \ + return (table##_Query*)[super columnIsBetween:from and_:to]; \ } \ @end @@ -368,59 +379,59 @@ #define TIGHTDB_QUERY_ACCESSOR_DEF_String(table, col_name) \ @interface table##_QueryAccessor_##col_name : TightdbQueryAccessorString \ --(table##_Query *)columnIsEqualTo:(NSString *)value; \ --(table##_Query *)columnIsEqualTo:(NSString *)value caseSensitive:(BOOL)caseSensitive; \ --(table##_Query *)columnIsNotEqualTo:(NSString *)value; \ --(table##_Query *)columnIsNotEqualTo:(NSString *)value caseSensitive:(BOOL)caseSensitive; \ --(table##_Query *)columnBeginsWith:(NSString *)value; \ --(table##_Query *)columnBeginsWith:(NSString *)value caseSensitive:(BOOL)caseSensitive; \ --(table##_Query *)columnEndsWith:(NSString *)value; \ --(table##_Query *)columnEndsWith:(NSString *)value caseSensitive:(BOOL)caseSensitive; \ --(table##_Query *)columnContains:(NSString *)value; \ --(table##_Query *)columnContains:(NSString *)value caseSensitive:(BOOL)caseSensitive; \ +-(table##_Query*)columnIsEqualTo:(NSString*)value; \ +-(table##_Query*)columnIsEqualTo:(NSString*)value caseSensitive:(BOOL)caseSensitive; \ +-(table##_Query*)columnIsNotEqualTo:(NSString*)value; \ +-(table##_Query*)columnIsNotEqualTo:(NSString*)value caseSensitive:(BOOL)caseSensitive; \ +-(table##_Query*)columnBeginsWith:(NSString*)value; \ +-(table##_Query*)columnBeginsWith:(NSString*)value caseSensitive:(BOOL)caseSensitive; \ +-(table##_Query*)columnEndsWith:(NSString*)value; \ +-(table##_Query*)columnEndsWith:(NSString*)value caseSensitive:(BOOL)caseSensitive; \ +-(table##_Query*)columnContains:(NSString*)value; \ +-(table##_Query*)columnContains:(NSString*)value caseSensitive:(BOOL)caseSensitive; \ @end #define TIGHTDB_QUERY_ACCESSOR_IMPL_String(table, col_name) \ @implementation table##_QueryAccessor_##col_name \ --(table##_Query *)columnIsEqualTo:(NSString *)value \ +-(table##_Query*)columnIsEqualTo:(NSString*)value \ { \ - return (table##_Query *)[super columnIsEqualTo:value]; \ + return (table##_Query*)[super columnIsEqualTo:value]; \ } \ --(table##_Query *)columnIsEqualTo:(NSString *)value caseSensitive:(BOOL)caseSensitive \ +-(table##_Query*)columnIsEqualTo:(NSString*)value caseSensitive:(BOOL)caseSensitive \ { \ - return (table##_Query *)[super columnIsEqualTo:value caseSensitive:caseSensitive]; \ + return (table##_Query*)[super columnIsEqualTo:value caseSensitive:caseSensitive]; \ } \ --(table##_Query *)columnIsNotEqualTo:(NSString *)value \ +-(table##_Query*)columnIsNotEqualTo:(NSString*)value \ { \ - return (table##_Query *)[super columnIsNotEqualTo:value]; \ + return (table##_Query*)[super columnIsNotEqualTo:value]; \ } \ --(table##_Query *)columnIsNotEqualTo:(NSString *)value caseSensitive:(BOOL)caseSensitive \ +-(table##_Query*)columnIsNotEqualTo:(NSString*)value caseSensitive:(BOOL)caseSensitive \ { \ - return (table##_Query *)[super columnIsNotEqualTo:value caseSensitive:caseSensitive]; \ + return (table##_Query*)[super columnIsNotEqualTo:value caseSensitive:caseSensitive]; \ } \ --(table##_Query *)columnBeginsWith:(NSString *)value \ +-(table##_Query*)columnBeginsWith:(NSString*)value \ { \ - return (table##_Query *)[super columnBeginsWith:value]; \ + return (table##_Query*)[super columnBeginsWith:value]; \ } \ --(table##_Query *)columnBeginsWith:(NSString *)value caseSensitive:(BOOL)caseSensitive \ +-(table##_Query*)columnBeginsWith:(NSString*)value caseSensitive:(BOOL)caseSensitive \ { \ - return (table##_Query *)[super columnBeginsWith:value caseSensitive:caseSensitive]; \ + return (table##_Query*)[super columnBeginsWith:value caseSensitive:caseSensitive]; \ } \ --(table##_Query *)columnEndsWith:(NSString *)value \ +-(table##_Query*)columnEndsWith:(NSString*)value \ { \ - return (table##_Query *)[super columnEndsWith:value]; \ + return (table##_Query*)[super columnEndsWith:value]; \ } \ --(table##_Query *)columnEndsWith:(NSString *)value caseSensitive:(BOOL)caseSensitive \ +-(table##_Query*)columnEndsWith:(NSString*)value caseSensitive:(BOOL)caseSensitive \ { \ - return (table##_Query *)[super columnEndsWith:value caseSensitive:caseSensitive]; \ + return (table##_Query*)[super columnEndsWith:value caseSensitive:caseSensitive]; \ } \ --(table##_Query *)columnContains:(NSString *)value \ +-(table##_Query*)columnContains:(NSString*)value \ { \ - return (table##_Query *)[super columnContains:value]; \ + return (table##_Query*)[super columnContains:value]; \ } \ --(table##_Query *)columnContains:(NSString *)value caseSensitive:(BOOL)caseSensitive \ +-(table##_Query*)columnContains:(NSString*)value caseSensitive:(BOOL)caseSensitive \ { \ - return (table##_Query *)[super columnContains:value caseSensitive:caseSensitive]; \ + return (table##_Query*)[super columnContains:value caseSensitive:caseSensitive]; \ } \ @end @@ -429,34 +440,34 @@ #define TIGHTDB_QUERY_ACCESSOR_DEF_Binary(table, col_name) \ @interface table##_QueryAccessor_##col_name : TightdbQueryAccessorBinary \ --(table##_Query *)columnIsEqualTo:(TightdbBinary *)value; \ --(table##_Query *)columnIsNotEqualTo:(TightdbBinary *)value; \ --(table##_Query *)columnBeginsWith:(TightdbBinary *)value; \ --(table##_Query *)columnEndsWith:(TightdbBinary *)value; \ --(table##_Query *)columnContains:(TightdbBinary *)value; \ +-(table##_Query*)columnIsEqualTo:(TightdbBinary*)value; \ +-(table##_Query*)columnIsNotEqualTo:(TightdbBinary*)value; \ +-(table##_Query*)columnBeginsWith:(TightdbBinary*)value; \ +-(table##_Query*)columnEndsWith:(TightdbBinary*)value; \ +-(table##_Query*)columnContains:(TightdbBinary*)value; \ @end #define TIGHTDB_QUERY_ACCESSOR_IMPL_Binary(table, col_name) \ @implementation table##_QueryAccessor_##col_name \ --(table##_Query *)columnIsEqualTo:(TightdbBinary *)value \ +-(table##_Query*)columnIsEqualTo:(TightdbBinary*)value \ { \ - return (table##_Query *)[super columnIsEqualTo:value]; \ + return (table##_Query*)[super columnIsEqualTo:value]; \ } \ --(table##_Query *)columnIsNotEqualTo:(TightdbBinary *)value \ +-(table##_Query*)columnIsNotEqualTo:(TightdbBinary*)value \ { \ - return (table##_Query *)[super columnIsNotEqualTo:value]; \ + return (table##_Query*)[super columnIsNotEqualTo:value]; \ } \ --(table##_Query *)columnBeginsWith:(TightdbBinary *)value \ +-(table##_Query*)columnBeginsWith:(TightdbBinary*)value \ { \ - return (table##_Query *)[super columnBeginsWith:value]; \ + return (table##_Query*)[super columnBeginsWith:value]; \ } \ --(table##_Query *)columnEndsWith:(TightdbBinary *)value \ +-(table##_Query*)columnEndsWith:(TightdbBinary*)value \ { \ - return (table##_Query *)[super columnEndsWith:value]; \ + return (table##_Query*)[super columnEndsWith:value]; \ } \ --(table##_Query *)columnContains:(TightdbBinary *)value \ +-(table##_Query*)columnContains:(TightdbBinary*)value \ { \ - return (table##_Query *)[super columnContains:value]; \ + return (table##_Query*)[super columnContains:value]; \ } \ @end @@ -465,44 +476,44 @@ #define TIGHTDB_QUERY_ACCESSOR_DEF_Date(table, col_name) \ @interface table##_QueryAccessor_##col_name : TightdbQueryAccessorDate \ --(table##_Query *)columnIsEqualTo:(time_t)value; \ --(table##_Query *)columnIsNotEqualTo:(time_t)value; \ --(table##_Query *)columnIsGreaterThan:(time_t)value; \ --(table##_Query *)columnIsGreaterThanOrEqualTo:(time_t)value; \ --(table##_Query *)columnIsLessThan:(time_t)value; \ --(table##_Query *)columnIsLessThanOrEqualTo:(time_t)value; \ --(table##_Query *)columnIsBetween:(time_t)from and_:(time_t)to; \ +-(table##_Query*)columnIsEqualTo:(time_t)value; \ +-(table##_Query*)columnIsNotEqualTo:(time_t)value; \ +-(table##_Query*)columnIsGreaterThan:(time_t)value; \ +-(table##_Query*)columnIsGreaterThanOrEqualTo:(time_t)value; \ +-(table##_Query*)columnIsLessThan:(time_t)value; \ +-(table##_Query*)columnIsLessThanOrEqualTo:(time_t)value; \ +-(table##_Query*)columnIsBetween:(time_t)from and_:(time_t)to; \ @end #define TIGHTDB_QUERY_ACCESSOR_IMPL_Date(table, col_name) \ @implementation table##_QueryAccessor_##col_name \ --(table##_Query *)columnIsEqualTo:(time_t)value \ +-(table##_Query*)columnIsEqualTo:(time_t)value \ { \ - return (table##_Query *)[super columnIsEqualTo:value]; \ + return (table##_Query*)[super columnIsEqualTo:value]; \ } \ --(table##_Query *)columnIsNotEqualTo:(time_t)value \ +-(table##_Query*)columnIsNotEqualTo:(time_t)value \ { \ - return (table##_Query *)[super columnIsNotEqualTo:value]; \ + return (table##_Query*)[super columnIsNotEqualTo:value]; \ } \ --(table##_Query *)columnIsGreaterThan:(time_t)value \ +-(table##_Query*)columnIsGreaterThan:(time_t)value \ { \ - return (table##_Query *)[super columnIsGreaterThan:value]; \ + return (table##_Query*)[super columnIsGreaterThan:value]; \ } \ --(table##_Query *)columnIsGreaterThanOrEqualTo:(time_t)value \ +-(table##_Query*)columnIsGreaterThanOrEqualTo:(time_t)value \ { \ - return (table##_Query *)[super columnIsGreaterThanOrEqualTo:value]; \ + return (table##_Query*)[super columnIsGreaterThanOrEqualTo:value]; \ } \ --(table##_Query *)columnIsLessThan:(time_t)value \ +-(table##_Query*)columnIsLessThan:(time_t)value \ { \ - return (table##_Query *)[super columnIsLessThan:value]; \ + return (table##_Query*)[super columnIsLessThan:value]; \ } \ --(table##_Query *)columnIsLessThanOrEqualTo:(time_t)value \ +-(table##_Query*)columnIsLessThanOrEqualTo:(time_t)value \ { \ - return (table##_Query *)[super columnIsLessThanOrEqualTo:value]; \ + return (table##_Query*)[super columnIsLessThanOrEqualTo:value]; \ } \ --(table##_Query *)columnIsBetween:(time_t)from and_:(time_t)to \ +-(table##_Query*)columnIsBetween:(time_t)from and_:(time_t)to \ { \ - return (table##_Query *)[super columnIsBetween:from and_:to]; \ + return (table##_Query*)[super columnIsBetween:from and_:to]; \ } \ @end diff --git a/src/tightdb/objc/query_objc.mm b/src/tightdb/objc/query_objc.mm index ff0c161c98..276be45384 100644 --- a/src/tightdb/objc/query_objc.mm +++ b/src/tightdb/objc/query_objc.mm @@ -50,8 +50,8 @@ -(id)initWithTable:(TightdbTable *)table error:(NSError *__autoreleasing *)error if (self) { _table = table; TIGHTDB_EXCEPTION_ERRHANDLER( - _query = new tightdb::Query([_table getTable].where()); - , @"com.tightdb.query", nil); + _query = new tightdb::Query([_table getTable].where());, + nil); } return self; } @@ -120,23 +120,17 @@ -(TightdbTable *)getTable -(TightdbQuery *)group { - TIGHTDB_EXCEPTION_ERRHANDLER_EX( - _query->group(); - , @"com.tightdb.query", self, &_error); + TIGHTDB_EXCEPTION_ERRHANDLER_EX(_query->group();, self, &_error); return self; } -(TightdbQuery *)or { - TIGHTDB_EXCEPTION_ERRHANDLER_EX( - _query->Or(); - , @"com.tightdb.query", self, &_error); + TIGHTDB_EXCEPTION_ERRHANDLER_EX(_query->Or();, self, &_error); return self; } -(TightdbQuery *)endgroup { - TIGHTDB_EXCEPTION_ERRHANDLER_EX( - _query->end_group(); - , @"com.tightdb.query", self, &_error); + TIGHTDB_EXCEPTION_ERRHANDLER_EX(_query->end_group();, self, &_error); return self; } -(void)subtable:(size_t)column @@ -162,8 +156,8 @@ -(NSNumber *)countWithError:(NSError *__autoreleasing *)error return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber TIGHTDB_OBJC_SIZE_T_NUMBER_IN:_query->count()]; - , @"com.tightdb.query", nil); + return [NSNumber TIGHTDB_OBJC_SIZE_T_NUMBER_IN:_query->count()];, + nil); } -(NSNumber *)remove @@ -181,8 +175,8 @@ -(NSNumber *)removeWithError:(NSError *__autoreleasing *)error return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber TIGHTDB_OBJC_SIZE_T_NUMBER_IN:_query->remove()]; - , @"com.tightdb.query", nil); + return [NSNumber TIGHTDB_OBJC_SIZE_T_NUMBER_IN:_query->remove()];, + nil); } -(NSNumber *)minimumWithIntColumn:(size_t)col_ndx @@ -199,8 +193,8 @@ -(NSNumber *)minimumWithIntColumn:(size_t)col_ndx error:(NSError *__autoreleasin return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithLongLong:_query->minimum_int(col_ndx)]; - , @"com.tightdb.query", nil); + return [NSNumber numberWithLongLong:_query->minimum_int(col_ndx)];, + nil); } -(NSNumber *)minimumWithFloatColumn:(size_t)col_ndx @@ -217,8 +211,8 @@ -(NSNumber *)minimumWithFloatColumn:(size_t)col_ndx error:(NSError *__autoreleas return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithFloat:_query->minimum_float(col_ndx)]; - , @"com.tightdb.query", nil); + return [NSNumber numberWithFloat:_query->minimum_float(col_ndx)];, + nil); } -(NSNumber *)minimumWithDoubleColumn:(size_t)col_ndx @@ -235,8 +229,8 @@ -(NSNumber *)minimumWithDoubleColumn:(size_t)col_ndx error:(NSError *__autorelea return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithDouble:_query->minimum_double(col_ndx)]; - , @"com.tightdb.query", nil); + return [NSNumber numberWithDouble:_query->minimum_double(col_ndx)];, + nil); } -(NSNumber *)maximumWithIntColumn:(size_t)col_ndx @@ -253,8 +247,8 @@ -(NSNumber *)maximumWithIntColumn:(size_t)col_ndx error:(NSError *__autoreleasin return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithLongLong:_query->maximum_int(col_ndx)]; - , @"com.tightdb.query", nil); + return [NSNumber numberWithLongLong:_query->maximum_int(col_ndx)];, + nil); } -(NSNumber *)maximumWithFloatColumn:(size_t)col_ndx { @@ -270,8 +264,8 @@ -(NSNumber *)maximumWithFloatColumn:(size_t)col_ndx error:(NSError *__autoreleas return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithFloat:_query->maximum_float(col_ndx)]; - , @"com.tightdb.query", nil); + return [NSNumber numberWithFloat:_query->maximum_float(col_ndx)];, + nil); } -(NSNumber *)maximumWithDoubleColumn:(size_t)col_ndx @@ -288,8 +282,8 @@ -(NSNumber *)maximumWithDoubleColumn:(size_t)col_ndx error:(NSError *__autorelea return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithDouble:_query->maximum_double(col_ndx)]; - , @"com.tightdb.query", nil); + return [NSNumber numberWithDouble:_query->maximum_double(col_ndx)];, + nil); } -(NSNumber *)sumWithIntColumn:(size_t)col_ndx @@ -306,8 +300,8 @@ -(NSNumber *)sumWithIntColumn:(size_t)col_ndx error:(NSError *__autoreleasing *) return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithLongLong:_query->sum_int(col_ndx)]; - , @"com.tightdb.query", nil); + return [NSNumber numberWithLongLong:_query->sum_int(col_ndx)];, + nil); } -(NSNumber *)sumWithFloatColumn:(size_t)col_ndx @@ -324,8 +318,8 @@ -(NSNumber *)sumWithFloatColumn:(size_t)col_ndx error:(NSError *__autoreleasing return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithFloat:_query->sum_float(col_ndx)]; - , @"com.tightdb.query", nil); + return [NSNumber numberWithFloat:_query->sum_float(col_ndx)];, + nil); } -(NSNumber *)sumWithDoubleColumn:(size_t)col_ndx @@ -342,8 +336,8 @@ -(NSNumber *)sumWithDoubleColumn:(size_t)col_ndx error:(NSError *__autoreleasing return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithDouble:_query->sum_double(col_ndx)]; - , @"com.tightdb.query", nil); + return [NSNumber numberWithDouble:_query->sum_double(col_ndx)];, + nil); } -(NSNumber *)averageWithIntColumn:(size_t)col_ndx @@ -360,8 +354,8 @@ -(NSNumber *)averageWithIntColumn:(size_t)col_ndx error:(NSError *__autoreleasin return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithDouble:_query->average_int(col_ndx)]; - , @"com.tightdb.query", nil); + return [NSNumber numberWithDouble:_query->average_int(col_ndx)];, + nil); } -(NSNumber *)averageWithFloatColumn:(size_t)col_ndx { @@ -377,8 +371,8 @@ -(NSNumber *)averageWithFloatColumn:(size_t)col_ndx error:(NSError *__autoreleas return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithDouble:_query->average_float(col_ndx)]; - , @"com.tightdb.query", nil); + return [NSNumber numberWithDouble:_query->average_float(col_ndx)];, + nil); } -(NSNumber *)averageWithDoubleColumn:(size_t)col_ndx @@ -396,8 +390,8 @@ -(NSNumber *)averageWithDoubleColumn:(size_t)col_ndx error:(NSError *__autorelea return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithDouble:_query->average_double(col_ndx)]; - , @"com.tightdb.query", nil); + return [NSNumber numberWithDouble:_query->average_double(col_ndx)];, + nil); } -(tightdb::TableView)getTableView @@ -426,9 +420,7 @@ -(size_t)find:(size_t)last error:(NSError *__autoreleasing *)error } return size_t(-1); } - TIGHTDB_EXCEPTION_ERRHANDLER( - return _query->find(last); - , @"com.tightdb.query", size_t(-1)); + TIGHTDB_EXCEPTION_ERRHANDLER(return _query->find(last);, size_t(-1)); } @@ -698,56 +690,56 @@ -(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query -(TightdbQuery *)columnIsEqualTo:(int64_t)value { TIGHTDB_EXCEPTION_ERRHANDLER_EX( - [_query getQuery]->equal(_column_ndx, value); - , @"com.tightdb.queryaccessor", _query, &_query->_error); + [_query getQuery]->equal(_column_ndx, value);, + _query, &_query->_error); return _query; } -(TightdbQuery *)columnIsNotEqualTo:(int64_t)value { TIGHTDB_EXCEPTION_ERRHANDLER_EX( - [_query getQuery]->not_equal(_column_ndx, value); - , @"com.tightdb.queryaccessor", _query, &_query->_error); + [_query getQuery]->not_equal(_column_ndx, value);, + _query, &_query->_error); return _query; } -(TightdbQuery *)columnIsGreaterThan:(int64_t)value { TIGHTDB_EXCEPTION_ERRHANDLER_EX( - [_query getQuery]->greater(_column_ndx, value); - , @"com.tightdb.queryaccessor", _query, &_query->_error); + [_query getQuery]->greater(_column_ndx, value);, + _query, &_query->_error); return _query; } -(TightdbQuery *)columnIsGreaterThanOrEqualTo:(int64_t)value { TIGHTDB_EXCEPTION_ERRHANDLER_EX( - [_query getQuery]->greater_equal(_column_ndx, value); - , @"com.tightdb.queryaccessor", _query, &_query->_error); + [_query getQuery]->greater_equal(_column_ndx, value);, + _query, &_query->_error); return _query; } -(TightdbQuery *)columnIsLessThan:(int64_t)value { TIGHTDB_EXCEPTION_ERRHANDLER_EX( - [_query getQuery]->less(_column_ndx, value); - , @"com.tightdb.queryaccessor", _query, &_query->_error); + [_query getQuery]->less(_column_ndx, value);, + _query, &_query->_error); return _query; } -(TightdbQuery *)columnIsLessThanOrEqualTo:(int64_t)value { TIGHTDB_EXCEPTION_ERRHANDLER_EX( - [_query getQuery]->less_equal(_column_ndx, value); - , @"com.tightdb.queryaccessor", _query, &_query->_error); + [_query getQuery]->less_equal(_column_ndx, value);, + _query, &_query->_error); return _query; } -(TightdbQuery *)columnIsBetween:(int64_t)from and_:(int64_t)to { TIGHTDB_EXCEPTION_ERRHANDLER_EX( - [_query getQuery]->between(_column_ndx, from, to); - , @"com.tightdb.queryaccessor", _query, &_query->_error); + [_query getQuery]->between(_column_ndx, from, to);, + _query, &_query->_error); return _query; } diff --git a/src/tightdb/objc/table.h b/src/tightdb/objc/table.h index 55e6e712d4..e1d9acb18c 100644 --- a/src/tightdb/objc/table.h +++ b/src/tightdb/objc/table.h @@ -61,15 +61,15 @@ @end -@interface TightdbSpec: NSObject +@interface TightdbDescriptor: NSObject /// Returns NO on memory allocation error. -(BOOL)addColumnWithType:(TightdbType)type andName:(NSString *)name; -(BOOL)addColumnWithType:(TightdbType)type andName:(NSString *)name error:(NSError *__autoreleasing *)error; /// Returns nil on memory allocation error. --(TightdbSpec *)addColumnTable:(NSString *)name; --(TightdbSpec *)addColumnTable:(NSString *)name error:(NSError *__autoreleasing *)error; --(TightdbSpec *)getSubspec:(size_t)colNdx; --(TightdbSpec *)getSubspec:(size_t)colNdx error:(NSError *__autoreleasing *)error; +-(TightdbDescriptor *)addColumnTable:(NSString *)name; +-(TightdbDescriptor *)addColumnTable:(NSString *)name error:(NSError *__autoreleasing *)error; +-(TightdbDescriptor *)getSubdescriptor:(size_t)colNdx; +-(TightdbDescriptor *)getSubdescriptor:(size_t)colNdx error:(NSError *__autoreleasing *)error; -(size_t)getColumnCount; -(TightdbType)getColumnType:(size_t)colNdx; -(NSString *)getColumnName:(size_t)colNdx; @@ -78,8 +78,6 @@ @interface TightdbTable: NSObject --(BOOL)updateFromSpec; --(BOOL)updateFromSpecWithError:(NSError *__autoreleasing *)error; -(NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained *)stackbuf count:(NSUInteger)len; -(BOOL)isEqual:(TightdbTable *)other; @@ -119,8 +117,8 @@ -(NSString *)getColumnName:(size_t)ndx; -(size_t)getColumnIndex:(NSString *)name; -(TightdbType)getColumnType:(size_t)ndx; --(TightdbSpec *)getSpec; --(TightdbSpec *)getSpecWithError:(NSError *__autoreleasing *)error; +-(TightdbDescriptor *)getDescriptor; +-(TightdbDescriptor *)getDescriptorWithError:(NSError *__autoreleasing *)error; -(BOOL)isEmpty; -(size_t)count; -(TightdbCursor *)addRow; diff --git a/src/tightdb/objc/table_objc.mm b/src/tightdb/objc/table_objc.mm index ba2d25ee21..3b6dc9e8f5 100644 --- a/src/tightdb/objc/table_objc.mm +++ b/src/tightdb/objc/table_objc.mm @@ -4,6 +4,7 @@ // #include +#include #include #include @@ -21,7 +22,7 @@ @implementation TightdbBinary { tightdb::BinaryData _data; } --(id)initWithData:(const char *)data size:(size_t)size +-(id)initWithData:(const char*)data size:(size_t)size { self = [super init]; if (self) { @@ -37,7 +38,7 @@ -(id)initWithBinary:(tightdb::BinaryData)data } return self; } --(const char *)getData +-(const char*)getData { return _data.data(); } @@ -45,7 +46,7 @@ -(size_t)getSize { return _data.size(); } --(BOOL)isEqual:(TightdbBinary *)bin +-(BOOL)isEqual:(TightdbBinary*)bin { return _data == bin->_data; } @@ -58,85 +59,85 @@ -(BOOL)isEqual:(TightdbBinary *)bin @interface TightdbMixed() @property (nonatomic) tightdb::Mixed mixed; -@property (nonatomic, strong) TightdbTable *table; -+(TightdbMixed *)mixedWithMixed:(tightdb::Mixed&)other; +@property (nonatomic, strong) TightdbTable* table; ++(TightdbMixed*)mixedWithMixed:(tightdb::Mixed&)other; @end @implementation TightdbMixed @synthesize mixed = _mixed; @synthesize table = _table; -+(TightdbMixed *)mixedWithBool:(BOOL)value ++(TightdbMixed*)mixedWithBool:(BOOL)value { - TightdbMixed *mixed = [[TightdbMixed alloc] init]; + TightdbMixed* mixed = [[TightdbMixed alloc] init]; mixed.mixed = tightdb::Mixed((bool)value); return mixed; } -+(TightdbMixed *)mixedWithInt64:(int64_t)value ++(TightdbMixed*)mixedWithInt64:(int64_t)value { - TightdbMixed *mixed = [[TightdbMixed alloc] init]; + TightdbMixed* mixed = [[TightdbMixed alloc] init]; mixed.mixed = tightdb::Mixed(value); return mixed; } -+(TightdbMixed *)mixedWithFloat:(float)value ++(TightdbMixed*)mixedWithFloat:(float)value { - TightdbMixed *mixed = [[TightdbMixed alloc] init]; + TightdbMixed* mixed = [[TightdbMixed alloc] init]; mixed.mixed = tightdb::Mixed(value); return mixed; } -+(TightdbMixed *)mixedWithDouble:(double)value ++(TightdbMixed*)mixedWithDouble:(double)value { - TightdbMixed *mixed = [[TightdbMixed alloc] init]; + TightdbMixed* mixed = [[TightdbMixed alloc] init]; mixed.mixed = tightdb::Mixed(value); return mixed; } -+(TightdbMixed *)mixedWithString:(NSString *)value ++(TightdbMixed*)mixedWithString:(NSString*)value { - TightdbMixed *mixed = [[TightdbMixed alloc] init]; + TightdbMixed* mixed = [[TightdbMixed alloc] init]; mixed.mixed = tightdb::Mixed(ObjcStringAccessor(value)); return mixed; } -+(TightdbMixed *)mixedWithBinary:(TightdbBinary *)value ++(TightdbMixed*)mixedWithBinary:(TightdbBinary*)value { - TightdbMixed *mixed = [[TightdbMixed alloc] init]; + TightdbMixed* mixed = [[TightdbMixed alloc] init]; mixed.mixed = tightdb::Mixed([value getBinary]); return mixed; } -+(TightdbMixed *)mixedWithBinary:(const char *)data size:(size_t)size ++(TightdbMixed*)mixedWithBinary:(const char*)data size:(size_t)size { - TightdbMixed *mixed = [[TightdbMixed alloc] init]; + TightdbMixed* mixed = [[TightdbMixed alloc] init]; mixed.mixed = tightdb::Mixed(tightdb::BinaryData(data, size)); return mixed; } -+(TightdbMixed *)mixedWithDate:(time_t)value ++(TightdbMixed*)mixedWithDate:(time_t)value { - TightdbMixed *mixed = [[TightdbMixed alloc] init]; + TightdbMixed* mixed = [[TightdbMixed alloc] init]; mixed.mixed = tightdb::Mixed(tightdb::DateTime(value)); return mixed; } -+(TightdbMixed *)mixedWithTable:(TightdbTable *)value ++(TightdbMixed*)mixedWithTable:(TightdbTable*)value { - TightdbMixed *mixed = [[TightdbMixed alloc] init]; + TightdbMixed* mixed = [[TightdbMixed alloc] init]; mixed.mixed = tightdb::Mixed(tightdb::Mixed::subtable_tag()); mixed.table = value; return mixed; } -+(TightdbMixed *)mixedWithMixed:(tightdb::Mixed&)value ++(TightdbMixed*)mixedWithMixed:(tightdb::Mixed&)value { - TightdbMixed *mixed = [[TightdbMixed alloc] init]; + TightdbMixed* mixed = [[TightdbMixed alloc] init]; mixed.mixed = value; return mixed; } --(BOOL)isEqual:(TightdbMixed *)other +-(BOOL)isEqual:(TightdbMixed*)other { const tightdb::DataType type = _mixed.get_type(); if (type != other->_mixed.get_type()) return NO; @@ -189,12 +190,12 @@ -(double)getDouble return _mixed.get_double(); } --(NSString *)getString +-(NSString*)getString { return to_objc_string(_mixed.get_string()); } --(TightdbBinary *)getBinary +-(TightdbBinary*)getBinary { return [[TightdbBinary alloc] initWithBinary:_mixed.get_binary()]; } @@ -204,117 +205,114 @@ -(time_t)getDate return _mixed.get_datetime().get_datetime(); } --(TightdbTable *)getTable +-(TightdbTable*)getTable { return _table; } @end -@interface TightdbSpec() -@property (nonatomic) tightdb::Spec *spec; -@property (nonatomic) BOOL isOwned; -+(TightdbSpec *)specWithSpec:(tightdb::Spec*)spec readOnly:(BOOL)readOnly isOwned:(BOOL)isOwned error:(NSError *__autoreleasing *)error; +class Fido { + public: + Fido() { cerr << "**************************************************** CONSTRUCT ****************************************************\n"; } + ~Fido() { cerr << "---------------------------------------------------- destruct ----------------------------------------------------\n"; } +}; + + +@interface TightdbDescriptor() ++(TightdbDescriptor*)descWithDesc:(tightdb::Descriptor*)desc readOnly:(BOOL)read_only error:(NSError* __autoreleasing*)error; @end -@implementation TightdbSpec +@implementation TightdbDescriptor { - BOOL _readOnly; + tightdb::DescriptorRef m_desc; + Fido fido; + BOOL m_read_only; } -@synthesize spec = _spec; -@synthesize isOwned = _isOwned; -+(TightdbSpec *)specWithSpec:(tightdb::Spec *)spec readOnly:(BOOL)readOnly isOwned:(BOOL)isOwned error:(NSError *__autoreleasing *)error ++(TightdbDescriptor*)descWithDesc:(tightdb::Descriptor*)desc readOnly:(BOOL)read_only error:(NSError* __autoreleasing*)error { - TightdbSpec *spec2 = [[TightdbSpec alloc] init]; - spec2->_readOnly = readOnly; - if (isOwned) { - TIGHTDB_EXCEPTION_ERRHANDLER( - spec2.spec = new tightdb::Spec(*spec); - , @"com.tightdb.spec", nil); - spec2.isOwned = TRUE; - } - else { - spec2.spec = spec; - spec2.isOwned = FALSE; - } - return spec2; + static_cast(error); + TightdbDescriptor* desc_2 = [[TightdbDescriptor alloc] init]; + desc_2->m_desc.reset(desc); + desc_2->m_read_only = read_only; + return desc_2; } -// FIXME: Provide a version of this method that takes a 'const char *'. This will simplify _addColumns of MyTable. +// FIXME: Provide a version of this method that takes a 'const char*'. This will simplify _addColumns of MyTable. // FIXME: Detect errors from core library --(BOOL)addColumnWithType:(TightdbType)type andName:(NSString *)name +-(BOOL)addColumnWithType:(TightdbType)type andName:(NSString*)name { return [self addColumnWithType:type andName:name error:nil]; } --(BOOL)addColumnWithType:(TightdbType)type andName:(NSString *)name error:(NSError *__autoreleasing *)error +-(BOOL)addColumnWithType:(TightdbType)type andName:(NSString*)name error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.spec", tdb_err_FailRdOnly, @"Tried to add column while read only"); + *error = make_tightdb_error(tdb_err_FailRdOnly, @"Tried to add column while read only"); return NO; } TIGHTDB_EXCEPTION_ERRHANDLER( - _spec->add_column(tightdb::DataType(type), ObjcStringAccessor(name)); - , @"com.tightdb.spec", NO); + m_desc->add_column(tightdb::DataType(type), ObjcStringAccessor(name));, + NO); return YES; } --(TightdbSpec *)addColumnTable:(NSString *)name +-(TightdbDescriptor*)addColumnTable:(NSString*)name { return [self addColumnTable:name error:nil]; } --(TightdbSpec *)addColumnTable:(NSString *)name error:(NSError *__autoreleasing *)error +-(TightdbDescriptor*)addColumnTable:(NSString*)name error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.spec", tdb_err_FailRdOnly, @"Tried to add column while read only"); + *error = make_tightdb_error(tdb_err_FailRdOnly, @"Tried to add column while read only"); return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - tightdb::Spec tmp = _spec->add_subtable_column(ObjcStringAccessor(name)); - return [TightdbSpec specWithSpec:&tmp readOnly:FALSE isOwned:TRUE error:error]; - , @"com.tightdb.spec", nil); + tightdb::DescriptorRef subdesc; + m_desc->add_column(tightdb::type_Table, ObjcStringAccessor(name), &subdesc); + return [TightdbDescriptor descWithDesc:subdesc.get() readOnly:FALSE error:error];, + nil); } --(TightdbSpec *)getSubspec:(size_t)col_ndx +-(TightdbDescriptor*)getSubdescriptor:(size_t)col_ndx { - return [self getSubspec:col_ndx error:nil]; + return [self getSubdescriptor:col_ndx error:nil]; } --(TightdbSpec *)getSubspec:(size_t)col_ndx error:(NSError *__autoreleasing *)error +-(TightdbDescriptor*)getSubdescriptor:(size_t)col_ndx error:(NSError* __autoreleasing*)error { TIGHTDB_EXCEPTION_ERRHANDLER( - tightdb::Spec subspec = _spec->get_subtable_spec(col_ndx); - return [TightdbSpec specWithSpec:&subspec readOnly:_readOnly isOwned:TRUE error:error]; - , @"com.tightdb.spec", nil); + tightdb::DescriptorRef subdesc = m_desc->get_subdescriptor(col_ndx); + return [TightdbDescriptor descWithDesc:subdesc.get() readOnly:m_read_only error:error];, + nil); } -(size_t)getColumnCount { - return _spec->get_column_count(); + return m_desc->get_column_count(); } -(TightdbType)getColumnType:(size_t)ndx { - return (TightdbType)_spec->get_column_type(ndx); + return (TightdbType)m_desc->get_column_type(ndx); } --(NSString *)getColumnName:(size_t)ndx +-(NSString*)getColumnName:(size_t)ndx { - return to_objc_string(_spec->get_column_name(ndx)); + return to_objc_string(m_desc->get_column_name(ndx)); } --(size_t)getColumnIndex:(NSString *)name +-(size_t)getColumnIndex:(NSString*)name { - return _spec->get_column_index(ObjcStringAccessor(name)); + return m_desc->get_column_index(ObjcStringAccessor(name)); } -(void)dealloc { #ifdef TIGHTDB_DEBUG - NSLog(@"TightdbSpec dealloc"); + NSLog(@"TightdbDescriptor dealloc"); #endif - if (_isOwned) delete _spec; } @@ -322,17 +320,17 @@ -(void)dealloc @interface TightdbView() -@property (nonatomic) tightdb::TableView *tableView; +@property (nonatomic) tightdb::TableView* tableView; @end @implementation TightdbView { - TightdbTable *_table; - TightdbCursor *tmpCursor; + TightdbTable* _table; + TightdbCursor* tmpCursor; } @synthesize tableView = _tableView; --(id)initFromQuery:(TightdbQuery *)query +-(id)initFromQuery:(TightdbQuery*)query { self = [super init]; if (self) { @@ -343,22 +341,22 @@ -(id)initFromQuery:(TightdbQuery *)query } --(TightdbTable *)getTable +-(TightdbTable*)getTable { return _table; } -+(TightdbView *)tableViewWithTable:(TightdbTable *)table ++(TightdbView*)tableViewWithTable:(TightdbTable*)table { - (void)table; - TightdbView *tableView = [[TightdbView alloc] init]; + static_cast(table); + TightdbView* tableView = [[TightdbView alloc] init]; tableView.tableView = new tightdb::TableView(); // not longer needs table at construction return tableView; } -+(TightdbView *)tableViewWithTableView:(tightdb::TableView)table ++(TightdbView*)tableViewWithTableView:(tightdb::TableView)table { - TightdbView *tableView = [[TightdbView alloc] init]; + TightdbView*tableView = [[TightdbView alloc] init]; tableView.tableView = new tightdb::TableView(table); return tableView; } @@ -372,7 +370,7 @@ -(void)dealloc delete _tableView; } --(TightdbCursor *)cursorAtIndex:(size_t)ndx +-(TightdbCursor*)cursorAtIndex:(size_t)ndx { // The cursor constructor checks the index is in bounds. However, getSourceIndex should // not be called with illegal index. @@ -403,7 +401,7 @@ -(time_t)getDate:(size_t)col_ndx ndx:(size_t)ndx { return _tableView->get_datetime(col_ndx, ndx).get_datetime(); } --(NSString *)getString:(size_t)col_ndx ndx:(size_t)ndx +-(NSString*)getString:(size_t)col_ndx ndx:(size_t)ndx { return to_objc_string(_tableView->get_string(col_ndx, ndx)); } @@ -420,21 +418,22 @@ -(size_t)getSourceIndex:(size_t)ndx return _tableView->get_source_ndx(ndx); } --(TightdbCursor *)getCursor +-(TightdbCursor*)getCursor { return tmpCursor = [[TightdbCursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:0]]; } -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained *)stackbuf count:(NSUInteger)len +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState*)state objects:(id __unsafe_unretained*)stackbuf count:(NSUInteger)len { - (void)len; + static_cast(len); if(state->state == 0) { - state->mutationsPtr = (unsigned long *)objc_unretainedPointer(self); - TightdbCursor *tmp = [self getCursor]; + const unsigned long* ptr = static_cast(objc_unretainedPointer(self)); + state->mutationsPtr = const_cast(ptr); // FIXME: This casting away of constness seems dangerous. Is it? + TightdbCursor* tmp = [self getCursor]; *stackbuf = tmp; } if (state->state < [self count]) { - [((TightdbCursor *)*stackbuf) setNdx:[self getSourceIndex:state->state]]; + [((TightdbCursor*)*stackbuf) setNdx:[self getSourceIndex:state->state]]; state->itemsPtr = stackbuf; state->state++; } @@ -452,10 +451,10 @@ - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state object @implementation TightdbTable { - id _parent; - BOOL _readOnly; + id m_parent; + BOOL m_read_only; - TightdbCursor *tmpCursor; + TightdbCursor* tmpCursor; } @synthesize table = _table; @@ -463,7 +462,7 @@ -(id)init { self = [super init]; if (self) { - _readOnly = NO; + m_read_only = NO; _table = tightdb::Table::create(); // FIXME: May throw } return self; @@ -475,25 +474,13 @@ -(id)_initRaw return self; } --(BOOL)updateFromSpec -{ - return [self updateFromSpecWithError:nil]; -} --(BOOL)updateFromSpecWithError:(NSError *__autoreleasing *)error -{ - TIGHTDB_EXCEPTION_ERRHANDLER( - static_cast(&*self.table)->update_from_spec(); - , @"com.tightdb.table", NO); - return YES; -} - -(BOOL)_checkType { return YES; // Dummy - must be overridden in tightdb.h - Check if spec matches the macro definitions } --(TightdbCursor *)getCursor +-(TightdbCursor*)getCursor { return tmpCursor = [[TightdbCursor alloc] initWithTable:self ndx:0]; } @@ -505,16 +492,17 @@ -(void)clearCursor // Clarify if we need the method. } -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained *)stackbuf count:(NSUInteger)len +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState*)state objects:(id __unsafe_unretained*)stackbuf count:(NSUInteger)len { - (void)len; + static_cast(len); if(state->state == 0) { - state->mutationsPtr = (unsigned long *)objc_unretainedPointer(self); - TightdbCursor *tmp = [self getCursor]; + const unsigned long* ptr = static_cast(objc_unretainedPointer(self)); + state->mutationsPtr = const_cast(ptr); // FIXME: This casting away of constness seems dangerous. Is it? + TightdbCursor* tmp = [self getCursor]; *stackbuf = tmp; } if (state->state < [self count]) { - [((TightdbCursor *)*stackbuf) setNdx:state->state]; + [((TightdbCursor*)*stackbuf) setNdx:state->state]; state->itemsPtr = stackbuf; state->state++; } @@ -535,20 +523,20 @@ - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state object -(void)setParent:(id)parent { - _parent = parent; + m_parent = parent; } --(void)setReadOnly:(BOOL)readOnly +-(void)setReadOnly:(BOOL)read_only { - _readOnly = readOnly; + m_read_only = read_only; } --(BOOL)isEqual:(TightdbTable *)other +-(BOOL)isEqual:(TightdbTable*)other { return *_table == *other->_table; } --(BOOL)setSubtable:(size_t)col_ndx ndx:(size_t)ndx withTable:(TightdbTable *)subtable +-(BOOL)setSubtable:(size_t)col_ndx ndx:(size_t)ndx withTable:(TightdbTable*)subtable { // 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). @@ -562,17 +550,17 @@ -(BOOL)setSubtable:(size_t)col_ndx ndx:(size_t)ndx withTable:(TightdbTable *)sub return NO; } --(TightdbTable *)getSubtable:(size_t)col_ndx ndx:(size_t)ndx +-(TightdbTable*)getSubtable:(size_t)col_ndx ndx:(size_t)ndx { const tightdb::DataType t = _table->get_column_type(col_ndx); if (t != tightdb::type_Table) return nil; tightdb::TableRef r = _table->get_subtable(col_ndx, ndx); if (!r) return nil; - TightdbTable *table = [[TightdbTable alloc] _initRaw]; + TightdbTable* table = [[TightdbTable alloc] _initRaw]; if (TIGHTDB_UNLIKELY(!table)) return nil; [table setTable:move(r)]; [table setParent:self]; - [table setReadOnly:_readOnly]; + [table setReadOnly:m_read_only]; return table; } @@ -583,11 +571,11 @@ -(id)getSubtable:(size_t)col_ndx ndx:(size_t)ndx withClass:(__unsafe_unretained if (t != tightdb::type_Table) return nil; tightdb::TableRef r = _table->get_subtable(col_ndx, ndx); if (!r) return nil; - TightdbTable *table = [[classObj alloc] _initRaw]; + TightdbTable* table = [[classObj alloc] _initRaw]; if (TIGHTDB_UNLIKELY(!table)) return nil; [table setTable:move(r)]; [table setParent:self]; - [table setReadOnly:_readOnly]; + [table setReadOnly:m_read_only]; if (![table _checkType]) return nil; return table; } @@ -595,11 +583,11 @@ -(id)getSubtable:(size_t)col_ndx ndx:(size_t)ndx withClass:(__unsafe_unretained // FIXME: Check that the specified class derives from TightdbTable. -(BOOL)isClass:(__unsafe_unretained Class)classObj { - TightdbTable *table = [[classObj alloc] _initRaw]; + TightdbTable* table = [[classObj alloc] _initRaw]; if (TIGHTDB_LIKELY(table)) { [table setTable:_table]; - [table setParent:_parent]; - [table setReadOnly:_readOnly]; + [table setParent:m_parent]; + [table setReadOnly:m_read_only]; if ([table _checkType]) return YES; } return NO; @@ -608,12 +596,13 @@ -(BOOL)isClass:(__unsafe_unretained Class)classObj // FIXME: Check that the specified class derives from TightdbTable. -(id)castClass:(__unsafe_unretained Class)classObj { - TightdbTable *table = [[classObj alloc] _initRaw]; + TightdbTable* table = [[classObj alloc] _initRaw]; if (TIGHTDB_LIKELY(table)) { [table setTable:_table]; - [table setParent:_parent]; - [table setReadOnly:_readOnly]; - if (![table _checkType]) return nil; + [table setParent:m_parent]; + [table setReadOnly:m_read_only]; + if (![table _checkType]) + return nil; } return table; } @@ -623,18 +612,18 @@ -(void)dealloc #ifdef TIGHTDB_DEBUG NSLog(@"TightdbTable dealloc"); #endif - _parent = nil; + m_parent = nil; // FIXME: Does this really make a difference? } -(size_t)getColumnCount { return _table->get_column_count(); } --(NSString *)getColumnName:(size_t)ndx +-(NSString*)getColumnName:(size_t)ndx { return to_objc_string(_table->get_column_name(ndx)); } --(size_t)getColumnIndex:(NSString *)name +-(size_t)getColumnIndex:(NSString*)name { return _table->get_column_index(ObjcStringAccessor(name)); } @@ -642,15 +631,15 @@ -(TightdbType)getColumnType:(size_t)ndx { return (TightdbType)_table->get_column_type(ndx); } --(TightdbSpec *)getSpec +-(TightdbDescriptor*)getDescriptor { - return [self getSpecWithError:nil]; + return [self getDescriptorWithError:nil]; } --(TightdbSpec *)getSpecWithError:(NSError *__autoreleasing *)error +-(TightdbDescriptor*)getDescriptorWithError:(NSError* __autoreleasing*)error { - tightdb::Spec& spec = tightdb::LangBindHelper::get_spec(*_table); - BOOL readOnly = _readOnly || _table->has_shared_spec(); - return [TightdbSpec specWithSpec:&spec readOnly:readOnly isOwned:FALSE error:error]; + tightdb::DescriptorRef desc = _table->get_descriptor(); + BOOL read_only = m_read_only || _table->has_shared_type(); + return [TightdbDescriptor descWithDesc:desc.get() readOnly:read_only error:error]; } -(BOOL)isEmpty { @@ -661,7 +650,7 @@ -(size_t)count return _table->size(); } --(TightdbCursor *)addRow +-(TightdbCursor*)addRow { return [[TightdbCursor alloc] initWithTable:self ndx:[self _addRow]]; } @@ -670,16 +659,14 @@ -(size_t)_addRow { return [self _addRowWithError:nil]; } --(size_t)_addRowWithError:(NSError *__autoreleasing *)error +-(size_t)_addRowWithError:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, @"Tried to add row while readonly."); + *error = make_tightdb_error(tdb_err_FailRdOnly, @"Tried to add row while read-only."); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER( - return _table->add_empty_row(); - , @"com.tightdb.table", 0); + TIGHTDB_EXCEPTION_ERRHANDLER(return _table->add_empty_row();, 0); } -(size_t)_addRows:(size_t)rowCount @@ -687,31 +674,29 @@ -(size_t)_addRows:(size_t)rowCount return [self _addRows:rowCount error:nil]; } --(size_t)_addRows:(size_t)rowCount error:(NSError *__autoreleasing *)error +-(size_t)_addRows:(size_t)rowCount error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, @"Tried to add row while readonly."); + *error = make_tightdb_error(tdb_err_FailRdOnly, @"Tried to add row while read-only."); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER( - return _table->add_empty_row(rowCount); - , @"com.tightdb.table", 0); + TIGHTDB_EXCEPTION_ERRHANDLER(return _table->add_empty_row(rowCount);, 0); } --(TightdbCursor *)cursorAtIndex:(size_t)ndx +-(TightdbCursor*)cursorAtIndex:(size_t)ndx { // initWithTable checks for illegal index. return [[TightdbCursor alloc] initWithTable:self ndx:ndx]; } --(TightdbCursor *)cursorAtLastIndex +-(TightdbCursor*)cursorAtLastIndex { return [[TightdbCursor alloc] initWithTable:self ndx:[self count]-1]; } --(TightdbCursor *)insertRowAtIndex:(size_t)ndx +-(TightdbCursor*)insertRowAtIndex:(size_t)ndx { [self insertRow:ndx]; return [[TightdbCursor alloc] initWithTable:self ndx:ndx]; @@ -722,17 +707,15 @@ -(BOOL)insertRow:(size_t)ndx return [self insertRow:ndx error:nil]; } --(BOOL)insertRow:(size_t)ndx error:(NSError *__autoreleasing *)error +-(BOOL)insertRow:(size_t)ndx error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, @"Tried to insert row while readonly."); + *error = make_tightdb_error(tdb_err_FailRdOnly, @"Tried to insert row while read-only."); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER( - _table->insert_empty_row(ndx); - , @"com.tightdb.table", 0); + TIGHTDB_EXCEPTION_ERRHANDLER(_table->insert_empty_row(ndx);, 0); return YES; } @@ -740,16 +723,14 @@ -(BOOL)clear { return [self clearWithError:nil]; } --(BOOL)clearWithError:(NSError *__autoreleasing *)error +-(BOOL)clearWithError:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, @"Tried to clear while readonly."); + *error = make_tightdb_error(tdb_err_FailRdOnly, @"Tried to clear while read-only."); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER( - _table->clear(); - , @"com.tightdb.table", NO); + TIGHTDB_EXCEPTION_ERRHANDLER(_table->clear();, NO); return YES; } @@ -758,16 +739,14 @@ -(BOOL)removeRowAtIndex:(size_t)ndx return [self removeRowAtIndex:ndx error:nil]; } --(BOOL)removeRowAtIndex:(size_t)ndx error:(NSError *__autoreleasing *)error +-(BOOL)removeRowAtIndex:(size_t)ndx error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to remove row while read only ndx: %llu", (unsigned long long)ndx]); + *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to remove row while read only ndx: %llu", (unsigned long long)ndx]); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER( - _table->remove(ndx); - , @"com.tightdb.table", NO); + TIGHTDB_EXCEPTION_ERRHANDLER(_table->remove(ndx);, NO); return YES; } @@ -776,16 +755,14 @@ -(BOOL)removeLastRow return [self removeLastRowWithError:nil]; } --(BOOL)removeLastRowWithError:(NSError *__autoreleasing *)error +-(BOOL)removeLastRowWithError:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, @"Tried to remove last while readonly."); + *error = make_tightdb_error(tdb_err_FailRdOnly, @"Tried to remove last while read-only."); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER( - _table->remove_last(); - , @"com.tightdb.table", NO); + TIGHTDB_EXCEPTION_ERRHANDLER(_table->remove_last();, NO); return YES; } -(int64_t)get:(size_t)col_ndx ndx:(size_t)ndx @@ -798,16 +775,14 @@ -(BOOL)set:(size_t)col_ndx ndx:(size_t)ndx value:(int64_t)value return [self set:col_ndx ndx:ndx value:value error:nil]; } --(BOOL)set:(size_t)col_ndx ndx:(size_t)ndx value:(int64_t)value error:(NSError *__autoreleasing *)error +-(BOOL)set:(size_t)col_ndx ndx:(size_t)ndx value:(int64_t)value error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *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( - _table->set_int(col_ndx, ndx, value); - , @"com.tightdb.table", NO); + TIGHTDB_EXCEPTION_ERRHANDLER(_table->set_int(col_ndx, ndx, value);, NO); return YES; } @@ -821,16 +796,14 @@ -(BOOL)setBool:(size_t)col_ndx ndx:(size_t)ndx value:(BOOL)value return [self setBool:col_ndx ndx:ndx value:value error:nil]; } --(BOOL)setBool:(size_t)col_ndx ndx:(size_t)ndx value:(BOOL)value error:(NSError *__autoreleasing *)error +-(BOOL)setBool:(size_t)col_ndx ndx:(size_t)ndx value:(BOOL)value error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *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( - _table->set_bool(col_ndx, ndx, value); - , @"com.tightdb.table", NO); + TIGHTDB_EXCEPTION_ERRHANDLER(_table->set_bool(col_ndx, ndx, value);, NO); return YES; } @@ -844,16 +817,14 @@ -(BOOL)setFloat:(size_t)col_ndx ndx:(size_t)ndx value:(float)value return [self setFloat:col_ndx ndx:ndx value:value error:nil]; } --(BOOL)setFloat:(size_t)col_ndx ndx:(size_t)ndx value:(float)value error:(NSError *__autoreleasing *)error +-(BOOL)setFloat:(size_t)col_ndx ndx:(size_t)ndx value:(float)value error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *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( - _table->set_float(col_ndx, ndx, value); - , @"com.tightdb.table", NO); + TIGHTDB_EXCEPTION_ERRHANDLER(_table->set_float(col_ndx, ndx, value);, NO); return YES; } @@ -867,16 +838,14 @@ -(BOOL)setDouble:(size_t)col_ndx ndx:(size_t)ndx value:(double)value return [self setDouble:col_ndx ndx:ndx value:value error:nil]; } --(BOOL)setDouble:(size_t)col_ndx ndx:(size_t)ndx value:(double)value error:(NSError *__autoreleasing *)error +-(BOOL)setDouble:(size_t)col_ndx ndx:(size_t)ndx value:(double)value error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *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( - _table->set_double(col_ndx, ndx, value); - , @"com.tightdb.table", NO); + TIGHTDB_EXCEPTION_ERRHANDLER(_table->set_double(col_ndx, ndx, value);, NO); return YES; } @@ -890,16 +859,14 @@ -(BOOL)setDate:(size_t)col_ndx ndx:(size_t)ndx value:(time_t)value return [self setDate:col_ndx ndx:ndx value:value error:nil]; } --(BOOL)setDate:(size_t)col_ndx ndx:(size_t)ndx value:(time_t)value error:(NSError *__autoreleasing *)error +-(BOOL)setDate:(size_t)col_ndx ndx:(size_t)ndx value:(time_t)value error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *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( - _table->set_datetime(col_ndx, ndx, value); - , @"com.tightdb.table", NO); + TIGHTDB_EXCEPTION_ERRHANDLER(_table->set_datetime(col_ndx, ndx, value);, NO); return YES; } @@ -908,16 +875,14 @@ -(BOOL)insertBool:(size_t)col_ndx ndx:(size_t)ndx value:(BOOL)value return [self insertBool:col_ndx ndx:ndx value:value error:nil]; } --(BOOL)insertBool:(size_t)col_ndx ndx:(size_t)ndx value:(BOOL)value error:(NSError *__autoreleasing *)error +-(BOOL)insertBool:(size_t)col_ndx ndx:(size_t)ndx value:(BOOL)value error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER( - _table->insert_bool(col_ndx, ndx, value); - , @"com.tightdb.table", NO); + TIGHTDB_EXCEPTION_ERRHANDLER(_table->insert_bool(col_ndx, ndx, value);, NO); return YES; } @@ -927,16 +892,14 @@ -(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 +-(BOOL)insertInt:(size_t)col_ndx ndx:(size_t)ndx value:(int64_t)value error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER( - _table->insert_int(col_ndx, ndx, value); - , @"com.tightdb.table", NO); + TIGHTDB_EXCEPTION_ERRHANDLER(_table->insert_int(col_ndx, ndx, value);, NO); return YES; } @@ -945,16 +908,14 @@ -(BOOL)insertFloat:(size_t)col_ndx ndx:(size_t)ndx value:(float)value return [self insertFloat:col_ndx ndx:ndx value:value error:nil]; } --(BOOL)insertFloat:(size_t)col_ndx ndx:(size_t)ndx value:(float)value error:(NSError *__autoreleasing *)error +-(BOOL)insertFloat:(size_t)col_ndx ndx:(size_t)ndx value:(float)value error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER( - _table->insert_float(col_ndx, ndx, value); - , @"com.tightdb.table", NO); + TIGHTDB_EXCEPTION_ERRHANDLER(_table->insert_float(col_ndx, ndx, value);, NO); return YES; } @@ -963,70 +924,68 @@ -(BOOL)insertDouble:(size_t)col_ndx ndx:(size_t)ndx value:(double)value return [self insertDouble:col_ndx ndx:ndx value:value error:nil]; } --(BOOL)insertDouble:(size_t)col_ndx ndx:(size_t)ndx value:(double)value error:(NSError *__autoreleasing *)error +-(BOOL)insertDouble:(size_t)col_ndx ndx:(size_t)ndx value:(double)value error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER( - _table->insert_double(col_ndx, ndx, value); - , @"com.tightdb.table", NO); + TIGHTDB_EXCEPTION_ERRHANDLER(_table->insert_double(col_ndx, ndx, value);, NO); return YES; } --(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 { return [self insertString:col_ndx ndx:ndx value:value error:nil]; } --(BOOL)insertString:(size_t)col_ndx ndx:(size_t)ndx value:(NSString *)value error:(NSError *__autoreleasing *)error +-(BOOL)insertString:(size_t)col_ndx ndx:(size_t)ndx value:(NSString*)value error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } TIGHTDB_EXCEPTION_ERRHANDLER( - _table->insert_string(col_ndx, ndx, ObjcStringAccessor(value)); - , @"com.tightdb.table", NO); + _table->insert_string(col_ndx, ndx, ObjcStringAccessor(value));, + NO); return YES; } --(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 { return [self insertBinary:col_ndx ndx:ndx value:value error:nil]; } --(BOOL)insertBinary:(size_t)col_ndx ndx:(size_t)ndx value:(TightdbBinary *)value error:(NSError *__autoreleasing *)error +-(BOOL)insertBinary:(size_t)col_ndx ndx:(size_t)ndx value:(TightdbBinary*)value error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } TIGHTDB_EXCEPTION_ERRHANDLER( - _table->insert_binary(col_ndx, ndx, [value getBinary]); - , @"com.tightdb.table", NO); + _table->insert_binary(col_ndx, ndx, [value getBinary]);, + NO); return YES; } --(BOOL)insertBinary:(size_t)col_ndx ndx:(size_t)ndx data:(const char *)data size:(size_t)size +-(BOOL)insertBinary:(size_t)col_ndx ndx:(size_t)ndx data:(const char*)data size:(size_t)size { return [self insertBinary:col_ndx ndx:ndx data:data size:size error:nil]; } --(BOOL)insertBinary:(size_t)col_ndx ndx:(size_t)ndx data:(const char *)data size:(size_t)size error:(NSError *__autoreleasing *)error +-(BOOL)insertBinary:(size_t)col_ndx ndx:(size_t)ndx data:(const char*)data size:(size_t)size error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } TIGHTDB_EXCEPTION_ERRHANDLER( - _table->insert_binary(col_ndx, ndx, tightdb::BinaryData(data, size)); - , @"com.tightdb.table", NO); + _table->insert_binary(col_ndx, ndx, tightdb::BinaryData(data, size));, + NO); return YES; } @@ -1035,16 +994,14 @@ -(BOOL)insertDate:(size_t)col_ndx ndx:(size_t)ndx value:(time_t)value return [self insertDate:col_ndx ndx:ndx value:value error:nil]; } --(BOOL)insertDate:(size_t)col_ndx ndx:(size_t)ndx value:(time_t)value error:(NSError *__autoreleasing *)error +-(BOOL)insertDate:(size_t)col_ndx ndx:(size_t)ndx value:(time_t)value error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER( - _table->insert_datetime(col_ndx, ndx, value); - , @"com.tightdb.table", NO); + TIGHTDB_EXCEPTION_ERRHANDLER(_table->insert_datetime(col_ndx, ndx, value);, NO); return YES; } @@ -1053,74 +1010,72 @@ -(BOOL)insertDone return [self insertDoneWithError:nil]; } --(BOOL)insertDoneWithError:(NSError *__autoreleasing *)error +-(BOOL)insertDoneWithError:(NSError* __autoreleasing*)error { - TIGHTDB_EXCEPTION_ERRHANDLER( - _table->insert_done(); - , @"com.tightdb.table", NO); + TIGHTDB_EXCEPTION_ERRHANDLER(_table->insert_done();, NO); return YES; } --(NSString *)getString:(size_t)col_ndx ndx:(size_t)ndx +-(NSString*)getString:(size_t)col_ndx ndx:(size_t)ndx { return to_objc_string(_table->get_string(col_ndx, ndx)); } --(BOOL)setString:(size_t)col_ndx ndx:(size_t)ndx value:(NSString *)value +-(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 +-(BOOL)setString:(size_t)col_ndx ndx:(size_t)ndx value:(NSString*)value error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *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( - _table->set_string(col_ndx, ndx, ObjcStringAccessor(value)); - , @"com.tightdb.table", NO); + _table->set_string(col_ndx, ndx, ObjcStringAccessor(value));, + NO); return YES; } --(TightdbBinary *)getBinary:(size_t)col_ndx ndx:(size_t)ndx +-(TightdbBinary*)getBinary:(size_t)col_ndx ndx:(size_t)ndx { return [[TightdbBinary alloc] initWithBinary:_table->get_binary(col_ndx, ndx)]; } --(BOOL)setBinary:(size_t)col_ndx ndx:(size_t)ndx value:(TightdbBinary *)value +-(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 +-(BOOL)setBinary:(size_t)col_ndx ndx:(size_t)ndx value:(TightdbBinary*)value error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *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( - _table->set_binary(col_ndx, ndx, [value getBinary]); - , @"com.tightdb.table", NO); + _table->set_binary(col_ndx, ndx, [value getBinary]);, + NO); return YES; } --(BOOL)setBinary:(size_t)col_ndx ndx:(size_t)ndx data:(const char *)data size:(size_t)size +-(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 +-(BOOL)setBinary:(size_t)col_ndx ndx:(size_t)ndx data:(const char*)data size:(size_t)size error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *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( - _table->set_binary(col_ndx, ndx, tightdb::BinaryData(data, size)); - , @"com.tightdb.table", NO); + _table->set_binary(col_ndx, ndx, tightdb::BinaryData(data, size));, + NO); return YES; } @@ -1134,35 +1089,33 @@ -(BOOL)insertSubtable:(size_t)col_ndx ndx:(size_t)row_ndx return [self insertSubtable:col_ndx ndx:row_ndx error:nil]; } --(BOOL)insertSubtable:(size_t)col_ndx ndx:(size_t)row_ndx error:(NSError *__autoreleasing *)error +-(BOOL)insertSubtable:(size_t)col_ndx ndx:(size_t)row_ndx error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER( - _table->insert_subtable(col_ndx, row_ndx); - , @"com.tightdb.table", NO); + TIGHTDB_EXCEPTION_ERRHANDLER(_table->insert_subtable(col_ndx, row_ndx);, NO); return YES; } --(BOOL)_insertSubtableCopy:(size_t)col_ndx row:(size_t)row_ndx subtable:(TightdbTable *)subtable +-(BOOL)_insertSubtableCopy:(size_t)col_ndx row:(size_t)row_ndx subtable:(TightdbTable*)subtable { return [self _insertSubtableCopy:col_ndx row:row_ndx subtable:subtable error:nil]; } --(BOOL)_insertSubtableCopy:(size_t)col_ndx row:(size_t)row_ndx subtable:(TightdbTable *)subtable error:(NSError *__autoreleasing *)error +-(BOOL)_insertSubtableCopy:(size_t)col_ndx row:(size_t)row_ndx subtable:(TightdbTable*)subtable error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } TIGHTDB_EXCEPTION_ERRHANDLER( - tightdb::LangBindHelper::insert_subtable(*_table, col_ndx, row_ndx, [subtable getTable]); - , @"com.tightdb.table", NO); + tightdb::LangBindHelper::insert_subtable(*_table, col_ndx, row_ndx, [subtable getTable]);, + NO); return YES; } @@ -1170,31 +1123,29 @@ -(BOOL)clearSubtable:(size_t)col_ndx ndx:(size_t)row_ndx { return [self clearSubtable:col_ndx ndx:row_ndx error:nil]; } --(BOOL)clearSubtable:(size_t)col_ndx ndx:(size_t)row_ndx error:(NSError *__autoreleasing *)error +-(BOOL)clearSubtable:(size_t)col_ndx ndx:(size_t)row_ndx error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to clear while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to clear while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER( - _table->clear_subtable(col_ndx, row_ndx); - , @"com.tightdb.table", NO); + TIGHTDB_EXCEPTION_ERRHANDLER(_table->clear_subtable(col_ndx, row_ndx);, NO); return YES; } --(TightdbMixed *)getMixed:(size_t)col_ndx ndx:(size_t)row_ndx +-(TightdbMixed*)getMixed:(size_t)col_ndx ndx:(size_t)row_ndx { tightdb::Mixed tmp = _table->get_mixed(col_ndx, row_ndx); - TightdbMixed *mixed = [TightdbMixed mixedWithMixed:tmp]; + TightdbMixed* mixed = [TightdbMixed mixedWithMixed:tmp]; if ([mixed getType] == tightdb_Table) { tightdb::TableRef r = _table->get_subtable(col_ndx, row_ndx); if (!r) return nil; - TightdbTable *table = [[TightdbTable alloc] _initRaw]; + TightdbTable* table = [[TightdbTable alloc] _initRaw]; if (TIGHTDB_UNLIKELY(!table)) return nil; [table setTable:move(r)]; [table setParent:self]; - [table setReadOnly:_readOnly]; + [table setReadOnly:m_read_only]; if (![table _checkType]) return nil; [mixed setTable:table]; @@ -1207,64 +1158,64 @@ -(TightdbType)getMixedType:(size_t)col_ndx ndx:(size_t)row_ndx return (TightdbType)_table->get_mixed_type(col_ndx, row_ndx); } --(BOOL)insertMixed:(size_t)col_ndx ndx:(size_t)row_ndx value:(TightdbMixed *)value +-(BOOL)insertMixed:(size_t)col_ndx ndx:(size_t)row_ndx value:(TightdbMixed*)value { return [self insertMixed:col_ndx ndx:row_ndx value:value error:nil]; } --(BOOL)insertMixed:(size_t)col_ndx ndx:(size_t)row_ndx value:(TightdbMixed *)value error:(NSError *__autoreleasing *)error +-(BOOL)insertMixed:(size_t)col_ndx ndx:(size_t)row_ndx value:(TightdbMixed*)value error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } TIGHTDB_EXCEPTION_ERRHANDLER( - if (value.mixed.get_type() == tightdb::type_Table && value.table) { - tightdb::LangBindHelper::insert_mixed_subtable(*_table, col_ndx, row_ndx, - [value.table getTable]); - } - else { - _table->insert_mixed(col_ndx, row_ndx, value.mixed); - } - , @"com.tightdb.table", NO); + if (value.mixed.get_type() == tightdb::type_Table && value.table) { + tightdb::LangBindHelper::insert_mixed_subtable(*_table, col_ndx, row_ndx, + [value.table getTable]); + } + else { + _table->insert_mixed(col_ndx, row_ndx, value.mixed); + }, + NO); return YES; } --(BOOL)setMixed:(size_t)col_ndx ndx:(size_t)row_ndx value:(TightdbMixed *)value +-(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 +-(BOOL)setMixed:(size_t)col_ndx ndx:(size_t)row_ndx value:(TightdbMixed*)value error:(NSError* __autoreleasing*)error { - if (_readOnly) { + if (m_read_only) { if (error) - *error = make_tightdb_error(@"com.tightdb.table", tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]); + *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( - if (value.mixed.get_type() == tightdb::type_Table && value.table) { - tightdb::LangBindHelper::set_mixed_subtable(*_table, col_ndx, row_ndx, - [value.table getTable]); - } - else { - _table->set_mixed(col_ndx, row_ndx, value.mixed); - } - , @"com.tightdb.table", NO); + if (value.mixed.get_type() == tightdb::type_Table && value.table) { + tightdb::LangBindHelper::set_mixed_subtable(*_table, col_ndx, row_ndx, + [value.table getTable]); + } + else { + _table->set_mixed(col_ndx, row_ndx, value.mixed); + }, + NO); return YES; } --(size_t)addColumnWithType:(TightdbType)type andName:(NSString *)name +-(size_t)addColumnWithType:(TightdbType)type andName:(NSString*)name { return [self addColumnWithType:type andName:name error:nil]; } --(size_t)addColumnWithType:(TightdbType)type andName:(NSString *)name error:(NSError *__autoreleasing *)error +-(size_t)addColumnWithType:(TightdbType)type andName:(NSString*)name error:(NSError* __autoreleasing*)error { TIGHTDB_EXCEPTION_ERRHANDLER( - return _table->add_column(tightdb::DataType(type), ObjcStringAccessor(name)); - , @"com.tightdb.table", 0); + return _table->add_column(tightdb::DataType(type), ObjcStringAccessor(name));, + 0); } -(size_t)findBool:(size_t)col_ndx value:(BOOL)value @@ -1283,11 +1234,11 @@ -(size_t)findDouble:(size_t)col_ndx value:(double)value { return _table->find_first_double(col_ndx, value); } --(size_t)findString:(size_t)col_ndx value:(NSString *)value +-(size_t)findString:(size_t)col_ndx value:(NSString*)value { return _table->find_first_string(col_ndx, ObjcStringAccessor(value)); } --(size_t)findBinary:(size_t)col_ndx value:(TightdbBinary *)value +-(size_t)findBinary:(size_t)col_ndx value:(TightdbBinary*)value { return _table->find_first_binary(col_ndx, [value getBinary]); } @@ -1295,7 +1246,7 @@ -(size_t)findDate:(size_t)col_ndx value:(time_t)value { return _table->find_first_datetime(col_ndx, value); } --(size_t)findMixed:(size_t)col_ndx value:(TightdbMixed *)value +-(size_t)findMixed:(size_t)col_ndx value:(TightdbMixed*)value { static_cast(col_ndx); static_cast(value); @@ -1305,18 +1256,18 @@ -(size_t)findMixed:(size_t)col_ndx value:(TightdbMixed *)value return 0; } --(TightdbView *)findAll:(TightdbView *)view column:(size_t)col_ndx value:(int64_t)value +-(TightdbView*)findAll:(TightdbView*)view column:(size_t)col_ndx value:(int64_t)value { *view.tableView = _table->find_all_int(col_ndx, value); return view; } --(TightdbQuery *)where +-(TightdbQuery*)where { return [self whereWithError:nil]; } --(TightdbQuery *)whereWithError:(NSError *__autoreleasing *)error +-(TightdbQuery*)whereWithError:(NSError* __autoreleasing*)error { return [[TightdbQuery alloc] initWithTable:self error:error]; } @@ -1334,11 +1285,9 @@ -(BOOL)optimize return [self optimizeWithError:nil]; } --(BOOL)optimizeWithError:(NSError *__autoreleasing *)error +-(BOOL)optimizeWithError:(NSError* __autoreleasing*)error { - TIGHTDB_EXCEPTION_ERRHANDLER( - _table->optimize(); - , @"com.tightdb.table", NO); + TIGHTDB_EXCEPTION_ERRHANDLER(_table->optimize();, NO); return YES; } @@ -1354,7 +1303,7 @@ -(size_t)countWithDoubleColumn:(size_t)col_ndx andValue:(double)target { return _table->count_double(col_ndx, target); } --(size_t)countWithStringColumn:(size_t)col_ndx andValue:(NSString *)target +-(size_t)countWithStringColumn:(size_t)col_ndx andValue:(NSString*)target { return _table->count_string(col_ndx, ObjcStringAccessor(target)); } @@ -1427,7 +1376,7 @@ -(void)verify @implementation TightdbColumnProxy @synthesize table = _table, column = _column; --(id)initWithTable:(TightdbTable *)table column:(size_t)column +-(id)initWithTable:(TightdbTable*)table column:(size_t)column { self = [super init]; if (self) { @@ -1454,9 +1403,9 @@ -(size_t)find:(int64_t)value { return [self.table findInt:self.column value:value]; } --(TightdbView *)findAll:(int64_t)value +-(TightdbView*)findAll:(int64_t)value { - TightdbView *view = [TightdbView tableViewWithTable:self.table]; + TightdbView* view = [TightdbView tableViewWithTable:self.table]; return [self.table findAll:view column:self.column value:value]; } -(int64_t)minimum @@ -1524,14 +1473,14 @@ -(double)average @end @implementation TightdbColumnProxy_String --(size_t)find:(NSString *)value +-(size_t)find:(NSString*)value { return [self.table findString:self.column value:value]; } @end @implementation TightdbColumnProxy_Binary --(size_t)find:(TightdbBinary *)value +-(size_t)find:(TightdbBinary*)value { return [self.table findBinary:self.column value:value]; } @@ -1548,7 +1497,7 @@ @implementation TightdbColumnProxy_Subtable @end @implementation TightdbColumnProxy_Mixed --(size_t)find:(TightdbMixed *)value +-(size_t)find:(TightdbMixed*)value { return [self.table findMixed:self.column value:value]; } diff --git a/src/tightdb/objc/table_priv.h b/src/tightdb/objc/table_priv.h index 58e3ca74d9..cf6fc9b930 100644 --- a/src/tightdb/objc/table_priv.h +++ b/src/tightdb/objc/table_priv.h @@ -21,7 +21,7 @@ -(void)setParent:(id)parent; // Workaround for ARC release problem. --(void)setReadOnly:(BOOL)readOnly; +-(void)setReadOnly:(BOOL)read_only; /// Also returns NO if memory allocation fails. -(BOOL)_checkType; diff --git a/src/tightdb/objc/test/err_handling.mm b/src/tightdb/objc/test/err_handling.mm index 82a8d3ac0f..ca8f406c41 100644 --- a/src/tightdb/objc/test/err_handling.mm +++ b/src/tightdb/objc/test/err_handling.mm @@ -54,15 +54,15 @@ @implementation MACTestErrHandling - (void)testErrHandling { - NSError *error = nil; + NSError* error = nil; //------------------------------------------------------ NSLog(@"--- Creating tables ---"); //------------------------------------------------------ - TightdbGroup *group = [TightdbGroup group]; + 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]]; // Add some rows error = nil; @@ -97,7 +97,7 @@ - (void)testErrHandling NSLog(@"PeopleErrTable Size: %lu - is %@. [6 - not empty]", [people count], [people isEmpty] ? @"empty" : @"not empty"); - NSFileManager *fm = [NSFileManager defaultManager]; + NSFileManager* fm = [NSFileManager defaultManager]; // Write the group to disk [fm removeItemAtPath:@"peopleErr.tightdb" error:NULL]; @@ -111,7 +111,7 @@ - (void)testErrHandling NSLog(@"--- Changing permissions ---"); //------------------------------------------------------ - NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithCapacity:1]; + NSMutableDictionary* attributes = [NSMutableDictionary dictionaryWithCapacity:1]; [attributes setValue:[NSNumber numberWithShort:0444] forKey:NSFilePosixPermissions]; error = nil; @@ -126,7 +126,7 @@ - (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 groupWithFilename:@"peopleErr.tightdb" error:&error]; if (error) { NSLog(@"%@", [error localizedDescription]); } else { @@ -153,10 +153,10 @@ - (void)testErrHandling STFail(@"File should have been possible to open"); } - PeopleErrTable *diskTable = [fromDisk getTable:@"employees" withClass:[PeopleErrTable class]]; + PeopleErrTable* diskTable = [fromDisk getTable:@"employees" withClass:[PeopleErrTable class]]; // Fake readonly. - [((TightdbTable *)diskTable) setReadOnly:true]; + [((TightdbTable*)diskTable) setReadOnly:true]; NSLog(@"Disktable size: %zu", [diskTable count]); @@ -176,61 +176,57 @@ - (void)testErrHandling -(void)testErrorInsert { - NSError *error; + NSError* error; // Create table with all column types - TightdbTable *table = [[TightdbTable alloc] init]; - TightdbSpec *s = [table getSpec]; - if (![s addColumnWithType:tightdb_Int andName:@"int" error:&error]) { + TightdbTable* table = [[TightdbTable alloc] init]; + TightdbDescriptor* desc = [table getDescriptor]; + if (![desc addColumnWithType:tightdb_Int andName:@"int" error:&error]) { NSLog(@"%@", [error localizedDescription]); STFail(@"addColumn failed."); } - if (![s addColumnWithType:tightdb_Bool andName:@"bool" error:&error]) { + if (![desc addColumnWithType:tightdb_Bool andName:@"bool" error:&error]) { NSLog(@"%@", [error localizedDescription]); STFail(@"addColumn failed."); } - if (![s addColumnWithType:tightdb_Date andName:@"date" error:&error]) { + if (![desc addColumnWithType:tightdb_Date andName:@"date" error:&error]) { NSLog(@"%@", [error localizedDescription]); STFail(@"addColumn failed."); } - if (![s addColumnWithType:tightdb_String andName:@"string" error:&error]) { + if (![desc addColumnWithType:tightdb_String andName:@"string" error:&error]) { NSLog(@"%@", [error localizedDescription]); STFail(@"addColumn failed."); } - if (![s addColumnWithType:tightdb_String andName:@"string_long" error:&error]) { + if (![desc addColumnWithType:tightdb_String andName:@"string_long" error:&error]) { NSLog(@"%@", [error localizedDescription]); STFail(@"addColumn failed."); } - if (![s addColumnWithType:tightdb_String andName:@"string_enum" error:&error]) { + if (![desc addColumnWithType:tightdb_String andName:@"string_enum" error:&error]) { NSLog(@"%@", [error localizedDescription]); STFail(@"addColumn failed."); } - if (![s addColumnWithType:tightdb_Binary andName:@"binary" error:&error]) { + if (![desc addColumnWithType:tightdb_Binary andName:@"binary" error:&error]) { NSLog(@"%@", [error localizedDescription]); STFail(@"addColumn failed."); } - if (![s addColumnWithType:tightdb_Mixed andName:@"mixed" error:&error]) { + if (![desc addColumnWithType:tightdb_Mixed andName:@"mixed" error:&error]) { NSLog(@"%@", [error localizedDescription]); STFail(@"addColumn failed."); } - TightdbSpec *sub; - if (!(sub = [s addColumnTable:@"tables" error:&error])) { + TightdbDescriptor* subdesc; + if (!(subdesc = [desc addColumnTable:@"tables" error:&error])) { NSLog(@"%@", [error localizedDescription]); STFail(@"addColumn failed."); } - if (![sub addColumnWithType:tightdb_Int andName:@"sub_first" error:&error]) { + if (![subdesc addColumnWithType:tightdb_Int andName:@"sub_first" error:&error]) { NSLog(@"%@", [error localizedDescription]); STFail(@"addColumn failed."); } - if (![sub addColumnWithType:tightdb_String andName:@"sub_second" error:&error]) { + if (![subdesc addColumnWithType:tightdb_String andName:@"sub_second" error:&error]) { NSLog(@"%@", [error localizedDescription]); STFail(@"addColumn failed."); } - if (![table updateFromSpecWithError:&error]) { - NSLog(@"%@", [error localizedDescription]); - STFail(@"UpdateFromSpec failed."); - } // Add some rows for (size_t i = 0; i < 15; ++i) { @@ -312,7 +308,7 @@ -(void)testErrorInsert // Add sub-tables if (i == 2) { - TightdbTable *subtable = [table getSubtable:8 ndx:i]; + TightdbTable* subtable = [table getSubtable:8 ndx:i]; if (![subtable insertInt:0 ndx:0 value:42 error:&error]) { NSLog(@"%@", [error localizedDescription]); STFail(@"Insert failed."); @@ -370,19 +366,19 @@ -(void)testErrorInsert - (void)testQueryErrHandling { - TestQueryErrAllTypes *table = [[TestQueryErrAllTypes alloc] init]; + TestQueryErrAllTypes* table = [[TestQueryErrAllTypes alloc] init]; NSLog(@"Table: %@", table); STAssertNotNil(table, @"Table is nil"); const char bin[4] = { 0, 1, 2, 3 }; - TightdbBinary *bin1 = [[TightdbBinary alloc] initWithData:bin size:sizeof bin / 2]; - TightdbBinary *bin2 = [[TightdbBinary alloc] initWithData:bin size:sizeof bin]; + TightdbBinary* bin1 = [[TightdbBinary alloc] initWithData:bin size:sizeof bin / 2]; + TightdbBinary* bin2 = [[TightdbBinary alloc] initWithData:bin size:sizeof bin]; time_t timeNow = [[NSDate date] timeIntervalSince1970]; - // TestQueryErrSub *subtab1 = [[TestQueryErrSub alloc] init]; - TestQueryErrSub *subtab2 = [[TestQueryErrSub alloc] init]; + // TestQueryErrSub* subtab1 = [[TestQueryErrSub alloc] init]; + TestQueryErrSub* subtab2 = [[TestQueryErrSub alloc] init]; [subtab2 addAge:100]; - TightdbMixed *mixInt1 = [TightdbMixed mixedWithInt64:1]; - TightdbMixed *mixSubtab = [TightdbMixed mixedWithTable:subtab2]; + TightdbMixed* mixInt1 = [TightdbMixed mixedWithInt64:1]; + TightdbMixed* mixSubtab = [TightdbMixed mixedWithTable:subtab2]; [table addBoolCol:NO IntCol:54 FloatCol:0.7 DoubleCol:0.8 StringCol:@"foo" BinaryCol:bin1 DateCol:0 TableCol:nil MixedCol:mixInt1]; @@ -401,7 +397,7 @@ - (void)testQueryErrHandling // STAssertEquals([[[table where].TableCol columnIsEqualTo:subtab1] count], (size_t)1, @"TableCol equal"); // STAssertEquals([[[table where].MixedCol columnIsEqualTo:mixInt1] count], (size_t)1, @"MixedCol equal"); - TestQueryErrAllTypes_Query *query = [[table where].BoolCol columnIsEqualTo:NO]; + TestQueryErrAllTypes_Query* query = [[table where].BoolCol columnIsEqualTo:NO]; STAssertEquals([[query.IntCol minimum] longLongValue], (int64_t)54, @"IntCol min"); STAssertEquals([[query.IntCol maximum] longLongValue], (int64_t)54, @"IntCol max"); @@ -463,7 +459,7 @@ - (void)testQueryErrHandling [[[table where].BinaryCol columnEndsWith:bin1].BoolCol columnIsEqualTo:NO]; [[[table where].BinaryCol columnContains:bin1].BoolCol columnIsEqualTo:NO]; - TestQueryErrAllTypes_View *view = [[[[table where].DateCol columnIsEqualTo:0].BoolCol columnIsEqualTo:NO] findAll]; + TestQueryErrAllTypes_View* view = [[[[table where].DateCol columnIsEqualTo:0].BoolCol columnIsEqualTo:NO] findAll]; for (size_t i = 0; i < [view count]; i++) { NSLog(@"%zu: %c", i, [[view cursorAtIndex:i] BoolCol]); } diff --git a/src/tightdb/objc/test/get_subtable.m b/src/tightdb/objc/test/get_subtable.m index b7d45330c8..50ce5094cb 100644 --- a/src/tightdb/objc/test/get_subtable.m +++ b/src/tightdb/objc/test/get_subtable.m @@ -32,27 +32,26 @@ @implementation MACTestGetSubtable - (void)testGetSubtable { // Create table with all column types - TightdbTable *table = [[TightdbTable alloc] init]; - TightdbSpec *s = [table getSpec]; - [s addColumnWithType:tightdb_Bool andName:@"Outer"]; - [s addColumnWithType:tightdb_Int andName:@"Number"]; - TightdbSpec *sub = [s addColumnTable:@"GetSubtable"]; - [sub addColumnWithType:tightdb_Bool andName:@"Hired"]; - [sub addColumnWithType:tightdb_Int andName:@"Age"]; - [table updateFromSpec]; + TightdbTable* table = [[TightdbTable alloc] init]; + TightdbDescriptor* desc = [table getDescriptor]; + [desc addColumnWithType:tightdb_Bool andName:@"Outer"]; + [desc addColumnWithType:tightdb_Int andName:@"Number"]; + TightdbDescriptor* subdesc = [desc addColumnTable:@"GetSubtable"]; + [subdesc addColumnWithType:tightdb_Bool andName:@"Hired"]; + [subdesc addColumnWithType:tightdb_Int andName:@"Age"]; [table insertBool:0 ndx:0 value:NO]; [table insertInt:1 ndx:0 value:10]; [table insertSubtable:2 ndx:0]; [table insertDone]; - TightdbTable *subtable = [table getSubtable:2 ndx:0]; + TightdbTable* subtable = [table getSubtable:2 ndx: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_Cursor *cursor = [testTable cursorAtIndex:0]; + GetSubtable* testTable = [table getSubtable:2 ndx: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"); diff --git a/src/tightdb/objc/test/group_misc_2.m b/src/tightdb/objc/test/group_misc_2.m index e0ce6a474e..b62dfbfd15 100644 --- a/src/tightdb/objc/test/group_misc_2.m +++ b/src/tightdb/objc/test/group_misc_2.m @@ -41,10 +41,10 @@ @implementation MACTestGroupMisc2 - (void)testGroup_Misc2 { size_t row; - TightdbGroup *group = [TightdbGroup group]; + 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]]; NSLog(@"Table: %@", table); NSLog(@"HasTable: %i", [group hasTable:@"employees" withClass:[MyTable class]] ); @@ -66,13 +66,13 @@ - (void)testGroup_Misc2 NSLog(@"Mary: %zu", row); STAssertEquals(row, (size_t)1,@"Mary should have been there"); - TightdbView *view = [table.Age findAll:21]; + TightdbView* view = [table.Age findAll:21]; size_t cnt = [view count]; // cnt = 2 STAssertEquals(cnt, (size_t)2,@"Should be two rows in view"); //------------------------------------------------------ - MyTable2 *table2 = [[MyTable2 alloc] init]; + MyTable2* table2 = [[MyTable2 alloc] init]; // Add some rows [table2 addHired:YES Age:20]; @@ -82,7 +82,7 @@ - (void)testGroup_Misc2 [table2 addHired:YES Age:54]; // Create query (current employees between 20 and 30 years old) - MyTable2_Query *q = [[[table2 where].Hired columnIsEqualTo:YES].Age columnIsBetween:20 and_:30]; + MyTable2_Query* q = [[[table2 where].Hired columnIsEqualTo:YES].Age columnIsBetween:20 and_:30]; // Get number of matching entries NSLog(@"Query count: %zu", [[q count] unsignedLongValue]); @@ -94,7 +94,7 @@ - (void)testGroup_Misc2 STAssertEquals(avg, 21.0,@"Expected 20.5 average"); // Execute the query and return a table (view) - TightdbView *res = [q findAll]; + TightdbView* res = [q findAll]; for (size_t i = 0; i < [res count]; i++) { // cursor missing. Only low-level interface! NSLog(@"%zu: is %lld years old",i , [res get:1 ndx:i]); @@ -102,21 +102,21 @@ - (void)testGroup_Misc2 //------------------------------------------------------ - NSFileManager *fm = [NSFileManager defaultManager]; + NSFileManager* fm = [NSFileManager defaultManager]; // Write to disk [fm removeItemAtPath:@"employees.tightdb" error:NULL]; [group write:@"employees.tightdb"]; // 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 groupWithFilename:@"employees.tightdb"]; + MyTable* diskTable = [fromDisk getTable:@"employees" withClass:[MyTable class]]; [diskTable addName:@"Anni" Age:54 Hired:YES Spare:0]; // [diskTable insertAtIndex: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]; + MyTable_Cursor* cursor = [diskTable cursorAtIndex:i]; NSLog(@"%zu: %@", i, [cursor Name]); NSLog(@"%zu: %@", i, cursor.Name); NSLog(@"%zu: %@", i, [diskTable getString:0 ndx:i]); @@ -127,8 +127,8 @@ - (void)testGroup_Misc2 const char* data = [group writeToMem:&size]; // 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:data size:size]; + MyTable* memTable = [fromMem getTable:@"employees" withClass:[MyTable class]]; for (size_t i = 0; i < [memTable count]; i++) { // ??? cursor NSLog(@"%zu: %@", i, memTable.Name); @@ -138,8 +138,8 @@ - (void)testGroup_Misc2 - (void)testQuery { - TightdbGroup *group = [TightdbGroup group]; - QueryTable *table = [group getTable:@"Query table" withClass:[QueryTable class]]; + TightdbGroup* group = [TightdbGroup group]; + QueryTable* table = [group getTable:@"Query table" withClass:[QueryTable class]]; // Add some rows [table addFirst:2 Second:@"a"]; @@ -148,7 +148,7 @@ - (void)testQuery [table addFirst:8 Second:@"The quick brown fox"]; { - QueryTable_Query *q = [[table where].First columnIsBetween:3 and_:7]; // Between + QueryTable_Query* q = [[table where].First columnIsBetween:3 and_:7]; // Between STAssertEquals((size_t)2, [[q count] unsignedLongValue], @"count != 2"); // STAssertEquals(9, [q.First sum]); // Sum STAssertEquals(4.5, [[q.First average] doubleValue], @"Avg!=4.5"); // Average @@ -156,33 +156,33 @@ - (void)testQuery // STAssertEquals(5, [q.First max]); // Maximum } { - QueryTable_Query *q = [[table where].Second columnContains:@"quick" caseSensitive:NO]; // String contains + QueryTable_Query* q = [[table where].Second columnContains:@"quick" caseSensitive:NO]; // String contains STAssertEquals((size_t)1, [[q count] unsignedLongValue], @"count != 1"); } { - QueryTable_Query *q = [[table where].Second columnBeginsWith:@"The" caseSensitive:NO]; // String prefix + QueryTable_Query* q = [[table where].Second columnBeginsWith:@"The" caseSensitive:NO]; // String prefix STAssertEquals((size_t)1, [[q count] unsignedLongValue], @"count != 1"); } { - QueryTable_Query *q = [[table where].Second columnEndsWith:@"The" caseSensitive:NO]; // String suffix + QueryTable_Query* q = [[table where].Second columnEndsWith:@"The" caseSensitive:NO]; // String suffix STAssertEquals((size_t)0, [[q count] unsignedLongValue], @"count != 1"); } { - QueryTable_Query *q = [[[table where].Second columnIsNotEqualTo:@"a" caseSensitive:NO].Second columnIsNotEqualTo:@"b" caseSensitive:NO]; // And + QueryTable_Query* q = [[[table where].Second columnIsNotEqualTo:@"a" caseSensitive:NO].Second columnIsNotEqualTo:@"b" caseSensitive:NO]; // And STAssertEquals((size_t)1, [[q count] unsignedLongValue], @"count != 1"); } { - QueryTable_Query *q = [[[[table where].Second columnIsNotEqualTo:@"a" caseSensitive:NO] or].Second columnIsNotEqualTo:@"b" caseSensitive:NO]; // Or + QueryTable_Query* q = [[[[table where].Second columnIsNotEqualTo:@"a" caseSensitive:NO] or].Second columnIsNotEqualTo:@"b" caseSensitive:NO]; // Or STAssertEquals((size_t)4, [[q count] unsignedLongValue], @"count != 1"); } { - QueryTable_Query *q = [[[[[[[table where].Second columnIsEqualTo:@"a" caseSensitive:NO] group].First columnIsLessThan:3] or].First columnIsGreaterThan:5] endgroup]; // Parentheses + QueryTable_Query* q = [[[[[[[table where].Second columnIsEqualTo:@"a" caseSensitive:NO] group].First columnIsLessThan:3] or].First columnIsGreaterThan:5] endgroup]; // Parentheses STAssertEquals((size_t)1, [[q count] unsignedLongValue], @"count != 1"); } { - QueryTable_Query *q = [[[[[table where].Second columnIsEqualTo:@"a" caseSensitive:NO].First columnIsLessThan:3] or].First columnIsGreaterThan:5]; // No parenthesis + QueryTable_Query* q = [[[[[table where].Second columnIsEqualTo:@"a" caseSensitive:NO].First columnIsLessThan:3] or].First columnIsGreaterThan:5]; // No parenthesis STAssertEquals((size_t)2, [[q count] unsignedLongValue], @"count != 2"); - TightdbView *tv = [q findAll]; + TightdbView* tv = [q findAll]; STAssertEquals((size_t)2, [tv count], @"count != 2"); STAssertEquals((int64_t)8, [tv get:0 ndx:1], @"First != 8"); } @@ -195,19 +195,18 @@ - (void)testQuery */ - (void)testSubtables { - TightdbGroup *group = [TightdbGroup group]; - TightdbTable *table = [group getTable:@"table" withClass:[TightdbTable class]]; + TightdbGroup* group = [TightdbGroup group]; + TightdbTable* table = [group getTable:@"table" withClass:[TightdbTable class]]; - // Specify the table schema + // Specify the table type { - TightdbSpec *s = [table getSpec]; - [s addColumnWithType:tightdb_Int andName:@"int"]; + TightdbDescriptor* desc = [table getDescriptor]; + [desc addColumnWithType:tightdb_Int andName:@"int"]; { - TightdbSpec *sub = [s addColumnTable:@"tab"]; - [sub addColumnWithType:tightdb_Int andName:@"int"]; + TightdbDescriptor* subdesc = [desc addColumnTable:@"tab"]; + [subdesc addColumnWithType:tightdb_Int andName:@"int"]; } - [s addColumnWithType:tightdb_Mixed andName:@"mix"]; - [table updateFromSpec]; + [desc addColumnWithType:tightdb_Mixed andName:@"mix"]; } int COL_TABLE_INT = 0; @@ -220,7 +219,7 @@ - (void)testSubtables [table set:COL_TABLE_INT ndx:0 value:700]; // Add two rows to the subtable - TightdbTable *subtable = [table getSubtable:COL_TABLE_TAB ndx:0]; + TightdbTable* subtable = [table getSubtable:COL_TABLE_TAB ndx:0]; [subtable addRow]; [subtable set:COL_SUBTABLE_INT ndx:0 value:800]; [subtable addRow]; @@ -230,12 +229,11 @@ - (void)testSubtables [table setMixed:COL_TABLE_MIX ndx:0 value: [TightdbMixed mixedWithTable:nil]]; /* Fails!!! - // Specify its schema - OCTopLevelTable *subtable2 = [table getTopLevelTable:COL_TABLE_MIX ndx:0]; + // Specify its type + OCTopLevelTable* subtable2 = [table getTopLevelTable:COL_TABLE_MIX ndx:0]; { - TightdbSpec *s = [subtable2 getSpec]; - [s addColumnWithType:tightdb_Int andName:@"int"]; - [subtable2 updateFromSpec:[s getRef]]; + TightdbDescriptor* desc = [subtable2 getDescriptor]; + [desc addColumnWithType:tightdb_Int andName:@"int"]; } // Add a row to it [subtable2 addRow]; diff --git a/src/tightdb/objc/test/table.m b/src/tightdb/objc/test/table.m index bd428b47ed..a560d65c12 100644 --- a/src/tightdb/objc/test/table.m +++ b/src/tightdb/objc/test/table.m @@ -27,7 +27,7 @@ @implementation MACtestTable - (void)testTable { - TightdbTable *_table = [[TightdbTable alloc] init]; + TightdbTable* _table = [[TightdbTable alloc] init]; NSLog(@"Table: %@", _table); STAssertNotNil(_table, @"Table is nil"); @@ -49,7 +49,7 @@ - (void)testTable //[_table set:0 ndx:ndx value:0]; //[_table set:1 ndx:ndx value:10]; - TightdbCursor *cursor = [_table addRow]; + TightdbCursor* cursor = [_table addRow]; size_t ndx = [cursor index]; [cursor setInt:0 inColumn:0]; [cursor setInt:10 inColumn:1]; @@ -66,7 +66,7 @@ - (void)testTable - (void)testDataTypes_Typed { - TestTableAllTypes *table = [[TestTableAllTypes alloc] init]; + TestTableAllTypes* table = [[TestTableAllTypes alloc] init]; NSLog(@"Table: %@", table); STAssertNotNil(table, @"Table is nil"); @@ -82,17 +82,17 @@ - (void)testDataTypes_Typed STAssertEquals(tightdb_Mixed, [table getColumnType:8], @"Ninth column not mixed"); const char bin[4] = { 0, 1, 2, 3 }; - TightdbBinary *bin1 = [[TightdbBinary alloc] initWithData:bin size:sizeof bin / 2]; - TightdbBinary *bin2 = [[TightdbBinary alloc] initWithData:bin size:sizeof bin]; + TightdbBinary* bin1 = [[TightdbBinary alloc] initWithData:bin size:sizeof bin / 2]; + TightdbBinary* bin2 = [[TightdbBinary alloc] initWithData:bin size:sizeof bin]; time_t timeNow = [[NSDate date] timeIntervalSince1970]; - TestTableSub *subtab1 = [[TestTableSub alloc] init]; - TestTableSub *subtab2 = [[TestTableSub alloc] init]; + TestTableSub* subtab1 = [[TestTableSub alloc] init]; + TestTableSub* subtab2 = [[TestTableSub alloc] init]; [subtab1 addAge:200]; [subtab2 addAge:100]; - TightdbMixed *mixInt1 = [TightdbMixed mixedWithInt64:1]; - TightdbMixed *mixSubtab = [TightdbMixed mixedWithTable:subtab2]; + TightdbMixed* mixInt1 = [TightdbMixed mixedWithInt64:1]; + TightdbMixed* mixSubtab = [TightdbMixed mixedWithTable:subtab2]; - TestTableAllTypes_Cursor *c; + TestTableAllTypes_Cursor* c; c = [table addRow]; @@ -104,8 +104,8 @@ - (void)testDataTypes_Typed c.BoolCol = YES ; c.IntCol = 506 ; c.FloatCol = 7.7 ; c.DoubleCol = 8.8 ; c.StringCol = @"banach"; c.BinaryCol = bin2 ; c.DateCol = timeNow ; c.TableCol = subtab2 ; c.MixedCol = mixSubtab ; - TestTableAllTypes_Cursor *row1 = [table cursorAtIndex:0]; - TestTableAllTypes_Cursor *row2 = [table cursorAtIndex:1]; + TestTableAllTypes_Cursor* row1 = [table cursorAtIndex:0]; + TestTableAllTypes_Cursor* row2 = [table cursorAtIndex:1]; STAssertEquals(row1.BoolCol, NO, @"row1.BoolCol"); STAssertEquals(row2.BoolCol, YES, @"row2.BoolCol"); @@ -141,27 +141,26 @@ - (void)testDataTypes_Typed STAssertEquals([table.DoubleCol sum], 0.8 + 8.8, @"DoubleCol sum"); STAssertEquals([table.DoubleCol average], (0.8 + 8.8) / 2, @"DoubleCol avg"); } + - (void)testDataTypes_Dynamic { - - TightdbTable *table = [[TightdbTable alloc] init]; + TightdbTable* table = [[TightdbTable alloc] init]; NSLog(@"Table: %@", table); STAssertNotNil(table, @"Table is nil"); - TightdbSpec *spec = [table getSpec]; + TightdbDescriptor* desc = [table getDescriptor]; - [spec addColumnWithType:tightdb_Bool andName:@"BoolCol"]; const size_t BoolCol = 0; - [spec addColumnWithType:tightdb_Int andName:@"IntCol"]; const size_t IntCol = 1; - [spec addColumnWithType:tightdb_Float andName:@"FloatCol"]; const size_t FloatCol = 2; - [spec addColumnWithType:tightdb_Double andName:@"DoubleCol"]; const size_t DoubleCol = 3; - [spec addColumnWithType:tightdb_String andName:@"StringCol"]; const size_t StringCol = 4; - [spec addColumnWithType:tightdb_Binary andName:@"BinaryCol"]; const size_t BinaryCol = 5; - [spec addColumnWithType:tightdb_Date andName:@"DateCol"]; const size_t DateCol = 6; - TightdbSpec *specTableCol = [spec addColumnTable:@"TableCol"]; const size_t TableCol = 7; - [spec addColumnWithType:tightdb_Mixed andName:@"MixedCol"]; const size_t MixedCol = 8; + [desc addColumnWithType:tightdb_Bool andName:@"BoolCol"]; const size_t BoolCol = 0; + [desc addColumnWithType:tightdb_Int andName:@"IntCol"]; const size_t IntCol = 1; + [desc addColumnWithType:tightdb_Float andName:@"FloatCol"]; const size_t FloatCol = 2; + [desc addColumnWithType:tightdb_Double andName:@"DoubleCol"]; const size_t DoubleCol = 3; + [desc addColumnWithType:tightdb_String andName:@"StringCol"]; const size_t StringCol = 4; + [desc addColumnWithType:tightdb_Binary andName:@"BinaryCol"]; const size_t BinaryCol = 5; + [desc addColumnWithType:tightdb_Date andName:@"DateCol"]; const size_t DateCol = 6; + TightdbDescriptor* subdesc = [desc addColumnTable:@"TableCol"]; const size_t TableCol = 7; + [desc addColumnWithType:tightdb_Mixed andName:@"MixedCol"]; const size_t MixedCol = 8; - [specTableCol addColumnWithType:tightdb_Int andName:@"TableCol_IntCol"]; - [table updateFromSpec]; + [subdesc addColumnWithType:tightdb_Int andName:@"TableCol_IntCol"]; // Verify column types STAssertEquals(tightdb_Bool, [table getColumnType:0], @"First column not bool"); @@ -176,20 +175,20 @@ - (void)testDataTypes_Dynamic const char bin[4] = { 0, 1, 2, 3 }; - TightdbBinary *bin1 = [[TightdbBinary alloc] initWithData:bin size:sizeof bin / 2]; - TightdbBinary *bin2 = [[TightdbBinary alloc] initWithData:bin size:sizeof bin]; + TightdbBinary* bin1 = [[TightdbBinary alloc] initWithData:bin size:sizeof bin / 2]; + TightdbBinary* bin2 = [[TightdbBinary alloc] initWithData:bin size:sizeof bin]; time_t timeNow = [[NSDate date] timeIntervalSince1970]; - TightdbTable *subtab1 = [[TightdbTable alloc] init]; + TightdbTable* subtab1 = [[TightdbTable alloc] init]; [subtab1 addColumnWithType:tightdb_Int andName:@"TableCol_IntCol"]; - TightdbTable *subtab2 = [[TightdbTable alloc] init]; + TightdbTable* subtab2 = [[TightdbTable alloc] init]; [subtab2 addColumnWithType:tightdb_Int andName:@"TableCol_IntCol"]; - TightdbCursor *cursor; + TightdbCursor* cursor; @@ -203,10 +202,10 @@ - (void)testDataTypes_Dynamic - TightdbMixed *mixInt1 = [TightdbMixed mixedWithInt64:1]; - TightdbMixed *mixSubtab = [TightdbMixed mixedWithTable:subtab2]; + TightdbMixed* mixInt1 = [TightdbMixed mixedWithInt64:1]; + TightdbMixed* mixSubtab = [TightdbMixed mixedWithTable:subtab2]; - TightdbCursor *c; + TightdbCursor* c; @@ -236,8 +235,8 @@ - (void)testDataTypes_Dynamic [c setTable: subtab2 inColumn:TableCol]; [c setMixed: mixSubtab inColumn:MixedCol]; - TightdbCursor *row1 = [table cursorAtIndex:0]; - TightdbCursor *row2 = [table cursorAtIndex:1]; + TightdbCursor* row1 = [table cursorAtIndex:0]; + TightdbCursor* row2 = [table cursorAtIndex:1]; STAssertEquals([row1 getBoolInColumn:BoolCol], NO, @"row1.BoolCol"); STAssertEquals([row2 getBoolInColumn:BoolCol], YES, @"row2.BoolCol"); diff --git a/src/tightdb/objc/test/table_delete_all.m b/src/tightdb/objc/test/table_delete_all.m index 762cc43378..577b275d93 100644 --- a/src/tightdb/objc/test/table_delete_all.m +++ b/src/tightdb/objc/test/table_delete_all.m @@ -14,20 +14,19 @@ @implementation MACTestTableDeleteAll -(void)testTableDeleteAll { // Create table with all column types - TightdbTable *table = [[TightdbTable alloc] init]; - TightdbSpec *s = [table getSpec]; - [s addColumnWithType:tightdb_Int andName:@"int"]; - [s addColumnWithType:tightdb_Bool andName:@"bool"]; - [s addColumnWithType:tightdb_Date andName:@"date"]; - [s addColumnWithType:tightdb_String andName:@"string"]; - [s addColumnWithType:tightdb_String andName:@"string_long"]; - [s addColumnWithType:tightdb_String andName:@"string_enum"]; - [s addColumnWithType:tightdb_Binary andName:@"binary"]; - [s addColumnWithType:tightdb_Mixed andName:@"mixed"]; - TightdbSpec *sub = [s addColumnTable:@"tables"]; - [sub addColumnWithType:tightdb_Int andName:@"sub_first"]; - [sub addColumnWithType:tightdb_String andName:@"sub_second"]; - [table updateFromSpec]; + TightdbTable* table = [[TightdbTable alloc] init]; + TightdbDescriptor* desc = [table getDescriptor]; + [desc addColumnWithType:tightdb_Int andName:@"int"]; + [desc addColumnWithType:tightdb_Bool andName:@"bool"]; + [desc addColumnWithType:tightdb_Date andName:@"date"]; + [desc addColumnWithType:tightdb_String andName:@"string"]; + [desc addColumnWithType:tightdb_String andName:@"string_long"]; + [desc addColumnWithType:tightdb_String andName:@"string_enum"]; + [desc addColumnWithType:tightdb_Binary andName:@"binary"]; + [desc addColumnWithType:tightdb_Mixed andName:@"mixed"]; + TightdbDescriptor* subdesc = [desc addColumnTable:@"tables"]; + [subdesc addColumnWithType:tightdb_Int andName:@"sub_first"]; + [subdesc addColumnWithType:tightdb_String andName:@"sub_second"]; // Add some rows for (size_t i = 0; i < 15; ++i) { @@ -66,7 +65,7 @@ -(void)testTableDeleteAll // Add sub-tables if (i == 2) { - TightdbTable *subtable = [table getSubtable:8 ndx:i]; + TightdbTable* subtable = [table getSubtable:8 ndx:i]; [subtable insertInt:0 ndx:0 value:42]; [subtable insertString:1 ndx:0 value:@"meaning"]; [subtable insertDone]; diff --git a/src/tightdb/objc/tightdb.h b/src/tightdb/objc/tightdb.h index a5292b77e5..19f4f2ddd6 100644 --- a/src/tightdb/objc/tightdb.h +++ b/src/tightdb/objc/tightdb.h @@ -42,35 +42,35 @@ TIGHTDB_CURSOR_PROPERTY_DEF(CName1, CType1) \ @class TableName##_View; \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName1, CType1) \ @interface TableName##_Query: TightdbQuery \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName1 *CName1; \ --(TableName##_Query *)group; \ --(TableName##_Query *)or; \ --(TableName##_Query *)endgroup; \ --(TableName##_Query *)subtable:(size_t)column; \ --(TableName##_Query *)parent; \ --(TableName##_View *)findAll; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName1* CName1; \ +-(TableName##_Query*)group; \ +-(TableName##_Query*)or; \ +-(TableName##_Query*)endgroup; \ +-(TableName##_Query*)subtable:(size_t)column; \ +-(TableName##_Query*)parent; \ +-(TableName##_View*)findAll; \ @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; \ +-(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 error:(NSError**)error; \ -(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1; \ --(TableName##_Query *)where; \ --(TableName##_Cursor *)addRow; \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ --(TableName##_Cursor *)cursorAtLastIndex; \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx; \ +-(TableName##_Query*)where; \ +-(TableName##_Cursor*)addRow; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtLastIndex; \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx; \ @end \ @interface TableName##_View: TightdbView \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @end #define TIGHTDB_TABLE_IMPL_1(TableName, CName1, CType1) \ @implementation TableName##_Cursor \ { \ - TightdbAccessor *_##CName1; \ + TightdbAccessor* _##CName1; \ } \ --(id)initWithTable:(TightdbTable *)table ndx:(size_t)ndx \ +-(id)initWithTable:(TightdbTable*)table ndx:(size_t)ndx \ { \ self = [super initWithTable:table ndx:ndx]; \ if (self) { \ @@ -82,7 +82,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName1, CType1) \ @end \ @implementation TableName##_Query \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ -(long)getFastEnumStart \ { \ @@ -92,12 +92,12 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName1, CType1) \ { \ return [self find:ndx]; \ } \ --(TightdbCursor *)getCursor:(long)ndx \ +-(TightdbCursor*)getCursor:(long)ndx \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:ndx]; \ } \ @synthesize CName1 = _CName1; \ --(id)initWithTable:(TightdbTable *)table \ +-(id)initWithTable:(TightdbTable*)table \ { \ self = [super initWithTable:table]; \ if (self) { \ @@ -105,32 +105,32 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName1, CType1) \ } \ return self; \ } \ --(TableName##_Query *)group \ +-(TableName##_Query*)group \ { \ [super group]; \ return self; \ } \ --(TableName##_Query *)or \ +-(TableName##_Query*)or \ { \ [super or]; \ return self; \ } \ --(TableName##_Query *)endgroup \ +-(TableName##_Query*)endgroup \ { \ [super endgroup]; \ return self; \ } \ --(TableName##_Query *)subtable:(size_t)column \ +-(TableName##_Query*)subtable:(size_t)column \ { \ [super subtable:column]; \ return self; \ } \ --(TableName##_Query *)parent \ +-(TableName##_Query*)parent \ { \ [super parent]; \ return self; \ } \ --(TableName##_View *)findAll \ +-(TableName##_View*)findAll \ { \ return [[TableName##_View alloc] initFromQuery:self]; \ } \ @@ -138,22 +138,25 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName1, CType1) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ @implementation TableName \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ \ -(id)_initRaw \ { \ self = [super _initRaw]; \ - if (!self) return nil; \ + if (!self) \ + return nil; \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ return self; \ } \ -(id)init \ { \ self = [super init]; \ - if (!self) return nil; \ - if (![self _addColumns]) return nil; \ + if (!self) \ + return nil; \ + if (![self _addColumns]) \ + return nil; \ \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ return self; \ @@ -162,10 +165,11 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ { \ return [self add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 error:nil]; \ } \ --(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 error:(NSError **)error\ +-(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 error:(NSError**)error\ { \ - const size_t ndx = [self count]; \ - if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 0, ndx, CName1, CType1, error)) return NO; \ + size_t ndx = [self count]; \ + if (!TIGHTDB_COLUMN_INSERT_ERROR(self, 0, ndx, CName1, CType1, error)) \ + return NO; \ return [self insertDoneWithError:error]; \ } \ -(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 \ @@ -173,66 +177,69 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ [self insertDone]; \ } \ --(TableName##_Query *)where \ +-(TableName##_Query*)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ --(TableName##_Cursor *)addRow \ +-(TableName##_Cursor*)addRow \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[super _addRow]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TableName##_Cursor *)cursorAtLastIndex \ +-(TableName##_Cursor*)cursorAtLastIndex \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[self count]-1]; \ } \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx \ { \ [super insertRowAtIndex:ndx]; \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:self ndx:0]; \ } \ -+(BOOL)_checkType:(TightdbSpec *)spec \ ++(BOOL)_checkType:(TightdbDescriptor*)desc \ { \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 0, CName1, CType1) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 0, CName1, CType1) \ return YES; \ } \ -(BOOL)_checkType \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _checkType:spec]) return NO; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _checkType:desc]) \ + return NO; \ return YES; \ } \ -+(BOOL)_addColumns:(TightdbSpec *)spec \ ++(BOOL)_addColumns:(TightdbDescriptor*)desc \ { \ - TIGHTDB_ADD_COLUMN(spec, CName1, CType1) \ + TIGHTDB_ADD_COLUMN(desc, CName1, CType1) \ return YES; \ } \ -(BOOL)_addColumns \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _addColumns:spec]) return NO; \ - [self updateFromSpec]; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _addColumns:desc]) \ + return NO; \ return YES; \ } \ @end \ @implementation TableName##_View \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:0]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:ndx]]; \ } \ @@ -253,38 +260,38 @@ TIGHTDB_CURSOR_PROPERTY_DEF(CName2, CType2) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName1, CType1) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName2, CType2) \ @interface TableName##_Query: TightdbQuery \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName1 *CName1; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName2 *CName2; \ --(TableName##_Query *)group; \ --(TableName##_Query *)or; \ --(TableName##_Query *)endgroup; \ --(TableName##_Query *)subtable:(size_t)column; \ --(TableName##_Query *)parent; \ --(TableName##_View *)findAll; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName1* CName1; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName2* CName2; \ +-(TableName##_Query*)group; \ +-(TableName##_Query*)or; \ +-(TableName##_Query*)endgroup; \ +-(TableName##_Query*)subtable:(size_t)column; \ +-(TableName##_Query*)parent; \ +-(TableName##_View*)findAll; \ @end \ @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; \ +-(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; \ --(TableName##_Query *)where; \ --(TableName##_Cursor *)addRow; \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ --(TableName##_Cursor *)cursorAtLastIndex; \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx; \ +-(TableName##_Query*)where; \ +-(TableName##_Cursor*)addRow; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtLastIndex; \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx; \ @end \ @interface TableName##_View: TightdbView \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @end #define TIGHTDB_TABLE_IMPL_2(TableName, CName1, CType1, CName2, CType2) \ @implementation TableName##_Cursor \ { \ - TightdbAccessor *_##CName1; \ - TightdbAccessor *_##CName2; \ + TightdbAccessor* _##CName1; \ + TightdbAccessor* _##CName2; \ } \ --(id)initWithTable:(TightdbTable *)table ndx:(size_t)ndx \ +-(id)initWithTable:(TightdbTable*)table ndx:(size_t)ndx \ { \ self = [super initWithTable:table ndx:ndx]; \ if (self) { \ @@ -298,7 +305,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName2, CType2) \ @end \ @implementation TableName##_Query \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ -(long)getFastEnumStart \ { \ @@ -308,13 +315,13 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName2, CType2) \ { \ return [self find:ndx]; \ } \ --(TightdbCursor *)getCursor:(long)ndx \ +-(TightdbCursor*)getCursor:(long)ndx \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:ndx]; \ } \ @synthesize CName1 = _CName1; \ @synthesize CName2 = _CName2; \ --(id)initWithTable:(TightdbTable *)table \ +-(id)initWithTable:(TightdbTable*)table \ { \ self = [super initWithTable:table]; \ if (self) { \ @@ -323,32 +330,32 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName2, CType2) \ } \ return self; \ } \ --(TableName##_Query *)group \ +-(TableName##_Query*)group \ { \ [super group]; \ return self; \ } \ --(TableName##_Query *)or \ +-(TableName##_Query*)or \ { \ [super or]; \ return self; \ } \ --(TableName##_Query *)endgroup \ +-(TableName##_Query*)endgroup \ { \ [super endgroup]; \ return self; \ } \ --(TableName##_Query *)subtable:(size_t)column \ +-(TableName##_Query*)subtable:(size_t)column \ { \ [super subtable:column]; \ return self; \ } \ --(TableName##_Query *)parent \ +-(TableName##_Query*)parent \ { \ [super parent]; \ return self; \ } \ --(TableName##_View *)findAll \ +-(TableName##_View*)findAll \ { \ return [[TableName##_View alloc] initFromQuery:self]; \ } \ @@ -357,7 +364,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName2, CType2) \ @implementation TableName \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ @@ -365,7 +372,8 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ -(id)_initRaw \ { \ self = [super _initRaw]; \ - if (!self) return nil; \ + if (!self) \ + return nil; \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ return self; \ @@ -373,8 +381,10 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ -(id)init \ { \ self = [super init]; \ - if (!self) return nil; \ - if (![self _addColumns]) return nil; \ + if (!self) \ + return nil; \ + if (![self _addColumns]) \ + return nil; \ \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ @@ -384,11 +394,13 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ { \ 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\ +-(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 error:(NSError**)error\ { \ - const 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; \ + 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]; \ } \ -(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 \ @@ -397,68 +409,71 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ [self insertDone]; \ } \ --(TableName##_Query *)where \ +-(TableName##_Query*)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ --(TableName##_Cursor *)addRow \ +-(TableName##_Cursor*)addRow \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[super _addRow]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TableName##_Cursor *)cursorAtLastIndex \ +-(TableName##_Cursor*)cursorAtLastIndex \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[self count]-1]; \ } \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx \ { \ [super insertRowAtIndex:ndx]; \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:self ndx:0]; \ } \ -+(BOOL)_checkType:(TightdbSpec *)spec \ ++(BOOL)_checkType:(TightdbDescriptor*)desc \ { \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 0, CName1, CType1) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 1, CName2, CType2) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 0, CName1, CType1) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 1, CName2, CType2) \ return YES; \ } \ -(BOOL)_checkType \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _checkType:spec]) return NO; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _checkType:desc]) \ + return NO; \ return YES; \ } \ -+(BOOL)_addColumns:(TightdbSpec *)spec \ ++(BOOL)_addColumns:(TightdbDescriptor*)desc \ { \ - TIGHTDB_ADD_COLUMN(spec, CName1, CType1) \ - TIGHTDB_ADD_COLUMN(spec, CName2, CType2) \ + TIGHTDB_ADD_COLUMN(desc, CName1, CType1) \ + TIGHTDB_ADD_COLUMN(desc, CName2, CType2) \ return YES; \ } \ -(BOOL)_addColumns \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _addColumns:spec]) return NO; \ - [self updateFromSpec]; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _addColumns:desc]) \ + return NO; \ return YES; \ } \ @end \ @implementation TableName##_View \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:0]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:ndx]]; \ } \ @@ -481,41 +496,41 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName1, CType1) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName2, CType2) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName3, CType3) \ @interface TableName##_Query: TightdbQuery \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName1 *CName1; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName2 *CName2; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName3 *CName3; \ --(TableName##_Query *)group; \ --(TableName##_Query *)or; \ --(TableName##_Query *)endgroup; \ --(TableName##_Query *)subtable:(size_t)column; \ --(TableName##_Query *)parent; \ --(TableName##_View *)findAll; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName1* CName1; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName2* CName2; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName3* CName3; \ +-(TableName##_Query*)group; \ +-(TableName##_Query*)or; \ +-(TableName##_Query*)endgroup; \ +-(TableName##_Query*)subtable:(size_t)column; \ +-(TableName##_Query*)parent; \ +-(TableName##_View*)findAll; \ @end \ @interface TableName: TightdbTable \ 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; \ +-(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; \ --(TableName##_Query *)where; \ --(TableName##_Cursor *)addRow; \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ --(TableName##_Cursor *)cursorAtLastIndex; \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx; \ +-(TableName##_Query*)where; \ +-(TableName##_Cursor*)addRow; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtLastIndex; \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx; \ @end \ @interface TableName##_View: TightdbView \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @end #define TIGHTDB_TABLE_IMPL_3(TableName, CName1, CType1, CName2, CType2, CName3, CType3) \ @implementation TableName##_Cursor \ { \ - TightdbAccessor *_##CName1; \ - TightdbAccessor *_##CName2; \ - TightdbAccessor *_##CName3; \ + TightdbAccessor* _##CName1; \ + TightdbAccessor* _##CName2; \ + TightdbAccessor* _##CName3; \ } \ --(id)initWithTable:(TightdbTable *)table ndx:(size_t)ndx \ +-(id)initWithTable:(TightdbTable*)table ndx:(size_t)ndx \ { \ self = [super initWithTable:table ndx:ndx]; \ if (self) { \ @@ -531,7 +546,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName3, CType3) \ @end \ @implementation TableName##_Query \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ -(long)getFastEnumStart \ { \ @@ -541,14 +556,14 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName3, CType3) \ { \ return [self find:ndx]; \ } \ --(TightdbCursor *)getCursor:(long)ndx \ +-(TightdbCursor*)getCursor:(long)ndx \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:ndx]; \ } \ @synthesize CName1 = _CName1; \ @synthesize CName2 = _CName2; \ @synthesize CName3 = _CName3; \ --(id)initWithTable:(TightdbTable *)table \ +-(id)initWithTable:(TightdbTable*)table \ { \ self = [super initWithTable:table]; \ if (self) { \ @@ -558,32 +573,32 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName3, CType3) \ } \ return self; \ } \ --(TableName##_Query *)group \ +-(TableName##_Query*)group \ { \ [super group]; \ return self; \ } \ --(TableName##_Query *)or \ +-(TableName##_Query*)or \ { \ [super or]; \ return self; \ } \ --(TableName##_Query *)endgroup \ +-(TableName##_Query*)endgroup \ { \ [super endgroup]; \ return self; \ } \ --(TableName##_Query *)subtable:(size_t)column \ +-(TableName##_Query*)subtable:(size_t)column \ { \ [super subtable:column]; \ return self; \ } \ --(TableName##_Query *)parent \ +-(TableName##_Query*)parent \ { \ [super parent]; \ return self; \ } \ --(TableName##_View *)findAll \ +-(TableName##_View*)findAll \ { \ return [[TableName##_View alloc] initFromQuery:self]; \ } \ @@ -593,7 +608,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName2, CType2) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName3, CType3) \ @implementation TableName \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ @@ -602,7 +617,8 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName3, CType3) \ -(id)_initRaw \ { \ self = [super _initRaw]; \ - if (!self) return nil; \ + if (!self) \ + return nil; \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ @@ -611,8 +627,10 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName3, CType3) \ -(id)init \ { \ self = [super init]; \ - if (!self) return nil; \ - if (![self _addColumns]) return nil; \ + if (!self) \ + return nil; \ + if (![self _addColumns]) \ + return nil; \ \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ @@ -623,12 +641,15 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName3, CType3) \ { \ 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\ +-(BOOL)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 error:(NSError**)error\ { \ - const 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; \ + 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]; \ } \ -(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 \ @@ -638,70 +659,73 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName3, CType3) \ TIGHTDB_COLUMN_INSERT(self, 2, ndx, CName3, CType3); \ [self insertDone]; \ } \ --(TableName##_Query *)where \ +-(TableName##_Query*)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ --(TableName##_Cursor *)addRow \ +-(TableName##_Cursor*)addRow \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[super _addRow]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TableName##_Cursor *)cursorAtLastIndex \ +-(TableName##_Cursor*)cursorAtLastIndex \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[self count]-1]; \ } \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx \ { \ [super insertRowAtIndex:ndx]; \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:self ndx:0]; \ } \ -+(BOOL)_checkType:(TightdbSpec *)spec \ ++(BOOL)_checkType:(TightdbDescriptor*)desc \ { \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 0, CName1, CType1) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 1, CName2, CType2) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 2, CName3, CType3) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 0, CName1, CType1) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 1, CName2, CType2) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 2, CName3, CType3) \ return YES; \ } \ -(BOOL)_checkType \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _checkType:spec]) return NO; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _checkType:desc]) \ + return NO; \ return YES; \ } \ -+(BOOL)_addColumns:(TightdbSpec *)spec \ ++(BOOL)_addColumns:(TightdbDescriptor*)desc \ { \ - TIGHTDB_ADD_COLUMN(spec, CName1, CType1) \ - TIGHTDB_ADD_COLUMN(spec, CName2, CType2) \ - TIGHTDB_ADD_COLUMN(spec, CName3, CType3) \ + TIGHTDB_ADD_COLUMN(desc, CName1, CType1) \ + TIGHTDB_ADD_COLUMN(desc, CName2, CType2) \ + TIGHTDB_ADD_COLUMN(desc, CName3, CType3) \ return YES; \ } \ -(BOOL)_addColumns \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _addColumns:spec]) return NO; \ - [self updateFromSpec]; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _addColumns:desc]) \ + return NO; \ return YES; \ } \ @end \ @implementation TableName##_View \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:0]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:ndx]]; \ } \ @@ -726,16 +750,16 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName2, CType2) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName3, CType3) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName4, CType4) \ @interface TableName##_Query: TightdbQuery \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName1 *CName1; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName2 *CName2; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName3 *CName3; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName4 *CName4; \ --(TableName##_Query *)group; \ --(TableName##_Query *)or; \ --(TableName##_Query *)endgroup; \ --(TableName##_Query *)subtable:(size_t)column; \ --(TableName##_Query *)parent; \ --(TableName##_View *)findAll; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName1* CName1; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName2* CName2; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName3* CName3; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName4* CName4; \ +-(TableName##_Query*)group; \ +-(TableName##_Query*)or; \ +-(TableName##_Query*)endgroup; \ +-(TableName##_Query*)subtable:(size_t)column; \ +-(TableName##_Query*)parent; \ +-(TableName##_View*)findAll; \ @end \ @interface TableName: TightdbTable \ TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ @@ -743,27 +767,27 @@ 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; \ +-(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; \ --(TableName##_Query *)where; \ --(TableName##_Cursor *)addRow; \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ --(TableName##_Cursor *)cursorAtLastIndex; \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx; \ +-(TableName##_Query*)where; \ +-(TableName##_Cursor*)addRow; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtLastIndex; \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx; \ @end \ @interface TableName##_View: TightdbView \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @end #define TIGHTDB_TABLE_IMPL_4(TableName, CName1, CType1, CName2, CType2, CName3, CType3, CName4, CType4) \ @implementation TableName##_Cursor \ { \ - TightdbAccessor *_##CName1; \ - TightdbAccessor *_##CName2; \ - TightdbAccessor *_##CName3; \ - TightdbAccessor *_##CName4; \ + TightdbAccessor* _##CName1; \ + TightdbAccessor* _##CName2; \ + TightdbAccessor* _##CName3; \ + TightdbAccessor* _##CName4; \ } \ --(id)initWithTable:(TightdbTable *)table ndx:(size_t)ndx \ +-(id)initWithTable:(TightdbTable*)table ndx:(size_t)ndx \ { \ self = [super initWithTable:table ndx:ndx]; \ if (self) { \ @@ -781,7 +805,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName4, CType4) \ @end \ @implementation TableName##_Query \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ -(long)getFastEnumStart \ { \ @@ -791,7 +815,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName4, CType4) \ { \ return [self find:ndx]; \ } \ --(TightdbCursor *)getCursor:(long)ndx \ +-(TightdbCursor*)getCursor:(long)ndx \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:ndx]; \ } \ @@ -799,7 +823,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName4, CType4) \ @synthesize CName2 = _CName2; \ @synthesize CName3 = _CName3; \ @synthesize CName4 = _CName4; \ --(id)initWithTable:(TightdbTable *)table \ +-(id)initWithTable:(TightdbTable*)table \ { \ self = [super initWithTable:table]; \ if (self) { \ @@ -810,32 +834,32 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName4, CType4) \ } \ return self; \ } \ --(TableName##_Query *)group \ +-(TableName##_Query*)group \ { \ [super group]; \ return self; \ } \ --(TableName##_Query *)or \ +-(TableName##_Query*)or \ { \ [super or]; \ return self; \ } \ --(TableName##_Query *)endgroup \ +-(TableName##_Query*)endgroup \ { \ [super endgroup]; \ return self; \ } \ --(TableName##_Query *)subtable:(size_t)column \ +-(TableName##_Query*)subtable:(size_t)column \ { \ [super subtable:column]; \ return self; \ } \ --(TableName##_Query *)parent \ +-(TableName##_Query*)parent \ { \ [super parent]; \ return self; \ } \ --(TableName##_View *)findAll \ +-(TableName##_View*)findAll \ { \ return [[TableName##_View alloc] initFromQuery:self]; \ } \ @@ -846,7 +870,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName3, CType3) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName4, CType4) \ @implementation TableName \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ @@ -856,7 +880,8 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName4, CType4) \ -(id)_initRaw \ { \ self = [super _initRaw]; \ - if (!self) return nil; \ + if (!self) \ + return nil; \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ @@ -866,8 +891,10 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName4, CType4) \ -(id)init \ { \ self = [super init]; \ - if (!self) return nil; \ - if (![self _addColumns]) return nil; \ + if (!self) \ + return nil; \ + if (![self _addColumns]) \ + return nil; \ \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ @@ -879,13 +906,17 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName4, CType4) \ { \ 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\ -{ \ - const 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; \ +-(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\ +{ \ + 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]; \ } \ -(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 \ @@ -896,72 +927,75 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName4, CType4) \ TIGHTDB_COLUMN_INSERT(self, 3, ndx, CName4, CType4); \ [self insertDone]; \ } \ --(TableName##_Query *)where \ +-(TableName##_Query*)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ --(TableName##_Cursor *)addRow \ +-(TableName##_Cursor*)addRow \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[super _addRow]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TableName##_Cursor *)cursorAtLastIndex \ +-(TableName##_Cursor*)cursorAtLastIndex \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[self count]-1]; \ } \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx \ { \ [super insertRowAtIndex:ndx]; \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:self ndx:0]; \ } \ -+(BOOL)_checkType:(TightdbSpec *)spec \ ++(BOOL)_checkType:(TightdbDescriptor*)desc \ { \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 0, CName1, CType1) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 1, CName2, CType2) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 2, CName3, CType3) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 3, CName4, CType4) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 0, CName1, CType1) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 1, CName2, CType2) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 2, CName3, CType3) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 3, CName4, CType4) \ return YES; \ } \ -(BOOL)_checkType \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _checkType:spec]) return NO; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _checkType:desc]) \ + return NO; \ return YES; \ } \ -+(BOOL)_addColumns:(TightdbSpec *)spec \ ++(BOOL)_addColumns:(TightdbDescriptor*)desc \ { \ - TIGHTDB_ADD_COLUMN(spec, CName1, CType1) \ - TIGHTDB_ADD_COLUMN(spec, CName2, CType2) \ - TIGHTDB_ADD_COLUMN(spec, CName3, CType3) \ - TIGHTDB_ADD_COLUMN(spec, CName4, CType4) \ + TIGHTDB_ADD_COLUMN(desc, CName1, CType1) \ + TIGHTDB_ADD_COLUMN(desc, CName2, CType2) \ + TIGHTDB_ADD_COLUMN(desc, CName3, CType3) \ + TIGHTDB_ADD_COLUMN(desc, CName4, CType4) \ return YES; \ } \ -(BOOL)_addColumns \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _addColumns:spec]) return NO; \ - [self updateFromSpec]; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _addColumns:desc]) \ + return NO; \ return YES; \ } \ @end \ @implementation TableName##_View \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:0]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:ndx]]; \ } \ @@ -988,17 +1022,17 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName3, CType3) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName4, CType4) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName5, CType5) \ @interface TableName##_Query: TightdbQuery \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName1 *CName1; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName2 *CName2; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName3 *CName3; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName4 *CName4; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName5 *CName5; \ --(TableName##_Query *)group; \ --(TableName##_Query *)or; \ --(TableName##_Query *)endgroup; \ --(TableName##_Query *)subtable:(size_t)column; \ --(TableName##_Query *)parent; \ --(TableName##_View *)findAll; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName1* CName1; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName2* CName2; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName3* CName3; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName4* CName4; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName5* CName5; \ +-(TableName##_Query*)group; \ +-(TableName##_Query*)or; \ +-(TableName##_Query*)endgroup; \ +-(TableName##_Query*)subtable:(size_t)column; \ +-(TableName##_Query*)parent; \ +-(TableName##_View*)findAll; \ @end \ @interface TableName: TightdbTable \ TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ @@ -1007,28 +1041,28 @@ 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; \ +-(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; \ --(TableName##_Query *)where; \ --(TableName##_Cursor *)addRow; \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ --(TableName##_Cursor *)cursorAtLastIndex; \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx; \ +-(TableName##_Query*)where; \ +-(TableName##_Cursor*)addRow; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtLastIndex; \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx; \ @end \ @interface TableName##_View: TightdbView \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @end #define TIGHTDB_TABLE_IMPL_5(TableName, CName1, CType1, CName2, CType2, CName3, CType3, CName4, CType4, CName5, CType5) \ @implementation TableName##_Cursor \ { \ - TightdbAccessor *_##CName1; \ - TightdbAccessor *_##CName2; \ - TightdbAccessor *_##CName3; \ - TightdbAccessor *_##CName4; \ - TightdbAccessor *_##CName5; \ + TightdbAccessor* _##CName1; \ + TightdbAccessor* _##CName2; \ + TightdbAccessor* _##CName3; \ + TightdbAccessor* _##CName4; \ + TightdbAccessor* _##CName5; \ } \ --(id)initWithTable:(TightdbTable *)table ndx:(size_t)ndx \ +-(id)initWithTable:(TightdbTable*)table ndx:(size_t)ndx \ { \ self = [super initWithTable:table ndx:ndx]; \ if (self) { \ @@ -1048,7 +1082,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName5, CType5) \ @end \ @implementation TableName##_Query \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ -(long)getFastEnumStart \ { \ @@ -1058,7 +1092,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName5, CType5) \ { \ return [self find:ndx]; \ } \ --(TightdbCursor *)getCursor:(long)ndx \ +-(TightdbCursor*)getCursor:(long)ndx \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:ndx]; \ } \ @@ -1067,7 +1101,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName5, CType5) \ @synthesize CName3 = _CName3; \ @synthesize CName4 = _CName4; \ @synthesize CName5 = _CName5; \ --(id)initWithTable:(TightdbTable *)table \ +-(id)initWithTable:(TightdbTable*)table \ { \ self = [super initWithTable:table]; \ if (self) { \ @@ -1079,32 +1113,32 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName5, CType5) \ } \ return self; \ } \ --(TableName##_Query *)group \ +-(TableName##_Query*)group \ { \ [super group]; \ return self; \ } \ --(TableName##_Query *)or \ +-(TableName##_Query*)or \ { \ [super or]; \ return self; \ } \ --(TableName##_Query *)endgroup \ +-(TableName##_Query*)endgroup \ { \ [super endgroup]; \ return self; \ } \ --(TableName##_Query *)subtable:(size_t)column \ +-(TableName##_Query*)subtable:(size_t)column \ { \ [super subtable:column]; \ return self; \ } \ --(TableName##_Query *)parent \ +-(TableName##_Query*)parent \ { \ [super parent]; \ return self; \ } \ --(TableName##_View *)findAll \ +-(TableName##_View*)findAll \ { \ return [[TableName##_View alloc] initFromQuery:self]; \ } \ @@ -1116,7 +1150,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName4, CType4) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName5, CType5) \ @implementation TableName \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ @@ -1127,7 +1161,8 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName5, CType5) \ -(id)_initRaw \ { \ self = [super _initRaw]; \ - if (!self) return nil; \ + if (!self) \ + return nil; \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ @@ -1138,8 +1173,10 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName5, CType5) \ -(id)init \ { \ self = [super init]; \ - if (!self) return nil; \ - if (![self _addColumns]) return nil; \ + if (!self) \ + return nil; \ + if (![self _addColumns]) \ + return nil; \ \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ @@ -1152,14 +1189,19 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName5, CType5) \ { \ 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\ -{ \ - const 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; \ +-(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\ +{ \ + 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]; \ } \ -(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 \ @@ -1171,74 +1213,77 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName5, CType5) \ TIGHTDB_COLUMN_INSERT(self, 4, ndx, CName5, CType5); \ [self insertDone]; \ } \ --(TableName##_Query *)where \ +-(TableName##_Query*)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ --(TableName##_Cursor *)addRow \ +-(TableName##_Cursor*)addRow \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[super _addRow]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TableName##_Cursor *)cursorAtLastIndex \ +-(TableName##_Cursor*)cursorAtLastIndex \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[self count]-1]; \ } \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx \ { \ [super insertRowAtIndex:ndx]; \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:self ndx:0]; \ } \ -+(BOOL)_checkType:(TightdbSpec *)spec \ ++(BOOL)_checkType:(TightdbDescriptor*)desc \ { \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 0, CName1, CType1) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 1, CName2, CType2) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 2, CName3, CType3) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 3, CName4, CType4) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 4, CName5, CType5) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 0, CName1, CType1) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 1, CName2, CType2) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 2, CName3, CType3) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 3, CName4, CType4) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 4, CName5, CType5) \ return YES; \ } \ -(BOOL)_checkType \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _checkType:spec]) return NO; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _checkType:desc]) \ + return NO; \ return YES; \ } \ -+(BOOL)_addColumns:(TightdbSpec *)spec \ ++(BOOL)_addColumns:(TightdbDescriptor*)desc \ { \ - TIGHTDB_ADD_COLUMN(spec, CName1, CType1) \ - TIGHTDB_ADD_COLUMN(spec, CName2, CType2) \ - TIGHTDB_ADD_COLUMN(spec, CName3, CType3) \ - TIGHTDB_ADD_COLUMN(spec, CName4, CType4) \ - TIGHTDB_ADD_COLUMN(spec, CName5, CType5) \ + TIGHTDB_ADD_COLUMN(desc, CName1, CType1) \ + TIGHTDB_ADD_COLUMN(desc, CName2, CType2) \ + TIGHTDB_ADD_COLUMN(desc, CName3, CType3) \ + TIGHTDB_ADD_COLUMN(desc, CName4, CType4) \ + TIGHTDB_ADD_COLUMN(desc, CName5, CType5) \ return YES; \ } \ -(BOOL)_addColumns \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _addColumns:spec]) return NO; \ - [self updateFromSpec]; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _addColumns:desc]) \ + return NO; \ return YES; \ } \ @end \ @implementation TableName##_View \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:0]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:ndx]]; \ } \ @@ -1267,18 +1312,18 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName4, CType4) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName5, CType5) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName6, CType6) \ @interface TableName##_Query: TightdbQuery \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName1 *CName1; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName2 *CName2; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName3 *CName3; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName4 *CName4; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName5 *CName5; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName6 *CName6; \ --(TableName##_Query *)group; \ --(TableName##_Query *)or; \ --(TableName##_Query *)endgroup; \ --(TableName##_Query *)subtable:(size_t)column; \ --(TableName##_Query *)parent; \ --(TableName##_View *)findAll; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName1* CName1; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName2* CName2; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName3* CName3; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName4* CName4; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName5* CName5; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName6* CName6; \ +-(TableName##_Query*)group; \ +-(TableName##_Query*)or; \ +-(TableName##_Query*)endgroup; \ +-(TableName##_Query*)subtable:(size_t)column; \ +-(TableName##_Query*)parent; \ +-(TableName##_View*)findAll; \ @end \ @interface TableName: TightdbTable \ TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ @@ -1288,29 +1333,29 @@ 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; \ +-(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; \ --(TableName##_Query *)where; \ --(TableName##_Cursor *)addRow; \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ --(TableName##_Cursor *)cursorAtLastIndex; \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx; \ +-(TableName##_Query*)where; \ +-(TableName##_Cursor*)addRow; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtLastIndex; \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx; \ @end \ @interface TableName##_View: TightdbView \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @end #define TIGHTDB_TABLE_IMPL_6(TableName, CName1, CType1, CName2, CType2, CName3, CType3, CName4, CType4, CName5, CType5, CName6, CType6) \ @implementation TableName##_Cursor \ { \ - TightdbAccessor *_##CName1; \ - TightdbAccessor *_##CName2; \ - TightdbAccessor *_##CName3; \ - TightdbAccessor *_##CName4; \ - TightdbAccessor *_##CName5; \ - TightdbAccessor *_##CName6; \ + TightdbAccessor* _##CName1; \ + TightdbAccessor* _##CName2; \ + TightdbAccessor* _##CName3; \ + TightdbAccessor* _##CName4; \ + TightdbAccessor* _##CName5; \ + TightdbAccessor* _##CName6; \ } \ --(id)initWithTable:(TightdbTable *)table ndx:(size_t)ndx \ +-(id)initWithTable:(TightdbTable*)table ndx:(size_t)ndx \ { \ self = [super initWithTable:table ndx:ndx]; \ if (self) { \ @@ -1332,7 +1377,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName6, CType6) \ @end \ @implementation TableName##_Query \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ -(long)getFastEnumStart \ { \ @@ -1342,7 +1387,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName6, CType6) \ { \ return [self find:ndx]; \ } \ --(TightdbCursor *)getCursor:(long)ndx \ +-(TightdbCursor*)getCursor:(long)ndx \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:ndx]; \ } \ @@ -1352,7 +1397,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName6, CType6) \ @synthesize CName4 = _CName4; \ @synthesize CName5 = _CName5; \ @synthesize CName6 = _CName6; \ --(id)initWithTable:(TightdbTable *)table \ +-(id)initWithTable:(TightdbTable*)table \ { \ self = [super initWithTable:table]; \ if (self) { \ @@ -1365,32 +1410,32 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName6, CType6) \ } \ return self; \ } \ --(TableName##_Query *)group \ +-(TableName##_Query*)group \ { \ [super group]; \ return self; \ } \ --(TableName##_Query *)or \ +-(TableName##_Query*)or \ { \ [super or]; \ return self; \ } \ --(TableName##_Query *)endgroup \ +-(TableName##_Query*)endgroup \ { \ [super endgroup]; \ return self; \ } \ --(TableName##_Query *)subtable:(size_t)column \ +-(TableName##_Query*)subtable:(size_t)column \ { \ [super subtable:column]; \ return self; \ } \ --(TableName##_Query *)parent \ +-(TableName##_Query*)parent \ { \ [super parent]; \ return self; \ } \ --(TableName##_View *)findAll \ +-(TableName##_View*)findAll \ { \ return [[TableName##_View alloc] initFromQuery:self]; \ } \ @@ -1403,7 +1448,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName5, CType5) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName6, CType6) \ @implementation TableName \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ @@ -1415,7 +1460,8 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName6, CType6) \ -(id)_initRaw \ { \ self = [super _initRaw]; \ - if (!self) return nil; \ + if (!self) \ + return nil; \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ @@ -1427,8 +1473,10 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName6, CType6) \ -(id)init \ { \ self = [super init]; \ - if (!self) return nil; \ - if (![self _addColumns]) return nil; \ + if (!self) \ + return nil; \ + if (![self _addColumns]) \ + return nil; \ \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ @@ -1442,15 +1490,21 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName6, CType6) \ { \ 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\ -{ \ - const 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; \ +-(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\ +{ \ + 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]; \ } \ -(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 \ @@ -1463,76 +1517,79 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName6, CType6) \ TIGHTDB_COLUMN_INSERT(self, 5, ndx, CName6, CType6); \ [self insertDone]; \ } \ --(TableName##_Query *)where \ +-(TableName##_Query*)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ --(TableName##_Cursor *)addRow \ +-(TableName##_Cursor*)addRow \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[super _addRow]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TableName##_Cursor *)cursorAtLastIndex \ +-(TableName##_Cursor*)cursorAtLastIndex \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[self count]-1]; \ } \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx \ { \ [super insertRowAtIndex:ndx]; \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:self ndx:0]; \ } \ -+(BOOL)_checkType:(TightdbSpec *)spec \ ++(BOOL)_checkType:(TightdbDescriptor*)desc \ { \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 0, CName1, CType1) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 1, CName2, CType2) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 2, CName3, CType3) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 3, CName4, CType4) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 4, CName5, CType5) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 5, CName6, CType6) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 0, CName1, CType1) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 1, CName2, CType2) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 2, CName3, CType3) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 3, CName4, CType4) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 4, CName5, CType5) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 5, CName6, CType6) \ return YES; \ } \ -(BOOL)_checkType \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _checkType:spec]) return NO; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _checkType:desc]) \ + return NO; \ return YES; \ } \ -+(BOOL)_addColumns:(TightdbSpec *)spec \ ++(BOOL)_addColumns:(TightdbDescriptor*)desc \ { \ - TIGHTDB_ADD_COLUMN(spec, CName1, CType1) \ - TIGHTDB_ADD_COLUMN(spec, CName2, CType2) \ - TIGHTDB_ADD_COLUMN(spec, CName3, CType3) \ - TIGHTDB_ADD_COLUMN(spec, CName4, CType4) \ - TIGHTDB_ADD_COLUMN(spec, CName5, CType5) \ - TIGHTDB_ADD_COLUMN(spec, CName6, CType6) \ + TIGHTDB_ADD_COLUMN(desc, CName1, CType1) \ + TIGHTDB_ADD_COLUMN(desc, CName2, CType2) \ + TIGHTDB_ADD_COLUMN(desc, CName3, CType3) \ + TIGHTDB_ADD_COLUMN(desc, CName4, CType4) \ + TIGHTDB_ADD_COLUMN(desc, CName5, CType5) \ + TIGHTDB_ADD_COLUMN(desc, CName6, CType6) \ return YES; \ } \ -(BOOL)_addColumns \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _addColumns:spec]) return NO; \ - [self updateFromSpec]; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _addColumns:desc]) \ + return NO; \ return YES; \ } \ @end \ @implementation TableName##_View \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:0]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:ndx]]; \ } \ @@ -1563,19 +1620,19 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName5, CType5) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName6, CType6) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName7, CType7) \ @interface TableName##_Query: TightdbQuery \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName1 *CName1; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName2 *CName2; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName3 *CName3; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName4 *CName4; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName5 *CName5; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName6 *CName6; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName7 *CName7; \ --(TableName##_Query *)group; \ --(TableName##_Query *)or; \ --(TableName##_Query *)endgroup; \ --(TableName##_Query *)subtable:(size_t)column; \ --(TableName##_Query *)parent; \ --(TableName##_View *)findAll; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName1* CName1; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName2* CName2; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName3* CName3; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName4* CName4; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName5* CName5; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName6* CName6; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName7* CName7; \ +-(TableName##_Query*)group; \ +-(TableName##_Query*)or; \ +-(TableName##_Query*)endgroup; \ +-(TableName##_Query*)subtable:(size_t)column; \ +-(TableName##_Query*)parent; \ +-(TableName##_View*)findAll; \ @end \ @interface TableName: TightdbTable \ TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ @@ -1586,30 +1643,30 @@ 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; \ +-(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; \ --(TableName##_Query *)where; \ --(TableName##_Cursor *)addRow; \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ --(TableName##_Cursor *)cursorAtLastIndex; \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx; \ +-(TableName##_Query*)where; \ +-(TableName##_Cursor*)addRow; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtLastIndex; \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx; \ @end \ @interface TableName##_View: TightdbView \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @end #define TIGHTDB_TABLE_IMPL_7(TableName, CName1, CType1, CName2, CType2, CName3, CType3, CName4, CType4, CName5, CType5, CName6, CType6, CName7, CType7) \ @implementation TableName##_Cursor \ { \ - TightdbAccessor *_##CName1; \ - TightdbAccessor *_##CName2; \ - TightdbAccessor *_##CName3; \ - TightdbAccessor *_##CName4; \ - TightdbAccessor *_##CName5; \ - TightdbAccessor *_##CName6; \ - TightdbAccessor *_##CName7; \ + TightdbAccessor* _##CName1; \ + TightdbAccessor* _##CName2; \ + TightdbAccessor* _##CName3; \ + TightdbAccessor* _##CName4; \ + TightdbAccessor* _##CName5; \ + TightdbAccessor* _##CName6; \ + TightdbAccessor* _##CName7; \ } \ --(id)initWithTable:(TightdbTable *)table ndx:(size_t)ndx \ +-(id)initWithTable:(TightdbTable*)table ndx:(size_t)ndx \ { \ self = [super initWithTable:table ndx:ndx]; \ if (self) { \ @@ -1633,7 +1690,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName7, CType7) \ @end \ @implementation TableName##_Query \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ -(long)getFastEnumStart \ { \ @@ -1643,7 +1700,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName7, CType7) \ { \ return [self find:ndx]; \ } \ --(TightdbCursor *)getCursor:(long)ndx \ +-(TightdbCursor*)getCursor:(long)ndx \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:ndx]; \ } \ @@ -1654,7 +1711,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName7, CType7) \ @synthesize CName5 = _CName5; \ @synthesize CName6 = _CName6; \ @synthesize CName7 = _CName7; \ --(id)initWithTable:(TightdbTable *)table \ +-(id)initWithTable:(TightdbTable*)table \ { \ self = [super initWithTable:table]; \ if (self) { \ @@ -1668,32 +1725,32 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName7, CType7) \ } \ return self; \ } \ --(TableName##_Query *)group \ +-(TableName##_Query*)group \ { \ [super group]; \ return self; \ } \ --(TableName##_Query *)or \ +-(TableName##_Query*)or \ { \ [super or]; \ return self; \ } \ --(TableName##_Query *)endgroup \ +-(TableName##_Query*)endgroup \ { \ [super endgroup]; \ return self; \ } \ --(TableName##_Query *)subtable:(size_t)column \ +-(TableName##_Query*)subtable:(size_t)column \ { \ [super subtable:column]; \ return self; \ } \ --(TableName##_Query *)parent \ +-(TableName##_Query*)parent \ { \ [super parent]; \ return self; \ } \ --(TableName##_View *)findAll \ +-(TableName##_View*)findAll \ { \ return [[TableName##_View alloc] initFromQuery:self]; \ } \ @@ -1707,7 +1764,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName6, CType6) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName7, CType7) \ @implementation TableName \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ @@ -1720,7 +1777,8 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName7, CType7) \ -(id)_initRaw \ { \ self = [super _initRaw]; \ - if (!self) return nil; \ + if (!self) \ + return nil; \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ @@ -1733,8 +1791,10 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName7, CType7) \ -(id)init \ { \ self = [super init]; \ - if (!self) return nil; \ - if (![self _addColumns]) return nil; \ + if (!self) \ + return nil; \ + if (![self _addColumns]) \ + return nil; \ \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ @@ -1749,16 +1809,23 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName7, CType7) \ { \ 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\ -{ \ - const 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; \ +-(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\ +{ \ + 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]; \ } \ -(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 \ @@ -1772,78 +1839,81 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName7, CType7) \ TIGHTDB_COLUMN_INSERT(self, 6, ndx, CName7, CType7); \ [self insertDone]; \ } \ --(TableName##_Query *)where \ +-(TableName##_Query*)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ --(TableName##_Cursor *)addRow \ +-(TableName##_Cursor*)addRow \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[super _addRow]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TableName##_Cursor *)cursorAtLastIndex \ +-(TableName##_Cursor*)cursorAtLastIndex \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[self count]-1]; \ } \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx \ { \ [super insertRowAtIndex:ndx]; \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:self ndx:0]; \ } \ -+(BOOL)_checkType:(TightdbSpec *)spec \ ++(BOOL)_checkType:(TightdbDescriptor*)desc \ { \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 0, CName1, CType1) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 1, CName2, CType2) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 2, CName3, CType3) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 3, CName4, CType4) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 4, CName5, CType5) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 5, CName6, CType6) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 6, CName7, CType7) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 0, CName1, CType1) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 1, CName2, CType2) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 2, CName3, CType3) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 3, CName4, CType4) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 4, CName5, CType5) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 5, CName6, CType6) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 6, CName7, CType7) \ return YES; \ } \ -(BOOL)_checkType \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _checkType:spec]) return NO; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _checkType:desc]) \ + return NO; \ return YES; \ } \ -+(BOOL)_addColumns:(TightdbSpec *)spec \ ++(BOOL)_addColumns:(TightdbDescriptor*)desc \ { \ - TIGHTDB_ADD_COLUMN(spec, CName1, CType1) \ - TIGHTDB_ADD_COLUMN(spec, CName2, CType2) \ - TIGHTDB_ADD_COLUMN(spec, CName3, CType3) \ - TIGHTDB_ADD_COLUMN(spec, CName4, CType4) \ - TIGHTDB_ADD_COLUMN(spec, CName5, CType5) \ - TIGHTDB_ADD_COLUMN(spec, CName6, CType6) \ - TIGHTDB_ADD_COLUMN(spec, CName7, CType7) \ + TIGHTDB_ADD_COLUMN(desc, CName1, CType1) \ + TIGHTDB_ADD_COLUMN(desc, CName2, CType2) \ + TIGHTDB_ADD_COLUMN(desc, CName3, CType3) \ + TIGHTDB_ADD_COLUMN(desc, CName4, CType4) \ + TIGHTDB_ADD_COLUMN(desc, CName5, CType5) \ + TIGHTDB_ADD_COLUMN(desc, CName6, CType6) \ + TIGHTDB_ADD_COLUMN(desc, CName7, CType7) \ return YES; \ } \ -(BOOL)_addColumns \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _addColumns:spec]) return NO; \ - [self updateFromSpec]; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _addColumns:desc]) \ + return NO; \ return YES; \ } \ @end \ @implementation TableName##_View \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:0]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:ndx]]; \ } \ @@ -1876,20 +1946,20 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName6, CType6) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName7, CType7) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName8, CType8) \ @interface TableName##_Query: TightdbQuery \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName1 *CName1; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName2 *CName2; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName3 *CName3; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName4 *CName4; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName5 *CName5; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName6 *CName6; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName7 *CName7; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName8 *CName8; \ --(TableName##_Query *)group; \ --(TableName##_Query *)or; \ --(TableName##_Query *)endgroup; \ --(TableName##_Query *)subtable:(size_t)column; \ --(TableName##_Query *)parent; \ --(TableName##_View *)findAll; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName1* CName1; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName2* CName2; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName3* CName3; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName4* CName4; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName5* CName5; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName6* CName6; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName7* CName7; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName8* CName8; \ +-(TableName##_Query*)group; \ +-(TableName##_Query*)or; \ +-(TableName##_Query*)endgroup; \ +-(TableName##_Query*)subtable:(size_t)column; \ +-(TableName##_Query*)parent; \ +-(TableName##_View*)findAll; \ @end \ @interface TableName: TightdbTable \ TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ @@ -1901,31 +1971,31 @@ 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; \ +-(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; \ --(TableName##_Query *)where; \ --(TableName##_Cursor *)addRow; \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ --(TableName##_Cursor *)cursorAtLastIndex; \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx; \ +-(TableName##_Query*)where; \ +-(TableName##_Cursor*)addRow; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtLastIndex; \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx; \ @end \ @interface TableName##_View: TightdbView \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @end #define TIGHTDB_TABLE_IMPL_8(TableName, CName1, CType1, CName2, CType2, CName3, CType3, CName4, CType4, CName5, CType5, CName6, CType6, CName7, CType7, CName8, CType8) \ @implementation TableName##_Cursor \ { \ - TightdbAccessor *_##CName1; \ - TightdbAccessor *_##CName2; \ - TightdbAccessor *_##CName3; \ - TightdbAccessor *_##CName4; \ - TightdbAccessor *_##CName5; \ - TightdbAccessor *_##CName6; \ - TightdbAccessor *_##CName7; \ - TightdbAccessor *_##CName8; \ + TightdbAccessor* _##CName1; \ + TightdbAccessor* _##CName2; \ + TightdbAccessor* _##CName3; \ + TightdbAccessor* _##CName4; \ + TightdbAccessor* _##CName5; \ + TightdbAccessor* _##CName6; \ + TightdbAccessor* _##CName7; \ + TightdbAccessor* _##CName8; \ } \ --(id)initWithTable:(TightdbTable *)table ndx:(size_t)ndx \ +-(id)initWithTable:(TightdbTable*)table ndx:(size_t)ndx \ { \ self = [super initWithTable:table ndx:ndx]; \ if (self) { \ @@ -1951,7 +2021,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName8, CType8) \ @end \ @implementation TableName##_Query \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ -(long)getFastEnumStart \ { \ @@ -1961,7 +2031,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName8, CType8) \ { \ return [self find:ndx]; \ } \ --(TightdbCursor *)getCursor:(long)ndx \ +-(TightdbCursor*)getCursor:(long)ndx \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:ndx]; \ } \ @@ -1973,7 +2043,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName8, CType8) \ @synthesize CName6 = _CName6; \ @synthesize CName7 = _CName7; \ @synthesize CName8 = _CName8; \ --(id)initWithTable:(TightdbTable *)table \ +-(id)initWithTable:(TightdbTable*)table \ { \ self = [super initWithTable:table]; \ if (self) { \ @@ -1988,32 +2058,32 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName8, CType8) \ } \ return self; \ } \ --(TableName##_Query *)group \ +-(TableName##_Query*)group \ { \ [super group]; \ return self; \ } \ --(TableName##_Query *)or \ +-(TableName##_Query*)or \ { \ [super or]; \ return self; \ } \ --(TableName##_Query *)endgroup \ +-(TableName##_Query*)endgroup \ { \ [super endgroup]; \ return self; \ } \ --(TableName##_Query *)subtable:(size_t)column \ +-(TableName##_Query*)subtable:(size_t)column \ { \ [super subtable:column]; \ return self; \ } \ --(TableName##_Query *)parent \ +-(TableName##_Query*)parent \ { \ [super parent]; \ return self; \ } \ --(TableName##_View *)findAll \ +-(TableName##_View*)findAll \ { \ return [[TableName##_View alloc] initFromQuery:self]; \ } \ @@ -2028,7 +2098,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName7, CType7) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName8, CType8) \ @implementation TableName \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ @@ -2042,7 +2112,8 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName8, CType8) \ -(id)_initRaw \ { \ self = [super _initRaw]; \ - if (!self) return nil; \ + if (!self) \ + return nil; \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ @@ -2056,8 +2127,10 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName8, CType8) \ -(id)init \ { \ self = [super init]; \ - if (!self) return nil; \ - if (![self _addColumns]) return nil; \ + if (!self) \ + return nil; \ + if (![self _addColumns]) \ + return nil; \ \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ @@ -2073,17 +2146,25 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName8, CType8) \ { \ 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\ -{ \ - const 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; \ +-(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\ +{ \ + 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]; \ } \ -(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 \ @@ -2098,80 +2179,83 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName8, CType8) \ TIGHTDB_COLUMN_INSERT(self, 7, ndx, CName8, CType8); \ [self insertDone]; \ } \ --(TableName##_Query *)where \ +-(TableName##_Query*)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ --(TableName##_Cursor *)addRow \ +-(TableName##_Cursor*)addRow \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[super _addRow]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TableName##_Cursor *)cursorAtLastIndex \ +-(TableName##_Cursor*)cursorAtLastIndex \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[self count]-1]; \ } \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx \ { \ [super insertRowAtIndex:ndx]; \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:self ndx:0]; \ } \ -+(BOOL)_checkType:(TightdbSpec *)spec \ ++(BOOL)_checkType:(TightdbDescriptor*)desc \ { \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 0, CName1, CType1) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 1, CName2, CType2) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 2, CName3, CType3) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 3, CName4, CType4) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 4, CName5, CType5) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 5, CName6, CType6) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 6, CName7, CType7) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 7, CName8, CType8) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 0, CName1, CType1) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 1, CName2, CType2) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 2, CName3, CType3) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 3, CName4, CType4) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 4, CName5, CType5) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 5, CName6, CType6) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 6, CName7, CType7) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 7, CName8, CType8) \ return YES; \ } \ -(BOOL)_checkType \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _checkType:spec]) return NO; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _checkType:desc]) \ + return NO; \ return YES; \ } \ -+(BOOL)_addColumns:(TightdbSpec *)spec \ ++(BOOL)_addColumns:(TightdbDescriptor*)desc \ { \ - TIGHTDB_ADD_COLUMN(spec, CName1, CType1) \ - TIGHTDB_ADD_COLUMN(spec, CName2, CType2) \ - TIGHTDB_ADD_COLUMN(spec, CName3, CType3) \ - TIGHTDB_ADD_COLUMN(spec, CName4, CType4) \ - TIGHTDB_ADD_COLUMN(spec, CName5, CType5) \ - TIGHTDB_ADD_COLUMN(spec, CName6, CType6) \ - TIGHTDB_ADD_COLUMN(spec, CName7, CType7) \ - TIGHTDB_ADD_COLUMN(spec, CName8, CType8) \ + TIGHTDB_ADD_COLUMN(desc, CName1, CType1) \ + TIGHTDB_ADD_COLUMN(desc, CName2, CType2) \ + TIGHTDB_ADD_COLUMN(desc, CName3, CType3) \ + TIGHTDB_ADD_COLUMN(desc, CName4, CType4) \ + TIGHTDB_ADD_COLUMN(desc, CName5, CType5) \ + TIGHTDB_ADD_COLUMN(desc, CName6, CType6) \ + TIGHTDB_ADD_COLUMN(desc, CName7, CType7) \ + TIGHTDB_ADD_COLUMN(desc, CName8, CType8) \ return YES; \ } \ -(BOOL)_addColumns \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _addColumns:spec]) return NO; \ - [self updateFromSpec]; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _addColumns:desc]) \ + return NO; \ return YES; \ } \ @end \ @implementation TableName##_View \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:0]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:ndx]]; \ } \ @@ -2206,21 +2290,21 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName7, CType7) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName8, CType8) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName9, CType9) \ @interface TableName##_Query: TightdbQuery \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName1 *CName1; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName2 *CName2; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName3 *CName3; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName4 *CName4; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName5 *CName5; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName6 *CName6; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName7 *CName7; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName8 *CName8; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName9 *CName9; \ --(TableName##_Query *)group; \ --(TableName##_Query *)or; \ --(TableName##_Query *)endgroup; \ --(TableName##_Query *)subtable:(size_t)column; \ --(TableName##_Query *)parent; \ --(TableName##_View *)findAll; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName1* CName1; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName2* CName2; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName3* CName3; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName4* CName4; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName5* CName5; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName6* CName6; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName7* CName7; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName8* CName8; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName9* CName9; \ +-(TableName##_Query*)group; \ +-(TableName##_Query*)or; \ +-(TableName##_Query*)endgroup; \ +-(TableName##_Query*)subtable:(size_t)column; \ +-(TableName##_Query*)parent; \ +-(TableName##_View*)findAll; \ @end \ @interface TableName: TightdbTable \ TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ @@ -2233,32 +2317,32 @@ 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; \ +-(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; \ --(TableName##_Query *)where; \ --(TableName##_Cursor *)addRow; \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ --(TableName##_Cursor *)cursorAtLastIndex; \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx; \ +-(TableName##_Query*)where; \ +-(TableName##_Cursor*)addRow; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtLastIndex; \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx; \ @end \ @interface TableName##_View: TightdbView \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @end #define TIGHTDB_TABLE_IMPL_9(TableName, CName1, CType1, CName2, CType2, CName3, CType3, CName4, CType4, CName5, CType5, CName6, CType6, CName7, CType7, CName8, CType8, CName9, CType9) \ @implementation TableName##_Cursor \ { \ - TightdbAccessor *_##CName1; \ - TightdbAccessor *_##CName2; \ - TightdbAccessor *_##CName3; \ - TightdbAccessor *_##CName4; \ - TightdbAccessor *_##CName5; \ - TightdbAccessor *_##CName6; \ - TightdbAccessor *_##CName7; \ - TightdbAccessor *_##CName8; \ - TightdbAccessor *_##CName9; \ + TightdbAccessor* _##CName1; \ + TightdbAccessor* _##CName2; \ + TightdbAccessor* _##CName3; \ + TightdbAccessor* _##CName4; \ + TightdbAccessor* _##CName5; \ + TightdbAccessor* _##CName6; \ + TightdbAccessor* _##CName7; \ + TightdbAccessor* _##CName8; \ + TightdbAccessor* _##CName9; \ } \ --(id)initWithTable:(TightdbTable *)table ndx:(size_t)ndx \ +-(id)initWithTable:(TightdbTable*)table ndx:(size_t)ndx \ { \ self = [super initWithTable:table ndx:ndx]; \ if (self) { \ @@ -2286,7 +2370,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName9, CType9) \ @end \ @implementation TableName##_Query \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ -(long)getFastEnumStart \ { \ @@ -2296,7 +2380,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName9, CType9) \ { \ return [self find:ndx]; \ } \ --(TightdbCursor *)getCursor:(long)ndx \ +-(TightdbCursor*)getCursor:(long)ndx \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:ndx]; \ } \ @@ -2309,7 +2393,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName9, CType9) \ @synthesize CName7 = _CName7; \ @synthesize CName8 = _CName8; \ @synthesize CName9 = _CName9; \ --(id)initWithTable:(TightdbTable *)table \ +-(id)initWithTable:(TightdbTable*)table \ { \ self = [super initWithTable:table]; \ if (self) { \ @@ -2325,32 +2409,32 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName9, CType9) \ } \ return self; \ } \ --(TableName##_Query *)group \ +-(TableName##_Query*)group \ { \ [super group]; \ return self; \ } \ --(TableName##_Query *)or \ +-(TableName##_Query*)or \ { \ [super or]; \ return self; \ } \ --(TableName##_Query *)endgroup \ +-(TableName##_Query*)endgroup \ { \ [super endgroup]; \ return self; \ } \ --(TableName##_Query *)subtable:(size_t)column \ +-(TableName##_Query*)subtable:(size_t)column \ { \ [super subtable:column]; \ return self; \ } \ --(TableName##_Query *)parent \ +-(TableName##_Query*)parent \ { \ [super parent]; \ return self; \ } \ --(TableName##_View *)findAll \ +-(TableName##_View*)findAll \ { \ return [[TableName##_View alloc] initFromQuery:self]; \ } \ @@ -2366,7 +2450,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName8, CType8) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName9, CType9) \ @implementation TableName \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ @@ -2381,7 +2465,8 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName9, CType9) \ -(id)_initRaw \ { \ self = [super _initRaw]; \ - if (!self) return nil; \ + if (!self) \ + return nil; \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ @@ -2396,8 +2481,10 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName9, CType9) \ -(id)init \ { \ self = [super init]; \ - if (!self) return nil; \ - if (![self _addColumns]) return nil; \ + if (!self) \ + return nil; \ + if (![self _addColumns]) \ + return nil; \ \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ @@ -2414,18 +2501,27 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName9, CType9) \ { \ 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\ -{ \ - const 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; \ +-(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\ +{ \ + 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]; \ } \ -(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 \ @@ -2441,82 +2537,85 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName9, CType9) \ TIGHTDB_COLUMN_INSERT(self, 8, ndx, CName9, CType9); \ [self insertDone]; \ } \ --(TableName##_Query *)where \ +-(TableName##_Query*)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ --(TableName##_Cursor *)addRow \ +-(TableName##_Cursor*)addRow \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[super _addRow]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TableName##_Cursor *)cursorAtLastIndex \ +-(TableName##_Cursor*)cursorAtLastIndex \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[self count]-1]; \ } \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx \ { \ [super insertRowAtIndex:ndx]; \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:self ndx:0]; \ } \ -+(BOOL)_checkType:(TightdbSpec *)spec \ -{ \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 0, CName1, CType1) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 1, CName2, CType2) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 2, CName3, CType3) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 3, CName4, CType4) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 4, CName5, CType5) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 5, CName6, CType6) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 6, CName7, CType7) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 7, CName8, CType8) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 8, CName9, CType9) \ ++(BOOL)_checkType:(TightdbDescriptor*)desc \ +{ \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 0, CName1, CType1) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 1, CName2, CType2) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 2, CName3, CType3) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 3, CName4, CType4) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 4, CName5, CType5) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 5, CName6, CType6) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 6, CName7, CType7) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 7, CName8, CType8) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 8, CName9, CType9) \ return YES; \ } \ -(BOOL)_checkType \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _checkType:spec]) return NO; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _checkType:desc]) \ + return NO; \ return YES; \ } \ -+(BOOL)_addColumns:(TightdbSpec *)spec \ -{ \ - TIGHTDB_ADD_COLUMN(spec, CName1, CType1) \ - TIGHTDB_ADD_COLUMN(spec, CName2, CType2) \ - TIGHTDB_ADD_COLUMN(spec, CName3, CType3) \ - TIGHTDB_ADD_COLUMN(spec, CName4, CType4) \ - TIGHTDB_ADD_COLUMN(spec, CName5, CType5) \ - TIGHTDB_ADD_COLUMN(spec, CName6, CType6) \ - TIGHTDB_ADD_COLUMN(spec, CName7, CType7) \ - TIGHTDB_ADD_COLUMN(spec, CName8, CType8) \ - TIGHTDB_ADD_COLUMN(spec, CName9, CType9) \ ++(BOOL)_addColumns:(TightdbDescriptor*)desc \ +{ \ + TIGHTDB_ADD_COLUMN(desc, CName1, CType1) \ + TIGHTDB_ADD_COLUMN(desc, CName2, CType2) \ + TIGHTDB_ADD_COLUMN(desc, CName3, CType3) \ + TIGHTDB_ADD_COLUMN(desc, CName4, CType4) \ + TIGHTDB_ADD_COLUMN(desc, CName5, CType5) \ + TIGHTDB_ADD_COLUMN(desc, CName6, CType6) \ + TIGHTDB_ADD_COLUMN(desc, CName7, CType7) \ + TIGHTDB_ADD_COLUMN(desc, CName8, CType8) \ + TIGHTDB_ADD_COLUMN(desc, CName9, CType9) \ return YES; \ } \ -(BOOL)_addColumns \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _addColumns:spec]) return NO; \ - [self updateFromSpec]; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _addColumns:desc]) \ + return NO; \ return YES; \ } \ @end \ @implementation TableName##_View \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:0]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:ndx]]; \ } \ @@ -2553,22 +2652,22 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName8, CType8) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName9, CType9) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName10, CType10) \ @interface TableName##_Query: TightdbQuery \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName1 *CName1; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName2 *CName2; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName3 *CName3; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName4 *CName4; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName5 *CName5; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName6 *CName6; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName7 *CName7; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName8 *CName8; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName9 *CName9; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName10 *CName10; \ --(TableName##_Query *)group; \ --(TableName##_Query *)or; \ --(TableName##_Query *)endgroup; \ --(TableName##_Query *)subtable:(size_t)column; \ --(TableName##_Query *)parent; \ --(TableName##_View *)findAll; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName1* CName1; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName2* CName2; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName3* CName3; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName4* CName4; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName5* CName5; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName6* CName6; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName7* CName7; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName8* CName8; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName9* CName9; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName10* CName10; \ +-(TableName##_Query*)group; \ +-(TableName##_Query*)or; \ +-(TableName##_Query*)endgroup; \ +-(TableName##_Query*)subtable:(size_t)column; \ +-(TableName##_Query*)parent; \ +-(TableName##_View*)findAll; \ @end \ @interface TableName: TightdbTable \ TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ @@ -2582,33 +2681,33 @@ 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; \ +-(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; \ --(TableName##_Query *)where; \ --(TableName##_Cursor *)addRow; \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ --(TableName##_Cursor *)cursorAtLastIndex; \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx; \ +-(TableName##_Query*)where; \ +-(TableName##_Cursor*)addRow; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtLastIndex; \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx; \ @end \ @interface TableName##_View: TightdbView \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @end #define TIGHTDB_TABLE_IMPL_10(TableName, CName1, CType1, CName2, CType2, CName3, CType3, CName4, CType4, CName5, CType5, CName6, CType6, CName7, CType7, CName8, CType8, CName9, CType9, CName10, CType10) \ @implementation TableName##_Cursor \ { \ - TightdbAccessor *_##CName1; \ - TightdbAccessor *_##CName2; \ - TightdbAccessor *_##CName3; \ - TightdbAccessor *_##CName4; \ - TightdbAccessor *_##CName5; \ - TightdbAccessor *_##CName6; \ - TightdbAccessor *_##CName7; \ - TightdbAccessor *_##CName8; \ - TightdbAccessor *_##CName9; \ - TightdbAccessor *_##CName10; \ + TightdbAccessor* _##CName1; \ + TightdbAccessor* _##CName2; \ + TightdbAccessor* _##CName3; \ + TightdbAccessor* _##CName4; \ + TightdbAccessor* _##CName5; \ + TightdbAccessor* _##CName6; \ + TightdbAccessor* _##CName7; \ + TightdbAccessor* _##CName8; \ + TightdbAccessor* _##CName9; \ + TightdbAccessor* _##CName10; \ } \ --(id)initWithTable:(TightdbTable *)table ndx:(size_t)ndx \ +-(id)initWithTable:(TightdbTable*)table ndx:(size_t)ndx \ { \ self = [super initWithTable:table ndx:ndx]; \ if (self) { \ @@ -2638,7 +2737,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName10, CType10) \ @end \ @implementation TableName##_Query \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ -(long)getFastEnumStart \ { \ @@ -2648,7 +2747,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName10, CType10) \ { \ return [self find:ndx]; \ } \ --(TightdbCursor *)getCursor:(long)ndx \ +-(TightdbCursor*)getCursor:(long)ndx \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:ndx]; \ } \ @@ -2662,7 +2761,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName10, CType10) \ @synthesize CName8 = _CName8; \ @synthesize CName9 = _CName9; \ @synthesize CName10 = _CName10; \ --(id)initWithTable:(TightdbTable *)table \ +-(id)initWithTable:(TightdbTable*)table \ { \ self = [super initWithTable:table]; \ if (self) { \ @@ -2679,32 +2778,32 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName10, CType10) \ } \ return self; \ } \ --(TableName##_Query *)group \ +-(TableName##_Query*)group \ { \ [super group]; \ return self; \ } \ --(TableName##_Query *)or \ +-(TableName##_Query*)or \ { \ [super or]; \ return self; \ } \ --(TableName##_Query *)endgroup \ +-(TableName##_Query*)endgroup \ { \ [super endgroup]; \ return self; \ } \ --(TableName##_Query *)subtable:(size_t)column \ +-(TableName##_Query*)subtable:(size_t)column \ { \ [super subtable:column]; \ return self; \ } \ --(TableName##_Query *)parent \ +-(TableName##_Query*)parent \ { \ [super parent]; \ return self; \ } \ --(TableName##_View *)findAll \ +-(TableName##_View*)findAll \ { \ return [[TableName##_View alloc] initFromQuery:self]; \ } \ @@ -2721,7 +2820,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName9, CType9) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName10, CType10) \ @implementation TableName \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ @@ -2737,7 +2836,8 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName10, CType10) \ -(id)_initRaw \ { \ self = [super _initRaw]; \ - if (!self) return nil; \ + if (!self) \ + return nil; \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ @@ -2753,8 +2853,10 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName10, CType10) \ -(id)init \ { \ self = [super init]; \ - if (!self) return nil; \ - if (![self _addColumns]) return nil; \ + if (!self) \ + return nil; \ + if (![self _addColumns]) \ + return nil; \ \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ @@ -2772,19 +2874,29 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName10, CType10) \ { \ 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\ -{ \ - const 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; \ +-(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\ +{ \ + 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]; \ } \ -(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 \ @@ -2801,84 +2913,87 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName10, CType10) \ TIGHTDB_COLUMN_INSERT(self, 9, ndx, CName10, CType10); \ [self insertDone]; \ } \ --(TableName##_Query *)where \ +-(TableName##_Query*)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ --(TableName##_Cursor *)addRow \ +-(TableName##_Cursor*)addRow \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[super _addRow]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TableName##_Cursor *)cursorAtLastIndex \ +-(TableName##_Cursor*)cursorAtLastIndex \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[self count]-1]; \ } \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx \ { \ [super insertRowAtIndex:ndx]; \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:self ndx:0]; \ } \ -+(BOOL)_checkType:(TightdbSpec *)spec \ -{ \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 0, CName1, CType1) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 1, CName2, CType2) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 2, CName3, CType3) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 3, CName4, CType4) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 4, CName5, CType5) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 5, CName6, CType6) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 6, CName7, CType7) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 7, CName8, CType8) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 8, CName9, CType9) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 9, CName10, CType10) \ ++(BOOL)_checkType:(TightdbDescriptor*)desc \ +{ \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 0, CName1, CType1) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 1, CName2, CType2) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 2, CName3, CType3) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 3, CName4, CType4) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 4, CName5, CType5) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 5, CName6, CType6) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 6, CName7, CType7) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 7, CName8, CType8) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 8, CName9, CType9) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 9, CName10, CType10) \ return YES; \ } \ -(BOOL)_checkType \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _checkType:spec]) return NO; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _checkType:desc]) \ + return NO; \ return YES; \ } \ -+(BOOL)_addColumns:(TightdbSpec *)spec \ -{ \ - TIGHTDB_ADD_COLUMN(spec, CName1, CType1) \ - TIGHTDB_ADD_COLUMN(spec, CName2, CType2) \ - TIGHTDB_ADD_COLUMN(spec, CName3, CType3) \ - TIGHTDB_ADD_COLUMN(spec, CName4, CType4) \ - TIGHTDB_ADD_COLUMN(spec, CName5, CType5) \ - TIGHTDB_ADD_COLUMN(spec, CName6, CType6) \ - TIGHTDB_ADD_COLUMN(spec, CName7, CType7) \ - TIGHTDB_ADD_COLUMN(spec, CName8, CType8) \ - TIGHTDB_ADD_COLUMN(spec, CName9, CType9) \ - TIGHTDB_ADD_COLUMN(spec, CName10, CType10) \ ++(BOOL)_addColumns:(TightdbDescriptor*)desc \ +{ \ + TIGHTDB_ADD_COLUMN(desc, CName1, CType1) \ + TIGHTDB_ADD_COLUMN(desc, CName2, CType2) \ + TIGHTDB_ADD_COLUMN(desc, CName3, CType3) \ + TIGHTDB_ADD_COLUMN(desc, CName4, CType4) \ + TIGHTDB_ADD_COLUMN(desc, CName5, CType5) \ + TIGHTDB_ADD_COLUMN(desc, CName6, CType6) \ + TIGHTDB_ADD_COLUMN(desc, CName7, CType7) \ + TIGHTDB_ADD_COLUMN(desc, CName8, CType8) \ + TIGHTDB_ADD_COLUMN(desc, CName9, CType9) \ + TIGHTDB_ADD_COLUMN(desc, CName10, CType10) \ return YES; \ } \ -(BOOL)_addColumns \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _addColumns:spec]) return NO; \ - [self updateFromSpec]; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _addColumns:desc]) \ + return NO; \ return YES; \ } \ @end \ @implementation TableName##_View \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:0]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:ndx]]; \ } \ @@ -2917,23 +3032,23 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName9, CType9) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName10, CType10) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName11, CType11) \ @interface TableName##_Query: TightdbQuery \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName1 *CName1; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName2 *CName2; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName3 *CName3; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName4 *CName4; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName5 *CName5; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName6 *CName6; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName7 *CName7; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName8 *CName8; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName9 *CName9; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName10 *CName10; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName11 *CName11; \ --(TableName##_Query *)group; \ --(TableName##_Query *)or; \ --(TableName##_Query *)endgroup; \ --(TableName##_Query *)subtable:(size_t)column; \ --(TableName##_Query *)parent; \ --(TableName##_View *)findAll; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName1* CName1; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName2* CName2; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName3* CName3; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName4* CName4; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName5* CName5; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName6* CName6; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName7* CName7; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName8* CName8; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName9* CName9; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName10* CName10; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName11* CName11; \ +-(TableName##_Query*)group; \ +-(TableName##_Query*)or; \ +-(TableName##_Query*)endgroup; \ +-(TableName##_Query*)subtable:(size_t)column; \ +-(TableName##_Query*)parent; \ +-(TableName##_View*)findAll; \ @end \ @interface TableName: TightdbTable \ TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ @@ -2948,34 +3063,34 @@ 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; \ +-(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; \ --(TableName##_Query *)where; \ --(TableName##_Cursor *)addRow; \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ --(TableName##_Cursor *)cursorAtLastIndex; \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx; \ +-(TableName##_Query*)where; \ +-(TableName##_Cursor*)addRow; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtLastIndex; \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx; \ @end \ @interface TableName##_View: TightdbView \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @end #define TIGHTDB_TABLE_IMPL_11(TableName, CName1, CType1, CName2, CType2, CName3, CType3, CName4, CType4, CName5, CType5, CName6, CType6, CName7, CType7, CName8, CType8, CName9, CType9, CName10, CType10, CName11, CType11) \ @implementation TableName##_Cursor \ { \ - TightdbAccessor *_##CName1; \ - TightdbAccessor *_##CName2; \ - TightdbAccessor *_##CName3; \ - TightdbAccessor *_##CName4; \ - TightdbAccessor *_##CName5; \ - TightdbAccessor *_##CName6; \ - TightdbAccessor *_##CName7; \ - TightdbAccessor *_##CName8; \ - TightdbAccessor *_##CName9; \ - TightdbAccessor *_##CName10; \ - TightdbAccessor *_##CName11; \ + TightdbAccessor* _##CName1; \ + TightdbAccessor* _##CName2; \ + TightdbAccessor* _##CName3; \ + TightdbAccessor* _##CName4; \ + TightdbAccessor* _##CName5; \ + TightdbAccessor* _##CName6; \ + TightdbAccessor* _##CName7; \ + TightdbAccessor* _##CName8; \ + TightdbAccessor* _##CName9; \ + TightdbAccessor* _##CName10; \ + TightdbAccessor* _##CName11; \ } \ --(id)initWithTable:(TightdbTable *)table ndx:(size_t)ndx \ +-(id)initWithTable:(TightdbTable*)table ndx:(size_t)ndx \ { \ self = [super initWithTable:table ndx:ndx]; \ if (self) { \ @@ -3007,7 +3122,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName11, CType11) \ @end \ @implementation TableName##_Query \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ -(long)getFastEnumStart \ { \ @@ -3017,7 +3132,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName11, CType11) \ { \ return [self find:ndx]; \ } \ --(TightdbCursor *)getCursor:(long)ndx \ +-(TightdbCursor*)getCursor:(long)ndx \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:ndx]; \ } \ @@ -3032,7 +3147,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName11, CType11) \ @synthesize CName9 = _CName9; \ @synthesize CName10 = _CName10; \ @synthesize CName11 = _CName11; \ --(id)initWithTable:(TightdbTable *)table \ +-(id)initWithTable:(TightdbTable*)table \ { \ self = [super initWithTable:table]; \ if (self) { \ @@ -3050,32 +3165,32 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName11, CType11) \ } \ return self; \ } \ --(TableName##_Query *)group \ +-(TableName##_Query*)group \ { \ [super group]; \ return self; \ } \ --(TableName##_Query *)or \ +-(TableName##_Query*)or \ { \ [super or]; \ return self; \ } \ --(TableName##_Query *)endgroup \ +-(TableName##_Query*)endgroup \ { \ [super endgroup]; \ return self; \ } \ --(TableName##_Query *)subtable:(size_t)column \ +-(TableName##_Query*)subtable:(size_t)column \ { \ [super subtable:column]; \ return self; \ } \ --(TableName##_Query *)parent \ +-(TableName##_Query*)parent \ { \ [super parent]; \ return self; \ } \ --(TableName##_View *)findAll \ +-(TableName##_View*)findAll \ { \ return [[TableName##_View alloc] initFromQuery:self]; \ } \ @@ -3093,7 +3208,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName10, CType10) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName11, CType11) \ @implementation TableName \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ @@ -3110,7 +3225,8 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName11, CType11) \ -(id)_initRaw \ { \ self = [super _initRaw]; \ - if (!self) return nil; \ + if (!self) \ + return nil; \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ @@ -3127,8 +3243,10 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName11, CType11) \ -(id)init \ { \ self = [super init]; \ - if (!self) return nil; \ - if (![self _addColumns]) return nil; \ + if (!self) \ + return nil; \ + if (![self _addColumns]) \ + return nil; \ \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ @@ -3147,20 +3265,31 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName11, CType11) \ { \ 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\ -{ \ - const 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; \ +-(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\ +{ \ + 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]; \ } \ -(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 \ @@ -3178,86 +3307,89 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName11, CType11) \ TIGHTDB_COLUMN_INSERT(self, 10, ndx, CName11, CType11); \ [self insertDone]; \ } \ --(TableName##_Query *)where \ +-(TableName##_Query*)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ --(TableName##_Cursor *)addRow \ +-(TableName##_Cursor*)addRow \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[super _addRow]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TableName##_Cursor *)cursorAtLastIndex \ +-(TableName##_Cursor*)cursorAtLastIndex \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[self count]-1]; \ } \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx \ { \ [super insertRowAtIndex:ndx]; \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:self ndx:0]; \ } \ -+(BOOL)_checkType:(TightdbSpec *)spec \ -{ \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 0, CName1, CType1) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 1, CName2, CType2) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 2, CName3, CType3) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 3, CName4, CType4) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 4, CName5, CType5) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 5, CName6, CType6) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 6, CName7, CType7) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 7, CName8, CType8) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 8, CName9, CType9) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 9, CName10, CType10) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 10, CName11, CType11) \ ++(BOOL)_checkType:(TightdbDescriptor*)desc \ +{ \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 0, CName1, CType1) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 1, CName2, CType2) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 2, CName3, CType3) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 3, CName4, CType4) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 4, CName5, CType5) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 5, CName6, CType6) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 6, CName7, CType7) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 7, CName8, CType8) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 8, CName9, CType9) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 9, CName10, CType10) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 10, CName11, CType11) \ return YES; \ } \ -(BOOL)_checkType \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _checkType:spec]) return NO; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _checkType:desc]) \ + return NO; \ return YES; \ } \ -+(BOOL)_addColumns:(TightdbSpec *)spec \ -{ \ - TIGHTDB_ADD_COLUMN(spec, CName1, CType1) \ - TIGHTDB_ADD_COLUMN(spec, CName2, CType2) \ - TIGHTDB_ADD_COLUMN(spec, CName3, CType3) \ - TIGHTDB_ADD_COLUMN(spec, CName4, CType4) \ - TIGHTDB_ADD_COLUMN(spec, CName5, CType5) \ - TIGHTDB_ADD_COLUMN(spec, CName6, CType6) \ - TIGHTDB_ADD_COLUMN(spec, CName7, CType7) \ - TIGHTDB_ADD_COLUMN(spec, CName8, CType8) \ - TIGHTDB_ADD_COLUMN(spec, CName9, CType9) \ - TIGHTDB_ADD_COLUMN(spec, CName10, CType10) \ - TIGHTDB_ADD_COLUMN(spec, CName11, CType11) \ ++(BOOL)_addColumns:(TightdbDescriptor*)desc \ +{ \ + TIGHTDB_ADD_COLUMN(desc, CName1, CType1) \ + TIGHTDB_ADD_COLUMN(desc, CName2, CType2) \ + TIGHTDB_ADD_COLUMN(desc, CName3, CType3) \ + TIGHTDB_ADD_COLUMN(desc, CName4, CType4) \ + TIGHTDB_ADD_COLUMN(desc, CName5, CType5) \ + TIGHTDB_ADD_COLUMN(desc, CName6, CType6) \ + TIGHTDB_ADD_COLUMN(desc, CName7, CType7) \ + TIGHTDB_ADD_COLUMN(desc, CName8, CType8) \ + TIGHTDB_ADD_COLUMN(desc, CName9, CType9) \ + TIGHTDB_ADD_COLUMN(desc, CName10, CType10) \ + TIGHTDB_ADD_COLUMN(desc, CName11, CType11) \ return YES; \ } \ -(BOOL)_addColumns \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _addColumns:spec]) return NO; \ - [self updateFromSpec]; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _addColumns:desc]) \ + return NO; \ return YES; \ } \ @end \ @implementation TableName##_View \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:0]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:ndx]]; \ } \ @@ -3298,24 +3430,24 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName10, CType10) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName11, CType11) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName12, CType12) \ @interface TableName##_Query: TightdbQuery \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName1 *CName1; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName2 *CName2; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName3 *CName3; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName4 *CName4; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName5 *CName5; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName6 *CName6; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName7 *CName7; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName8 *CName8; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName9 *CName9; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName10 *CName10; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName11 *CName11; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName12 *CName12; \ --(TableName##_Query *)group; \ --(TableName##_Query *)or; \ --(TableName##_Query *)endgroup; \ --(TableName##_Query *)subtable:(size_t)column; \ --(TableName##_Query *)parent; \ --(TableName##_View *)findAll; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName1* CName1; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName2* CName2; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName3* CName3; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName4* CName4; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName5* CName5; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName6* CName6; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName7* CName7; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName8* CName8; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName9* CName9; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName10* CName10; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName11* CName11; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName12* CName12; \ +-(TableName##_Query*)group; \ +-(TableName##_Query*)or; \ +-(TableName##_Query*)endgroup; \ +-(TableName##_Query*)subtable:(size_t)column; \ +-(TableName##_Query*)parent; \ +-(TableName##_View*)findAll; \ @end \ @interface TableName: TightdbTable \ TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ @@ -3331,35 +3463,35 @@ 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; \ +-(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; \ --(TableName##_Query *)where; \ --(TableName##_Cursor *)addRow; \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ --(TableName##_Cursor *)cursorAtLastIndex; \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx; \ +-(TableName##_Query*)where; \ +-(TableName##_Cursor*)addRow; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtLastIndex; \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx; \ @end \ @interface TableName##_View: TightdbView \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @end #define TIGHTDB_TABLE_IMPL_12(TableName, CName1, CType1, CName2, CType2, CName3, CType3, CName4, CType4, CName5, CType5, CName6, CType6, CName7, CType7, CName8, CType8, CName9, CType9, CName10, CType10, CName11, CType11, CName12, CType12) \ @implementation TableName##_Cursor \ { \ - TightdbAccessor *_##CName1; \ - TightdbAccessor *_##CName2; \ - TightdbAccessor *_##CName3; \ - TightdbAccessor *_##CName4; \ - TightdbAccessor *_##CName5; \ - TightdbAccessor *_##CName6; \ - TightdbAccessor *_##CName7; \ - TightdbAccessor *_##CName8; \ - TightdbAccessor *_##CName9; \ - TightdbAccessor *_##CName10; \ - TightdbAccessor *_##CName11; \ - TightdbAccessor *_##CName12; \ -} \ --(id)initWithTable:(TightdbTable *)table ndx:(size_t)ndx \ + TightdbAccessor* _##CName1; \ + TightdbAccessor* _##CName2; \ + TightdbAccessor* _##CName3; \ + TightdbAccessor* _##CName4; \ + TightdbAccessor* _##CName5; \ + TightdbAccessor* _##CName6; \ + TightdbAccessor* _##CName7; \ + TightdbAccessor* _##CName8; \ + TightdbAccessor* _##CName9; \ + TightdbAccessor* _##CName10; \ + TightdbAccessor* _##CName11; \ + TightdbAccessor* _##CName12; \ +} \ +-(id)initWithTable:(TightdbTable*)table ndx:(size_t)ndx \ { \ self = [super initWithTable:table ndx:ndx]; \ if (self) { \ @@ -3393,7 +3525,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName12, CType12) \ @end \ @implementation TableName##_Query \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ -(long)getFastEnumStart \ { \ @@ -3403,7 +3535,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName12, CType12) \ { \ return [self find:ndx]; \ } \ --(TightdbCursor *)getCursor:(long)ndx \ +-(TightdbCursor*)getCursor:(long)ndx \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:ndx]; \ } \ @@ -3419,7 +3551,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName12, CType12) \ @synthesize CName10 = _CName10; \ @synthesize CName11 = _CName11; \ @synthesize CName12 = _CName12; \ --(id)initWithTable:(TightdbTable *)table \ +-(id)initWithTable:(TightdbTable*)table \ { \ self = [super initWithTable:table]; \ if (self) { \ @@ -3438,32 +3570,32 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName12, CType12) \ } \ return self; \ } \ --(TableName##_Query *)group \ +-(TableName##_Query*)group \ { \ [super group]; \ return self; \ } \ --(TableName##_Query *)or \ +-(TableName##_Query*)or \ { \ [super or]; \ return self; \ } \ --(TableName##_Query *)endgroup \ +-(TableName##_Query*)endgroup \ { \ [super endgroup]; \ return self; \ } \ --(TableName##_Query *)subtable:(size_t)column \ +-(TableName##_Query*)subtable:(size_t)column \ { \ [super subtable:column]; \ return self; \ } \ --(TableName##_Query *)parent \ +-(TableName##_Query*)parent \ { \ [super parent]; \ return self; \ } \ --(TableName##_View *)findAll \ +-(TableName##_View*)findAll \ { \ return [[TableName##_View alloc] initFromQuery:self]; \ } \ @@ -3482,7 +3614,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName11, CType11) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName12, CType12) \ @implementation TableName \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ @@ -3500,7 +3632,8 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName12, CType12) \ -(id)_initRaw \ { \ self = [super _initRaw]; \ - if (!self) return nil; \ + if (!self) \ + return nil; \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ @@ -3518,8 +3651,10 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName12, CType12) \ -(id)init \ { \ self = [super init]; \ - if (!self) return nil; \ - if (![self _addColumns]) return nil; \ + if (!self) \ + return nil; \ + if (![self _addColumns]) \ + return nil; \ \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ @@ -3539,21 +3674,33 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName12, CType12) \ { \ 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\ -{ \ - const 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; \ +-(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\ +{ \ + 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]; \ } \ -(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 \ @@ -3572,88 +3719,91 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName12, CType12) \ TIGHTDB_COLUMN_INSERT(self, 11, ndx, CName12, CType12); \ [self insertDone]; \ } \ --(TableName##_Query *)where \ +-(TableName##_Query*)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ --(TableName##_Cursor *)addRow \ +-(TableName##_Cursor*)addRow \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[super _addRow]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TableName##_Cursor *)cursorAtLastIndex \ +-(TableName##_Cursor*)cursorAtLastIndex \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[self count]-1]; \ } \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx \ { \ [super insertRowAtIndex:ndx]; \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:self ndx:0]; \ } \ -+(BOOL)_checkType:(TightdbSpec *)spec \ -{ \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 0, CName1, CType1) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 1, CName2, CType2) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 2, CName3, CType3) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 3, CName4, CType4) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 4, CName5, CType5) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 5, CName6, CType6) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 6, CName7, CType7) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 7, CName8, CType8) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 8, CName9, CType9) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 9, CName10, CType10) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 10, CName11, CType11) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 11, CName12, CType12) \ ++(BOOL)_checkType:(TightdbDescriptor*)desc \ +{ \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 0, CName1, CType1) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 1, CName2, CType2) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 2, CName3, CType3) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 3, CName4, CType4) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 4, CName5, CType5) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 5, CName6, CType6) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 6, CName7, CType7) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 7, CName8, CType8) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 8, CName9, CType9) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 9, CName10, CType10) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 10, CName11, CType11) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 11, CName12, CType12) \ return YES; \ } \ -(BOOL)_checkType \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _checkType:spec]) return NO; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _checkType:desc]) \ + return NO; \ return YES; \ } \ -+(BOOL)_addColumns:(TightdbSpec *)spec \ -{ \ - TIGHTDB_ADD_COLUMN(spec, CName1, CType1) \ - TIGHTDB_ADD_COLUMN(spec, CName2, CType2) \ - TIGHTDB_ADD_COLUMN(spec, CName3, CType3) \ - TIGHTDB_ADD_COLUMN(spec, CName4, CType4) \ - TIGHTDB_ADD_COLUMN(spec, CName5, CType5) \ - TIGHTDB_ADD_COLUMN(spec, CName6, CType6) \ - TIGHTDB_ADD_COLUMN(spec, CName7, CType7) \ - TIGHTDB_ADD_COLUMN(spec, CName8, CType8) \ - TIGHTDB_ADD_COLUMN(spec, CName9, CType9) \ - TIGHTDB_ADD_COLUMN(spec, CName10, CType10) \ - TIGHTDB_ADD_COLUMN(spec, CName11, CType11) \ - TIGHTDB_ADD_COLUMN(spec, CName12, CType12) \ ++(BOOL)_addColumns:(TightdbDescriptor*)desc \ +{ \ + TIGHTDB_ADD_COLUMN(desc, CName1, CType1) \ + TIGHTDB_ADD_COLUMN(desc, CName2, CType2) \ + TIGHTDB_ADD_COLUMN(desc, CName3, CType3) \ + TIGHTDB_ADD_COLUMN(desc, CName4, CType4) \ + TIGHTDB_ADD_COLUMN(desc, CName5, CType5) \ + TIGHTDB_ADD_COLUMN(desc, CName6, CType6) \ + TIGHTDB_ADD_COLUMN(desc, CName7, CType7) \ + TIGHTDB_ADD_COLUMN(desc, CName8, CType8) \ + TIGHTDB_ADD_COLUMN(desc, CName9, CType9) \ + TIGHTDB_ADD_COLUMN(desc, CName10, CType10) \ + TIGHTDB_ADD_COLUMN(desc, CName11, CType11) \ + TIGHTDB_ADD_COLUMN(desc, CName12, CType12) \ return YES; \ } \ -(BOOL)_addColumns \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _addColumns:spec]) return NO; \ - [self updateFromSpec]; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _addColumns:desc]) \ + return NO; \ return YES; \ } \ @end \ @implementation TableName##_View \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:0]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:ndx]]; \ } \ @@ -3696,25 +3846,25 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName11, CType11) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName12, CType12) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName13, CType13) \ @interface TableName##_Query: TightdbQuery \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName1 *CName1; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName2 *CName2; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName3 *CName3; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName4 *CName4; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName5 *CName5; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName6 *CName6; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName7 *CName7; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName8 *CName8; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName9 *CName9; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName10 *CName10; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName11 *CName11; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName12 *CName12; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName13 *CName13; \ --(TableName##_Query *)group; \ --(TableName##_Query *)or; \ --(TableName##_Query *)endgroup; \ --(TableName##_Query *)subtable:(size_t)column; \ --(TableName##_Query *)parent; \ --(TableName##_View *)findAll; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName1* CName1; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName2* CName2; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName3* CName3; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName4* CName4; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName5* CName5; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName6* CName6; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName7* CName7; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName8* CName8; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName9* CName9; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName10* CName10; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName11* CName11; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName12* CName12; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName13* CName13; \ +-(TableName##_Query*)group; \ +-(TableName##_Query*)or; \ +-(TableName##_Query*)endgroup; \ +-(TableName##_Query*)subtable:(size_t)column; \ +-(TableName##_Query*)parent; \ +-(TableName##_View*)findAll; \ @end \ @interface TableName: TightdbTable \ TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ @@ -3731,36 +3881,36 @@ 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; \ +-(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; \ --(TableName##_Query *)where; \ --(TableName##_Cursor *)addRow; \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ --(TableName##_Cursor *)cursorAtLastIndex; \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx; \ +-(TableName##_Query*)where; \ +-(TableName##_Cursor*)addRow; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtLastIndex; \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx; \ @end \ @interface TableName##_View: TightdbView \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @end #define TIGHTDB_TABLE_IMPL_13(TableName, CName1, CType1, CName2, CType2, CName3, CType3, CName4, CType4, CName5, CType5, CName6, CType6, CName7, CType7, CName8, CType8, CName9, CType9, CName10, CType10, CName11, CType11, CName12, CType12, CName13, CType13) \ @implementation TableName##_Cursor \ { \ - TightdbAccessor *_##CName1; \ - TightdbAccessor *_##CName2; \ - TightdbAccessor *_##CName3; \ - TightdbAccessor *_##CName4; \ - TightdbAccessor *_##CName5; \ - TightdbAccessor *_##CName6; \ - TightdbAccessor *_##CName7; \ - TightdbAccessor *_##CName8; \ - TightdbAccessor *_##CName9; \ - TightdbAccessor *_##CName10; \ - TightdbAccessor *_##CName11; \ - TightdbAccessor *_##CName12; \ - TightdbAccessor *_##CName13; \ -} \ --(id)initWithTable:(TightdbTable *)table ndx:(size_t)ndx \ + TightdbAccessor* _##CName1; \ + TightdbAccessor* _##CName2; \ + TightdbAccessor* _##CName3; \ + TightdbAccessor* _##CName4; \ + TightdbAccessor* _##CName5; \ + TightdbAccessor* _##CName6; \ + TightdbAccessor* _##CName7; \ + TightdbAccessor* _##CName8; \ + TightdbAccessor* _##CName9; \ + TightdbAccessor* _##CName10; \ + TightdbAccessor* _##CName11; \ + TightdbAccessor* _##CName12; \ + TightdbAccessor* _##CName13; \ +} \ +-(id)initWithTable:(TightdbTable*)table ndx:(size_t)ndx \ { \ self = [super initWithTable:table ndx:ndx]; \ if (self) { \ @@ -3796,7 +3946,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName13, CType13) \ @end \ @implementation TableName##_Query \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ -(long)getFastEnumStart \ { \ @@ -3806,7 +3956,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName13, CType13) \ { \ return [self find:ndx]; \ } \ --(TightdbCursor *)getCursor:(long)ndx \ +-(TightdbCursor*)getCursor:(long)ndx \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:ndx]; \ } \ @@ -3823,7 +3973,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName13, CType13) \ @synthesize CName11 = _CName11; \ @synthesize CName12 = _CName12; \ @synthesize CName13 = _CName13; \ --(id)initWithTable:(TightdbTable *)table \ +-(id)initWithTable:(TightdbTable*)table \ { \ self = [super initWithTable:table]; \ if (self) { \ @@ -3843,32 +3993,32 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName13, CType13) \ } \ return self; \ } \ --(TableName##_Query *)group \ +-(TableName##_Query*)group \ { \ [super group]; \ return self; \ } \ --(TableName##_Query *)or \ +-(TableName##_Query*)or \ { \ [super or]; \ return self; \ } \ --(TableName##_Query *)endgroup \ +-(TableName##_Query*)endgroup \ { \ [super endgroup]; \ return self; \ } \ --(TableName##_Query *)subtable:(size_t)column \ +-(TableName##_Query*)subtable:(size_t)column \ { \ [super subtable:column]; \ return self; \ } \ --(TableName##_Query *)parent \ +-(TableName##_Query*)parent \ { \ [super parent]; \ return self; \ } \ --(TableName##_View *)findAll \ +-(TableName##_View*)findAll \ { \ return [[TableName##_View alloc] initFromQuery:self]; \ } \ @@ -3888,7 +4038,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName12, CType12) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName13, CType13) \ @implementation TableName \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ @@ -3907,7 +4057,8 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName13, CType13) \ -(id)_initRaw \ { \ self = [super _initRaw]; \ - if (!self) return nil; \ + if (!self) \ + return nil; \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ @@ -3926,8 +4077,10 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName13, CType13) \ -(id)init \ { \ self = [super init]; \ - if (!self) return nil; \ - if (![self _addColumns]) return nil; \ + if (!self) \ + return nil; \ + if (![self _addColumns]) \ + return nil; \ \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ @@ -3948,22 +4101,35 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName13, CType13) \ { \ 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\ -{ \ - const 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; \ +-(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\ +{ \ + 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]; \ } \ -(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 \ @@ -3983,90 +4149,93 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName13, CType13) \ TIGHTDB_COLUMN_INSERT(self, 12, ndx, CName13, CType13); \ [self insertDone]; \ } \ --(TableName##_Query *)where \ +-(TableName##_Query*)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ --(TableName##_Cursor *)addRow \ +-(TableName##_Cursor*)addRow \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[super _addRow]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TableName##_Cursor *)cursorAtLastIndex \ +-(TableName##_Cursor*)cursorAtLastIndex \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[self count]-1]; \ } \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx \ { \ [super insertRowAtIndex:ndx]; \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:self ndx:0]; \ } \ -+(BOOL)_checkType:(TightdbSpec *)spec \ -{ \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 0, CName1, CType1) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 1, CName2, CType2) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 2, CName3, CType3) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 3, CName4, CType4) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 4, CName5, CType5) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 5, CName6, CType6) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 6, CName7, CType7) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 7, CName8, CType8) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 8, CName9, CType9) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 9, CName10, CType10) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 10, CName11, CType11) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 11, CName12, CType12) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 12, CName13, CType13) \ ++(BOOL)_checkType:(TightdbDescriptor*)desc \ +{ \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 0, CName1, CType1) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 1, CName2, CType2) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 2, CName3, CType3) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 3, CName4, CType4) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 4, CName5, CType5) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 5, CName6, CType6) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 6, CName7, CType7) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 7, CName8, CType8) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 8, CName9, CType9) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 9, CName10, CType10) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 10, CName11, CType11) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 11, CName12, CType12) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 12, CName13, CType13) \ return YES; \ } \ -(BOOL)_checkType \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _checkType:spec]) return NO; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _checkType:desc]) \ + return NO; \ return YES; \ } \ -+(BOOL)_addColumns:(TightdbSpec *)spec \ -{ \ - TIGHTDB_ADD_COLUMN(spec, CName1, CType1) \ - TIGHTDB_ADD_COLUMN(spec, CName2, CType2) \ - TIGHTDB_ADD_COLUMN(spec, CName3, CType3) \ - TIGHTDB_ADD_COLUMN(spec, CName4, CType4) \ - TIGHTDB_ADD_COLUMN(spec, CName5, CType5) \ - TIGHTDB_ADD_COLUMN(spec, CName6, CType6) \ - TIGHTDB_ADD_COLUMN(spec, CName7, CType7) \ - TIGHTDB_ADD_COLUMN(spec, CName8, CType8) \ - TIGHTDB_ADD_COLUMN(spec, CName9, CType9) \ - TIGHTDB_ADD_COLUMN(spec, CName10, CType10) \ - TIGHTDB_ADD_COLUMN(spec, CName11, CType11) \ - TIGHTDB_ADD_COLUMN(spec, CName12, CType12) \ - TIGHTDB_ADD_COLUMN(spec, CName13, CType13) \ ++(BOOL)_addColumns:(TightdbDescriptor*)desc \ +{ \ + TIGHTDB_ADD_COLUMN(desc, CName1, CType1) \ + TIGHTDB_ADD_COLUMN(desc, CName2, CType2) \ + TIGHTDB_ADD_COLUMN(desc, CName3, CType3) \ + TIGHTDB_ADD_COLUMN(desc, CName4, CType4) \ + TIGHTDB_ADD_COLUMN(desc, CName5, CType5) \ + TIGHTDB_ADD_COLUMN(desc, CName6, CType6) \ + TIGHTDB_ADD_COLUMN(desc, CName7, CType7) \ + TIGHTDB_ADD_COLUMN(desc, CName8, CType8) \ + TIGHTDB_ADD_COLUMN(desc, CName9, CType9) \ + TIGHTDB_ADD_COLUMN(desc, CName10, CType10) \ + TIGHTDB_ADD_COLUMN(desc, CName11, CType11) \ + TIGHTDB_ADD_COLUMN(desc, CName12, CType12) \ + TIGHTDB_ADD_COLUMN(desc, CName13, CType13) \ return YES; \ } \ -(BOOL)_addColumns \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _addColumns:spec]) return NO; \ - [self updateFromSpec]; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _addColumns:desc]) \ + return NO; \ return YES; \ } \ @end \ @implementation TableName##_View \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:0]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:ndx]]; \ } \ @@ -4111,26 +4280,26 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName12, CType12) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName13, CType13) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName14, CType14) \ @interface TableName##_Query: TightdbQuery \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName1 *CName1; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName2 *CName2; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName3 *CName3; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName4 *CName4; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName5 *CName5; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName6 *CName6; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName7 *CName7; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName8 *CName8; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName9 *CName9; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName10 *CName10; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName11 *CName11; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName12 *CName12; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName13 *CName13; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName14 *CName14; \ --(TableName##_Query *)group; \ --(TableName##_Query *)or; \ --(TableName##_Query *)endgroup; \ --(TableName##_Query *)subtable:(size_t)column; \ --(TableName##_Query *)parent; \ --(TableName##_View *)findAll; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName1* CName1; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName2* CName2; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName3* CName3; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName4* CName4; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName5* CName5; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName6* CName6; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName7* CName7; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName8* CName8; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName9* CName9; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName10* CName10; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName11* CName11; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName12* CName12; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName13* CName13; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName14* CName14; \ +-(TableName##_Query*)group; \ +-(TableName##_Query*)or; \ +-(TableName##_Query*)endgroup; \ +-(TableName##_Query*)subtable:(size_t)column; \ +-(TableName##_Query*)parent; \ +-(TableName##_View*)findAll; \ @end \ @interface TableName: TightdbTable \ TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ @@ -4148,37 +4317,37 @@ 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; \ +-(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; \ --(TableName##_Query *)where; \ --(TableName##_Cursor *)addRow; \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ --(TableName##_Cursor *)cursorAtLastIndex; \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx; \ +-(TableName##_Query*)where; \ +-(TableName##_Cursor*)addRow; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtLastIndex; \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx; \ @end \ @interface TableName##_View: TightdbView \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @end #define TIGHTDB_TABLE_IMPL_14(TableName, CName1, CType1, CName2, CType2, CName3, CType3, CName4, CType4, CName5, CType5, CName6, CType6, CName7, CType7, CName8, CType8, CName9, CType9, CName10, CType10, CName11, CType11, CName12, CType12, CName13, CType13, CName14, CType14) \ @implementation TableName##_Cursor \ { \ - TightdbAccessor *_##CName1; \ - TightdbAccessor *_##CName2; \ - TightdbAccessor *_##CName3; \ - TightdbAccessor *_##CName4; \ - TightdbAccessor *_##CName5; \ - TightdbAccessor *_##CName6; \ - TightdbAccessor *_##CName7; \ - TightdbAccessor *_##CName8; \ - TightdbAccessor *_##CName9; \ - TightdbAccessor *_##CName10; \ - TightdbAccessor *_##CName11; \ - TightdbAccessor *_##CName12; \ - TightdbAccessor *_##CName13; \ - TightdbAccessor *_##CName14; \ -} \ --(id)initWithTable:(TightdbTable *)table ndx:(size_t)ndx \ + TightdbAccessor* _##CName1; \ + TightdbAccessor* _##CName2; \ + TightdbAccessor* _##CName3; \ + TightdbAccessor* _##CName4; \ + TightdbAccessor* _##CName5; \ + TightdbAccessor* _##CName6; \ + TightdbAccessor* _##CName7; \ + TightdbAccessor* _##CName8; \ + TightdbAccessor* _##CName9; \ + TightdbAccessor* _##CName10; \ + TightdbAccessor* _##CName11; \ + TightdbAccessor* _##CName12; \ + TightdbAccessor* _##CName13; \ + TightdbAccessor* _##CName14; \ +} \ +-(id)initWithTable:(TightdbTable*)table ndx:(size_t)ndx \ { \ self = [super initWithTable:table ndx:ndx]; \ if (self) { \ @@ -4216,7 +4385,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName14, CType14) \ @end \ @implementation TableName##_Query \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ -(long)getFastEnumStart \ { \ @@ -4226,7 +4395,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName14, CType14) \ { \ return [self find:ndx]; \ } \ --(TightdbCursor *)getCursor:(long)ndx \ +-(TightdbCursor*)getCursor:(long)ndx \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:ndx]; \ } \ @@ -4244,7 +4413,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName14, CType14) \ @synthesize CName12 = _CName12; \ @synthesize CName13 = _CName13; \ @synthesize CName14 = _CName14; \ --(id)initWithTable:(TightdbTable *)table \ +-(id)initWithTable:(TightdbTable*)table \ { \ self = [super initWithTable:table]; \ if (self) { \ @@ -4265,32 +4434,32 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName14, CType14) \ } \ return self; \ } \ --(TableName##_Query *)group \ +-(TableName##_Query*)group \ { \ [super group]; \ return self; \ } \ --(TableName##_Query *)or \ +-(TableName##_Query*)or \ { \ [super or]; \ return self; \ } \ --(TableName##_Query *)endgroup \ +-(TableName##_Query*)endgroup \ { \ [super endgroup]; \ return self; \ } \ --(TableName##_Query *)subtable:(size_t)column \ +-(TableName##_Query*)subtable:(size_t)column \ { \ [super subtable:column]; \ return self; \ } \ --(TableName##_Query *)parent \ +-(TableName##_Query*)parent \ { \ [super parent]; \ return self; \ } \ --(TableName##_View *)findAll \ +-(TableName##_View*)findAll \ { \ return [[TableName##_View alloc] initFromQuery:self]; \ } \ @@ -4311,7 +4480,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName13, CType13) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName14, CType14) \ @implementation TableName \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ @@ -4331,7 +4500,8 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName14, CType14) \ -(id)_initRaw \ { \ self = [super _initRaw]; \ - if (!self) return nil; \ + if (!self) \ + return nil; \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ @@ -4351,8 +4521,10 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName14, CType14) \ -(id)init \ { \ self = [super init]; \ - if (!self) return nil; \ - if (![self _addColumns]) return nil; \ + if (!self) \ + return nil; \ + if (![self _addColumns]) \ + return nil; \ \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ @@ -4374,23 +4546,37 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName14, CType14) \ { \ 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\ -{ \ - const 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; \ +-(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\ +{ \ + 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]; \ } \ -(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 \ @@ -4411,92 +4597,95 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName14, CType14) \ TIGHTDB_COLUMN_INSERT(self, 13, ndx, CName14, CType14); \ [self insertDone]; \ } \ --(TableName##_Query *)where \ +-(TableName##_Query*)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ --(TableName##_Cursor *)addRow \ +-(TableName##_Cursor*)addRow \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[super _addRow]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TableName##_Cursor *)cursorAtLastIndex \ +-(TableName##_Cursor*)cursorAtLastIndex \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[self count]-1]; \ } \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx \ { \ [super insertRowAtIndex:ndx]; \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:self ndx:0]; \ } \ -+(BOOL)_checkType:(TightdbSpec *)spec \ -{ \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 0, CName1, CType1) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 1, CName2, CType2) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 2, CName3, CType3) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 3, CName4, CType4) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 4, CName5, CType5) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 5, CName6, CType6) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 6, CName7, CType7) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 7, CName8, CType8) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 8, CName9, CType9) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 9, CName10, CType10) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 10, CName11, CType11) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 11, CName12, CType12) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 12, CName13, CType13) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 13, CName14, CType14) \ ++(BOOL)_checkType:(TightdbDescriptor*)desc \ +{ \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 0, CName1, CType1) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 1, CName2, CType2) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 2, CName3, CType3) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 3, CName4, CType4) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 4, CName5, CType5) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 5, CName6, CType6) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 6, CName7, CType7) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 7, CName8, CType8) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 8, CName9, CType9) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 9, CName10, CType10) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 10, CName11, CType11) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 11, CName12, CType12) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 12, CName13, CType13) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 13, CName14, CType14) \ return YES; \ } \ -(BOOL)_checkType \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _checkType:spec]) return NO; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _checkType:desc]) \ + return NO; \ return YES; \ } \ -+(BOOL)_addColumns:(TightdbSpec *)spec \ -{ \ - TIGHTDB_ADD_COLUMN(spec, CName1, CType1) \ - TIGHTDB_ADD_COLUMN(spec, CName2, CType2) \ - TIGHTDB_ADD_COLUMN(spec, CName3, CType3) \ - TIGHTDB_ADD_COLUMN(spec, CName4, CType4) \ - TIGHTDB_ADD_COLUMN(spec, CName5, CType5) \ - TIGHTDB_ADD_COLUMN(spec, CName6, CType6) \ - TIGHTDB_ADD_COLUMN(spec, CName7, CType7) \ - TIGHTDB_ADD_COLUMN(spec, CName8, CType8) \ - TIGHTDB_ADD_COLUMN(spec, CName9, CType9) \ - TIGHTDB_ADD_COLUMN(spec, CName10, CType10) \ - TIGHTDB_ADD_COLUMN(spec, CName11, CType11) \ - TIGHTDB_ADD_COLUMN(spec, CName12, CType12) \ - TIGHTDB_ADD_COLUMN(spec, CName13, CType13) \ - TIGHTDB_ADD_COLUMN(spec, CName14, CType14) \ ++(BOOL)_addColumns:(TightdbDescriptor*)desc \ +{ \ + TIGHTDB_ADD_COLUMN(desc, CName1, CType1) \ + TIGHTDB_ADD_COLUMN(desc, CName2, CType2) \ + TIGHTDB_ADD_COLUMN(desc, CName3, CType3) \ + TIGHTDB_ADD_COLUMN(desc, CName4, CType4) \ + TIGHTDB_ADD_COLUMN(desc, CName5, CType5) \ + TIGHTDB_ADD_COLUMN(desc, CName6, CType6) \ + TIGHTDB_ADD_COLUMN(desc, CName7, CType7) \ + TIGHTDB_ADD_COLUMN(desc, CName8, CType8) \ + TIGHTDB_ADD_COLUMN(desc, CName9, CType9) \ + TIGHTDB_ADD_COLUMN(desc, CName10, CType10) \ + TIGHTDB_ADD_COLUMN(desc, CName11, CType11) \ + TIGHTDB_ADD_COLUMN(desc, CName12, CType12) \ + TIGHTDB_ADD_COLUMN(desc, CName13, CType13) \ + TIGHTDB_ADD_COLUMN(desc, CName14, CType14) \ return YES; \ } \ -(BOOL)_addColumns \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _addColumns:spec]) return NO; \ - [self updateFromSpec]; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _addColumns:desc]) \ + return NO; \ return YES; \ } \ @end \ @implementation TableName##_View \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:0]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:ndx]]; \ } \ @@ -4543,27 +4732,27 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName13, CType13) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName14, CType14) \ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName15, CType15) \ @interface TableName##_Query: TightdbQuery \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName1 *CName1; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName2 *CName2; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName3 *CName3; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName4 *CName4; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName5 *CName5; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName6 *CName6; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName7 *CName7; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName8 *CName8; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName9 *CName9; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName10 *CName10; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName11 *CName11; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName12 *CName12; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName13 *CName13; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName14 *CName14; \ -@property(nonatomic, strong) TableName##_QueryAccessor_##CName15 *CName15; \ --(TableName##_Query *)group; \ --(TableName##_Query *)or; \ --(TableName##_Query *)endgroup; \ --(TableName##_Query *)subtable:(size_t)column; \ --(TableName##_Query *)parent; \ --(TableName##_View *)findAll; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName1* CName1; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName2* CName2; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName3* CName3; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName4* CName4; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName5* CName5; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName6* CName6; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName7* CName7; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName8* CName8; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName9* CName9; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName10* CName10; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName11* CName11; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName12* CName12; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName13* CName13; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName14* CName14; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName15* CName15; \ +-(TableName##_Query*)group; \ +-(TableName##_Query*)or; \ +-(TableName##_Query*)endgroup; \ +-(TableName##_Query*)subtable:(size_t)column; \ +-(TableName##_Query*)parent; \ +-(TableName##_View*)findAll; \ @end \ @interface TableName: TightdbTable \ TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ @@ -4582,38 +4771,38 @@ 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; \ +-(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; \ --(TableName##_Query *)where; \ --(TableName##_Cursor *)addRow; \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ --(TableName##_Cursor *)cursorAtLastIndex; \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx; \ +-(TableName##_Query*)where; \ +-(TableName##_Cursor*)addRow; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtLastIndex; \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx; \ @end \ @interface TableName##_View: TightdbView \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @end #define TIGHTDB_TABLE_IMPL_15(TableName, CName1, CType1, CName2, CType2, CName3, CType3, CName4, CType4, CName5, CType5, CName6, CType6, CName7, CType7, CName8, CType8, CName9, CType9, CName10, CType10, CName11, CType11, CName12, CType12, CName13, CType13, CName14, CType14, CName15, CType15) \ @implementation TableName##_Cursor \ { \ - TightdbAccessor *_##CName1; \ - TightdbAccessor *_##CName2; \ - TightdbAccessor *_##CName3; \ - TightdbAccessor *_##CName4; \ - TightdbAccessor *_##CName5; \ - TightdbAccessor *_##CName6; \ - TightdbAccessor *_##CName7; \ - TightdbAccessor *_##CName8; \ - TightdbAccessor *_##CName9; \ - TightdbAccessor *_##CName10; \ - TightdbAccessor *_##CName11; \ - TightdbAccessor *_##CName12; \ - TightdbAccessor *_##CName13; \ - TightdbAccessor *_##CName14; \ - TightdbAccessor *_##CName15; \ -} \ --(id)initWithTable:(TightdbTable *)table ndx:(size_t)ndx \ + TightdbAccessor* _##CName1; \ + TightdbAccessor* _##CName2; \ + TightdbAccessor* _##CName3; \ + TightdbAccessor* _##CName4; \ + TightdbAccessor* _##CName5; \ + TightdbAccessor* _##CName6; \ + TightdbAccessor* _##CName7; \ + TightdbAccessor* _##CName8; \ + TightdbAccessor* _##CName9; \ + TightdbAccessor* _##CName10; \ + TightdbAccessor* _##CName11; \ + TightdbAccessor* _##CName12; \ + TightdbAccessor* _##CName13; \ + TightdbAccessor* _##CName14; \ + TightdbAccessor* _##CName15; \ +} \ +-(id)initWithTable:(TightdbTable*)table ndx:(size_t)ndx \ { \ self = [super initWithTable:table ndx:ndx]; \ if (self) { \ @@ -4653,7 +4842,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName15, CType15) \ @end \ @implementation TableName##_Query \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ -(long)getFastEnumStart \ { \ @@ -4663,7 +4852,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName15, CType15) \ { \ return [self find:ndx]; \ } \ --(TightdbCursor *)getCursor:(long)ndx \ +-(TightdbCursor*)getCursor:(long)ndx \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:ndx]; \ } \ @@ -4682,7 +4871,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName15, CType15) \ @synthesize CName13 = _CName13; \ @synthesize CName14 = _CName14; \ @synthesize CName15 = _CName15; \ --(id)initWithTable:(TightdbTable *)table \ +-(id)initWithTable:(TightdbTable*)table \ { \ self = [super initWithTable:table]; \ if (self) { \ @@ -4704,32 +4893,32 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName15, CType15) \ } \ return self; \ } \ --(TableName##_Query *)group \ +-(TableName##_Query*)group \ { \ [super group]; \ return self; \ } \ --(TableName##_Query *)or \ +-(TableName##_Query*)or \ { \ [super or]; \ return self; \ } \ --(TableName##_Query *)endgroup \ +-(TableName##_Query*)endgroup \ { \ [super endgroup]; \ return self; \ } \ --(TableName##_Query *)subtable:(size_t)column \ +-(TableName##_Query*)subtable:(size_t)column \ { \ [super subtable:column]; \ return self; \ } \ --(TableName##_Query *)parent \ +-(TableName##_Query*)parent \ { \ [super parent]; \ return self; \ } \ --(TableName##_View *)findAll \ +-(TableName##_View*)findAll \ { \ return [[TableName##_View alloc] initFromQuery:self]; \ } \ @@ -4751,7 +4940,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName14, CType14) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName15, CType15) \ @implementation TableName \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ @@ -4772,7 +4961,8 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName15, CType15) \ -(id)_initRaw \ { \ self = [super _initRaw]; \ - if (!self) return nil; \ + if (!self) \ + return nil; \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ @@ -4793,8 +4983,10 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName15, CType15) \ -(id)init \ { \ self = [super init]; \ - if (!self) return nil; \ - if (![self _addColumns]) return nil; \ + if (!self) \ + return nil; \ + if (![self _addColumns]) \ + return nil; \ \ TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ @@ -4817,24 +5009,39 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName15, CType15) \ { \ 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\ -{ \ - const 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; \ +-(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\ +{ \ + 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]; \ } \ -(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 \ @@ -4856,94 +5063,97 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName15, CType15) \ TIGHTDB_COLUMN_INSERT(self, 14, ndx, CName15, CType15); \ [self insertDone]; \ } \ --(TableName##_Query *)where \ +-(TableName##_Query*)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ --(TableName##_Cursor *)addRow \ +-(TableName##_Cursor*)addRow \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[super _addRow]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TableName##_Cursor *)cursorAtLastIndex \ +-(TableName##_Cursor*)cursorAtLastIndex \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[self count]-1]; \ } \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx \ { \ [super insertRowAtIndex:ndx]; \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:self ndx:0]; \ } \ -+(BOOL)_checkType:(TightdbSpec *)spec \ -{ \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 0, CName1, CType1) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 1, CName2, CType2) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 2, CName3, CType3) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 3, CName4, CType4) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 4, CName5, CType5) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 5, CName6, CType6) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 6, CName7, CType7) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 7, CName8, CType8) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 8, CName9, CType9) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 9, CName10, CType10) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 10, CName11, CType11) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 11, CName12, CType12) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 12, CName13, CType13) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 13, CName14, CType14) \ - TIGHTDB_CHECK_COLUMN_TYPE(spec, 14, CName15, CType15) \ ++(BOOL)_checkType:(TightdbDescriptor*)desc \ +{ \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 0, CName1, CType1) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 1, CName2, CType2) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 2, CName3, CType3) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 3, CName4, CType4) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 4, CName5, CType5) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 5, CName6, CType6) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 6, CName7, CType7) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 7, CName8, CType8) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 8, CName9, CType9) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 9, CName10, CType10) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 10, CName11, CType11) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 11, CName12, CType12) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 12, CName13, CType13) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 13, CName14, CType14) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, 14, CName15, CType15) \ return YES; \ } \ -(BOOL)_checkType \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _checkType:spec]) return NO; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _checkType:desc]) \ + return NO; \ return YES; \ } \ -+(BOOL)_addColumns:(TightdbSpec *)spec \ -{ \ - TIGHTDB_ADD_COLUMN(spec, CName1, CType1) \ - TIGHTDB_ADD_COLUMN(spec, CName2, CType2) \ - TIGHTDB_ADD_COLUMN(spec, CName3, CType3) \ - TIGHTDB_ADD_COLUMN(spec, CName4, CType4) \ - TIGHTDB_ADD_COLUMN(spec, CName5, CType5) \ - TIGHTDB_ADD_COLUMN(spec, CName6, CType6) \ - TIGHTDB_ADD_COLUMN(spec, CName7, CType7) \ - TIGHTDB_ADD_COLUMN(spec, CName8, CType8) \ - TIGHTDB_ADD_COLUMN(spec, CName9, CType9) \ - TIGHTDB_ADD_COLUMN(spec, CName10, CType10) \ - TIGHTDB_ADD_COLUMN(spec, CName11, CType11) \ - TIGHTDB_ADD_COLUMN(spec, CName12, CType12) \ - TIGHTDB_ADD_COLUMN(spec, CName13, CType13) \ - TIGHTDB_ADD_COLUMN(spec, CName14, CType14) \ - TIGHTDB_ADD_COLUMN(spec, CName15, CType15) \ ++(BOOL)_addColumns:(TightdbDescriptor*)desc \ +{ \ + TIGHTDB_ADD_COLUMN(desc, CName1, CType1) \ + TIGHTDB_ADD_COLUMN(desc, CName2, CType2) \ + TIGHTDB_ADD_COLUMN(desc, CName3, CType3) \ + TIGHTDB_ADD_COLUMN(desc, CName4, CType4) \ + TIGHTDB_ADD_COLUMN(desc, CName5, CType5) \ + TIGHTDB_ADD_COLUMN(desc, CName6, CType6) \ + TIGHTDB_ADD_COLUMN(desc, CName7, CType7) \ + TIGHTDB_ADD_COLUMN(desc, CName8, CType8) \ + TIGHTDB_ADD_COLUMN(desc, CName9, CType9) \ + TIGHTDB_ADD_COLUMN(desc, CName10, CType10) \ + TIGHTDB_ADD_COLUMN(desc, CName11, CType11) \ + TIGHTDB_ADD_COLUMN(desc, CName12, CType12) \ + TIGHTDB_ADD_COLUMN(desc, CName13, CType13) \ + TIGHTDB_ADD_COLUMN(desc, CName14, CType14) \ + TIGHTDB_ADD_COLUMN(desc, CName15, CType15) \ return YES; \ } \ -(BOOL)_addColumns \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _addColumns:spec]) return NO; \ - [self updateFromSpec]; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _addColumns:desc]) \ + return NO; \ return YES; \ } \ @end \ @implementation TableName##_View \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:0]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:ndx]]; \ } \ diff --git a/src/tightdb/objc/tightdb.h.cheetah b/src/tightdb/objc/tightdb.h.cheetah index c3f25b22e6..39023eed1d 100644 --- a/src/tightdb/objc/tightdb.h.cheetah +++ b/src/tightdb/objc/tightdb.h.cheetah @@ -63,14 +63,14 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName${j+1}, CType${j+1}) \ %end for @interface TableName##_Query: TightdbQuery \ %for $j in range($num_cols) -@property(nonatomic, strong) TableName##_QueryAccessor_##CName${j+1} *CName${j+1}; \ +@property(nonatomic, strong) TableName##_QueryAccessor_##CName${j+1}* CName${j+1}; \ %end for --(TableName##_Query *)group; \ --(TableName##_Query *)or; \ --(TableName##_Query *)endgroup; \ --(TableName##_Query *)subtable:(size_t)column; \ --(TableName##_Query *)parent; \ --(TableName##_View *)findAll; \ +-(TableName##_Query*)group; \ +-(TableName##_Query*)or; \ +-(TableName##_Query*)endgroup; \ +-(TableName##_Query*)subtable:(size_t)column; \ +-(TableName##_Query*)parent; \ +-(TableName##_View*)findAll; \ @end \ @interface TableName: TightdbTable \ %for $j in range($num_cols) @@ -91,20 +91,20 @@ CName${j+1}:(TIGHTDB_ARG_TYPE(CType${j+1}))CName${j+1}%slurp %end if CName${j+1}:(TIGHTDB_ARG_TYPE(CType${j+1}))CName${j+1}%slurp %end for - error:(NSError **)error; \ + error:(NSError**)error; \ -(void)insertAtIndex:(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 ; \ --(TableName##_Query *)where; \ --(TableName##_Cursor *)addRow; \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ --(TableName##_Cursor *)cursorAtLastIndex; \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx; \ +-(TableName##_Query*)where; \ +-(TableName##_Cursor*)addRow; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtLastIndex; \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx; \ @end \ @interface TableName##_View: TightdbView \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx; \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx; \ @end #define TIGHTDB_TABLE_IMPL_${num_cols}(TableName%slurp @@ -115,10 +115,10 @@ CName${j+1}:(TIGHTDB_ARG_TYPE(CType${j+1}))CName${j+1}%slurp @implementation TableName##_Cursor \ { \ %for $j in range($num_cols) - TightdbAccessor *_##CName${j+1}; \ + TightdbAccessor* _##CName${j+1}; \ %end for } \ --(id)initWithTable:(TightdbTable *)table ndx:(size_t)ndx \ +-(id)initWithTable:(TightdbTable*)table ndx:(size_t)ndx \ { \ self = [super initWithTable:table ndx:ndx]; \ if (self) { \ @@ -134,7 +134,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName${j+1}, CType${j+1}) \ @end \ @implementation TableName##_Query \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ -(long)getFastEnumStart \ { \ @@ -144,14 +144,14 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName${j+1}, CType${j+1}) \ { \ return [self find:ndx]; \ } \ --(TightdbCursor *)getCursor:(long)ndx \ +-(TightdbCursor*)getCursor:(long)ndx \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:ndx]; \ } \ %for $j in range($num_cols) @synthesize CName${j+1} = _CName${j+1}; \ %end for --(id)initWithTable:(TightdbTable *)table \ +-(id)initWithTable:(TightdbTable*)table \ { \ self = [super initWithTable:table]; \ if (self) { \ @@ -161,32 +161,32 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName${j+1}, CType${j+1}) \ } \ return self; \ } \ --(TableName##_Query *)group \ +-(TableName##_Query*)group \ { \ [super group]; \ return self; \ } \ --(TableName##_Query *)or \ +-(TableName##_Query*)or \ { \ [super or]; \ return self; \ } \ --(TableName##_Query *)endgroup \ +-(TableName##_Query*)endgroup \ { \ [super endgroup]; \ return self; \ } \ --(TableName##_Query *)subtable:(size_t)column \ +-(TableName##_Query*)subtable:(size_t)column \ { \ [super subtable:column]; \ return self; \ } \ --(TableName##_Query *)parent \ +-(TableName##_Query*)parent \ { \ [super parent]; \ return self; \ } \ --(TableName##_View *)findAll \ +-(TableName##_View*)findAll \ { \ return [[TableName##_View alloc] initFromQuery:self]; \ } \ @@ -196,7 +196,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName${j+1}, CType${j+1}) \ %end for @implementation TableName \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ %for $j in range($num_cols) TIGHTDB_COLUMN_PROXY_IMPL(CName${j+1}, CType${j+1}) \ @@ -205,7 +205,8 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName${j+1}, CType${j+1}) \ -(id)_initRaw \ { \ self = [super _initRaw]; \ - if (!self) return nil; \ + if (!self) \ + return nil; \ %for $j in range($num_cols) TIGHTDB_COLUMN_PROXY_INIT(self, ${j}, CName${j+1}, CType${j+1}); \ %end for @@ -214,8 +215,10 @@ TIGHTDB_COLUMN_PROXY_IMPL(CName${j+1}, CType${j+1}) \ -(id)init \ { \ self = [super init]; \ - if (!self) return nil; \ - if (![self _addColumns]) return nil; \ + if (!self) \ + return nil; \ + if (![self _addColumns]) \ + return nil; \ \ %for $j in range($num_cols) TIGHTDB_COLUMN_PROXY_INIT(self, ${j}, CName${j+1}, CType${j+1}); \ @@ -238,11 +241,12 @@ error:nil]; \ %for $j in range($num_cols) CName${j+1}:(TIGHTDB_ARG_TYPE(CType${j+1}))CName${j+1} %slurp %end for -error:(NSError **)error\ +error:(NSError**)error\ { \ - const size_t ndx = [self count]; \ + 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; \ + if (!TIGHTDB_COLUMN_INSERT_ERROR(self, ${j}, ndx, CName${j+1}, CType${j+1}, error)) \ + return NO; \ %end for return [self insertDoneWithError:error]; \ } \ @@ -257,70 +261,73 @@ CName${j+1}:(TIGHTDB_ARG_TYPE(CType${j+1}))CName${j+1} %slurp %end for [self insertDone]; \ } \ --(TableName##_Query *)where \ +-(TableName##_Query*)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ --(TableName##_Cursor *)addRow \ +-(TableName##_Cursor*)addRow \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[super _addRow]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TableName##_Cursor *)cursorAtLastIndex \ +-(TableName##_Cursor*)cursorAtLastIndex \ { \ return [[TableName##_Cursor alloc] initWithTable:self ndx:[self count]-1]; \ } \ --(TableName##_Cursor *)insertRowAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)insertRowAtIndex:(size_t)ndx \ { \ [super insertRowAtIndex:ndx]; \ return [[TableName##_Cursor alloc] initWithTable:self ndx:ndx]; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:self ndx:0]; \ } \ -+(BOOL)_checkType:(TightdbSpec *)spec \ ++(BOOL)_checkType:(TightdbDescriptor*)desc \ { \ %for $j in range($num_cols) - TIGHTDB_CHECK_COLUMN_TYPE(spec, ${j}, CName${j+1}, CType${j+1}) \ + TIGHTDB_CHECK_COLUMN_TYPE(desc, ${j}, CName${j+1}, CType${j+1}) \ %end for return YES; \ } \ -(BOOL)_checkType \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _checkType:spec]) return NO; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _checkType:desc]) \ + return NO; \ return YES; \ } \ -+(BOOL)_addColumns:(TightdbSpec *)spec \ ++(BOOL)_addColumns:(TightdbDescriptor*)desc \ { \ %for $j in range($num_cols) - TIGHTDB_ADD_COLUMN(spec, CName${j+1}, CType${j+1}) \ + TIGHTDB_ADD_COLUMN(desc, CName${j+1}, CType${j+1}) \ %end for return YES; \ } \ -(BOOL)_addColumns \ { \ - TightdbSpec *spec = [self getSpec]; \ - if (!spec) return NO; \ - if (![TableName _addColumns:spec]) return NO; \ - [self updateFromSpec]; \ + TightdbDescriptor* desc = [self getDescriptor]; \ + if (!desc) \ + return NO; \ + if (![TableName _addColumns:desc]) \ + return NO; \ return YES; \ } \ @end \ @implementation TableName##_View \ { \ - TableName##_Cursor *tmpCursor; \ + TableName##_Cursor* tmpCursor; \ } \ --(TightdbCursor *)getCursor \ +-(TightdbCursor*)getCursor \ { \ return tmpCursor = [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:0]]; \ } \ --(TableName##_Cursor *)cursorAtIndex:(size_t)ndx \ +-(TableName##_Cursor*)cursorAtIndex:(size_t)ndx \ { \ return [[TableName##_Cursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:ndx]]; \ } \ diff --git a/src/tightdb/objc/util.hpp b/src/tightdb/objc/util.hpp index 044d7c6ed2..b1ea5c121c 100644 --- a/src/tightdb/objc/util.hpp +++ b/src/tightdb/objc/util.hpp @@ -55,31 +55,31 @@ enum TightdbErr { tdb_err_Resource = 4, }; -inline NSError *make_tightdb_error(NSString *domain, TightdbErr code, NSString *desc) +inline NSError* make_tightdb_error(TightdbErr code, NSString *desc) { NSMutableDictionary* details = [NSMutableDictionary dictionary]; [details setValue:desc forKey:NSLocalizedDescriptionKey]; - return [NSError errorWithDomain:domain code:code userInfo:details]; + return [NSError errorWithDomain:@"com.tightdb" code:code userInfo:details]; } #define TIGHTDB_OBJC_SIZE_T_NUMBER_IN numberWithUnsignedLong #define TIGHTDB_OBJC_SIZE_T_NUMBER_OUT unsignedLongValue -#define TIGHTDB_EXCEPTION_ERRHANDLER(action, domain, failReturnValue) TIGHTDB_EXCEPTION_ERRHANDLER_EX(action, domain, failReturnValue, error) -#define TIGHTDB_EXCEPTION_ERRHANDLER_EX(action, domain, failReturnValue, errVar) try { action } \ +#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(domain, tdb_err_FileAccess, [NSString stringWithUTF8String:ex.what()]); \ + *errVar = make_tightdb_error(tdb_err_FileAccess, [NSString stringWithUTF8String:ex.what()]); \ return failReturnValue; \ } \ catch(tightdb::ResourceAllocError &ex) { \ if (errVar) \ - *errVar = make_tightdb_error(domain, tdb_err_Resource, [NSString stringWithUTF8String:ex.what()]); \ + *errVar = make_tightdb_error(tdb_err_Resource, [NSString stringWithUTF8String:ex.what()]); \ return failReturnValue; \ } \ catch (std::exception &ex) { \ if (errVar) \ - *errVar = make_tightdb_error(domain, tdb_err_Fail, [NSString stringWithUTF8String:ex.what()]); \ + *errVar = make_tightdb_error(tdb_err_Fail, [NSString stringWithUTF8String:ex.what()]); \ return failReturnValue; \ } From 55e57310ac985814847b01d3fafce008ba136b19 Mon Sep 17 00:00:00 2001 From: Kristian Spangsege Date: Thu, 30 Jan 2014 22:18:58 +0100 Subject: [PATCH 2/2] Many bug fixes. Major style fixup. --- src/tightdb/objc/group_objc.mm | 143 +++-- src/tightdb/objc/group_priv.h | 5 +- src/tightdb/objc/group_shared_objc.mm | 53 +- src/tightdb/objc/query_objc.mm | 674 ++++++++++---------- src/tightdb/objc/query_priv.h | 2 +- src/tightdb/objc/table.h | 28 +- src/tightdb/objc/table_objc.mm | 532 ++++++++------- src/tightdb/objc/table_priv.h | 11 +- src/tightdb/objc/test/group_misc_2.m | 2 +- src/tightdb/objc/test/tutorial.m | 2 +- src/tightdb/objc/tightdb.h | 30 +- src/tightdb/objc/tightdb.h.cheetah | 2 +- test-iphone/TightDbExample/ViewController.m | 2 +- 13 files changed, 773 insertions(+), 713 deletions(-) diff --git a/src/tightdb/objc/group_objc.mm b/src/tightdb/objc/group_objc.mm index 166253c9e7..8ae95ba099 100644 --- a/src/tightdb/objc/group_objc.mm +++ b/src/tightdb/objc/group_objc.mm @@ -15,77 +15,72 @@ using namespace std; -@interface TightdbGroup() -@property(nonatomic) tightdb::Group *group; -@property(nonatomic) BOOL readOnly; -@end - @implementation TightdbGroup -@synthesize group = _group; -@synthesize readOnly = _readOnly; +{ + tightdb::Group* m_group; + BOOL m_is_owned; + BOOL m_read_only; +} -+(TightdbGroup *)group ++(TightdbGroup*)group { return [self groupWithError:nil]; } -+(TightdbGroup *)groupWithError:(NSError *__autoreleasing *)error ++(TightdbGroup*)groupWithError:(NSError* __autoreleasing*)error { - TightdbGroup *group = [[TightdbGroup alloc] init]; - TIGHTDB_EXCEPTION_ERRHANDLER(group.group = new tightdb::Group();, nil); - group.readOnly = NO; + TightdbGroup* group = [[TightdbGroup alloc] init]; + TIGHTDB_EXCEPTION_ERRHANDLER(group->m_group = new tightdb::Group;, nil); + group->m_is_owned = YES; + group->m_read_only = NO; return group; } // Careful with this one - Remember that group will be deleted on dealloc. -+(TightdbGroup *)groupTightdbGroup:(tightdb::Group *)tightdbGroup readOnly:(BOOL)readOnly ++(TightdbGroup*)groupWithNativeGroup:(tightdb::Group*)group isOwned:(BOOL)is_owned readOnly:(BOOL)read_only { - TightdbGroup *group = [[TightdbGroup alloc] init]; - group.group = tightdbGroup; - group.readOnly = readOnly; - return group; + TightdbGroup* group_2 = [[TightdbGroup alloc] init]; + group_2->m_group = group; + group_2->m_is_owned = is_owned; + group_2->m_read_only = read_only; + return group_2; } -+(TightdbGroup *)groupWithFilename:(NSString *)filename ++(TightdbGroup*)groupWithFilename:(NSString*)filename { return [self groupWithFilename:filename error:nil]; } -+(TightdbGroup *)groupWithFilename:(NSString *)filename error:(NSError **)error ++(TightdbGroup*)groupWithFilename:(NSString*)filename error:(NSError**)error { - tightdb::Group* group; + TightdbGroup* group = [[TightdbGroup alloc] init]; + if (!group) + return nil; TIGHTDB_EXCEPTION_ERRHANDLER( - group = new tightdb::Group(tightdb::StringData(ObjcStringAccessor(filename)));, + group->m_group = new tightdb::Group(tightdb::StringData(ObjcStringAccessor(filename)));, nil); - TightdbGroup* group2 = [[TightdbGroup alloc] init]; - if (group2) { - group2.group = group; - group2.readOnly = NO; - } - return group2; + group->m_is_owned = YES; + group->m_read_only = NO; + return group; } -+(TightdbGroup *)groupWithBuffer:(const char *)data size:(size_t)size ++(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:(const char*)data size:(size_t)size error:(NSError* __autoreleasing*)error { - tightdb::Group* group; + TightdbGroup* group = [[TightdbGroup alloc] init]; + if (!group) + return nil; TIGHTDB_EXCEPTION_ERRHANDLER( - group = new tightdb::Group(tightdb::BinaryData(data, size));, + group->m_group = new tightdb::Group(tightdb::BinaryData(data, size));, nil); - TightdbGroup* group2 = [[TightdbGroup alloc] init]; - group2.group = group; - group2.readOnly = NO; - return group2; -} - --(void)clearGroup -{ - _group = 0; + group->m_is_owned = YES; + group->m_read_only = NO; + return group; } -(void)dealloc @@ -93,28 +88,29 @@ -(void)dealloc #ifdef TIGHTDB_DEBUG NSLog(@"TightdbGroup dealloc"); #endif - delete _group; + if (m_is_owned) + delete m_group; } -(size_t)getTableCount { - return _group->size(); + return m_group->size(); } --(NSString *)getTableName:(size_t)table_ndx +-(NSString*)getTableName:(size_t)table_ndx { - return to_objc_string(_group->get_table_name(table_ndx)); + return to_objc_string(m_group->get_table_name(table_ndx)); } --(BOOL)write:(NSString *)filePath +-(BOOL)write:(NSString*)file_path { - return [self write:filePath error:nil]; + return [self write:file_path error:nil]; } --(BOOL)write:(NSString *)filePath error:(NSError *__autoreleasing *)error +-(BOOL)write:(NSString*)file_path error:(NSError* __autoreleasing*)error { TIGHTDB_EXCEPTION_ERRHANDLER( - _group->write(tightdb::StringData(ObjcStringAccessor(filePath)));, + m_group->write(tightdb::StringData(ObjcStringAccessor(file_path)));, NO); return YES; } @@ -124,67 +120,74 @@ -(const char*)writeToMem:(size_t*)size return [self writeToMem:size error:nil]; } --(const char*)writeToMem:(size_t*)size error:(NSError *__autoreleasing *)error +-(const char*)writeToMem:(size_t*)size error:(NSError* __autoreleasing*)error { TIGHTDB_EXCEPTION_ERRHANDLER( - tightdb::BinaryData buffer = _group->write_to_mem(); + tightdb::BinaryData buffer = m_group->write_to_mem(); *size = buffer.size(); return buffer.data();, nil); } --(BOOL)hasTable:(NSString *)name +-(BOOL)hasTable:(NSString*)name { - return _group->has_table(ObjcStringAccessor(name)); + return m_group->has_table(ObjcStringAccessor(name)); } // FIXME: Avoid creating a table instance. It should be enough to create an TightdbDescriptor and then check that. // FIXME: Check that the specified class derives from Table. // FIXME: Find a way to avoid having to transcode the table name twice --(BOOL)hasTable:(NSString *)name withClass:(__unsafe_unretained Class)classObj +-(BOOL)hasTable:(NSString*)name withClass:(__unsafe_unretained Class)class_obj { - if (!_group->has_table(ObjcStringAccessor(name))) return NO; - TightdbTable* table = [self getTable:name withClass:classObj]; + if (!m_group->has_table(ObjcStringAccessor(name))) + return NO; + TightdbTable* table = [self getTable:name withClass:class_obj]; return table != nil; } --(id)getTable:(NSString *)name +-(id)getTable:(NSString*)name { return [self getTable:name error:nil]; } --(id)getTable:(NSString *)name error:(NSError *__autoreleasing *)error +-(id)getTable:(NSString*)name error:(NSError* __autoreleasing*)error { - TightdbTable *table = [[TightdbTable alloc] _initRaw]; - if (TIGHTDB_UNLIKELY(!table)) return nil; + TightdbTable* table = [[TightdbTable alloc] _initRaw]; + if (TIGHTDB_UNLIKELY(!table)) + return nil; TIGHTDB_EXCEPTION_ERRHANDLER( - [table setTable:_group->get_table(ObjcStringAccessor(name))];, + tightdb::TableRef table_2 = m_group->get_table(ObjcStringAccessor(name)); + [table setNativeTable:table_2.get()];, nil); [table setParent:self]; - [table setReadOnly:_readOnly]; + [table setReadOnly:m_read_only]; return table; } --(id)getTable:(NSString *)name withClass:(__unsafe_unretained Class)classObj +-(id)getTable:(NSString*)name withClass:(__unsafe_unretained Class)class_obj { - return [self getTable:name withClass:classObj error:nil]; + 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)classObj error:(NSError *__autoreleasing *)error +-(id)getTable:(NSString*)name withClass:(__unsafe_unretained Class)class_obj error:(NSError* __autoreleasing*)error { - TightdbTable *table = [[classObj alloc] _initRaw]; - if (TIGHTDB_UNLIKELY(!table)) return nil; + TightdbTable* table = [[class_obj alloc] _initRaw]; + if (TIGHTDB_UNLIKELY(!table)) + return nil; bool was_created; TIGHTDB_EXCEPTION_ERRHANDLER( - [table setTable:_group->get_table(ObjcStringAccessor(name), was_created)];, + tightdb::TableRef table_2 = m_group->get_table(ObjcStringAccessor(name), was_created); + [table setNativeTable:table_2.get()];, nil); [table setParent:self]; - [table setReadOnly:_readOnly]; + [table setReadOnly:m_read_only]; if (was_created) { - if (![table _addColumns]) return nil; + if (![table _addColumns]) + return nil; } else { - if (![table _checkType]) return nil; + if (![table _checkType]) + return nil; } return table; } diff --git a/src/tightdb/objc/group_priv.h b/src/tightdb/objc/group_priv.h index 5e7ea84124..d9abfd24f5 100644 --- a/src/tightdb/objc/group_priv.h +++ b/src/tightdb/objc/group_priv.h @@ -7,6 +7,7 @@ @interface TightdbGroup() -+(TightdbGroup *)groupTightdbGroup:(tightdb::Group *)tightdbGroup readOnly:(BOOL)readOnly; --(void)clearGroup; + ++(TightdbGroup*)groupWithNativeGroup:(tightdb::Group*)group isOwned:(BOOL)is_owned readOnly:(BOOL)read_only; + @end diff --git a/src/tightdb/objc/group_shared_objc.mm b/src/tightdb/objc/group_shared_objc.mm index d91d642ea2..7a22a6fe79 100644 --- a/src/tightdb/objc/group_shared_objc.mm +++ b/src/tightdb/objc/group_shared_objc.mm @@ -1,3 +1,4 @@ +#include #include #import @@ -10,14 +11,16 @@ @implementation TightdbSharedGroup { - tightdb::SharedGroup* _sharedGroup; + tightdb::util::UniquePtr m_shared_group; } -+(TightdbSharedGroup *)groupWithFilename:(NSString *)filename ++(TightdbSharedGroup*)groupWithFilename:(NSString*)filename { - tightdb::SharedGroup* shared_group; + TightdbSharedGroup* shared_group = [[TightdbSharedGroup alloc] init]; + if (!shared_group) + return nil; try { - shared_group = new tightdb::SharedGroup(tightdb::StringData(ObjcStringAccessor(filename))); + shared_group->m_shared_group.reset(new tightdb::SharedGroup(tightdb::StringData(ObjcStringAccessor(filename)))); } catch (...) { // FIXME: Diffrent exception types mean different things. More @@ -30,50 +33,46 @@ +(TightdbSharedGroup *)groupWithFilename:(NSString *)filename // anything derived from std::exception. return nil; } - TightdbSharedGroup* shared_group2 = [[TightdbSharedGroup alloc] init]; - if (shared_group2) { - shared_group2->_sharedGroup = shared_group; - } - return shared_group2; + return shared_group; } -(void)dealloc { - delete _sharedGroup; - _sharedGroup = 0; +#ifdef TIGHTDB_DEBUG + NSLog(@"TightdbSharedGroup dealloc"); +#endif } -(void)readTransaction:(TightdbSharedGroupReadTransactionBlock)block { - TightdbGroup* group; @try { - group = [TightdbGroup groupTightdbGroup:(tightdb::Group *)&_sharedGroup->begin_read() readOnly:YES]; - block(group); + const tightdb::Group& group = m_shared_group->begin_read(); + TightdbGroup* group_2 = [TightdbGroup groupWithNativeGroup:const_cast(&group) isOwned:NO readOnly:YES]; + block(group_2); } - @catch (NSException *exception) { + @catch (NSException* exception) { @throw exception; } @finally { - _sharedGroup->end_read(); - [group clearGroup]; + m_shared_group->end_read(); } } -(void)writeTransaction:(TightdbSharedGroupWriteTransactionBlock)block { - TightdbGroup* group; @try { - group = [TightdbGroup groupTightdbGroup:&_sharedGroup->begin_write() readOnly:NO]; - if (block(group)) - _sharedGroup->commit(); - else - _sharedGroup->rollback(); - [group clearGroup]; + 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(); + } } - @catch (NSException *exception) { - _sharedGroup->rollback(); - [group clearGroup]; + @catch (NSException* exception) { + m_shared_group->rollback(); @throw exception; } } diff --git a/src/tightdb/objc/query_objc.mm b/src/tightdb/objc/query_objc.mm index 276be45384..541427b8ca 100644 --- a/src/tightdb/objc/query_objc.mm +++ b/src/tightdb/objc/query_objc.mm @@ -3,10 +3,12 @@ // TightDB // +#include +#include +#include #include #include #include -#include #import #import @@ -18,48 +20,43 @@ using namespace std; -@interface TightdbView() -+(TightdbView *)tableViewWithTableView:(tightdb::TableView)table; -@end - - @interface TightdbQuery() { @public - NSError *_error; // To enable the flow of multiple stacked queries, any error is kept until the last step. + NSError* m_error; // To enable the flow of multiple stacked queries, any error is kept until the last step. } @end @implementation TightdbQuery { - tightdb::Query *_query; - __weak TightdbTable *_table; + tightdb::util::UniquePtr m_query; + __weak TightdbTable* m_table; - TightdbCursor *tmpCursor; + TightdbCursor* m_tmp_cursor; } --(id)initWithTable:(TightdbTable *)table +-(id)initWithTable:(TightdbTable*)table { return [self initWithTable:table error:nil]; } --(id)initWithTable:(TightdbTable *)table error:(NSError *__autoreleasing *)error +-(id)initWithTable:(TightdbTable*)table error:(NSError* __autoreleasing*)error { self = [super init]; if (self) { - _table = table; + m_table = table; TIGHTDB_EXCEPTION_ERRHANDLER( - _query = new tightdb::Query([_table getTable].where());, + m_query.reset(new tightdb::Query([table getNativeTable].where()));, nil); } return self; } --(TightdbCursor *)getCursor:(long)ndx +-(TightdbCursor*)getCursor:(long)ndx { - return tmpCursor = [[TightdbCursor alloc] initWithTable:[self getTable] ndx:ndx]; + return m_tmp_cursor = [[TightdbCursor alloc] initWithTable:[self getTable] ndx:ndx]; } -(long)getFastEnumStart @@ -72,18 +69,18 @@ -(long)incrementFastEnum:(long)ndx return [self find:ndx]; } -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained *)stackbuf count:(NSUInteger)len +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState*)state objects:(id __unsafe_unretained*)stackbuf count:(NSUInteger)len { (void)len; if(state->state == 0) { state->state = [self getFastEnumStart]; - state->mutationsPtr = (unsigned long *)objc_unretainedPointer(self); - TightdbCursor *tmp = [self getCursor:state->state]; + state->mutationsPtr = (unsigned long*)objc_unretainedPointer(self); + TightdbCursor* tmp = [self getCursor:state->state]; *stackbuf = tmp; } if ((int)state->state != -1) { - [((TightdbCursor *)*stackbuf) setNdx:state->state]; + [((TightdbCursor*)*stackbuf) setNdx:state->state]; state->itemsPtr = stackbuf; state->state = [self incrementFastEnum:state->state+1]; } else { @@ -95,545 +92,532 @@ - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state object return 1; } -// Due to cyclic ARC problems. You have to clear manually. (Must be called from client code) --(void)clear -{ - _table = nil; -} -(void)dealloc { #ifdef TIGHTDB_DEBUG - NSLog(@"Query dealloc"); + NSLog(@"TightdbQuery dealloc"); #endif - delete _query; } --(tightdb::Query *)getQuery +-(tightdb::Query&)getNativeQuery { - return _query; + return *m_query; } --(TightdbTable *)getTable +-(TightdbTable*)getTable { - return _table; + return m_table; } --(TightdbQuery *)group +-(TightdbQuery*)group { - TIGHTDB_EXCEPTION_ERRHANDLER_EX(_query->group();, self, &_error); + TIGHTDB_EXCEPTION_ERRHANDLER_EX(m_query->group();, self, &m_error); return self; } --(TightdbQuery *)or +-(TightdbQuery*)or { - TIGHTDB_EXCEPTION_ERRHANDLER_EX(_query->Or();, self, &_error); + TIGHTDB_EXCEPTION_ERRHANDLER_EX(m_query->Or();, self, &m_error); return self; } --(TightdbQuery *)endgroup +-(TightdbQuery*)endgroup { - TIGHTDB_EXCEPTION_ERRHANDLER_EX(_query->end_group();, self, &_error); + TIGHTDB_EXCEPTION_ERRHANDLER_EX(m_query->end_group();, self, &m_error); return self; } -(void)subtable:(size_t)column { - _query->subtable(column); + m_query->subtable(column); } -(void)parent { - _query->end_subtable(); + m_query->end_subtable(); } --(NSNumber *)count +-(NSNumber*)count { return [self countWithError:nil]; } --(NSNumber *)countWithError:(NSError *__autoreleasing *)error +-(NSNumber*)countWithError:(NSError* __autoreleasing*)error { - if (_error) { + if (m_error) { if (error) { - *error = _error; - _error = nil; + *error = m_error; + m_error = nil; } return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber TIGHTDB_OBJC_SIZE_T_NUMBER_IN:_query->count()];, + return [NSNumber TIGHTDB_OBJC_SIZE_T_NUMBER_IN:m_query->count()];, nil); } --(NSNumber *)remove +-(NSNumber*)remove { return [self removeWithError:nil]; } --(NSNumber *)removeWithError:(NSError *__autoreleasing *)error +-(NSNumber*)removeWithError:(NSError* __autoreleasing*)error { - if (_error) { + if (m_error) { if (error) { - *error = _error; - _error = nil; + *error = m_error; + m_error = nil; } return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber TIGHTDB_OBJC_SIZE_T_NUMBER_IN:_query->remove()];, + return [NSNumber TIGHTDB_OBJC_SIZE_T_NUMBER_IN:m_query->remove()];, nil); } --(NSNumber *)minimumWithIntColumn:(size_t)col_ndx +-(NSNumber*)minimumWithIntColumn:(size_t)col_ndx { return [self minimumWithIntColumn:col_ndx error:nil]; } --(NSNumber *)minimumWithIntColumn:(size_t)col_ndx error:(NSError *__autoreleasing *)error +-(NSNumber*)minimumWithIntColumn:(size_t)col_ndx error:(NSError* __autoreleasing*)error { - if (_error) { + if (m_error) { if (error) { - *error = _error; - _error = nil; + *error = m_error; + m_error = nil; } return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithLongLong:_query->minimum_int(col_ndx)];, + return [NSNumber numberWithLongLong:m_query->minimum_int(col_ndx)];, nil); } --(NSNumber *)minimumWithFloatColumn:(size_t)col_ndx +-(NSNumber*)minimumWithFloatColumn:(size_t)col_ndx { return [self minimumWithFloatColumn:col_ndx error:nil]; } --(NSNumber *)minimumWithFloatColumn:(size_t)col_ndx error:(NSError *__autoreleasing *)error +-(NSNumber*)minimumWithFloatColumn:(size_t)col_ndx error:(NSError* __autoreleasing*)error { - if (_error) { + if (m_error) { if (error) { - *error = _error; - _error = nil; + *error = m_error; + m_error = nil; } return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithFloat:_query->minimum_float(col_ndx)];, + return [NSNumber numberWithFloat:m_query->minimum_float(col_ndx)];, nil); } --(NSNumber *)minimumWithDoubleColumn:(size_t)col_ndx +-(NSNumber*)minimumWithDoubleColumn:(size_t)col_ndx { return [self minimumWithDoubleColumn:col_ndx error:nil]; } --(NSNumber *)minimumWithDoubleColumn:(size_t)col_ndx error:(NSError *__autoreleasing *)error +-(NSNumber*)minimumWithDoubleColumn:(size_t)col_ndx error:(NSError* __autoreleasing*)error { - if (_error) { + if (m_error) { if (error) { - *error = _error; - _error = nil; + *error = m_error; + m_error = nil; } return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithDouble:_query->minimum_double(col_ndx)];, + return [NSNumber numberWithDouble:m_query->minimum_double(col_ndx)];, nil); } --(NSNumber *)maximumWithIntColumn:(size_t)col_ndx +-(NSNumber*)maximumWithIntColumn:(size_t)col_ndx { return [self maximumWithIntColumn:col_ndx error:nil]; } --(NSNumber *)maximumWithIntColumn:(size_t)col_ndx error:(NSError *__autoreleasing *)error +-(NSNumber*)maximumWithIntColumn:(size_t)col_ndx error:(NSError* __autoreleasing*)error { - if (_error) { + if (m_error) { if (error) { - *error = _error; - _error = nil; + *error = m_error; + m_error = nil; } return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithLongLong:_query->maximum_int(col_ndx)];, + return [NSNumber numberWithLongLong:m_query->maximum_int(col_ndx)];, nil); } --(NSNumber *)maximumWithFloatColumn:(size_t)col_ndx +-(NSNumber*)maximumWithFloatColumn:(size_t)col_ndx { return [self maximumWithFloatColumn:col_ndx error:nil]; } --(NSNumber *)maximumWithFloatColumn:(size_t)col_ndx error:(NSError *__autoreleasing *)error +-(NSNumber*)maximumWithFloatColumn:(size_t)col_ndx error:(NSError* __autoreleasing*)error { - if (_error) { + if (m_error) { if (error) { - *error = _error; - _error = nil; + *error = m_error; + m_error = nil; } return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithFloat:_query->maximum_float(col_ndx)];, + return [NSNumber numberWithFloat:m_query->maximum_float(col_ndx)];, nil); } --(NSNumber *)maximumWithDoubleColumn:(size_t)col_ndx +-(NSNumber*)maximumWithDoubleColumn:(size_t)col_ndx { return [self maximumWithDoubleColumn:col_ndx error:nil]; } --(NSNumber *)maximumWithDoubleColumn:(size_t)col_ndx error:(NSError *__autoreleasing *)error +-(NSNumber*)maximumWithDoubleColumn:(size_t)col_ndx error:(NSError* __autoreleasing*)error { - if (_error) { + if (m_error) { if (error) { - *error = _error; - _error = nil; + *error = m_error; + m_error = nil; } return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithDouble:_query->maximum_double(col_ndx)];, + return [NSNumber numberWithDouble:m_query->maximum_double(col_ndx)];, nil); } --(NSNumber *)sumWithIntColumn:(size_t)col_ndx +-(NSNumber*)sumWithIntColumn:(size_t)col_ndx { return [self sumWithIntColumn:col_ndx error:nil]; } --(NSNumber *)sumWithIntColumn:(size_t)col_ndx error:(NSError *__autoreleasing *)error +-(NSNumber*)sumWithIntColumn:(size_t)col_ndx error:(NSError* __autoreleasing*)error { - if (_error) { + if (m_error) { if (error) { - *error = _error; - _error = nil; + *error = m_error; + m_error = nil; } return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithLongLong:_query->sum_int(col_ndx)];, + return [NSNumber numberWithLongLong:m_query->sum_int(col_ndx)];, nil); } --(NSNumber *)sumWithFloatColumn:(size_t)col_ndx +-(NSNumber*)sumWithFloatColumn:(size_t)col_ndx { return [self sumWithFloatColumn:col_ndx error:nil]; } --(NSNumber *)sumWithFloatColumn:(size_t)col_ndx error:(NSError *__autoreleasing *)error +-(NSNumber*)sumWithFloatColumn:(size_t)col_ndx error:(NSError* __autoreleasing*)error { - if (_error) { + if (m_error) { if (error) { - *error = _error; - _error = nil; + *error = m_error; + m_error = nil; } return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithFloat:_query->sum_float(col_ndx)];, + return [NSNumber numberWithFloat:m_query->sum_float(col_ndx)];, nil); } --(NSNumber *)sumWithDoubleColumn:(size_t)col_ndx +-(NSNumber*)sumWithDoubleColumn:(size_t)col_ndx { return [self sumWithDoubleColumn:col_ndx error:nil]; } --(NSNumber *)sumWithDoubleColumn:(size_t)col_ndx error:(NSError *__autoreleasing *)error +-(NSNumber*)sumWithDoubleColumn:(size_t)col_ndx error:(NSError* __autoreleasing*)error { - if (_error) { + if (m_error) { if (error) { - *error = _error; - _error = nil; + *error = m_error; + m_error = nil; } return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithDouble:_query->sum_double(col_ndx)];, + return [NSNumber numberWithDouble:m_query->sum_double(col_ndx)];, nil); } --(NSNumber *)averageWithIntColumn:(size_t)col_ndx +-(NSNumber*)averageWithIntColumn:(size_t)col_ndx { return [self averageWithIntColumn:col_ndx error:nil]; } --(NSNumber *)averageWithIntColumn:(size_t)col_ndx error:(NSError *__autoreleasing *)error +-(NSNumber*)averageWithIntColumn:(size_t)col_ndx error:(NSError* __autoreleasing*)error { - if (_error) { + if (m_error) { if (error) { - *error = _error; - _error = nil; + *error = m_error; + m_error = nil; } return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithDouble:_query->average_int(col_ndx)];, + return [NSNumber numberWithDouble:m_query->average_int(col_ndx)];, nil); } --(NSNumber *)averageWithFloatColumn:(size_t)col_ndx +-(NSNumber*)averageWithFloatColumn:(size_t)col_ndx { return [self averageWithFloatColumn:col_ndx error:nil]; } --(NSNumber *)averageWithFloatColumn:(size_t)col_ndx error:(NSError *__autoreleasing *)error +-(NSNumber*)averageWithFloatColumn:(size_t)col_ndx error:(NSError* __autoreleasing*)error { - if (_error) { + if (m_error) { if (error) { - *error = _error; - _error = nil; + *error = m_error; + m_error = nil; } return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithDouble:_query->average_float(col_ndx)];, + return [NSNumber numberWithDouble:m_query->average_float(col_ndx)];, nil); } --(NSNumber *)averageWithDoubleColumn:(size_t)col_ndx +-(NSNumber*)averageWithDoubleColumn:(size_t)col_ndx { return [self averageWithDoubleColumn:col_ndx error:nil]; } --(NSNumber *)averageWithDoubleColumn:(size_t)col_ndx error:(NSError *__autoreleasing *)error +-(NSNumber*)averageWithDoubleColumn:(size_t)col_ndx error:(NSError* __autoreleasing*)error { - if (_error) { + if (m_error) { if (error) { - *error = _error; - _error = nil; + *error = m_error; + m_error = nil; } return nil; } TIGHTDB_EXCEPTION_ERRHANDLER( - return [NSNumber numberWithDouble:_query->average_double(col_ndx)];, + return [NSNumber numberWithDouble:m_query->average_double(col_ndx)];, nil); } --(tightdb::TableView)getTableView +-(TightdbView*)findAll { - return _query->find_all(); + tightdb::TableView view = m_query->find_all(); + return [TightdbView viewWithTable:m_table andNativeView:view]; } - --(TightdbView *)findAll { - - // jjepsen: please review this. - return [[TightdbView alloc] initFromQuery:self]; -} - - -(size_t)find:(size_t)last { return [self find:last error:nil]; } --(size_t)find:(size_t)last error:(NSError *__autoreleasing *)error +-(size_t)find:(size_t)last error:(NSError* __autoreleasing*)error { - if (_error) { + if (m_error) { if (error) { - *error = _error; - _error = nil; + *error = m_error; + m_error = nil; } return size_t(-1); } - TIGHTDB_EXCEPTION_ERRHANDLER(return _query->find(last);, size_t(-1)); + TIGHTDB_EXCEPTION_ERRHANDLER(return m_query->find(last);, size_t(-1)); } // Conditions: --(TightdbQuery *)column:(size_t)colNdx isBetweenInt:(int64_t)from and_:(int64_t)to +-(TightdbQuery*)column:(size_t)colNdx isBetweenInt:(int64_t)from and_:(int64_t)to { - _query->between(colNdx, from, to); + m_query->between(colNdx, from, to); return self; } --(TightdbQuery *)column:(size_t)colNdx isBetweenFloat:(float)from and_:(float)to +-(TightdbQuery*)column:(size_t)colNdx isBetweenFloat:(float)from and_:(float)to { - _query->between(colNdx, from, to); + m_query->between(colNdx, from, to); return self; } --(TightdbQuery *)column:(size_t)colNdx isBetweenDouble:(double)from and_:(double)to +-(TightdbQuery*)column:(size_t)colNdx isBetweenDouble:(double)from and_:(double)to { - _query->between(colNdx, from, to); + m_query->between(colNdx, from, to); return self; } --(TightdbQuery *)column:(size_t)colNdx isBetweenDate:(time_t)from and_:(time_t)to +-(TightdbQuery*)column:(size_t)colNdx isBetweenDate:(time_t)from and_:(time_t)to { - _query->between_datetime(colNdx, from, to); + m_query->between_datetime(colNdx, from, to); return self; } --(TightdbQuery *)column:(size_t)colNdx isEqualToBool:(bool)value +-(TightdbQuery*)column:(size_t)colNdx isEqualToBool:(bool)value { - _query->equal(colNdx, value); + m_query->equal(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isEqualToInt:(int64_t)value +-(TightdbQuery*)column:(size_t)colNdx isEqualToInt:(int64_t)value { - _query->equal(colNdx, value); + m_query->equal(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isEqualToFloat:(float)value +-(TightdbQuery*)column:(size_t)colNdx isEqualToFloat:(float)value { - _query->equal(colNdx, value); + m_query->equal(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isEqualToDouble:(double)value +-(TightdbQuery*)column:(size_t)colNdx isEqualToDouble:(double)value { - _query->equal(colNdx, value); + m_query->equal(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isEqualToString:(NSString *)value +-(TightdbQuery*)column:(size_t)colNdx isEqualToString:(NSString*)value { - _query->equal(colNdx, ObjcStringAccessor(value)); + m_query->equal(colNdx, ObjcStringAccessor(value)); return self; } --(TightdbQuery *)column:(size_t)colNdx isEqualToString:(NSString *)value caseSensitive:(bool)caseSensitive +-(TightdbQuery*)column:(size_t)colNdx isEqualToString:(NSString*)value caseSensitive:(bool)caseSensitive { - _query->equal(colNdx, ObjcStringAccessor(value), caseSensitive); + m_query->equal(colNdx, ObjcStringAccessor(value), caseSensitive); return self; } --(TightdbQuery *)column:(size_t)colNdx isEqualToDate:(time_t)value +-(TightdbQuery*)column:(size_t)colNdx isEqualToDate:(time_t)value { - _query->equal_datetime(colNdx, value); + m_query->equal_datetime(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isEqualToBinary:(TightdbBinary *)value +-(TightdbQuery*)column:(size_t)colNdx isEqualToBinary:(TightdbBinary*)value { - _query->equal(colNdx, [value getBinary]); + m_query->equal(colNdx, [value getNativeBinary]); return self; } --(TightdbQuery *)column:(size_t)colNdx isNotEqualToInt:(int64_t)value +-(TightdbQuery*)column:(size_t)colNdx isNotEqualToInt:(int64_t)value { - _query->not_equal(colNdx, value); + m_query->not_equal(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isNotEqualToFloat:(float)value +-(TightdbQuery*)column:(size_t)colNdx isNotEqualToFloat:(float)value { - _query->not_equal(colNdx, value); + m_query->not_equal(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isNotEqualToDouble:(double)value +-(TightdbQuery*)column:(size_t)colNdx isNotEqualToDouble:(double)value { - _query->not_equal(colNdx, value); + m_query->not_equal(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isNotEqualToString:(NSString *)value +-(TightdbQuery*)column:(size_t)colNdx isNotEqualToString:(NSString*)value { - _query->not_equal(colNdx, ObjcStringAccessor(value)); + m_query->not_equal(colNdx, ObjcStringAccessor(value)); return self; } --(TightdbQuery *)column:(size_t)colNdx isNotEqualToString:(NSString *)value caseSensitive:(bool)caseSensitive +-(TightdbQuery*)column:(size_t)colNdx isNotEqualToString:(NSString*)value caseSensitive:(bool)caseSensitive { - _query->not_equal(colNdx, ObjcStringAccessor(value), caseSensitive); + m_query->not_equal(colNdx, ObjcStringAccessor(value), caseSensitive); return self; } --(TightdbQuery *)column:(size_t)colNdx isNotEqualToDate:(time_t)value +-(TightdbQuery*)column:(size_t)colNdx isNotEqualToDate:(time_t)value { - _query->not_equal_datetime(colNdx, value); + m_query->not_equal_datetime(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isNotEqualToBinary:(TightdbBinary *)value +-(TightdbQuery*)column:(size_t)colNdx isNotEqualToBinary:(TightdbBinary*)value { - _query->not_equal(colNdx, [value getBinary]); + m_query->not_equal(colNdx, [value getNativeBinary]); return self; } --(TightdbQuery *)column:(size_t)colNdx isGreaterThanInt:(int64_t)value +-(TightdbQuery*)column:(size_t)colNdx isGreaterThanInt:(int64_t)value { - _query->greater(colNdx, value); + m_query->greater(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isGreaterThanFloat:(float)value +-(TightdbQuery*)column:(size_t)colNdx isGreaterThanFloat:(float)value { - _query->greater(colNdx, value); + m_query->greater(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isGreaterThanDouble:(double)value +-(TightdbQuery*)column:(size_t)colNdx isGreaterThanDouble:(double)value { - _query->greater(colNdx, value); + m_query->greater(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isGreaterThanDate:(time_t)value +-(TightdbQuery*)column:(size_t)colNdx isGreaterThanDate:(time_t)value { - _query->greater_datetime(colNdx, value); + m_query->greater_datetime(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isGreaterThanOrEqualToInt:(int64_t)value +-(TightdbQuery*)column:(size_t)colNdx isGreaterThanOrEqualToInt:(int64_t)value { - _query->greater_equal(colNdx, value); + m_query->greater_equal(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isGreaterThanOrEqualToFloat:(float)value +-(TightdbQuery*)column:(size_t)colNdx isGreaterThanOrEqualToFloat:(float)value { - _query->greater_equal(colNdx, value); + m_query->greater_equal(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isGreaterThanOrEqualToDouble:(double)value +-(TightdbQuery*)column:(size_t)colNdx isGreaterThanOrEqualToDouble:(double)value { - _query->greater_equal(colNdx, value); + m_query->greater_equal(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isGreaterThanOrEqualToDate:(time_t)value +-(TightdbQuery*)column:(size_t)colNdx isGreaterThanOrEqualToDate:(time_t)value { - _query->greater_equal_datetime(colNdx, value); + m_query->greater_equal_datetime(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isLessThanInt:(int64_t)value +-(TightdbQuery*)column:(size_t)colNdx isLessThanInt:(int64_t)value { - _query->less(colNdx, value); + m_query->less(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isLessThanFloat:(float)value +-(TightdbQuery*)column:(size_t)colNdx isLessThanFloat:(float)value { - _query->less(colNdx, value); + m_query->less(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isLessThanDouble:(double)value +-(TightdbQuery*)column:(size_t)colNdx isLessThanDouble:(double)value { - _query->less(colNdx, value); + m_query->less(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isLessThanDate:(time_t)value +-(TightdbQuery*)column:(size_t)colNdx isLessThanDate:(time_t)value { - _query->less_datetime(colNdx, value); + m_query->less_datetime(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isLessThanOrEqualToInt:(int64_t)value +-(TightdbQuery*)column:(size_t)colNdx isLessThanOrEqualToInt:(int64_t)value { - _query->less_equal(colNdx, value); + m_query->less_equal(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isLessThanOrEqualToFloat:(float)value +-(TightdbQuery*)column:(size_t)colNdx isLessThanOrEqualToFloat:(float)value { - _query->less_equal(colNdx, value); + m_query->less_equal(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isLessThanOrEqualToDouble:(double)value +-(TightdbQuery*)column:(size_t)colNdx isLessThanOrEqualToDouble:(double)value { - _query->less_equal(colNdx, value); + m_query->less_equal(colNdx, value); return self; } --(TightdbQuery *)column:(size_t)colNdx isLessThanOrEqualToDate:(time_t)value +-(TightdbQuery*)column:(size_t)colNdx isLessThanOrEqualToDate:(time_t)value { - _query->less_equal_datetime(colNdx, value); + m_query->less_equal_datetime(colNdx, value); return self; } @@ -652,10 +636,10 @@ -(TightdbQuery *)column:(size_t)colNdx isLessThanOrEqualToDate:(time_t)value @implementation TightdbQueryAccessorBool { - __weak TightdbQuery *_query; + __weak TightdbQuery* _query; size_t _column_ndx; } --(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query +-(id)initWithColumn:(size_t)columnId query:(TightdbQuery*)query { self = [super init]; if (self) { @@ -664,9 +648,9 @@ -(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query } return self; } --(TightdbQuery *)columnIsEqualTo:(BOOL)value +-(TightdbQuery*)columnIsEqualTo:(BOOL)value { - [_query getQuery]->equal(_column_ndx, (bool)value); + [_query getNativeQuery].equal(_column_ndx, bool(value)); return _query; } @end @@ -674,10 +658,10 @@ -(TightdbQuery *)columnIsEqualTo:(BOOL)value @implementation TightdbQueryAccessorInt { - __weak TightdbQuery *_query; + __weak TightdbQuery* _query; size_t _column_ndx; } --(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query +-(id)initWithColumn:(size_t)columnId query:(TightdbQuery*)query { self = [super init]; if (self) { @@ -687,92 +671,92 @@ -(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query return self; } --(TightdbQuery *)columnIsEqualTo:(int64_t)value +-(TightdbQuery*)columnIsEqualTo:(int64_t)value { TIGHTDB_EXCEPTION_ERRHANDLER_EX( - [_query getQuery]->equal(_column_ndx, value);, - _query, &_query->_error); + [_query getNativeQuery].equal(_column_ndx, value);, + _query, &_query->m_error); return _query; } --(TightdbQuery *)columnIsNotEqualTo:(int64_t)value +-(TightdbQuery*)columnIsNotEqualTo:(int64_t)value { TIGHTDB_EXCEPTION_ERRHANDLER_EX( - [_query getQuery]->not_equal(_column_ndx, value);, - _query, &_query->_error); + [_query getNativeQuery].not_equal(_column_ndx, value);, + _query, &_query->m_error); return _query; } --(TightdbQuery *)columnIsGreaterThan:(int64_t)value +-(TightdbQuery*)columnIsGreaterThan:(int64_t)value { TIGHTDB_EXCEPTION_ERRHANDLER_EX( - [_query getQuery]->greater(_column_ndx, value);, - _query, &_query->_error); + [_query getNativeQuery].greater(_column_ndx, value);, + _query, &_query->m_error); return _query; } --(TightdbQuery *)columnIsGreaterThanOrEqualTo:(int64_t)value +-(TightdbQuery*)columnIsGreaterThanOrEqualTo:(int64_t)value { TIGHTDB_EXCEPTION_ERRHANDLER_EX( - [_query getQuery]->greater_equal(_column_ndx, value);, - _query, &_query->_error); + [_query getNativeQuery].greater_equal(_column_ndx, value);, + _query, &_query->m_error); return _query; } --(TightdbQuery *)columnIsLessThan:(int64_t)value +-(TightdbQuery*)columnIsLessThan:(int64_t)value { TIGHTDB_EXCEPTION_ERRHANDLER_EX( - [_query getQuery]->less(_column_ndx, value);, - _query, &_query->_error); + [_query getNativeQuery].less(_column_ndx, value);, + _query, &_query->m_error); return _query; } --(TightdbQuery *)columnIsLessThanOrEqualTo:(int64_t)value +-(TightdbQuery*)columnIsLessThanOrEqualTo:(int64_t)value { TIGHTDB_EXCEPTION_ERRHANDLER_EX( - [_query getQuery]->less_equal(_column_ndx, value);, - _query, &_query->_error); + [_query getNativeQuery].less_equal(_column_ndx, value);, + _query, &_query->m_error); return _query; } --(TightdbQuery *)columnIsBetween:(int64_t)from and_:(int64_t)to +-(TightdbQuery*)columnIsBetween:(int64_t)from and_:(int64_t)to { TIGHTDB_EXCEPTION_ERRHANDLER_EX( - [_query getQuery]->between(_column_ndx, from, to);, - _query, &_query->_error); + [_query getNativeQuery].between(_column_ndx, from, to);, + _query, &_query->m_error); return _query; } --(NSNumber *)minimum +-(NSNumber*)minimum { return [self minimumWithError:nil]; } --(NSNumber *)minimumWithError:(NSError *__autoreleasing *)error +-(NSNumber*)minimumWithError:(NSError* __autoreleasing*)error { return [_query minimumWithIntColumn:_column_ndx error:error]; } --(NSNumber *)maximum +-(NSNumber*)maximum { return [self maximumWithError:nil]; } --(NSNumber *)maximumWithError:(NSError *__autoreleasing *)error +-(NSNumber*)maximumWithError:(NSError* __autoreleasing*)error { return [_query maximumWithIntColumn:_column_ndx error:error]; } --(NSNumber *)sum +-(NSNumber*)sum { return [self sumWithError:nil]; } --(NSNumber *)sumWithError:(NSError *__autoreleasing *)error +-(NSNumber*)sumWithError:(NSError* __autoreleasing*)error { return [_query sumWithIntColumn:_column_ndx error:error]; } --(NSNumber *)average +-(NSNumber*)average { return [self averageWithError:nil]; } --(NSNumber *)averageWithError:(NSError *__autoreleasing *)error +-(NSNumber*)averageWithError:(NSError* __autoreleasing*)error { return [_query averageWithIntColumn:_column_ndx error:error]; } @@ -781,10 +765,10 @@ -(NSNumber *)averageWithError:(NSError *__autoreleasing *)error @implementation TightdbQueryAccessorFloat { - __weak TightdbQuery *_query; + __weak TightdbQuery* _query; size_t _column_ndx; } --(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query +-(id)initWithColumn:(size_t)columnId query:(TightdbQuery*)query { self = [super init]; if (self) { @@ -794,78 +778,78 @@ -(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query return self; } --(TightdbQuery *)columnIsEqualTo:(float)value +-(TightdbQuery*)columnIsEqualTo:(float)value { - [_query getQuery]->equal(_column_ndx, value); + [_query getNativeQuery].equal(_column_ndx, value); return _query; } --(TightdbQuery *)columnIsNotEqualTo:(float)value +-(TightdbQuery*)columnIsNotEqualTo:(float)value { - [_query getQuery]->not_equal(_column_ndx, value); + [_query getNativeQuery].not_equal(_column_ndx, value); return _query; } --(TightdbQuery *)columnIsGreaterThan:(float)value +-(TightdbQuery*)columnIsGreaterThan:(float)value { - [_query getQuery]->greater(_column_ndx, value); + [_query getNativeQuery].greater(_column_ndx, value); return _query; } --(TightdbQuery *)columnIsGreaterThanOrEqualTo:(float)value +-(TightdbQuery*)columnIsGreaterThanOrEqualTo:(float)value { - [_query getQuery]->greater_equal(_column_ndx, value); + [_query getNativeQuery].greater_equal(_column_ndx, value); return _query; } --(TightdbQuery *)columnIsLessThan:(float)value +-(TightdbQuery*)columnIsLessThan:(float)value { - [_query getQuery]->less(_column_ndx, value); + [_query getNativeQuery].less(_column_ndx, value); return _query; } --(TightdbQuery *)columnIsLessThanOrEqualTo:(float)value +-(TightdbQuery*)columnIsLessThanOrEqualTo:(float)value { - [_query getQuery]->less_equal(_column_ndx, value); + [_query getNativeQuery].less_equal(_column_ndx, value); return _query; } --(TightdbQuery *)columnIsBetween:(float)from and_:(float)to +-(TightdbQuery*)columnIsBetween:(float)from and_:(float)to { - [_query getQuery]->between(_column_ndx, from, to); + [_query getNativeQuery].between(_column_ndx, from, to); return _query; } --(NSNumber *)minimum +-(NSNumber*)minimum { return [self minimumWithError:nil]; } --(NSNumber *)minimumWithError:(NSError *__autoreleasing *)error +-(NSNumber*)minimumWithError:(NSError* __autoreleasing*)error { return [_query minimumWithFloatColumn:_column_ndx error:error]; } --(NSNumber *)maximum +-(NSNumber*)maximum { return [self maximumWithError:nil]; } --(NSNumber *)maximumWithError:(NSError *__autoreleasing *)error +-(NSNumber*)maximumWithError:(NSError* __autoreleasing*)error { return [_query maximumWithFloatColumn:_column_ndx error:error]; } --(NSNumber *)sum +-(NSNumber*)sum { return [self sumWithError:nil]; } --(NSNumber *)sumWithError:(NSError *__autoreleasing *)error +-(NSNumber*)sumWithError:(NSError* __autoreleasing*)error { return [_query sumWithFloatColumn:_column_ndx error:error]; } --(NSNumber *)average +-(NSNumber*)average { return [self averageWithError:nil]; } --(NSNumber *)averageWithError:(NSError *__autoreleasing *)error +-(NSNumber*)averageWithError:(NSError* __autoreleasing*)error { return [_query averageWithFloatColumn:_column_ndx error:error]; } @@ -874,10 +858,10 @@ -(NSNumber *)averageWithError:(NSError *__autoreleasing *)error @implementation TightdbQueryAccessorDouble { - __weak TightdbQuery *_query; + __weak TightdbQuery* _query; size_t _column_ndx; } --(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query +-(id)initWithColumn:(size_t)columnId query:(TightdbQuery*)query { self = [super init]; if (self) { @@ -887,78 +871,78 @@ -(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query return self; } --(TightdbQuery *)columnIsEqualTo:(double)value +-(TightdbQuery*)columnIsEqualTo:(double)value { - [_query getQuery]->equal(_column_ndx, value); + [_query getNativeQuery].equal(_column_ndx, value); return _query; } --(TightdbQuery *)columnIsNotEqualTo:(double)value +-(TightdbQuery*)columnIsNotEqualTo:(double)value { - [_query getQuery]->not_equal(_column_ndx, value); + [_query getNativeQuery].not_equal(_column_ndx, value); return _query; } --(TightdbQuery *)columnIsGreaterThan:(double)value +-(TightdbQuery*)columnIsGreaterThan:(double)value { - [_query getQuery]->greater(_column_ndx, value); + [_query getNativeQuery].greater(_column_ndx, value); return _query; } --(TightdbQuery *)columnIsGreaterThanOrEqualTo:(double)value +-(TightdbQuery*)columnIsGreaterThanOrEqualTo:(double)value { - [_query getQuery]->greater_equal(_column_ndx, value); + [_query getNativeQuery].greater_equal(_column_ndx, value); return _query; } --(TightdbQuery *)columnIsLessThan:(double)value +-(TightdbQuery*)columnIsLessThan:(double)value { - [_query getQuery]->less(_column_ndx, value); + [_query getNativeQuery].less(_column_ndx, value); return _query; } --(TightdbQuery *)columnIsLessThanOrEqualTo:(double)value +-(TightdbQuery*)columnIsLessThanOrEqualTo:(double)value { - [_query getQuery]->less_equal(_column_ndx, value); + [_query getNativeQuery].less_equal(_column_ndx, value); return _query; } --(TightdbQuery *)columnIsBetween:(double)from and_:(double)to +-(TightdbQuery*)columnIsBetween:(double)from and_:(double)to { - [_query getQuery]->between(_column_ndx, from, to); + [_query getNativeQuery].between(_column_ndx, from, to); return _query; } --(NSNumber *)minimum +-(NSNumber*)minimum { return [self minimumWithError:nil]; } --(NSNumber *)minimumWithError:(NSError *__autoreleasing *)error +-(NSNumber*)minimumWithError:(NSError* __autoreleasing*)error { return [_query minimumWithDoubleColumn:_column_ndx error:error]; } --(NSNumber *)maximum +-(NSNumber*)maximum { return [self maximumWithError:nil]; } --(NSNumber *)maximumWithError:(NSError *__autoreleasing *)error +-(NSNumber*)maximumWithError:(NSError* __autoreleasing*)error { return [_query maximumWithDoubleColumn:_column_ndx error:error]; } --(NSNumber *)sum +-(NSNumber*)sum { return [self sumWithError:nil]; } --(NSNumber *)sumWithError:(NSError *__autoreleasing *)error +-(NSNumber*)sumWithError:(NSError* __autoreleasing*)error { return [_query sumWithDoubleColumn:_column_ndx error:error]; } --(NSNumber *)average +-(NSNumber*)average { return [self averageWithError:nil]; } --(NSNumber *)averageWithError:(NSError *__autoreleasing *)error +-(NSNumber*)averageWithError:(NSError* __autoreleasing*)error { return [_query averageWithDoubleColumn:_column_ndx error:error]; } @@ -967,10 +951,10 @@ -(NSNumber *)averageWithError:(NSError *__autoreleasing *)error @implementation TightdbQueryAccessorString { - __weak TightdbQuery *_query; + __weak TightdbQuery* _query; size_t _column_ndx; } --(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query +-(id)initWithColumn:(size_t)columnId query:(TightdbQuery*)query { self = [super init]; if (self) { @@ -979,54 +963,54 @@ -(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query } return self; } --(TightdbQuery *)columnIsEqualTo:(NSString *)value +-(TightdbQuery*)columnIsEqualTo:(NSString*)value { - [_query getQuery]->equal(_column_ndx, ObjcStringAccessor(value)); + [_query getNativeQuery].equal(_column_ndx, ObjcStringAccessor(value)); return _query; } --(TightdbQuery *)columnIsEqualTo:(NSString *)value caseSensitive:(BOOL)caseSensitive +-(TightdbQuery*)columnIsEqualTo:(NSString*)value caseSensitive:(BOOL)caseSensitive { - [_query getQuery]->equal(_column_ndx, ObjcStringAccessor(value), caseSensitive); + [_query getNativeQuery].equal(_column_ndx, ObjcStringAccessor(value), caseSensitive); return _query; } --(TightdbQuery *)columnIsNotEqualTo:(NSString *)value +-(TightdbQuery*)columnIsNotEqualTo:(NSString*)value { - [_query getQuery]->not_equal(_column_ndx, ObjcStringAccessor(value)); + [_query getNativeQuery].not_equal(_column_ndx, ObjcStringAccessor(value)); return _query; } --(TightdbQuery *)columnIsNotEqualTo:(NSString *)value caseSensitive:(BOOL)caseSensitive +-(TightdbQuery*)columnIsNotEqualTo:(NSString*)value caseSensitive:(BOOL)caseSensitive { - [_query getQuery]->not_equal(_column_ndx, ObjcStringAccessor(value), caseSensitive); + [_query getNativeQuery].not_equal(_column_ndx, ObjcStringAccessor(value), caseSensitive); return _query; } --(TightdbQuery *)columnBeginsWith:(NSString *)value +-(TightdbQuery*)columnBeginsWith:(NSString*)value { - [_query getQuery]->begins_with(_column_ndx, ObjcStringAccessor(value)); + [_query getNativeQuery].begins_with(_column_ndx, ObjcStringAccessor(value)); return _query; } --(TightdbQuery *)columnBeginsWith:(NSString *)value caseSensitive:(BOOL)caseSensitive +-(TightdbQuery*)columnBeginsWith:(NSString*)value caseSensitive:(BOOL)caseSensitive { - [_query getQuery]->begins_with(_column_ndx, ObjcStringAccessor(value), caseSensitive); + [_query getNativeQuery].begins_with(_column_ndx, ObjcStringAccessor(value), caseSensitive); return _query; } --(TightdbQuery *)columnEndsWith:(NSString *)value +-(TightdbQuery*)columnEndsWith:(NSString*)value { - [_query getQuery]->ends_with(_column_ndx, ObjcStringAccessor(value)); + [_query getNativeQuery].ends_with(_column_ndx, ObjcStringAccessor(value)); return _query; } --(TightdbQuery *)columnEndsWith:(NSString *)value caseSensitive:(BOOL)caseSensitive +-(TightdbQuery*)columnEndsWith:(NSString*)value caseSensitive:(BOOL)caseSensitive { - [_query getQuery]->ends_with(_column_ndx, ObjcStringAccessor(value), caseSensitive); + [_query getNativeQuery].ends_with(_column_ndx, ObjcStringAccessor(value), caseSensitive); return _query; } --(TightdbQuery *)columnContains:(NSString *)value +-(TightdbQuery*)columnContains:(NSString*)value { - [_query getQuery]->contains(_column_ndx, ObjcStringAccessor(value)); + [_query getNativeQuery].contains(_column_ndx, ObjcStringAccessor(value)); return _query; } --(TightdbQuery *)columnContains:(NSString *)value caseSensitive:(BOOL)caseSensitive +-(TightdbQuery*)columnContains:(NSString*)value caseSensitive:(BOOL)caseSensitive { - [_query getQuery]->contains(_column_ndx, ObjcStringAccessor(value), caseSensitive); + [_query getNativeQuery].contains(_column_ndx, ObjcStringAccessor(value), caseSensitive); return _query; } @end @@ -1034,10 +1018,10 @@ -(TightdbQuery *)columnContains:(NSString *)value caseSensitive:(BOOL)caseSensit @implementation TightdbQueryAccessorBinary { - __weak TightdbQuery *_query; + __weak TightdbQuery* _query; size_t _column_ndx; } --(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query +-(id)initWithColumn:(size_t)columnId query:(TightdbQuery*)query { self = [super init]; if (self) { @@ -1046,29 +1030,29 @@ -(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query } return self; } --(TightdbQuery *)columnIsEqualTo:(TightdbBinary *)value +-(TightdbQuery*)columnIsEqualTo:(TightdbBinary*)value { - [_query getQuery]->equal(_column_ndx, [value getBinary]); + [_query getNativeQuery].equal(_column_ndx, [value getNativeBinary]); return _query; } --(TightdbQuery *)columnIsNotEqualTo:(TightdbBinary *)value +-(TightdbQuery*)columnIsNotEqualTo:(TightdbBinary*)value { - [_query getQuery]->not_equal(_column_ndx, [value getBinary]); + [_query getNativeQuery].not_equal(_column_ndx, [value getNativeBinary]); return _query; } --(TightdbQuery *)columnBeginsWith:(TightdbBinary *)value +-(TightdbQuery*)columnBeginsWith:(TightdbBinary*)value { - [_query getQuery]->begins_with(_column_ndx, [value getBinary]); + [_query getNativeQuery].begins_with(_column_ndx, [value getNativeBinary]); return _query; } --(TightdbQuery *)columnEndsWith:(TightdbBinary *)value +-(TightdbQuery*)columnEndsWith:(TightdbBinary*)value { - [_query getQuery]->ends_with(_column_ndx, [value getBinary]); + [_query getNativeQuery].ends_with(_column_ndx, [value getNativeBinary]); return _query; } --(TightdbQuery *)columnContains:(TightdbBinary *)value +-(TightdbQuery*)columnContains:(TightdbBinary*)value { - [_query getQuery]->contains(_column_ndx, [value getBinary]); + [_query getNativeQuery].contains(_column_ndx, [value getNativeBinary]); return _query; } @end @@ -1076,10 +1060,10 @@ -(TightdbQuery *)columnContains:(TightdbBinary *)value @implementation TightdbQueryAccessorDate { - __weak TightdbQuery *_query; + __weak TightdbQuery* _query; size_t _column_ndx; } --(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query +-(id)initWithColumn:(size_t)columnId query:(TightdbQuery*)query { self = [super init]; if (self) { @@ -1088,39 +1072,39 @@ -(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query } return self; } --(TightdbQuery *)columnIsEqualTo:(time_t)value +-(TightdbQuery*)columnIsEqualTo:(time_t)value { - [_query getQuery]->equal_datetime(_column_ndx, value); + [_query getNativeQuery].equal_datetime(_column_ndx, value); return _query; } --(TightdbQuery *)columnIsNotEqualTo:(time_t)value +-(TightdbQuery*)columnIsNotEqualTo:(time_t)value { - [_query getQuery]->not_equal_datetime(_column_ndx, value); + [_query getNativeQuery].not_equal_datetime(_column_ndx, value); return _query; } --(TightdbQuery *)columnIsGreaterThan:(time_t)value +-(TightdbQuery*)columnIsGreaterThan:(time_t)value { - [_query getQuery]->greater_datetime(_column_ndx, value); + [_query getNativeQuery].greater_datetime(_column_ndx, value); return _query; } --(TightdbQuery *)columnIsGreaterThanOrEqualTo:(time_t)value +-(TightdbQuery*)columnIsGreaterThanOrEqualTo:(time_t)value { - [_query getQuery]->greater_equal_datetime(_column_ndx, value); + [_query getNativeQuery].greater_equal_datetime(_column_ndx, value); return _query; } --(TightdbQuery *)columnIsLessThan:(time_t)value +-(TightdbQuery*)columnIsLessThan:(time_t)value { - [_query getQuery]->less_datetime(_column_ndx, value); + [_query getNativeQuery].less_datetime(_column_ndx, value); return _query; } --(TightdbQuery *)columnIsLessThanOrEqualTo:(time_t)value +-(TightdbQuery*)columnIsLessThanOrEqualTo:(time_t)value { - [_query getQuery]->less_equal_datetime(_column_ndx, value); + [_query getNativeQuery].less_equal_datetime(_column_ndx, value); return _query; } --(TightdbQuery *)columnIsBetween:(time_t)from and_:(time_t)to +-(TightdbQuery*)columnIsBetween:(time_t)from and_:(time_t)to { - [_query getQuery]->between_datetime(_column_ndx, from, to); + [_query getNativeQuery].between_datetime(_column_ndx, from, to); return _query; } @end @@ -1128,10 +1112,10 @@ -(TightdbQuery *)columnIsBetween:(time_t)from and_:(time_t)to @implementation TightdbQueryAccessorSubtable { - __weak TightdbQuery *_query; + __weak TightdbQuery* _query; size_t _column_ndx; } --(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query +-(id)initWithColumn:(size_t)columnId query:(TightdbQuery*)query { self = [super init]; if (self) { @@ -1145,10 +1129,10 @@ -(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query @implementation TightdbQueryAccessorMixed { - __weak TightdbQuery *_query; + __weak TightdbQuery* _query; size_t _column_ndx; } --(id)initWithColumn:(size_t)columnId query:(TightdbQuery *)query +-(id)initWithColumn:(size_t)columnId query:(TightdbQuery*)query { self = [super init]; if (self) { diff --git a/src/tightdb/objc/query_priv.h b/src/tightdb/objc/query_priv.h index 055c98f7e9..0043da5f79 100644 --- a/src/tightdb/objc/query_priv.h +++ b/src/tightdb/objc/query_priv.h @@ -6,5 +6,5 @@ #import @interface TightdbQuery() --(tightdb::TableView)getTableView; +-(tightdb::Query&)getNativeQuery; @end diff --git a/src/tightdb/objc/table.h b/src/tightdb/objc/table.h index e1d9acb18c..3bf8b7065f 100644 --- a/src/tightdb/objc/table.h +++ b/src/tightdb/objc/table.h @@ -146,6 +146,7 @@ -(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; @@ -164,6 +165,7 @@ // 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)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; @@ -215,6 +217,7 @@ -(size_t)addColumnWithType:(TightdbType)type andName:(NSString *)name error:(NSError *__autoreleasing *)error; // Searching +// FIXME: Should be findBool:(BOOL)value inColumn:(size_t)colNdx; -(size_t)findBool:(size_t)colNdx value:(BOOL)value; -(size_t)findInt:(size_t)colNdx value:(int64_t)value; -(size_t)findFloat:(size_t)colNdx value:(float)value; @@ -223,13 +226,22 @@ -(size_t)findBinary:(size_t)colNdx value:(TightdbBinary *)value; -(size_t)findDate:(size_t)colNdx value:(time_t)value; -(size_t)findMixed:(size_t)colNdx value:(TightdbMixed *)value; + +// FIXME: The naming scheme used here is superior to the one used in +// most of the other methods in this class. As time allows, this +// scheme must be migrated to all those other methods. +-(TightdbView *)findAllBool:(BOOL)value inColumn:(size_t)colNdx; +-(TightdbView *)findAllInt:(int64_t)value inColumn:(size_t)colNdx; +-(TightdbView *)findAllFloat:(float)value inColumn:(size_t)colNdx; +-(TightdbView *)findAllDouble:(double)value inColumn:(size_t)colNdx; +-(TightdbView *)findAllString:(NSString *)value inColumn:(size_t)colNdx; +-(TightdbView *)findAllBinary:(TightdbBinary *)value inColumn:(size_t)colNdx; +-(TightdbView *)findAllDate:(time_t)value inColumn:(size_t)colNdx; +-(TightdbView *)findAllMixed:(TightdbMixed *)value inColumn:(size_t)colNdx; + -(TightdbQuery *)where; -(TightdbQuery *)whereWithError:(NSError *__autoreleasing *)error; -// FIXME: Why does this one take a TableView as argument? --(TightdbView *)findAll:(TightdbView *)view column:(size_t)colNdx value:(int64_t)value; -// FIXME: Implement findAll for the rest of the column types. - // Indexing -(BOOL)hasIndex:(size_t)colNdx; -(void)setIndex:(size_t)colNdx; @@ -242,6 +254,7 @@ // FIXME: Do we want to conversion methods? Maybe use NSData. // Aggregate functions +// FIXME: Should be countInt:(int64_t)value inColumn:(size_t)colNdx; -(size_t)countWithIntColumn:(size_t)colNdx andValue:(int64_t)target; -(size_t)countWithFloatColumn:(size_t)colNdx andValue:(float)target; -(size_t)countWithDoubleColumn:(size_t)colNdx andValue:(double)target; @@ -271,9 +284,6 @@ @interface TightdbView: NSObject --(id)initFromQuery:(TightdbQuery *)query; -+(TightdbView *)tableViewWithTable:(TightdbTable *)table; - -(TightdbCursor *)cursorAtIndex:(size_t)ndx; -(size_t)count; @@ -287,6 +297,9 @@ -(TightdbTable *)getTable; -(size_t)getSourceIndex:(size_t)ndx; - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained *)stackbuf count:(NSUInteger)len; + +// Private +-(id)_initWithQuery:(TightdbQuery *)query; @end @@ -303,7 +316,6 @@ @interface TightdbColumnProxy_Int: TightdbColumnProxy -(size_t)find:(int64_t)value; --(TightdbView *)findAll:(int64_t)value; -(int64_t)minimum; -(int64_t)maximum; -(int64_t)sum; diff --git a/src/tightdb/objc/table_objc.mm b/src/tightdb/objc/table_objc.mm index 3b6dc9e8f5..adec5a7721 100644 --- a/src/tightdb/objc/table_objc.mm +++ b/src/tightdb/objc/table_objc.mm @@ -3,6 +3,7 @@ // TightDB // +#include #include #include #include @@ -20,13 +21,13 @@ @implementation TightdbBinary { - tightdb::BinaryData _data; + tightdb::BinaryData m_data; } -(id)initWithData:(const char*)data size:(size_t)size { self = [super init]; if (self) { - _data = tightdb::BinaryData(data, size); + m_data = tightdb::BinaryData(data, size); } return self; } @@ -34,130 +35,146 @@ -(id)initWithBinary:(tightdb::BinaryData)data { self = [super init]; if (self) { - _data = data; + m_data = data; } return self; } -(const char*)getData { - return _data.data(); + return m_data.data(); } -(size_t)getSize { - return _data.size(); + return m_data.size(); } -(BOOL)isEqual:(TightdbBinary*)bin { - return _data == bin->_data; + return m_data == bin->m_data; } --(tightdb::BinaryData)getBinary +-(tightdb::BinaryData)getNativeBinary { - return _data; + return m_data; } @end @interface TightdbMixed() -@property (nonatomic) tightdb::Mixed mixed; -@property (nonatomic, strong) TightdbTable* table; -+(TightdbMixed*)mixedWithMixed:(tightdb::Mixed&)other; ++(TightdbMixed*)mixedWithNativeMixed:(const tightdb::Mixed&)other; +-(tightdb::Mixed&)getNativeMixed; @end @implementation TightdbMixed -@synthesize mixed = _mixed; -@synthesize table = _table; +{ + tightdb::Mixed m_mixed; + TightdbTable* m_table; +} +(TightdbMixed*)mixedWithBool:(BOOL)value { TightdbMixed* mixed = [[TightdbMixed alloc] init]; - mixed.mixed = tightdb::Mixed((bool)value); + mixed->m_mixed = tightdb::Mixed(bool(value)); + mixed->m_table = nil; return mixed; } +(TightdbMixed*)mixedWithInt64:(int64_t)value { TightdbMixed* mixed = [[TightdbMixed alloc] init]; - mixed.mixed = tightdb::Mixed(value); + mixed->m_mixed = tightdb::Mixed(value); + mixed->m_table = nil; return mixed; } +(TightdbMixed*)mixedWithFloat:(float)value { TightdbMixed* mixed = [[TightdbMixed alloc] init]; - mixed.mixed = tightdb::Mixed(value); + mixed->m_mixed = tightdb::Mixed(value); + mixed->m_table = nil; return mixed; } +(TightdbMixed*)mixedWithDouble:(double)value { TightdbMixed* mixed = [[TightdbMixed alloc] init]; - mixed.mixed = tightdb::Mixed(value); + mixed->m_mixed = tightdb::Mixed(value); + mixed->m_table = nil; return mixed; } +(TightdbMixed*)mixedWithString:(NSString*)value { TightdbMixed* mixed = [[TightdbMixed alloc] init]; - mixed.mixed = tightdb::Mixed(ObjcStringAccessor(value)); + mixed->m_mixed = tightdb::Mixed(ObjcStringAccessor(value)); + mixed->m_table = nil; return mixed; } +(TightdbMixed*)mixedWithBinary:(TightdbBinary*)value { TightdbMixed* mixed = [[TightdbMixed alloc] init]; - mixed.mixed = tightdb::Mixed([value getBinary]); + mixed->m_mixed = tightdb::Mixed([value getNativeBinary]); + mixed->m_table = nil; return mixed; } +(TightdbMixed*)mixedWithBinary:(const char*)data size:(size_t)size { TightdbMixed* mixed = [[TightdbMixed alloc] init]; - mixed.mixed = tightdb::Mixed(tightdb::BinaryData(data, size)); + mixed->m_mixed = tightdb::Mixed(tightdb::BinaryData(data, size)); + mixed->m_table = nil; return mixed; } +(TightdbMixed*)mixedWithDate:(time_t)value { TightdbMixed* mixed = [[TightdbMixed alloc] init]; - mixed.mixed = tightdb::Mixed(tightdb::DateTime(value)); + mixed->m_mixed = tightdb::Mixed(tightdb::DateTime(value)); + mixed->m_table = nil; return mixed; } +(TightdbMixed*)mixedWithTable:(TightdbTable*)value { TightdbMixed* mixed = [[TightdbMixed alloc] init]; - mixed.mixed = tightdb::Mixed(tightdb::Mixed::subtable_tag()); - mixed.table = value; + mixed->m_mixed = tightdb::Mixed(tightdb::Mixed::subtable_tag()); + mixed->m_table = value; return mixed; } -+(TightdbMixed*)mixedWithMixed:(tightdb::Mixed&)value ++(TightdbMixed*)mixedWithNativeMixed:(const tightdb::Mixed&)value { TightdbMixed* mixed = [[TightdbMixed alloc] init]; - mixed.mixed = value; + mixed->m_mixed = value; + mixed->m_table = nil; return mixed; } +-(tightdb::Mixed&)getNativeMixed +{ + return m_mixed; +} + -(BOOL)isEqual:(TightdbMixed*)other { - const tightdb::DataType type = _mixed.get_type(); - if (type != other->_mixed.get_type()) return NO; + tightdb::DataType type = m_mixed.get_type(); + if (type != other->m_mixed.get_type()) + return NO; switch (type) { case tightdb::type_Bool: - return _mixed.get_bool() == other->_mixed.get_bool(); + return m_mixed.get_bool() == other->m_mixed.get_bool(); case tightdb::type_Int: - return _mixed.get_int() == other->_mixed.get_int(); + return m_mixed.get_int() == other->m_mixed.get_int(); case tightdb::type_Float: - return _mixed.get_float() == other->_mixed.get_float(); + return m_mixed.get_float() == other->m_mixed.get_float(); case tightdb::type_Double: - return _mixed.get_double() == other->_mixed.get_double(); + return m_mixed.get_double() == other->m_mixed.get_double(); case tightdb::type_String: - return _mixed.get_string() == other->_mixed.get_string(); + return m_mixed.get_string() == other->m_mixed.get_string(); case tightdb::type_Binary: - return _mixed.get_binary() == other->_mixed.get_binary(); + return m_mixed.get_binary() == other->m_mixed.get_binary(); case tightdb::type_DateTime: - return _mixed.get_datetime() == other->_mixed.get_datetime(); + return m_mixed.get_datetime() == other->m_mixed.get_datetime(); case tightdb::type_Table: - return [_table getTable] == [other->_table getTable]; // Compare table contents + return [m_table getNativeTable] == [other->m_table getNativeTable]; // Compare table contents case tightdb::type_Mixed: TIGHTDB_ASSERT(false); break; @@ -167,58 +184,51 @@ -(BOOL)isEqual:(TightdbMixed*)other -(TightdbType)getType { - return (TightdbType)_mixed.get_type(); + return TightdbType(m_mixed.get_type()); } -(BOOL)getBool { - return _mixed.get_bool(); + return m_mixed.get_bool(); } -(int64_t)getInt { - return _mixed.get_int(); + return m_mixed.get_int(); } -(float)getFloat { - return _mixed.get_float(); + return m_mixed.get_float(); } -(double)getDouble { - return _mixed.get_double(); + return m_mixed.get_double(); } -(NSString*)getString { - return to_objc_string(_mixed.get_string()); + return to_objc_string(m_mixed.get_string()); } -(TightdbBinary*)getBinary { - return [[TightdbBinary alloc] initWithBinary:_mixed.get_binary()]; + return [[TightdbBinary alloc] initWithBinary:m_mixed.get_binary()]; } -(time_t)getDate { - return _mixed.get_datetime().get_datetime(); + return m_mixed.get_datetime().get_datetime(); } -(TightdbTable*)getTable { - return _table; + return m_table; } @end -class Fido { - public: - Fido() { cerr << "**************************************************** CONSTRUCT ****************************************************\n"; } - ~Fido() { cerr << "---------------------------------------------------- destruct ----------------------------------------------------\n"; } -}; - - @interface TightdbDescriptor() +(TightdbDescriptor*)descWithDesc:(tightdb::Descriptor*)desc readOnly:(BOOL)read_only error:(NSError* __autoreleasing*)error; @end @@ -226,7 +236,6 @@ +(TightdbDescriptor*)descWithDesc:(tightdb::Descriptor*)desc readOnly:(BOOL)read @implementation TightdbDescriptor { tightdb::DescriptorRef m_desc; - Fido fido; BOOL m_read_only; } @@ -319,46 +328,37 @@ -(void)dealloc @end -@interface TightdbView() -@property (nonatomic) tightdb::TableView* tableView; -@end @implementation TightdbView { - TightdbTable* _table; - TightdbCursor* tmpCursor; + tightdb::util::UniquePtr m_view; + TightdbTable* m_table; + TightdbCursor* m_tmp_cursor; } -@synthesize tableView = _tableView; ++(TightdbView*)viewWithTable:(TightdbTable*)table andNativeView:(const tightdb::TableView&)view +{ + TightdbView* view_2 = [[TightdbView alloc] init]; + if (!view_2) + return nil; + view_2->m_view.reset(new tightdb::TableView(view)); // FIXME: Exception handling needed here + view_2->m_table = table; + return view_2; +} --(id)initFromQuery:(TightdbQuery*)query +-(id)_initWithQuery:(TightdbQuery*)query { self = [super init]; if (self) { - _table = [query getTable]; - self.tableView = new tightdb::TableView([query getTableView]); + tightdb::Query& query_2 = [query getNativeQuery]; + m_view.reset(new tightdb::TableView(query_2.find_all())); // FIXME: Exception handling needed here + m_table = [query getTable]; } return self; } - -(TightdbTable*)getTable { - return _table; -} - -+(TightdbView*)tableViewWithTable:(TightdbTable*)table -{ - static_cast(table); - TightdbView* tableView = [[TightdbView alloc] init]; - tableView.tableView = new tightdb::TableView(); // not longer needs table at construction - return tableView; -} - -+(TightdbView*)tableViewWithTableView:(tightdb::TableView)table -{ - TightdbView*tableView = [[TightdbView alloc] init]; - tableView.tableView = new tightdb::TableView(table); - return tableView; + return m_table; } -(void)dealloc @@ -366,8 +366,7 @@ -(void)dealloc #ifdef TIGHTDB_DEBUG NSLog(@"TightdbView dealloc"); #endif - _table = nil; - delete _tableView; + m_table = nil; // FIXME: What is the point of doing this? } -(TightdbCursor*)cursorAtIndex:(size_t)ndx @@ -378,49 +377,50 @@ -(TightdbCursor*)cursorAtIndex:(size_t)ndx if (ndx >= [self count]) return nil; - return [[TightdbCursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:ndx]]; + return [[TightdbCursor alloc] initWithTable:m_table ndx:[self getSourceIndex:ndx]]; } -(size_t)count { - return _tableView->size(); + return m_view->size(); } -(BOOL)isEmpty { - return _tableView->is_empty(); + return m_view->is_empty(); } -(int64_t)get:(size_t)col_ndx ndx:(size_t)ndx { - return _tableView->get_int(col_ndx, ndx); + return m_view->get_int(col_ndx, ndx); } -(BOOL)getBool:(size_t)col_ndx ndx:(size_t)ndx { - return _tableView->get_bool(col_ndx, ndx); + return m_view->get_bool(col_ndx, ndx); } -(time_t)getDate:(size_t)col_ndx ndx:(size_t)ndx { - return _tableView->get_datetime(col_ndx, ndx).get_datetime(); + return m_view->get_datetime(col_ndx, ndx).get_datetime(); } -(NSString*)getString:(size_t)col_ndx ndx:(size_t)ndx { - return to_objc_string(_tableView->get_string(col_ndx, ndx)); + return to_objc_string(m_view->get_string(col_ndx, ndx)); } -(void)removeRowAtIndex:(size_t)ndx { - _tableView->remove(ndx); + m_view->remove(ndx); } -(void)clear { - _tableView->clear(); + m_view->clear(); } -(size_t)getSourceIndex:(size_t)ndx { - return _tableView->get_source_ndx(ndx); + return m_view->get_source_ndx(ndx); } -(TightdbCursor*)getCursor { - return tmpCursor = [[TightdbCursor alloc] initWithTable:[self getTable] ndx:[self getSourceIndex:0]]; + return m_tmp_cursor = [[TightdbCursor alloc] initWithTable: m_table + ndx: m_view->get_source_ndx(0)]; } - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState*)state objects:(id __unsafe_unretained*)stackbuf count:(NSUInteger)len @@ -451,19 +451,18 @@ - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState*)state objects @implementation TightdbTable { + tightdb::TableRef m_table; id m_parent; BOOL m_read_only; - - TightdbCursor* tmpCursor; + TightdbCursor* m_tmp_cursor; } -@synthesize table = _table; -(id)init { self = [super init]; if (self) { m_read_only = NO; - _table = tightdb::Table::create(); // FIXME: May throw + m_table = tightdb::Table::create(); // FIXME: May throw } return self; } @@ -482,7 +481,7 @@ -(BOOL)_checkType -(TightdbCursor*)getCursor { - return tmpCursor = [[TightdbCursor alloc] initWithTable:self ndx:0]; + return m_tmp_cursor = [[TightdbCursor alloc] initWithTable:self ndx:0]; } -(void)clearCursor { @@ -516,9 +515,14 @@ - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState*)state objects return 1; } --(tightdb::Table &)getTable +-(tightdb::Table&)getNativeTable { - return *_table; + return *m_table; +} + +-(void)setNativeTable:(tightdb::Table*)table +{ + m_table.reset(table); } -(void)setParent:(id)parent @@ -533,7 +537,7 @@ -(void)setReadOnly:(BOOL)read_only -(BOOL)isEqual:(TightdbTable*)other { - return *_table == *other->_table; + return *m_table == *other->m_table; } -(BOOL)setSubtable:(size_t)col_ndx ndx:(size_t)ndx withTable:(TightdbTable*)subtable @@ -541,64 +545,72 @@ -(BOOL)setSubtable:(size_t)col_ndx ndx:(size_t)ndx withTable:(TightdbTable*)subt // 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). - const tightdb::DataType t = _table->get_column_type(col_ndx); + tightdb::DataType t = m_table->get_column_type(col_ndx); if (t == tightdb::type_Table) { // TODO: Handle any exeptions from core lib. - _table->set_subtable(col_ndx, ndx, &subtable.getTable); + m_table->set_subtable(col_ndx, ndx, &subtable.getNativeTable); return YES; - } else - return NO; + } + return NO; } -(TightdbTable*)getSubtable:(size_t)col_ndx ndx:(size_t)ndx { - const tightdb::DataType t = _table->get_column_type(col_ndx); - if (t != tightdb::type_Table) return nil; - tightdb::TableRef r = _table->get_subtable(col_ndx, ndx); - if (!r) return nil; - TightdbTable* table = [[TightdbTable alloc] _initRaw]; - if (TIGHTDB_UNLIKELY(!table)) return nil; - [table setTable:move(r)]; - [table setParent:self]; - [table setReadOnly:m_read_only]; - return table; + 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)classObj -{ - const tightdb::DataType t = _table->get_column_type(col_ndx); - if (t != tightdb::type_Table) return nil; - tightdb::TableRef r = _table->get_subtable(col_ndx, ndx); - if (!r) return nil; - TightdbTable* table = [[classObj alloc] _initRaw]; - if (TIGHTDB_UNLIKELY(!table)) return nil; - [table setTable:move(r)]; - [table setParent:self]; - [table setReadOnly:m_read_only]; - if (![table _checkType]) return nil; - return table; +-(id)getSubtable:(size_t)col_ndx ndx:(size_t)ndx withClass:(__unsafe_unretained Class)class_obj +{ + 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; } // FIXME: Check that the specified class derives from TightdbTable. --(BOOL)isClass:(__unsafe_unretained Class)classObj +-(BOOL)isClass:(__unsafe_unretained Class)class_obj { - TightdbTable* table = [[classObj alloc] _initRaw]; + TightdbTable* table = [[class_obj alloc] _initRaw]; if (TIGHTDB_LIKELY(table)) { - [table setTable:_table]; + [table setNativeTable:m_table.get()]; [table setParent:m_parent]; [table setReadOnly:m_read_only]; - if ([table _checkType]) return YES; + if ([table _checkType]) + return YES; } return NO; } // FIXME: Check that the specified class derives from TightdbTable. --(id)castClass:(__unsafe_unretained Class)classObj +-(id)castClass:(__unsafe_unretained Class)class_obj { - TightdbTable* table = [[classObj alloc] _initRaw]; + TightdbTable* table = [[class_obj alloc] _initRaw]; if (TIGHTDB_LIKELY(table)) { - [table setTable:_table]; + [table setNativeTable:m_table.get()]; [table setParent:m_parent]; [table setReadOnly:m_read_only]; if (![table _checkType]) @@ -617,19 +629,19 @@ -(void)dealloc -(size_t)getColumnCount { - return _table->get_column_count(); + return m_table->get_column_count(); } -(NSString*)getColumnName:(size_t)ndx { - return to_objc_string(_table->get_column_name(ndx)); + return to_objc_string(m_table->get_column_name(ndx)); } -(size_t)getColumnIndex:(NSString*)name { - return _table->get_column_index(ObjcStringAccessor(name)); + return m_table->get_column_index(ObjcStringAccessor(name)); } -(TightdbType)getColumnType:(size_t)ndx { - return (TightdbType)_table->get_column_type(ndx); + return TightdbType(m_table->get_column_type(ndx)); } -(TightdbDescriptor*)getDescriptor { @@ -637,17 +649,17 @@ -(TightdbDescriptor*)getDescriptor } -(TightdbDescriptor*)getDescriptorWithError:(NSError* __autoreleasing*)error { - tightdb::DescriptorRef desc = _table->get_descriptor(); - BOOL read_only = m_read_only || _table->has_shared_type(); + tightdb::DescriptorRef desc = m_table->get_descriptor(); + BOOL read_only = m_read_only || m_table->has_shared_type(); return [TightdbDescriptor descWithDesc:desc.get() readOnly:read_only error:error]; } -(BOOL)isEmpty { - return _table->is_empty(); + return m_table->is_empty(); } -(size_t)count { - return _table->size(); + return m_table->size(); } -(TightdbCursor*)addRow @@ -666,22 +678,22 @@ -(size_t)_addRowWithError:(NSError* __autoreleasing*)error *error = make_tightdb_error(tdb_err_FailRdOnly, @"Tried to add row while read-only."); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER(return _table->add_empty_row();, 0); + TIGHTDB_EXCEPTION_ERRHANDLER(return m_table->add_empty_row();, 0); } --(size_t)_addRows:(size_t)rowCount +-(size_t)_addRows:(size_t)num_rows { - return [self _addRows:rowCount error:nil]; + return [self _addRows:num_rows error:nil]; } --(size_t)_addRows:(size_t)rowCount error:(NSError* __autoreleasing*)error +-(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; } - TIGHTDB_EXCEPTION_ERRHANDLER(return _table->add_empty_row(rowCount);, 0); + TIGHTDB_EXCEPTION_ERRHANDLER(return m_table->add_empty_row(num_rows);, 0); } -(TightdbCursor*)cursorAtIndex:(size_t)ndx @@ -715,7 +727,7 @@ -(BOOL)insertRow:(size_t)ndx error:(NSError* __autoreleasing*)error return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER(_table->insert_empty_row(ndx);, 0); + TIGHTDB_EXCEPTION_ERRHANDLER(m_table->insert_empty_row(ndx);, 0); return YES; } @@ -730,7 +742,7 @@ -(BOOL)clearWithError:(NSError* __autoreleasing*)error *error = make_tightdb_error(tdb_err_FailRdOnly, @"Tried to clear while read-only."); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER(_table->clear();, NO); + TIGHTDB_EXCEPTION_ERRHANDLER(m_table->clear();, NO); return YES; } @@ -746,7 +758,7 @@ -(BOOL)removeRowAtIndex:(size_t)ndx error:(NSError* __autoreleasing*)error *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to remove row while read only ndx: %llu", (unsigned long long)ndx]); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER(_table->remove(ndx);, NO); + TIGHTDB_EXCEPTION_ERRHANDLER(m_table->remove(ndx);, NO); return YES; } @@ -762,12 +774,12 @@ -(BOOL)removeLastRowWithError:(NSError* __autoreleasing*)error *error = make_tightdb_error(tdb_err_FailRdOnly, @"Tried to remove last while read-only."); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER(_table->remove_last();, NO); + TIGHTDB_EXCEPTION_ERRHANDLER(m_table->remove_last();, NO); return YES; } -(int64_t)get:(size_t)col_ndx ndx:(size_t)ndx { - return _table->get_int(col_ndx, ndx); + return m_table->get_int(col_ndx, ndx); } -(BOOL)set:(size_t)col_ndx ndx:(size_t)ndx value:(int64_t)value @@ -782,13 +794,13 @@ -(BOOL)set:(size_t)col_ndx ndx:(size_t)ndx value:(int64_t)value error:(NSError* *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(_table->set_int(col_ndx, ndx, value);, NO); + TIGHTDB_EXCEPTION_ERRHANDLER(m_table->set_int(col_ndx, ndx, value);, NO); return YES; } -(BOOL)getBool:(size_t)col_ndx ndx:(size_t)ndx { - return _table->get_bool(col_ndx, ndx); + return m_table->get_bool(col_ndx, ndx); } -(BOOL)setBool:(size_t)col_ndx ndx:(size_t)ndx value:(BOOL)value @@ -803,13 +815,13 @@ -(BOOL)setBool:(size_t)col_ndx ndx:(size_t)ndx value:(BOOL)value error:(NSError* *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(_table->set_bool(col_ndx, ndx, value);, NO); + TIGHTDB_EXCEPTION_ERRHANDLER(m_table->set_bool(col_ndx, ndx, value);, NO); return YES; } -(float)getFloat:(size_t)col_ndx ndx:(size_t)ndx { - return _table->get_float(col_ndx, ndx); + return m_table->get_float(col_ndx, ndx); } -(BOOL)setFloat:(size_t)col_ndx ndx:(size_t)ndx value:(float)value @@ -824,13 +836,13 @@ -(BOOL)setFloat:(size_t)col_ndx ndx:(size_t)ndx value:(float)value error:(NSErro *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(_table->set_float(col_ndx, ndx, value);, NO); + TIGHTDB_EXCEPTION_ERRHANDLER(m_table->set_float(col_ndx, ndx, value);, NO); return YES; } -(double)getDouble:(size_t)col_ndx ndx:(size_t)ndx { - return _table->get_double(col_ndx, ndx); + return m_table->get_double(col_ndx, ndx); } -(BOOL)setDouble:(size_t)col_ndx ndx:(size_t)ndx value:(double)value @@ -845,13 +857,13 @@ -(BOOL)setDouble:(size_t)col_ndx ndx:(size_t)ndx value:(double)value error:(NSEr *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(_table->set_double(col_ndx, ndx, value);, NO); + TIGHTDB_EXCEPTION_ERRHANDLER(m_table->set_double(col_ndx, ndx, value);, NO); return YES; } -(time_t)getDate:(size_t)col_ndx ndx:(size_t)ndx { - return _table->get_datetime(col_ndx, ndx).get_datetime(); + return m_table->get_datetime(col_ndx, ndx).get_datetime(); } -(BOOL)setDate:(size_t)col_ndx ndx:(size_t)ndx value:(time_t)value @@ -866,7 +878,7 @@ -(BOOL)setDate:(size_t)col_ndx ndx:(size_t)ndx value:(time_t)value error:(NSErro *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(_table->set_datetime(col_ndx, ndx, value);, NO); + TIGHTDB_EXCEPTION_ERRHANDLER(m_table->set_datetime(col_ndx, ndx, value);, NO); return YES; } @@ -882,7 +894,7 @@ -(BOOL)insertBool:(size_t)col_ndx ndx:(size_t)ndx value:(BOOL)value error:(NSErr *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER(_table->insert_bool(col_ndx, ndx, value);, NO); + TIGHTDB_EXCEPTION_ERRHANDLER(m_table->insert_bool(col_ndx, ndx, value);, NO); return YES; } @@ -899,7 +911,7 @@ -(BOOL)insertInt:(size_t)col_ndx ndx:(size_t)ndx value:(int64_t)value error:(NSE *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER(_table->insert_int(col_ndx, ndx, value);, NO); + TIGHTDB_EXCEPTION_ERRHANDLER(m_table->insert_int(col_ndx, ndx, value);, NO); return YES; } @@ -915,7 +927,7 @@ -(BOOL)insertFloat:(size_t)col_ndx ndx:(size_t)ndx value:(float)value error:(NSE *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER(_table->insert_float(col_ndx, ndx, value);, NO); + TIGHTDB_EXCEPTION_ERRHANDLER(m_table->insert_float(col_ndx, ndx, value);, NO); return YES; } @@ -931,7 +943,7 @@ -(BOOL)insertDouble:(size_t)col_ndx ndx:(size_t)ndx value:(double)value error:(N *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER(_table->insert_double(col_ndx, ndx, value);, NO); + TIGHTDB_EXCEPTION_ERRHANDLER(m_table->insert_double(col_ndx, ndx, value);, NO); return YES; } @@ -948,7 +960,7 @@ -(BOOL)insertString:(size_t)col_ndx ndx:(size_t)ndx value:(NSString*)value error return NO; } TIGHTDB_EXCEPTION_ERRHANDLER( - _table->insert_string(col_ndx, ndx, ObjcStringAccessor(value));, + m_table->insert_string(col_ndx, ndx, ObjcStringAccessor(value));, NO); return YES; } @@ -966,7 +978,7 @@ -(BOOL)insertBinary:(size_t)col_ndx ndx:(size_t)ndx value:(TightdbBinary*)value return NO; } TIGHTDB_EXCEPTION_ERRHANDLER( - _table->insert_binary(col_ndx, ndx, [value getBinary]);, + m_table->insert_binary(col_ndx, ndx, [value getNativeBinary]);, NO); return YES; } @@ -984,7 +996,7 @@ -(BOOL)insertBinary:(size_t)col_ndx ndx:(size_t)ndx data:(const char*)data size: return NO; } TIGHTDB_EXCEPTION_ERRHANDLER( - _table->insert_binary(col_ndx, ndx, tightdb::BinaryData(data, size));, + m_table->insert_binary(col_ndx, ndx, tightdb::BinaryData(data, size));, NO); return YES; } @@ -1001,7 +1013,7 @@ -(BOOL)insertDate:(size_t)col_ndx ndx:(size_t)ndx value:(time_t)value error:(NSE *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER(_table->insert_datetime(col_ndx, ndx, value);, NO); + TIGHTDB_EXCEPTION_ERRHANDLER(m_table->insert_datetime(col_ndx, ndx, value);, NO); return YES; } @@ -1012,13 +1024,13 @@ -(BOOL)insertDone -(BOOL)insertDoneWithError:(NSError* __autoreleasing*)error { - TIGHTDB_EXCEPTION_ERRHANDLER(_table->insert_done();, NO); + TIGHTDB_EXCEPTION_ERRHANDLER(m_table->insert_done();, NO); return YES; } -(NSString*)getString:(size_t)col_ndx ndx:(size_t)ndx { - return to_objc_string(_table->get_string(col_ndx, 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 @@ -1033,14 +1045,14 @@ -(BOOL)setString:(size_t)col_ndx ndx:(size_t)ndx value:(NSString*)value error:(N return NO; } TIGHTDB_EXCEPTION_ERRHANDLER( - _table->set_string(col_ndx, ndx, ObjcStringAccessor(value));, + 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:_table->get_binary(col_ndx, 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 @@ -1056,7 +1068,7 @@ -(BOOL)setBinary:(size_t)col_ndx ndx:(size_t)ndx value:(TightdbBinary*)value err return NO; } TIGHTDB_EXCEPTION_ERRHANDLER( - _table->set_binary(col_ndx, ndx, [value getBinary]);, + m_table->set_binary(col_ndx, ndx, [value getNativeBinary]);, NO); return YES; } @@ -1074,14 +1086,14 @@ -(BOOL)setBinary:(size_t)col_ndx ndx:(size_t)ndx data:(const char*)data size:(si return NO; } TIGHTDB_EXCEPTION_ERRHANDLER( - _table->set_binary(col_ndx, ndx, tightdb::BinaryData(data, size));, + 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 { - return _table->get_subtable_size(col_ndx, row_ndx); + return m_table->get_subtable_size(col_ndx, row_ndx); } -(BOOL)insertSubtable:(size_t)col_ndx ndx:(size_t)row_ndx @@ -1096,7 +1108,7 @@ -(BOOL)insertSubtable:(size_t)col_ndx ndx:(size_t)row_ndx error:(NSError* __auto *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER(_table->insert_subtable(col_ndx, row_ndx);, NO); + TIGHTDB_EXCEPTION_ERRHANDLER(m_table->insert_subtable(col_ndx, row_ndx);, NO); return YES; } @@ -1114,7 +1126,7 @@ -(BOOL)_insertSubtableCopy:(size_t)col_ndx row:(size_t)row_ndx subtable:(Tightdb return NO; } TIGHTDB_EXCEPTION_ERRHANDLER( - tightdb::LangBindHelper::insert_subtable(*_table, col_ndx, row_ndx, [subtable getTable]);, + tightdb::LangBindHelper::insert_subtable(*m_table, col_ndx, row_ndx, [subtable getNativeTable]);, NO); return YES; } @@ -1130,32 +1142,35 @@ -(BOOL)clearSubtable:(size_t)col_ndx ndx:(size_t)row_ndx error:(NSError* __autor *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to clear while read only ColumnId: %llu", (unsigned long long)col_ndx]); return NO; } - TIGHTDB_EXCEPTION_ERRHANDLER(_table->clear_subtable(col_ndx, row_ndx);, NO); + TIGHTDB_EXCEPTION_ERRHANDLER(m_table->clear_subtable(col_ndx, row_ndx);, NO); return YES; } -(TightdbMixed*)getMixed:(size_t)col_ndx ndx:(size_t)row_ndx { - tightdb::Mixed tmp = _table->get_mixed(col_ndx, row_ndx); - TightdbMixed* mixed = [TightdbMixed mixedWithMixed:tmp]; - if ([mixed getType] == tightdb_Table) { - tightdb::TableRef r = _table->get_subtable(col_ndx, row_ndx); - if (!r) return nil; - TightdbTable* table = [[TightdbTable alloc] _initRaw]; - if (TIGHTDB_UNLIKELY(!table)) return nil; - [table setTable:move(r)]; - [table setParent:self]; - [table setReadOnly:m_read_only]; - if (![table _checkType]) return nil; - - [mixed setTable:table]; + tightdb::Mixed mixed = m_table->get_mixed(col_ndx, row_ndx); + if (mixed.get_type() != tightdb::type_Table) { + return [TightdbMixed mixedWithNativeMixed:mixed]; } - return 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 { - return (TightdbType)_table->get_mixed_type(col_ndx, row_ndx); + return TightdbType(m_table->get_mixed_type(col_ndx, row_ndx)); } -(BOOL)insertMixed:(size_t)col_ndx ndx:(size_t)row_ndx value:(TightdbMixed*)value @@ -1170,13 +1185,15 @@ -(BOOL)insertMixed:(size_t)col_ndx ndx:(size_t)row_ndx value:(TightdbMixed*)valu *error = make_tightdb_error(tdb_err_FailRdOnly, [NSString stringWithFormat:@"Tried to insert 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 (value.mixed.get_type() == tightdb::type_Table && value.table) { - tightdb::LangBindHelper::insert_mixed_subtable(*_table, col_ndx, row_ndx, - [value.table getTable]); + if (subtable) { + tightdb::LangBindHelper::insert_mixed_subtable(*m_table, col_ndx, row_ndx, + [subtable getNativeTable]); } else { - _table->insert_mixed(col_ndx, row_ndx, value.mixed); + m_table->insert_mixed(col_ndx, row_ndx, mixed); }, NO); return YES; @@ -1194,13 +1211,15 @@ -(BOOL)setMixed:(size_t)col_ndx ndx:(size_t)row_ndx value:(TightdbMixed*)value e *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 (value.mixed.get_type() == tightdb::type_Table && value.table) { - tightdb::LangBindHelper::set_mixed_subtable(*_table, col_ndx, row_ndx, - [value.table getTable]); + if (subtable) { + tightdb::LangBindHelper::set_mixed_subtable(*m_table, col_ndx, row_ndx, + [subtable getNativeTable]); } else { - _table->set_mixed(col_ndx, row_ndx, value.mixed); + m_table->set_mixed(col_ndx, row_ndx, mixed); }, NO); return YES; @@ -1214,37 +1233,37 @@ -(size_t)addColumnWithType:(TightdbType)type andName:(NSString*)name -(size_t)addColumnWithType:(TightdbType)type andName:(NSString*)name error:(NSError* __autoreleasing*)error { TIGHTDB_EXCEPTION_ERRHANDLER( - return _table->add_column(tightdb::DataType(type), ObjcStringAccessor(name));, + return m_table->add_column(tightdb::DataType(type), ObjcStringAccessor(name));, 0); } -(size_t)findBool:(size_t)col_ndx value:(BOOL)value { - return _table->find_first_bool(col_ndx, value); + return m_table->find_first_bool(col_ndx, value); } -(size_t)findInt:(size_t)col_ndx value:(int64_t)value { - return _table->find_first_int(col_ndx, value); + return m_table->find_first_int(col_ndx, value); } -(size_t)findFloat:(size_t)col_ndx value:(float)value { - return _table->find_first_float(col_ndx, value); + return m_table->find_first_float(col_ndx, value); } -(size_t)findDouble:(size_t)col_ndx value:(double)value { - return _table->find_first_double(col_ndx, value); + return m_table->find_first_double(col_ndx, value); } -(size_t)findString:(size_t)col_ndx value:(NSString*)value { - return _table->find_first_string(col_ndx, ObjcStringAccessor(value)); + return m_table->find_first_string(col_ndx, ObjcStringAccessor(value)); } -(size_t)findBinary:(size_t)col_ndx value:(TightdbBinary*)value { - return _table->find_first_binary(col_ndx, [value getBinary]); + return m_table->find_first_binary(col_ndx, [value getNativeBinary]); } -(size_t)findDate:(size_t)col_ndx value:(time_t)value { - return _table->find_first_datetime(col_ndx, value); + return m_table->find_first_datetime(col_ndx, value); } -(size_t)findMixed:(size_t)col_ndx value:(TightdbMixed*)value { @@ -1252,14 +1271,54 @@ -(size_t)findMixed:(size_t)col_ndx value:(TightdbMixed*)value static_cast(value); [NSException raise:@"NotImplemented" format:@"Not implemented"]; // FIXME: Implement this! - // return _table->find_first_mixed(col_ndx, value); +// return _table->find_first_mixed(col_ndx, [value getNativeMixed]); return 0; } --(TightdbView*)findAll:(TightdbView*)view column:(size_t)col_ndx value:(int64_t)value +-(TightdbView*)findAllBool:(BOOL)value inColumn:(size_t)col_ndx +{ + tightdb::TableView view = m_table->find_all_bool(col_ndx, value); + return [TightdbView viewWithTable:self andNativeView:view]; +} +-(TightdbView*)findAllInt:(int64_t)value inColumn:(size_t)col_ndx +{ + tightdb::TableView view = m_table->find_all_int(col_ndx, value); + return [TightdbView viewWithTable:self andNativeView:view]; +} +-(TightdbView*)findAllFloat:(float)value inColumn:(size_t)col_ndx +{ + tightdb::TableView view = m_table->find_all_float(col_ndx, value); + return [TightdbView viewWithTable:self andNativeView:view]; +} +-(TightdbView*)findAllDouble:(double)value inColumn:(size_t)col_ndx { - *view.tableView = _table->find_all_int(col_ndx, value); - return view; + tightdb::TableView view = m_table->find_all_double(col_ndx, value); + return [TightdbView viewWithTable:self andNativeView:view]; +} +-(TightdbView*)findAllString:(NSString*)value inColumn:(size_t)col_ndx +{ + tightdb::TableView view = m_table->find_all_string(col_ndx, ObjcStringAccessor(value)); + return [TightdbView viewWithTable:self andNativeView:view]; +} +-(TightdbView*)findAllBinary:(TightdbBinary*)value inColumn:(size_t)col_ndx +{ + tightdb::TableView view = m_table->find_all_binary(col_ndx, [value getNativeBinary]); + return [TightdbView viewWithTable:self andNativeView:view]; +} +-(TightdbView*)findAllDate:(time_t)value inColumn:(size_t)col_ndx +{ + tightdb::TableView view = m_table->find_all_datetime(col_ndx, value); + return [TightdbView viewWithTable:self andNativeView:view]; +} +-(TightdbView*)findAllMixed:(TightdbMixed*)value inColumn:(size_t)col_ndx +{ + static_cast(col_ndx); + static_cast(value); + [NSException raise:@"NotImplemented" format:@"Not implemented"]; + // FIXME: Implement this! +// tightdb::TableView view = m_table->find_all_mixed(col_ndx, [value getNativeMixed]); +// return [TightdbView viewWithTable:self andNativeView:view]; + return 0; } -(TightdbQuery*)where @@ -1271,13 +1330,15 @@ -(TightdbQuery*)whereWithError:(NSError* __autoreleasing*)error { return [[TightdbQuery alloc] initWithTable:self error:error]; } + -(BOOL)hasIndex:(size_t)col_ndx { - return _table->has_index(col_ndx); + return m_table->has_index(col_ndx); } + -(void)setIndex:(size_t)col_ndx { - _table->set_index(col_ndx); + m_table->set_index(col_ndx); } -(BOOL)optimize @@ -1287,77 +1348,77 @@ -(BOOL)optimize -(BOOL)optimizeWithError:(NSError* __autoreleasing*)error { - TIGHTDB_EXCEPTION_ERRHANDLER(_table->optimize();, NO); + TIGHTDB_EXCEPTION_ERRHANDLER(m_table->optimize();, NO); return YES; } -(size_t)countWithIntColumn:(size_t)col_ndx andValue:(int64_t)target { - return _table->count_int(col_ndx, target); + return m_table->count_int(col_ndx, target); } -(size_t)countWithFloatColumn:(size_t)col_ndx andValue:(float)target { - return _table->count_float(col_ndx, target); + return m_table->count_float(col_ndx, target); } -(size_t)countWithDoubleColumn:(size_t)col_ndx andValue:(double)target { - return _table->count_double(col_ndx, target); + return m_table->count_double(col_ndx, target); } -(size_t)countWithStringColumn:(size_t)col_ndx andValue:(NSString*)target { - return _table->count_string(col_ndx, ObjcStringAccessor(target)); + return m_table->count_string(col_ndx, ObjcStringAccessor(target)); } -(int64_t)sumWithIntColumn:(size_t)col_ndx { - return _table->sum_int(col_ndx); + return m_table->sum_int(col_ndx); } -(double)sumWithFloatColumn:(size_t)col_ndx { - return _table->sum_float(col_ndx); + return m_table->sum_float(col_ndx); } -(double)sumWithDoubleColumn:(size_t)col_ndx { - return _table->sum_double(col_ndx); + return m_table->sum_double(col_ndx); } -(int64_t)maximumWithIntColumn:(size_t)col_ndx { - return _table->maximum_int(col_ndx); + return m_table->maximum_int(col_ndx); } -(float)maximumWithFloatColumn:(size_t)col_ndx { - return _table->maximum_float(col_ndx); + return m_table->maximum_float(col_ndx); } -(double)maximumWithDoubleColumn:(size_t)col_ndx { - return _table->maximum_double(col_ndx); + return m_table->maximum_double(col_ndx); } -(int64_t)minimumWithIntColumn:(size_t)col_ndx { - return _table->minimum_int(col_ndx); + return m_table->minimum_int(col_ndx); } -(float)minimumWithFloatColumn:(size_t)col_ndx { - return _table->minimum_float(col_ndx); + return m_table->minimum_float(col_ndx); } -(double)minimumWithDoubleColumn:(size_t)col_ndx { - return _table->minimum_double(col_ndx); + return m_table->minimum_double(col_ndx); } -(double)averageWithIntColumn:(size_t)col_ndx { - return _table->average_int(col_ndx); + return m_table->average_int(col_ndx); } -(double)averageWithFloatColumn:(size_t)col_ndx { - return _table->average_float(col_ndx); + return m_table->average_float(col_ndx); } -(double)averageWithDoubleColumn:(size_t)col_ndx { - return _table->average_double(col_ndx); + return m_table->average_double(col_ndx); } -(BOOL)_addColumns @@ -1368,7 +1429,7 @@ -(BOOL)_addColumns #ifdef TIGHTDB_DEBUG -(void)verify { - _table->Verify(); + m_table->Verify(); } #endif @end @@ -1403,11 +1464,6 @@ -(size_t)find:(int64_t)value { return [self.table findInt:self.column value:value]; } --(TightdbView*)findAll:(int64_t)value -{ - TightdbView* view = [TightdbView tableViewWithTable:self.table]; - return [self.table findAll:view column:self.column value:value]; -} -(int64_t)minimum { return [self.table minimumWithIntColumn:self.column]; diff --git a/src/tightdb/objc/table_priv.h b/src/tightdb/objc/table_priv.h index cf6fc9b930..e6433736cb 100644 --- a/src/tightdb/objc/table_priv.h +++ b/src/tightdb/objc/table_priv.h @@ -8,16 +8,21 @@ @interface TightdbBinary() --(tightdb::BinaryData)getBinary; +-(tightdb::BinaryData)getNativeBinary; @end +@interface TightdbView() + ++(TightdbView*)viewWithTable:(TightdbTable*)table andNativeView:(const tightdb::TableView&)view; + +@end @interface TightdbTable() -@property (nonatomic) tightdb::TableRef table; +-(tightdb::Table&)getNativeTable; --(tightdb::Table&)getTable; +-(void)setNativeTable:(tightdb::Table*)table; -(void)setParent:(id)parent; // Workaround for ARC release problem. diff --git a/src/tightdb/objc/test/group_misc_2.m b/src/tightdb/objc/test/group_misc_2.m index b62dfbfd15..98e1d745dd 100644 --- a/src/tightdb/objc/test/group_misc_2.m +++ b/src/tightdb/objc/test/group_misc_2.m @@ -66,7 +66,7 @@ - (void)testGroup_Misc2 NSLog(@"Mary: %zu", row); STAssertEquals(row, (size_t)1,@"Mary should have been there"); - TightdbView* view = [table.Age findAll:21]; + MyTable_View *view = [[[table where].Age columnIsEqualTo:21] findAll]; size_t cnt = [view count]; // cnt = 2 STAssertEquals(cnt, (size_t)2,@"Should be two rows in view"); diff --git a/src/tightdb/objc/test/tutorial.m b/src/tightdb/objc/test/tutorial.m index fd18afaa63..d28481e74e 100644 --- a/src/tightdb/objc/test/tutorial.m +++ b/src/tightdb/objc/test/tutorial.m @@ -110,7 +110,7 @@ - (void)testTutorial NSLog(@"Mary: %zu", row); STAssertEquals(row, (size_t)1,@"Mary should have been there", nil); - TightdbView *view = [people.Age findAll:21]; + PeopleTable_View *view = [[[people where].Age columnIsEqualTo:21] findAll]; size_t cnt = [view count]; // cnt = 2 STAssertEquals(cnt, (size_t)2,@"Should be two rows in view", nil); diff --git a/src/tightdb/objc/tightdb.h b/src/tightdb/objc/tightdb.h index 19f4f2ddd6..994d770c3c 100644 --- a/src/tightdb/objc/tightdb.h +++ b/src/tightdb/objc/tightdb.h @@ -132,7 +132,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName1, CType1) \ } \ -(TableName##_View*)findAll \ { \ - return [[TableName##_View alloc] initFromQuery:self]; \ + return [[TableName##_View alloc] _initWithQuery:self]; \ } \ @end \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ @@ -357,7 +357,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName2, CType2) \ } \ -(TableName##_View*)findAll \ { \ - return [[TableName##_View alloc] initFromQuery:self]; \ + return [[TableName##_View alloc] _initWithQuery:self]; \ } \ @end \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ @@ -600,7 +600,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName3, CType3) \ } \ -(TableName##_View*)findAll \ { \ - return [[TableName##_View alloc] initFromQuery:self]; \ + return [[TableName##_View alloc] _initWithQuery:self]; \ } \ @end \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ @@ -861,7 +861,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName4, CType4) \ } \ -(TableName##_View*)findAll \ { \ - return [[TableName##_View alloc] initFromQuery:self]; \ + return [[TableName##_View alloc] _initWithQuery:self]; \ } \ @end \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ @@ -1140,7 +1140,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName5, CType5) \ } \ -(TableName##_View*)findAll \ { \ - return [[TableName##_View alloc] initFromQuery:self]; \ + return [[TableName##_View alloc] _initWithQuery:self]; \ } \ @end \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ @@ -1437,7 +1437,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName6, CType6) \ } \ -(TableName##_View*)findAll \ { \ - return [[TableName##_View alloc] initFromQuery:self]; \ + return [[TableName##_View alloc] _initWithQuery:self]; \ } \ @end \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ @@ -1752,7 +1752,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName7, CType7) \ } \ -(TableName##_View*)findAll \ { \ - return [[TableName##_View alloc] initFromQuery:self]; \ + return [[TableName##_View alloc] _initWithQuery:self]; \ } \ @end \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ @@ -2085,7 +2085,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName8, CType8) \ } \ -(TableName##_View*)findAll \ { \ - return [[TableName##_View alloc] initFromQuery:self]; \ + return [[TableName##_View alloc] _initWithQuery:self]; \ } \ @end \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ @@ -2436,7 +2436,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName9, CType9) \ } \ -(TableName##_View*)findAll \ { \ - return [[TableName##_View alloc] initFromQuery:self]; \ + return [[TableName##_View alloc] _initWithQuery:self]; \ } \ @end \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ @@ -2805,7 +2805,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName10, CType10) \ } \ -(TableName##_View*)findAll \ { \ - return [[TableName##_View alloc] initFromQuery:self]; \ + return [[TableName##_View alloc] _initWithQuery:self]; \ } \ @end \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ @@ -3192,7 +3192,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName11, CType11) \ } \ -(TableName##_View*)findAll \ { \ - return [[TableName##_View alloc] initFromQuery:self]; \ + return [[TableName##_View alloc] _initWithQuery:self]; \ } \ @end \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ @@ -3597,7 +3597,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName12, CType12) \ } \ -(TableName##_View*)findAll \ { \ - return [[TableName##_View alloc] initFromQuery:self]; \ + return [[TableName##_View alloc] _initWithQuery:self]; \ } \ @end \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ @@ -4020,7 +4020,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName13, CType13) \ } \ -(TableName##_View*)findAll \ { \ - return [[TableName##_View alloc] initFromQuery:self]; \ + return [[TableName##_View alloc] _initWithQuery:self]; \ } \ @end \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ @@ -4461,7 +4461,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName14, CType14) \ } \ -(TableName##_View*)findAll \ { \ - return [[TableName##_View alloc] initFromQuery:self]; \ + return [[TableName##_View alloc] _initWithQuery:self]; \ } \ @end \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ @@ -4920,7 +4920,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName15, CType15) \ } \ -(TableName##_View*)findAll \ { \ - return [[TableName##_View alloc] initFromQuery:self]; \ + return [[TableName##_View alloc] _initWithQuery:self]; \ } \ @end \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ diff --git a/src/tightdb/objc/tightdb.h.cheetah b/src/tightdb/objc/tightdb.h.cheetah index 39023eed1d..b9153b4b8b 100644 --- a/src/tightdb/objc/tightdb.h.cheetah +++ b/src/tightdb/objc/tightdb.h.cheetah @@ -188,7 +188,7 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName${j+1}, CType${j+1}) \ } \ -(TableName##_View*)findAll \ { \ - return [[TableName##_View alloc] initFromQuery:self]; \ + return [[TableName##_View alloc] _initWithQuery:self]; \ } \ @end \ %for $j in range($num_cols) diff --git a/test-iphone/TightDbExample/ViewController.m b/test-iphone/TightDbExample/ViewController.m index dfd723d0ad..c7fa2ba9b0 100644 --- a/test-iphone/TightDbExample/ViewController.m +++ b/test-iphone/TightDbExample/ViewController.m @@ -90,7 +90,7 @@ - (void)testGroup NSLog(@"Mary: %zu", row); [_utils Eval:row==1 msg:@"Mary should have been there"]; - TightdbView *view = [table.Age findAll:21]; + MyTable_View *view = [[[table where].Age columnIsEqualTo:21] findAll]; size_t cnt = [view count]; // cnt = 2 [_utils Eval:cnt == 2 msg:@"Should be two rows in view"];