From 300dd69065d2c73a56585874438c4cf8da758341 Mon Sep 17 00:00:00 2001 From: Kristian Spangsege Date: Fri, 22 Feb 2013 14:58:14 +0100 Subject: [PATCH] Support for 'float' and 'double' column types and a lot of other fixes --- src/tightdb/objc/cursor.h | 16 +- src/tightdb/objc/cursor_objc.mm | 52 +- src/tightdb/objc/data_type.h | 2 + src/tightdb/objc/group.h | 4 +- src/tightdb/objc/group_objc.mm | 8 +- src/tightdb/objc/helper_macros.h | 177 ++- src/tightdb/objc/query.h | 89 +- src/tightdb/objc/query_objc.mm | 332 +++++- src/tightdb/objc/table.h | 170 ++- src/tightdb/objc/table_objc.mm | 515 ++++++--- src/tightdb/objc/test/Makefile | 5 +- src/tightdb/objc/test/data_type.mm | 2 + src/tightdb/objc/test/enumerator.m | 4 +- src/tightdb/objc/test/group_misc_2.m | 24 +- src/tightdb/objc/test/mixed.m | 38 +- src/tightdb/objc/test/query.m | 78 ++ src/tightdb/objc/test/subtable.m | 12 +- src/tightdb/objc/test/table.m | 109 +- src/tightdb/objc/test/table_delete_all.m | 2 +- src/tightdb/objc/test/tutorial.m | 8 +- src/tightdb/objc/tightdb.h | 1306 ++++++++++------------ src/tightdb/objc/tightdb.h.py | 30 +- 22 files changed, 1876 insertions(+), 1107 deletions(-) create mode 100644 src/tightdb/objc/test/query.m diff --git a/src/tightdb/objc/cursor.h b/src/tightdb/objc/cursor.h index c74edc5dd5..ca7989e46e 100644 --- a/src/tightdb/objc/cursor.h +++ b/src/tightdb/objc/cursor.h @@ -21,6 +21,7 @@ #import @class Table; +@class BinaryData; @class OCMixed; #pragma mark - CursorBase @@ -39,14 +40,21 @@ accessors. */ @interface OCAccessor : NSObject -(id)initWithCursor:(CursorBase *)cursor columnId:(size_t)columnId; --(int64_t)getInt; --(void)setInt:(int64_t)value; -(BOOL)getBool; -(void)setBool:(BOOL)value; --(time_t)getDate; --(void)setDate:(time_t)value; +-(int64_t)getInt; +-(void)setInt:(int64_t)value; +-(float)getFloat; +-(void)setFloat:(float)value; +-(double)getDouble; +-(void)setDouble:(double)value; -(NSString *)getString; -(void)setString:(NSString *)value; +-(BinaryData *)getBinary; +-(void)setBinary:(BinaryData *)value; +-(void)setBinary:(const char *)data size:(size_t)size; +-(time_t)getDate; +-(void)setDate:(time_t)value; -(id)getSubtable:(Class)obj; -(OCMixed *)getMixed; -(void)setMixed:(OCMixed *)value; diff --git a/src/tightdb/objc/cursor_objc.mm b/src/tightdb/objc/cursor_objc.mm index 360b35bb25..9a6ed8aa28 100644 --- a/src/tightdb/objc/cursor_objc.mm +++ b/src/tightdb/objc/cursor_objc.mm @@ -59,6 +59,15 @@ -(id)initWithCursor:(CursorBase *)cursor columnId:(size_t)columnId } +-(BOOL)getBool +{ + return [_cursor.table getBool:_columnId ndx:_cursor.ndx]; +} +-(void)setBool:(BOOL)value +{ + [_cursor.table setBool:_columnId ndx:_cursor.ndx value:value]; +} + -(int64_t)getInt { return [_cursor.table get:_columnId ndx:_cursor.ndx]; @@ -67,22 +76,25 @@ -(void)setInt:(int64_t)value { [_cursor.table set:_columnId ndx:_cursor.ndx value:value]; } --(BOOL)getBool + +-(float)getFloat { - return [_cursor.table getBool:_columnId ndx:_cursor.ndx]; + return [_cursor.table getFloat:_columnId ndx:_cursor.ndx]; } --(void)setBool:(BOOL)value +-(void)setFloat:(float)value { - [_cursor.table setBool:_columnId ndx:_cursor.ndx value:value]; + [_cursor.table setFloat:_columnId ndx:_cursor.ndx value:value]; } --(time_t)getDate + +-(double)getDouble { - return [_cursor.table getDate:_columnId ndx:_cursor.ndx]; + return [_cursor.table getDouble:_columnId ndx:_cursor.ndx]; } --(void)setDate:(time_t)value +-(void)setDouble:(double)value { - [_cursor.table setDate:_columnId ndx:_cursor.ndx value:value]; + [_cursor.table setDouble:_columnId ndx:_cursor.ndx value:value]; } + -(NSString *)getString { return [_cursor.table getString:_columnId ndx:_cursor.ndx]; @@ -91,10 +103,34 @@ -(void)setString:(NSString *)value { [_cursor.table setString:_columnId ndx:_cursor.ndx value:value]; } + +-(BinaryData *)getBinary +{ + return [_cursor.table getBinary:_columnId ndx:_cursor.ndx]; +} +-(void)setBinary:(BinaryData *)value +{ + [_cursor.table setBinary:_columnId ndx:_cursor.ndx value:value]; +} +-(void)setBinary:(const char *)data size:(size_t)size +{ + [_cursor.table setBinary:_columnId ndx:_cursor.ndx data:data size:size]; +} + +-(time_t)getDate +{ + return [_cursor.table getDate:_columnId ndx:_cursor.ndx]; +} +-(void)setDate:(time_t)value +{ + [_cursor.table setDate:_columnId ndx:_cursor.ndx value:value]; +} + -(id)getSubtable:(Class)obj { return [_cursor.table getSubtable:_columnId ndx:_cursor.ndx withClass:obj]; } + -(OCMixed *)getMixed { return [_cursor.table getMixed:_columnId ndx:_cursor.ndx]; diff --git a/src/tightdb/objc/data_type.h b/src/tightdb/objc/data_type.h index e3c0aaab63..13071d001a 100644 --- a/src/tightdb/objc/data_type.h +++ b/src/tightdb/objc/data_type.h @@ -24,6 +24,8 @@ typedef enum { tightdb_Bool = 1, tightdb_Int = 0, + tightdb_Float = 9, + tightdb_Double = 10, tightdb_String = 2, tightdb_Binary = 4, tightdb_Date = 7, diff --git a/src/tightdb/objc/group.h b/src/tightdb/objc/group.h index 295c3ed125..55706ecd37 100644 --- a/src/tightdb/objc/group.h +++ b/src/tightdb/objc/group.h @@ -25,7 +25,7 @@ @interface Group : NSObject +(Group *)groupWithFilename:(NSString *)filename; -+(Group *)groupWithBuffer:(char*)buffer len:(size_t)len; ++(Group *)groupWithBuffer:(const char*)data size:(size_t)size; +(Group *)group; -(size_t)getTableCount; @@ -55,7 +55,7 @@ // Serialization -(void)write:(NSString *)filePath; --(char*)writeToMem:(size_t*)len; +-(const char*)writeToMem:(size_t*)size; // Conversion // FIXME: Do we want to conversion methods? Maybe use NSData. diff --git a/src/tightdb/objc/group_objc.mm b/src/tightdb/objc/group_objc.mm index aad0f9532c..0c004fd3e8 100644 --- a/src/tightdb/objc/group_objc.mm +++ b/src/tightdb/objc/group_objc.mm @@ -61,11 +61,11 @@ +(Group *)groupWithFilename:(NSString *)filename return group2; } -+(Group *)groupWithBuffer:(char *)buffer len:(size_t)len ++(Group *)groupWithBuffer:(const char *)data size:(size_t)size { tightdb::Group* group; try { - group = new tightdb::Group(tightdb::Group::BufferSpec(buffer, len)); + group = new tightdb::Group(tightdb::Group::BufferSpec(data, size)); } catch (...) { // FIXME: Diffrent exception types mean different things. More @@ -111,10 +111,10 @@ -(void)write:(NSString *)filePath { _group->write([filePath UTF8String]); // FIXME: May throw at least tightdb::File::OpenError (and various derivatives), tightdb::ResourceAllocError, and std::bad_alloc } --(char*)writeToMem:(size_t*)len +-(const char*)writeToMem:(size_t*)size { tightdb::Group::BufferSpec buffer = _group->write_to_mem(); // FIXME: May throw at least std::bad_alloc - *len = buffer.m_size; + *size = buffer.m_size; return buffer.m_data; } diff --git a/src/tightdb/objc/helper_macros.h b/src/tightdb/objc/helper_macros.h index 5f183da620..6c1a73d741 100644 --- a/src/tightdb/objc/helper_macros.h +++ b/src/tightdb/objc/helper_macros.h @@ -29,20 +29,26 @@ #define TIGHTDB_IS_SUBTABLE_5_2 N #define TIGHTDB_IS_SUBTABLE_Int x,x #define TIGHTDB_IS_SUBTABLE_Bool x,x -#define TIGHTDB_IS_SUBTABLE_Date x,x +#define TIGHTDB_IS_SUBTABLE_Float x,x +#define TIGHTDB_IS_SUBTABLE_Double x,x #define TIGHTDB_IS_SUBTABLE_String x,x #define TIGHTDB_IS_SUBTABLE_Binary x,x +#define TIGHTDB_IS_SUBTABLE_Date x,x #define TIGHTDB_IS_SUBTABLE_Mixed x,x #define TIGHTDB_TYPE_Bool BOOL #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 BinaryData * -#define TIGHTDB_TYPE_Date OCDate * +#define TIGHTDB_TYPE_Date time_t #define TIGHTDB_TYPE_Mixed OCMixed * #define TIGHTDB_TYPE_ID_Bool tightdb_Bool #define TIGHTDB_TYPE_ID_Int tightdb_Int +#define TIGHTDB_TYPE_ID_Float tightdb_Float +#define TIGHTDB_TYPE_ID_Double tightdb_Double #define TIGHTDB_TYPE_ID_String tightdb_String #define TIGHTDB_TYPE_ID_Binary tightdb_Binary #define TIGHTDB_TYPE_ID_Date tightdb_Date @@ -50,6 +56,34 @@ +// TIGHTDB_ARG_TYPE + +#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_N(type) TIGHTDB_TYPE_##type + + + +// TIGHTDB_COLUMN_PROXY + +#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) OCColumnProxy_Subtable *name; +#define TIGHTDB_COLUMN_PROXY_DEF_4_N(name, type) @property(nonatomic, strong) OCColumnProxy_##type *name; + +#define TIGHTDB_COLUMN_PROXY_IMPL(name, type) @synthesize name = _##name; + +#define TIGHTDB_COLUMN_PROXY_INIT(table, col, name, type) TIGHTDB_COLUMN_PROXY_INIT_2(TIGHTDB_IS_SUBTABLE(type), table, col, name, type) +#define TIGHTDB_COLUMN_PROXY_INIT_2(is_subtable, table, col, name, type) TIGHTDB_COLUMN_PROXY_INIT_3(is_subtable, table, col, name, type) +#define TIGHTDB_COLUMN_PROXY_INIT_3(is_subtable, table, col, name, type) TIGHTDB_COLUMN_PROXY_INIT_4_##is_subtable(table, col, name, type) +#define TIGHTDB_COLUMN_PROXY_INIT_4_Y(table, col, name, type) _##name = [[OCColumnProxy_Subtable alloc] initWithTable:table column:col] +#define TIGHTDB_COLUMN_PROXY_INIT_4_N(table, col, name, type) _##name = [[OCColumnProxy_##type alloc] initWithTable:table column:col] + + + // TIGHTDB_ADD_COLUMN #define TIGHTDB_ADD_COLUMN(spec, name, type) TIGHTDB_ADD_COLUMN_2(TIGHTDB_IS_SUBTABLE(type), spec, name, type) @@ -81,7 +115,7 @@ { \ if ([spec getColumnType:col] != tightdb_Table) return NO; \ if (![[spec getColumnName:col] isEqualToString:@#name]) return NO; \ - OCSpec *subspec = [spec getSpec:col]; \ + OCSpec *subspec = [spec getSubspec:col]; \ if (!subspec) return NO; \ if (![type _checkType:subspec]) return NO; \ } @@ -98,7 +132,7 @@ #define TIGHTDB_COLUMN_INSERT(table, col, row, value, type) TIGHTDB_COLUMN_INSERT_2(TIGHTDB_IS_SUBTABLE(type), table, col, row, value, type) #define TIGHTDB_COLUMN_INSERT_2(is_subtable, table, col, row, value, type) TIGHTDB_COLUMN_INSERT_3(is_subtable, table, col, row, value, type) #define TIGHTDB_COLUMN_INSERT_3(is_subtable, table, col, row, value, type) TIGHTDB_COLUMN_INSERT_4_##is_subtable(table, col, row, value, type) -#define TIGHTDB_COLUMN_INSERT_4_Y(table, col, row, _value, type) [table _insertSubtableCopy:col row_ndx:row subtable:_value] +#define TIGHTDB_COLUMN_INSERT_4_Y(table, col, _row, value, type) [table _insertSubtableCopy:col row:_row subtable:value] #define TIGHTDB_COLUMN_INSERT_4_N(table, col, row, _value, type) [table insert##type:col ndx:row value:_value] @@ -135,20 +169,14 @@ #define TIGHTDB_CURSOR_PROPERTY_DEF_SUBTABLE(name, type) \ -@property type *name; \ +@property (readonly) type *name; \ -(type *)name; \ --(void)set##name:(type *)value; -/* FIXME: Must implement setter as a table copying operation. */ #define TIGHTDB_CURSOR_PROPERTY_IMPL_SUBTABLE(name, type) \ -(type *)name \ { \ return [_##name getSubtable:[type class]]; \ } \ --(void)set##name:(type *)value \ -{ \ - (void)value; \ -} @@ -166,6 +194,7 @@ #define TIGHTDB_QUERY_ACCESSOR_IMPL_4_Y(table, col_name, col_type) TIGHTDB_QUERY_ACCESSOR_IMPL_SUBTABLE(table, col_name, col_type) #define TIGHTDB_QUERY_ACCESSOR_IMPL_4_N(table, col_name, col_type) TIGHTDB_QUERY_ACCESSOR_IMPL_##col_type(table, col_name) + // Boolean #define TIGHTDB_QUERY_ACCESSOR_DEF_Bool(table, col_name) \ @@ -181,24 +210,27 @@ } \ @end + // Integer #define TIGHTDB_QUERY_ACCESSOR_DEF_Int(table, col_name) \ @interface table##_QueryAccessor_##col_name : OCXQueryAccessorInt \ --(table##_Query *)equal:(size_t)value; \ --(table##_Query *)notEqual:(size_t)value; \ +-(table##_Query *)equal:(int64_t)value; \ +-(table##_Query *)notEqual:(int64_t)value; \ -(table##_Query *)greater:(int64_t)value; \ +-(table##_Query *)greaterEqual:(int64_t)value; \ -(table##_Query *)less:(int64_t)value; \ +-(table##_Query *)lessEqual:(int64_t)value; \ -(table##_Query *)between:(int64_t)from to:(int64_t)to; \ @end #define TIGHTDB_QUERY_ACCESSOR_IMPL_Int(table, col_name) \ @implementation table##_QueryAccessor_##col_name \ --(table##_Query *)equal:(size_t)value \ +-(table##_Query *)equal:(int64_t)value \ { \ return (table##_Query *)[super equal:value]; \ } \ --(table##_Query *)notEqual:(size_t)value \ +-(table##_Query *)notEqual:(int64_t)value \ { \ return (table##_Query *)[super notEqual:value]; \ } \ @@ -206,16 +238,117 @@ { \ return (table##_Query *)[super greater:value]; \ } \ +-(table##_Query *)greaterEqual:(int64_t)value \ +{ \ + return (table##_Query *)[super greaterEqual:value]; \ +} \ -(table##_Query *)less:(int64_t)value \ { \ return (table##_Query *)[super less:value]; \ } \ +-(table##_Query *)lessEqual:(int64_t)value \ +{ \ + return (table##_Query *)[super lessEqual:value]; \ +} \ -(table##_Query *)between:(int64_t)from to:(int64_t)to \ { \ return (table##_Query *)[super between:from to:to]; \ } \ @end + +// Float + +#define TIGHTDB_QUERY_ACCESSOR_DEF_Float(table, col_name) \ +@interface table##_QueryAccessor_##col_name : OCXQueryAccessorFloat \ +-(table##_Query *)equal:(float)value; \ +-(table##_Query *)notEqual:(float)value; \ +-(table##_Query *)greater:(float)value; \ +-(table##_Query *)greaterEqual:(float)value; \ +-(table##_Query *)less:(float)value; \ +-(table##_Query *)lessEqual:(float)value; \ +-(table##_Query *)between:(float)from to:(float)to; \ +@end + +#define TIGHTDB_QUERY_ACCESSOR_IMPL_Float(table, col_name) \ +@implementation table##_QueryAccessor_##col_name \ +-(table##_Query *)equal:(float)value \ +{ \ + return (table##_Query *)[super equal:value]; \ +} \ +-(table##_Query *)notEqual:(float)value \ +{ \ + return (table##_Query *)[super notEqual:value]; \ +} \ +-(table##_Query *)greater:(float)value \ +{ \ + return (table##_Query *)[super greater:value]; \ +} \ +-(table##_Query *)greaterEqual:(float)value \ +{ \ + return (table##_Query *)[super greaterEqual:value]; \ +} \ +-(table##_Query *)less:(float)value \ +{ \ + return (table##_Query *)[super less:value]; \ +} \ +-(table##_Query *)lessEqual:(float)value \ +{ \ + return (table##_Query *)[super lessEqual:value]; \ +} \ +-(table##_Query *)between:(float)from to:(float)to \ +{ \ + return (table##_Query *)[super between:from to:to]; \ +} \ +@end + + +// Double + +#define TIGHTDB_QUERY_ACCESSOR_DEF_Double(table, col_name) \ +@interface table##_QueryAccessor_##col_name : OCXQueryAccessorDouble \ +-(table##_Query *)equal:(double)value; \ +-(table##_Query *)notEqual:(double)value; \ +-(table##_Query *)greater:(double)value; \ +-(table##_Query *)greaterEqual:(double)value; \ +-(table##_Query *)less:(double)value; \ +-(table##_Query *)lessEqual:(double)value; \ +-(table##_Query *)between:(double)from to:(double)to; \ +@end + +#define TIGHTDB_QUERY_ACCESSOR_IMPL_Double(table, col_name) \ +@implementation table##_QueryAccessor_##col_name \ +-(table##_Query *)equal:(double)value \ +{ \ + return (table##_Query *)[super equal:value]; \ +} \ +-(table##_Query *)notEqual:(double)value \ +{ \ + return (table##_Query *)[super notEqual:value]; \ +} \ +-(table##_Query *)greater:(double)value \ +{ \ + return (table##_Query *)[super greater:value]; \ +} \ +-(table##_Query *)greaterEqual:(double)value \ +{ \ + return (table##_Query *)[super greaterEqual:value]; \ +} \ +-(table##_Query *)less:(double)value \ +{ \ + return (table##_Query *)[super less:value]; \ +} \ +-(table##_Query *)lessEqual:(double)value \ +{ \ + return (table##_Query *)[super lessEqual:value]; \ +} \ +-(table##_Query *)between:(double)from to:(double)to \ +{ \ + return (table##_Query *)[super between:from to:to]; \ +} \ +@end + + // String #define TIGHTDB_QUERY_ACCESSOR_DEF_String(table, col_name) \ @@ -251,6 +384,18 @@ } \ @end + +// Binary + +#define TIGHTDB_QUERY_ACCESSOR_DEF_Binary(table, col_name) \ +@interface table##_QueryAccessor_##col_name : OCXQueryAccessorBinary \ +@end + +#define TIGHTDB_QUERY_ACCESSOR_IMPL_Binary(table, col_name) \ +@implementation table##_QueryAccessor_##col_name \ +@end + + // Date #define TIGHTDB_QUERY_ACCESSOR_DEF_Date(table, col_name) \ @@ -261,6 +406,7 @@ @implementation table##_QueryAccessor_##col_name \ @end + // Subtable #define TIGHTDB_QUERY_ACCESSOR_DEF_SUBTABLE(table, col_name, col_type) \ @@ -271,6 +417,7 @@ @implementation table##_QueryAccessor_##col_name \ @end + // Mixed #define TIGHTDB_QUERY_ACCESSOR_DEF_Mixed(table, col_name) \ diff --git a/src/tightdb/objc/query.h b/src/tightdb/objc/query.h index a982406a10..18ac55a20e 100644 --- a/src/tightdb/objc/query.h +++ b/src/tightdb/objc/query.h @@ -35,12 +35,32 @@ -(void)subtable:(size_t)column; -(void)parent; -(size_t)count; --(double)avgOnColumn:(size_t)columndId; +-(int64_t)minInt:(size_t)colNdx; +-(float)minFloat:(size_t)colNdx; +-(double)minDouble:(size_t)colNdx; +-(int64_t)maxInt:(size_t)colNdx; +-(float)maxFloat:(size_t)colNdx; +-(double)maxDouble:(size_t)colNdx; +-(int64_t)sumInt:(size_t)colNdx; +-(double)sumFloat:(size_t)colNdx; +-(double)sumDouble:(size_t)colNdx; +-(double)avgInt:(size_t)colNdx; +-(double)avgFloat:(size_t)colNdx; +-(double)avgDouble:(size_t)colNdx; -(size_t)findNext:(size_t)last; -(NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained *)stackbuf count:(NSUInteger)len; //-(void)clear; @end + +#pragma mark - OCXQueryAccessorBool + +@interface OCXQueryAccessorBool : NSObject +-(id)initWithColumn:(size_t)columnId query:(Query *)query; +-(Query *)equal:(BOOL)value; +@end + + #pragma mark - OCXQueryAccessorInt @interface OCXQueryAccessorInt : NSObject @@ -48,41 +68,98 @@ -(Query *)equal:(int64_t)value; -(Query *)notEqual:(int64_t)value; -(Query *)greater:(int64_t)value; +-(Query *)greaterEqual:(int64_t)value; -(Query *)less:(int64_t)value; +-(Query *)lessEqual:(int64_t)value; -(Query *)between:(int64_t)from to:(int64_t)to; +-(int64_t)min; +-(int64_t)max; +-(int64_t)sum; -(double)avg; @end -#pragma mark - OCXQueryAccessorBool -@interface OCXQueryAccessorBool : NSObject +#pragma mark - OCXQueryAccessorFloat + +@interface OCXQueryAccessorFloat : NSObject -(id)initWithColumn:(size_t)columnId query:(Query *)query; --(Query *)equal:(BOOL)value; +-(Query *)equal:(float)value; +-(Query *)notEqual:(float)value; +-(Query *)greater:(float)value; +-(Query *)greaterEqual:(float)value; +-(Query *)less:(float)value; +-(Query *)lessEqual:(float)value; +-(Query *)between:(float)from to:(float)to; +-(float)min; +-(float)max; +-(double)sum; +-(double)avg; @end -#pragma mark - OCXQueryAccessorDate -@interface OCXQueryAccessorDate : NSObject +#pragma mark - OCXQueryAccessorDouble + +@interface OCXQueryAccessorDouble : NSObject -(id)initWithColumn:(size_t)columnId query:(Query *)query; +-(Query *)equal:(double)value; +-(Query *)notEqual:(double)value; +-(Query *)greater:(double)value; +-(Query *)greaterEqual:(double)value; +-(Query *)less:(double)value; +-(Query *)lessEqual:(double)value; +-(Query *)between:(double)from to:(double)to; +-(double)min; +-(double)max; +-(double)sum; +-(double)avg; @end + #pragma mark - OCXQueryAccessorString @interface OCXQueryAccessorString : NSObject -(id)initWithColumn:(size_t)columnId query:(Query *)query; +-(Query *)equal:(NSString *)value; -(Query *)equal:(NSString *)value caseSensitive:(BOOL)caseSensitive; +-(Query *)notEqual:(NSString *)value; -(Query *)notEqual:(NSString *)value caseSensitive:(BOOL)caseSensitive; +-(Query *)beginsWith:(NSString *)value; -(Query *)beginsWith:(NSString *)value caseSensitive:(BOOL)caseSensitive; +-(Query *)endsWith:(NSString *)value; -(Query *)endsWith:(NSString *)value caseSensitive:(BOOL)caseSensitive; +-(Query *)contains:(NSString *)value; -(Query *)contains:(NSString *)value caseSensitive:(BOOL)caseSensitive; @end + +#pragma mark - OCXQueryAccessorBinary + +@interface OCXQueryAccessorBinary : NSObject +-(id)initWithColumn:(size_t)columnId query:(Query *)query; +@end + + +#pragma mark - OCXQueryAccessorDate + +@interface OCXQueryAccessorDate : NSObject +-(id)initWithColumn:(size_t)columnId query:(Query *)query; +-(Query *)equal:(time_t)value; +-(Query *)notEqual:(time_t)value; +-(Query *)greater:(time_t)value; +-(Query *)greaterEqual:(time_t)value; +-(Query *)less:(time_t)value; +-(Query *)lessEqual:(time_t)value; +-(Query *)between:(time_t)from to:(time_t)to; +@end + + #pragma mark - OCXQueryAccessorSubtable @interface OCXQueryAccessorSubtable : NSObject -(id)initWithColumn:(size_t)columnId query:(Query *)query; @end + #pragma mark - OCXQueryAccessorMixed @interface OCXQueryAccessorMixed : NSObject diff --git a/src/tightdb/objc/query_objc.mm b/src/tightdb/objc/query_objc.mm index 67865ea0bd..3491fd6459 100644 --- a/src/tightdb/objc/query_objc.mm +++ b/src/tightdb/objc/query_objc.mm @@ -125,10 +125,56 @@ -(size_t)count return _query->count(); } --(double)avgOnColumn:(size_t)columndId +-(int64_t)minInt:(size_t)col_ndx { - size_t resultCount; - return _query->average(columndId, &resultCount); + return _query->minimum(col_ndx); +} +-(float)minFloat:(size_t)col_ndx +{ + return _query->minimum_float(col_ndx); +} +-(double)minDouble:(size_t)col_ndx +{ + return _query->minimum_double(col_ndx); +} + +-(int64_t)maxInt:(size_t)col_ndx +{ + return _query->maximum(col_ndx); +} +-(float)maxFloat:(size_t)col_ndx +{ + return _query->maximum_float(col_ndx); +} +-(double)maxDouble:(size_t)col_ndx +{ + return _query->maximum_double(col_ndx); +} + +-(int64_t)sumInt:(size_t)col_ndx +{ + return _query->sum(col_ndx); +} +-(double)sumFloat:(size_t)col_ndx +{ + return _query->sum_float(col_ndx); +} +-(double)sumDouble:(size_t)col_ndx +{ + return _query->sum_double(col_ndx); +} + +-(double)avgInt:(size_t)col_ndx +{ + return _query->average(col_ndx); +} +-(double)avgFloat:(size_t)col_ndx +{ + return _query->average_float(col_ndx); +} +-(double)avgDouble:(size_t)col_ndx +{ + return _query->average_double(col_ndx); } -(tightdb::TableView)getTableView @@ -142,9 +188,9 @@ -(size_t)findNext:(size_t)last @end -#pragma mark - OCXQueryAccessorInt +#pragma mark - OCXQueryAccessorBool -@implementation OCXQueryAccessorInt +@implementation OCXQueryAccessorBool { Query *_query; size_t _column_ndx; @@ -158,9 +204,29 @@ -(id)initWithColumn:(size_t)columnId query:(Query *)query } return self; } --(double)avg +-(Query *)equal:(BOOL)value { - return [_query avgOnColumn:_column_ndx]; + [_query getQuery]->equal(_column_ndx, (bool)value); + return _query; +} +@end + + +#pragma mark - OCXQueryAccessorInt + +@implementation OCXQueryAccessorInt +{ + Query *_query; + size_t _column_ndx; +} +-(id)initWithColumn:(size_t)columnId query:(Query *)query +{ + self = [super init]; + if (self) { + _query = query; + _column_ndx = columnId; + } + return self; } -(Query *)equal:(int64_t)value @@ -181,23 +247,52 @@ -(Query *)greater:(int64_t)value return _query; } +-(Query *)greaterEqual:(int64_t)value +{ + [_query getQuery]->greater_equal(_column_ndx, value); + return _query; +} + -(Query *)less:(int64_t)value { [_query getQuery]->less(_column_ndx, value); return _query; } +-(Query *)lessEqual:(int64_t)value +{ + [_query getQuery]->less_equal(_column_ndx, value); + return _query; +} + -(Query *)between:(int64_t)from to:(int64_t)to { [_query getQuery]->between(_column_ndx, from, to); return _query; } + +-(int64_t)min +{ + return [_query minInt:_column_ndx]; +} +-(int64_t)max +{ + return [_query maxInt:_column_ndx]; +} +-(int64_t)sum +{ + return [_query sumInt:_column_ndx]; +} +-(double)avg +{ + return [_query avgInt:_column_ndx]; +} @end -#pragma mark - OCXQueryAccessorBool +#pragma mark - OCXQueryAccessorFloat -@implementation OCXQueryAccessorBool +@implementation OCXQueryAccessorFloat { Query *_query; size_t _column_ndx; @@ -211,17 +306,71 @@ -(id)initWithColumn:(size_t)columnId query:(Query *)query } return self; } --(Query *)equal:(BOOL)value + +-(Query *)equal:(float)value { - [_query getQuery]->equal(_column_ndx, (bool)value); + [_query getQuery]->equal(_column_ndx, value); + return _query; +} + +-(Query *)notEqual:(float)value +{ + [_query getQuery]->not_equal(_column_ndx, value); + return _query; +} + +-(Query *)greater:(float)value +{ + [_query getQuery]->greater(_column_ndx, value); + return _query; +} + +-(Query *)greaterEqual:(float)value +{ + [_query getQuery]->greater_equal(_column_ndx, value); + return _query; +} + +-(Query *)less:(float)value +{ + [_query getQuery]->less(_column_ndx, value); return _query; } + +-(Query *)lessEqual:(float)value +{ + [_query getQuery]->less_equal(_column_ndx, value); + return _query; +} + +-(Query *)between:(float)from to:(float)to +{ + [_query getQuery]->between(_column_ndx, from, to); + return _query; +} + +-(float)min +{ + return [_query minFloat:_column_ndx]; +} +-(float)max +{ + return [_query maxFloat:_column_ndx]; +} +-(double)sum +{ + return [_query sumFloat:_column_ndx]; +} +-(double)avg +{ + return [_query avgFloat:_column_ndx]; +} @end -#pragma mark - OCXQueryAccessorDate +#pragma mark - OCXQueryAccessorDouble -@implementation OCXQueryAccessorDate +@implementation OCXQueryAccessorDouble { Query *_query; size_t _column_ndx; @@ -235,6 +384,65 @@ -(id)initWithColumn:(size_t)columnId query:(Query *)query } return self; } + +-(Query *)equal:(double)value +{ + [_query getQuery]->equal(_column_ndx, value); + return _query; +} + +-(Query *)notEqual:(double)value +{ + [_query getQuery]->not_equal(_column_ndx, value); + return _query; +} + +-(Query *)greater:(double)value +{ + [_query getQuery]->greater(_column_ndx, value); + return _query; +} + +-(Query *)greaterEqual:(double)value +{ + [_query getQuery]->greater_equal(_column_ndx, value); + return _query; +} + +-(Query *)less:(double)value +{ + [_query getQuery]->less(_column_ndx, value); + return _query; +} + +-(Query *)lessEqual:(double)value +{ + [_query getQuery]->less_equal(_column_ndx, value); + return _query; +} + +-(Query *)between:(double)from to:(double)to +{ + [_query getQuery]->between(_column_ndx, from, to); + return _query; +} + +-(double)min +{ + return [_query minDouble:_column_ndx]; +} +-(double)max +{ + return [_query maxDouble:_column_ndx]; +} +-(double)sum +{ + return [_query sumDouble:_column_ndx]; +} +-(double)avg +{ + return [_query avgDouble:_column_ndx]; +} @end @@ -254,26 +462,51 @@ -(id)initWithColumn:(size_t)columnId query:(Query *)query } return self; } +-(Query *)equal:(NSString *)value +{ + [_query getQuery]->equal(_column_ndx, [value UTF8String]); + return _query; +} -(Query *)equal:(NSString *)value caseSensitive:(BOOL)caseSensitive { [_query getQuery]->equal(_column_ndx, [value UTF8String], caseSensitive); return _query; } +-(Query *)notEqual:(NSString *)value +{ + [_query getQuery]->not_equal(_column_ndx, [value UTF8String]); + return _query; +} -(Query *)notEqual:(NSString *)value caseSensitive:(BOOL)caseSensitive { [_query getQuery]->not_equal(_column_ndx, [value UTF8String], caseSensitive); return _query; } +-(Query *)beginsWith:(NSString *)value +{ + [_query getQuery]->begins_with(_column_ndx, [value UTF8String]); + return _query; +} -(Query *)beginsWith:(NSString *)value caseSensitive:(BOOL)caseSensitive { [_query getQuery]->begins_with(_column_ndx, [value UTF8String], caseSensitive); return _query; } +-(Query *)endsWith:(NSString *)value +{ + [_query getQuery]->ends_with(_column_ndx, [value UTF8String]); + return _query; +} -(Query *)endsWith:(NSString *)value caseSensitive:(BOOL)caseSensitive { [_query getQuery]->ends_with(_column_ndx, [value UTF8String], caseSensitive); return _query; } +-(Query *)contains:(NSString *)value +{ + [_query getQuery]->contains(_column_ndx, [value UTF8String]); + return _query; +} -(Query *)contains:(NSString *)value caseSensitive:(BOOL)caseSensitive { [_query getQuery]->contains(_column_ndx, [value UTF8String], caseSensitive); @@ -282,6 +515,79 @@ -(Query *)contains:(NSString *)value caseSensitive:(BOOL)caseSensitive @end +#pragma mark - OCXQueryAccessorBinary + +@implementation OCXQueryAccessorBinary +{ + Query *_query; + size_t _column_ndx; +} +-(id)initWithColumn:(size_t)columnId query:(Query *)query +{ + self = [super init]; + if (self) { + _query = query; + _column_ndx = columnId; + } + return self; +} +@end + + +#pragma mark - OCXQueryAccessorDate + +@implementation OCXQueryAccessorDate +{ + Query *_query; + size_t _column_ndx; +} +-(id)initWithColumn:(size_t)columnId query:(Query *)query +{ + self = [super init]; + if (self) { + _query = query; + _column_ndx = columnId; + } + return self; +} +-(Query *)equal:(time_t)value +{ + [_query getQuery]->equal_date(_column_ndx, value); + return _query; +} +-(Query *)notEqual:(time_t)value +{ + [_query getQuery]->not_equal_date(_column_ndx, value); + return _query; +} +-(Query *)greater:(time_t)value +{ + [_query getQuery]->greater_date(_column_ndx, value); + return _query; +} +-(Query *)greaterEqual:(time_t)value +{ + [_query getQuery]->greater_equal_date(_column_ndx, value); + return _query; +} +-(Query *)less:(time_t)value +{ + [_query getQuery]->less_date(_column_ndx, value); + return _query; +} +-(Query *)lessEqual:(time_t)value +{ + [_query getQuery]->less_equal_date(_column_ndx, value); + return _query; +} +-(Query *)between:(time_t)from to:(time_t)to +{ + [_query getQuery]->between_date(_column_ndx, from, to); + return _query; +} +@end + + #pragma mark - OCXQueryAccessorSubtable @implementation OCXQueryAccessorSubtable diff --git a/src/tightdb/objc/table.h b/src/tightdb/objc/table.h index 85903b70c0..be219b6b30 100644 --- a/src/tightdb/objc/table.h +++ b/src/tightdb/objc/table.h @@ -26,7 +26,7 @@ @class TableView; @interface BinaryData : NSObject --(id)initWithData:(const char *)data len:(size_t)size; +-(id)initWithData:(const char *)data size:(size_t)size; -(const char *)getData; -(size_t)getSize; @@ -34,27 +34,25 @@ -(BOOL)isEqual:(BinaryData *)bin; @end -@interface OCDate : NSObject --(id)initWithDate:(time_t)d; --(time_t)getDate; --(BOOL)isEqual:(OCDate *)other; -@end - @interface OCMixed : NSObject +(OCMixed *)mixedWithBool:(BOOL)value; +(OCMixed *)mixedWithInt64:(int64_t)value; -+(OCMixed *)mixedWithString:(NSString *)string; -+(OCMixed *)mixedWithBinary:(BinaryData *)data; -+(OCMixed *)mixedWithBinary:(const char*)value length:(size_t)length; -+(OCMixed *)mixedWithDate:(OCDate *)date; -+(OCMixed *)mixedWithTable:(Table *)table; ++(OCMixed *)mixedWithFloat:(float)value; ++(OCMixed *)mixedWithDouble:(double)value; ++(OCMixed *)mixedWithString:(NSString *)value; ++(OCMixed *)mixedWithBinary:(BinaryData *)value; ++(OCMixed *)mixedWithBinary:(const char *)data size:(size_t)size; ++(OCMixed *)mixedWithDate:(time_t)value; ++(OCMixed *)mixedWithTable:(Table *)value; -(BOOL)isEqual:(OCMixed *)other; -(TightdbDataType)getType; --(int64_t)getInt; -(BOOL)getBool; --(OCDate *)getDate; +-(int64_t)getInt; +-(float)getFloat; +-(double)getDouble; -(NSString *)getString; -(BinaryData *)getBinary; +-(time_t)getDate; -(Table *)getTable; @end @@ -64,10 +62,10 @@ -(BOOL)addColumn:(TightdbDataType)type name:(NSString *)name; /// Returns nil on memory allocation error. -(OCSpec *)addColumnTable:(NSString *)name; --(OCSpec *)getSpec:(size_t)columnId; +-(OCSpec *)getSubspec:(size_t)colNdx; -(size_t)getColumnCount; --(TightdbDataType)getColumnType:(size_t)ndx; --(NSString *)getColumnName:(size_t)ndx; +-(TightdbDataType)getColumnType:(size_t)colNdx; +-(NSString *)getColumnName:(size_t)colNdx; -(size_t)getColumnIndex:(NSString *)name; @end @@ -76,6 +74,8 @@ -(void)updateFromSpec; -(NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained *)stackbuf count:(NSUInteger)len; +-(BOOL)isEqual:(Table *)other; + //@{ /// If the specified column is neither a subtable column, nor a mixed /// column, then these methods return nil. They also return nil for a @@ -87,8 +87,8 @@ /// /// The specified table class must be one that is declared by using /// one of the table macros TIGHTDB_TABLE_*. --(Table *)getSubtable:(size_t)columnId ndx:(size_t)ndx; --(id)getSubtable:(size_t)columnId ndx:(size_t)ndx withClass:(Class)obj; +-(Table *)getSubtable:(size_t)colNdx ndx:(size_t)ndx; +-(id)getSubtable:(size_t)colNdx ndx:(size_t)ndx withClass:(Class)obj; //@} /// This method will return NO if it encounters a memory allocation @@ -120,58 +120,68 @@ -(void)popBack; // Adaptive ints. --(int64_t)get:(size_t)columnId ndx:(size_t)ndx; --(void)set:(size_t)columnId ndx:(size_t)ndx value:(int64_t)value; --(BOOL)getBool:(size_t)columnId ndx:(size_t)ndx; --(void)setBool:(size_t)columnId ndx:(size_t)ndx value:(BOOL)value; --(time_t)getDate:(size_t)columnId ndx:(size_t)ndx; --(void)setDate:(size_t)columnId ndx:(size_t)ndx value:(time_t)value; +-(int64_t)get:(size_t)colNdx ndx:(size_t)ndx; +-(void)set:(size_t)colNdx ndx:(size_t)ndx value:(int64_t)value; +-(BOOL)getBool:(size_t)colNdx ndx:(size_t)ndx; +-(void)setBool:(size_t)colNdx ndx:(size_t)ndx value:(BOOL)value; +-(float)getFloat:(size_t)colNdx ndx:(size_t)ndx; +-(void)setFloat:(size_t)colNdx ndx:(size_t)ndx value:(float)value; +-(double)getDouble:(size_t)colNdx ndx:(size_t)ndx; +-(void)setDouble:(size_t)colNdx ndx:(size_t)ndx value:(double)value; +-(time_t)getDate:(size_t)colNdx ndx:(size_t)ndx; +-(void)setDate:(size_t)colNdx ndx:(size_t)ndx value:(time_t)value; // NOTE: Low-level insert functions. Always insert in all columns at once // and call InsertDone after to avoid table getting un-balanced. --(void)insertBool:(size_t)columnId ndx:(size_t)ndx value:(BOOL)value; --(void)insertInt:(size_t)columnId ndx:(size_t)ndx value:(int64_t)value; --(void)insertString:(size_t)columnId ndx:(size_t)ndx value:(NSString *)value; --(void)insertBinary:(size_t)columnId ndx:(size_t)ndx value:(void *)value len:(size_t)len; --(void)insertDate:(size_t)columnId ndx:(size_t)ndx value:(time_t)value; +-(void)insertBool:(size_t)colNdx ndx:(size_t)ndx value:(BOOL)value; +-(void)insertInt:(size_t)colNdx ndx:(size_t)ndx value:(int64_t)value; +-(void)insertFloat:(size_t)colNdx ndx:(size_t)ndx value:(float)value; +-(void)insertDouble:(size_t)colNdx ndx:(size_t)ndx value:(double)value; +-(void)insertString:(size_t)colNdx ndx:(size_t)ndx value:(NSString *)value; +-(void)insertBinary:(size_t)colNdx ndx:(size_t)ndx value:(BinaryData *)value; +-(void)insertBinary:(size_t)colNdx ndx:(size_t)ndx data:(const char *)data size:(size_t)size; +-(void)insertDate:(size_t)colNdx ndx:(size_t)ndx value:(time_t)value; -(void)insertDone; // Strings --(NSString *)getString:(size_t)columnId ndx:(size_t)ndx; --(void)setString:(size_t)columnId ndx:(size_t)ndx value:(NSString *)value; +-(NSString *)getString:(size_t)colNdx ndx:(size_t)ndx; +-(void)setString:(size_t)colNdx ndx:(size_t)ndx value:(NSString *)value; // Binary --(BinaryData *)getBinary:(size_t)columnId ndx:(size_t)ndx; --(void)setBinary:(size_t)columnId ndx:(size_t)ndx value:(void *)value len:(size_t)len; +-(BinaryData *)getBinary:(size_t)colNdx ndx:(size_t)ndx; +-(void)setBinary:(size_t)colNdx ndx:(size_t)ndx value:(BinaryData *)value; +-(void)setBinary:(size_t)colNdx ndx:(size_t)ndx data:(const char *)data size:(size_t)size; // Subtables --(size_t)getTableSize:(size_t)columnId ndx:(size_t)ndx; --(void)insertSubtable:(size_t)columnId ndx:(size_t)ndx; --(void)clearTable:(size_t)columnId ndx:(size_t)ndx; +-(size_t)getTableSize:(size_t)colNdx ndx:(size_t)ndx; +-(void)insertSubtable:(size_t)colNdx ndx:(size_t)ndx; +-(void)clearSubtable:(size_t)colNdx ndx:(size_t)ndx; // Mixed --(OCMixed *)getMixed:(size_t)columnId ndx:(size_t)ndx; --(TightdbDataType)getMixedType:(size_t)columnId ndx:(size_t)ndx; --(void)insertMixed:(size_t)columnId ndx:(size_t)ndx value:(OCMixed *)value; --(void)setMixed:(size_t)columnId ndx:(size_t)ndx value:(OCMixed *)value; +-(OCMixed *)getMixed:(size_t)colNdx ndx:(size_t)ndx; +-(TightdbDataType)getMixedType:(size_t)colNdx ndx:(size_t)ndx; +-(void)insertMixed:(size_t)colNdx ndx:(size_t)ndx value:(OCMixed *)value; +-(void)setMixed:(size_t)colNdx ndx:(size_t)ndx value:(OCMixed *)value; -(size_t)addColumn:(TightdbDataType)type name:(NSString *)name; // Searching --(size_t)findBool:(size_t)columnId value:(BOOL)value; --(size_t)findInt:(size_t)columnId value:(int64_t)value; --(size_t)findString:(size_t)columnId value:(NSString *)value; --(size_t)findBinary:(size_t)columnId value:(BinaryData *)value; --(size_t)findDate:(size_t)columnId value:(time_t)value; --(size_t)findMixed:(size_t)columnId value:(OCMixed *)value; +-(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; +-(size_t)findDouble:(size_t)colNdx value:(double)value; +-(size_t)findString:(size_t)colNdx value:(NSString *)value; +-(size_t)findBinary:(size_t)colNdx value:(BinaryData *)value; +-(size_t)findDate:(size_t)colNdx value:(time_t)value; +-(size_t)findMixed:(size_t)colNdx value:(OCMixed *)value; // FIXME: Why does this one take a TableView as argument? --(TableView *)findAll:(TableView *)view column:(size_t)columnId value:(int64_t)value; +-(TableView *)findAll:(TableView *)view column:(size_t)colNdx value:(int64_t)value; // FIXME: Implement findAll for the rest of the column types. // Indexing --(BOOL)hasIndex:(size_t)columnId; --(void)setIndex:(size_t)columnId; +-(BOOL)hasIndex:(size_t)colNdx; +-(void)setIndex:(size_t)colNdx; // Optimizing -(void)optimize; @@ -180,19 +190,30 @@ // FIXME: Do we want to conversion methods? Maybe use NSData. // Aggregate functions --(size_t)countInt:(size_t)columnId target:(int64_t)target; --(size_t)countString:(size_t)columnId target:(NSString *)target; --(int64_t)sum:(size_t)columnId; --(int64_t)maximum:(size_t)columnId; --(int64_t)minimum:(size_t)columnId; --(double)average:(size_t)columnId; +-(size_t)countInt:(size_t)colNdx target:(int64_t)target; +-(size_t)countFloat:(size_t)colNdx target:(float)target; +-(size_t)countDouble:(size_t)colNdx target:(double)target; +-(size_t)countString:(size_t)colNdx target:(NSString *)target; +-(int64_t)sumInt:(size_t)colNdx; +-(double)sumFloat:(size_t)colNdx; +-(double)sumDouble:(size_t)colNdx; +-(int64_t)maxInt:(size_t)colNdx; +-(float)maxFloat:(size_t)colNdx; +-(double)maxDouble:(size_t)colNdx; +-(int64_t)minInt:(size_t)colNdx; +-(float)minFloat:(size_t)colNdx; +-(double)minDouble:(size_t)colNdx; +-(double)avgInt:(size_t)colNdx; +-(double)avgFloat:(size_t)colNdx; +-(double)avgDouble:(size_t)colNDx; #ifdef TIGHTDB_DEBUG -(void)verify; #endif +// Private -(id)_initRaw; --(void)_insertSubtableCopy:(size_t)col_ndx row_ndx:(size_t)row_ndx subtable:(Table *)subtable; +-(void)_insertSubtableCopy:(size_t)colNdx row:(size_t)rowNdx subtable:(Table *)subtable; @end @@ -203,10 +224,10 @@ -(size_t)count; -(BOOL)isEmpty; --(int64_t)get:(size_t)columnId ndx:(size_t)ndx; --(BOOL)getBool:(size_t)columnId ndx:(size_t)ndx; --(time_t)getDate:(size_t)columnId ndx:(size_t)ndx; --(NSString *)getString:(size_t)columnId ndx:(size_t)ndx; +-(int64_t)get:(size_t)colNdx ndx:(size_t)ndx; +-(BOOL)getBool:(size_t)colNdx ndx:(size_t)ndx; +-(time_t)getDate:(size_t)colNdx ndx:(size_t)ndx; +-(NSString *)getString:(size_t)colNdx ndx:(size_t)ndx; // Deleting -(void)delete:(size_t)ndx; -(void)clear; @@ -226,19 +247,46 @@ @interface OCColumnProxy_Bool : OCColumnProxy -(size_t)find:(BOOL)value; @end + @interface OCColumnProxy_Int : OCColumnProxy -(size_t)find:(int64_t)value; -(TableView *)findAll:(int64_t)value; +-(int64_t)min; +-(int64_t)max; +-(int64_t)sum; +-(double)avg; @end + +@interface OCColumnProxy_Float : OCColumnProxy +-(size_t)find:(float)value; +-(float)min; +-(float)max; +-(double)sum; +-(double)avg; +@end + +@interface OCColumnProxy_Double : OCColumnProxy +-(size_t)find:(double)value; +-(double)min; +-(double)max; +-(double)sum; +-(double)avg; +@end + @interface OCColumnProxy_String : OCColumnProxy -(size_t)find:(NSString *)value; @end + @interface OCColumnProxy_Binary : OCColumnProxy -(size_t)find:(BinaryData *)value; @end + @interface OCColumnProxy_Date : OCColumnProxy -(size_t)find:(time_t) value; @end +@interface OCColumnProxy_Subtable : OCColumnProxy +@end + @interface OCColumnProxy_Mixed : OCColumnProxy -(size_t)find:(OCMixed *)value; @end diff --git a/src/tightdb/objc/table_objc.mm b/src/tightdb/objc/table_objc.mm index 01b259c55a..71e49fe500 100644 --- a/src/tightdb/objc/table_objc.mm +++ b/src/tightdb/objc/table_objc.mm @@ -7,6 +7,7 @@ #import #import +#import #import #import @@ -20,7 +21,7 @@ @implementation BinaryData { tightdb::BinaryData _data; } --(id)initWithData:(const char *)data len:(size_t)size +-(id)initWithData:(const char *)data size:(size_t)size { self = [super init]; if (self) { @@ -56,37 +57,6 @@ -(BOOL)isEqual:(BinaryData *)bin @end -#pragma mark - Date -@implementation OCDate -{ - tightdb::Date *_date; -} --(id)initWithDate:(time_t)d -{ - self = [super init]; - if (self) { - _date = new tightdb::Date(d); - } - return self; -} --(time_t)getDate -{ - return _date->get_date(); -} --(BOOL)isEqual:(OCDate *)other -{ - return [self getDate] == [other getDate]; -} - --(void)dealloc -{ -#ifdef TIGHTDB_DEBUG - NSLog(@"OCDate dealloc"); -#endif - delete _date; -} -@end - #pragma mark - Mixed @interface OCMixed() @property (nonatomic) tightdb::Mixed mixed; @@ -97,74 +67,74 @@ @implementation OCMixed @synthesize mixed = _mixed; @synthesize table = _table; -+(OCMixed *)mixedWithMixed:(tightdb::Mixed&)other ++(OCMixed *)mixedWithBool:(BOOL)value { OCMixed *mixed = [[OCMixed alloc] init]; - - mixed.mixed = other; - + mixed.mixed = tightdb::Mixed((bool)value); return mixed; } -+(OCMixed *)mixedWithTable:(Table *)table + ++(OCMixed *)mixedWithInt64:(int64_t)value { OCMixed *mixed = [[OCMixed alloc] init]; - - mixed.mixed = tightdb::Mixed(tightdb::Mixed::subtable_tag()); - mixed.table = table; + mixed.mixed = tightdb::Mixed(value); return mixed; } -+(OCMixed *)mixedWithBool:(BOOL)value ++(OCMixed *)mixedWithFloat:(float)value { OCMixed *mixed = [[OCMixed alloc] init]; - - mixed.mixed = tightdb::Mixed((bool)value); - + mixed.mixed = tightdb::Mixed(value); return mixed; } -+(OCMixed *)mixedWithDate:(OCDate *)date ++(OCMixed *)mixedWithDouble:(double)value { OCMixed *mixed = [[OCMixed alloc] init]; - - mixed.mixed = tightdb::Mixed(tightdb::Date([date getDate])); - + mixed.mixed = tightdb::Mixed(value); return mixed; } -+(OCMixed *)mixedWithInt64:(int64_t)value ++(OCMixed *)mixedWithString:(NSString *)value { OCMixed *mixed = [[OCMixed alloc] init]; - - mixed.mixed = tightdb::Mixed(value); - + mixed.mixed = tightdb::Mixed((const char *)[value UTF8String]); return mixed; } -+(OCMixed *)mixedWithString:(NSString *)string ++(OCMixed *)mixedWithBinary:(BinaryData *)value { OCMixed *mixed = [[OCMixed alloc] init]; - - mixed.mixed = tightdb::Mixed((const char *)[string UTF8String]); - + mixed.mixed = tightdb::Mixed([value getBinary]); return mixed; } -+(OCMixed *)mixedWithBinary:(BinaryData *)data ++(OCMixed *)mixedWithBinary:(const char *)data size:(size_t)size { OCMixed *mixed = [[OCMixed alloc] init]; - - mixed.mixed = tightdb::Mixed([data getBinary]); - + mixed.mixed = tightdb::Mixed(tightdb::BinaryData(data, size)); return mixed; } -+(OCMixed *)mixedWithBinary:(const char*)value length:(size_t)length ++(OCMixed *)mixedWithDate:(time_t)value { OCMixed *mixed = [[OCMixed alloc] init]; + mixed.mixed = tightdb::Mixed(tightdb::Date(value)); + return mixed; +} - mixed.mixed = tightdb::Mixed(tightdb::BinaryData(value, length)); ++(OCMixed *)mixedWithTable:(Table *)value +{ + OCMixed *mixed = [[OCMixed alloc] init]; + mixed.mixed = tightdb::Mixed(tightdb::Mixed::subtable_tag()); + mixed.table = value; + return mixed; +} ++(OCMixed *)mixedWithMixed:(tightdb::Mixed&)value +{ + OCMixed *mixed = [[OCMixed alloc] init]; + mixed.mixed = value; return mixed; } @@ -177,6 +147,10 @@ -(BOOL)isEqual:(OCMixed *)other return _mixed.get_bool() == other->_mixed.get_bool(); case tightdb::type_Int: return _mixed.get_int() == other->_mixed.get_int(); + case tightdb::type_Float: + return _mixed.get_float() == other->_mixed.get_float(); + case tightdb::type_Double: + return _mixed.get_double() == other->_mixed.get_double(); case tightdb::type_String: return std::strcmp(_mixed.get_string(), other->_mixed.get_string()) == 0; case tightdb::type_Binary: @@ -185,7 +159,6 @@ -(BOOL)isEqual:(OCMixed *)other return _mixed.get_date() == other->_mixed.get_date(); case tightdb::type_Table: return [_table getTable] == [other->_table getTable]; // Compare table contents - break; case tightdb::type_Mixed: TIGHTDB_ASSERT(false); break; @@ -197,18 +170,25 @@ -(TightdbDataType)getType { return (TightdbDataType)_mixed.get_type(); } + +-(BOOL)getBool +{ + return _mixed.get_bool(); +} + -(int64_t)getInt { return _mixed.get_int(); } --(BOOL)getBool + +-(float)getFloat { - return _mixed.get_bool(); + return _mixed.get_float(); } --(OCDate *)getDate +-(double)getDouble { - return [[OCDate alloc] initWithDate:_mixed.get_date()]; + return _mixed.get_double(); } -(NSString *)getString @@ -221,6 +201,11 @@ -(BinaryData *)getBinary return [[BinaryData alloc] initWithBinary:_mixed.get_binary()]; } +-(time_t)getDate +{ + return _mixed.get_date(); +} + -(Table *)getTable { return _table; @@ -269,9 +254,9 @@ -(OCSpec *)addColumnTable:(NSString *)name } // FIXME: Detect errors from core library --(OCSpec *)getSpec:(size_t)columnId +-(OCSpec *)getSubspec:(size_t)col_ndx { - tightdb::Spec tmp = _spec->get_subtable_spec(columnId); + tightdb::Spec tmp = _spec->get_subtable_spec(col_ndx); return [OCSpec specWithSpec:&tmp isOwned:TRUE]; } @@ -362,21 +347,21 @@ -(BOOL)isEmpty { return _tableView->is_empty(); } --(int64_t)get:(size_t)columnId ndx:(size_t)ndx +-(int64_t)get:(size_t)col_ndx ndx:(size_t)ndx { - return _tableView->get_int(columnId, ndx); + return _tableView->get_int(col_ndx, ndx); } --(BOOL)getBool:(size_t)columnId ndx:(size_t)ndx +-(BOOL)getBool:(size_t)col_ndx ndx:(size_t)ndx { - return _tableView->get_bool(columnId, ndx); + return _tableView->get_bool(col_ndx, ndx); } --(time_t)getDate:(size_t)columnId ndx:(size_t)ndx +-(time_t)getDate:(size_t)col_ndx ndx:(size_t)ndx { - return _tableView->get_date(columnId, ndx); + return _tableView->get_date(col_ndx, ndx); } --(NSString *)getString:(size_t)columnId ndx:(size_t)ndx +-(NSString *)getString:(size_t)col_ndx ndx:(size_t)ndx { - return [NSString stringWithUTF8String:_tableView->get_string(columnId, ndx)]; + return [NSString stringWithUTF8String:_tableView->get_string(col_ndx, ndx)]; } -(void)delete:(size_t)ndx { @@ -504,11 +489,16 @@ -(void)setReadOnly:(BOOL)readOnly _readOnly = readOnly; } --(Table *)getSubtable:(size_t)columnId ndx:(size_t)ndx +-(BOOL)isEqual:(Table *)other +{ + return *_table == *other->_table; +} + +-(Table *)getSubtable:(size_t)col_ndx ndx:(size_t)ndx { - const tightdb::DataType t = _table->get_column_type(columnId); + const tightdb::DataType t = _table->get_column_type(col_ndx); if (t != tightdb::type_Table && t != tightdb::type_Mixed) return nil; - tightdb::TableRef r = _table->get_subtable(columnId, ndx); + tightdb::TableRef r = _table->get_subtable(col_ndx, ndx); if (!r) return nil; Table *table = [[Table alloc] _initRaw]; if (TIGHTDB_UNLIKELY(!table)) return nil; @@ -519,11 +509,11 @@ -(Table *)getSubtable:(size_t)columnId ndx:(size_t)ndx } // FIXME: Check that the specified class derives from Table. --(id)getSubtable:(size_t)columnId ndx:(size_t)ndx withClass:(__unsafe_unretained Class)classObj +-(id)getSubtable:(size_t)col_ndx ndx:(size_t)ndx withClass:(__unsafe_unretained Class)classObj { - const tightdb::DataType t = _table->get_column_type(columnId); + const tightdb::DataType t = _table->get_column_type(col_ndx); if (t != tightdb::type_Table && t != tightdb::type_Mixed) return nil; - tightdb::TableRef r = _table->get_subtable(columnId, ndx); + tightdb::TableRef r = _table->get_subtable(col_ndx, ndx); if (!r) return nil; Table *table = [[classObj alloc] _initRaw]; if (TIGHTDB_UNLIKELY(!table)) return nil; @@ -621,65 +611,103 @@ -(void)popBack [NSException raise:@"Table is read only" format:@"Tried to pop back while read only"]; _table->remove_last(); } --(int64_t)get:(size_t)columnId ndx:(size_t)ndx +-(int64_t)get:(size_t)col_ndx ndx:(size_t)ndx +{ + return _table->get_int(col_ndx, ndx); +} +-(void)set:(size_t)col_ndx ndx:(size_t)ndx value:(int64_t)value +{ + if (_readOnly) + [NSException raise:@"Table is read only" format:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]; + _table->set_int(col_ndx, ndx, value); +} +-(BOOL)getBool:(size_t)col_ndx ndx:(size_t)ndx { - return _table->get_int(columnId, ndx); + return _table->get_bool(col_ndx, ndx); } --(void)set:(size_t)columnId ndx:(size_t)ndx value:(int64_t)value +-(void)setBool:(size_t)col_ndx ndx:(size_t)ndx value:(BOOL)value { if (_readOnly) - [NSException raise:@"Table is read only" format:@"Tried to set while read only ColumnId: %llu", (unsigned long long)columnId]; - _table->set_int(columnId, ndx, value); + [NSException raise:@"Table is read only" format:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]; + _table->set_bool(col_ndx, ndx, value); } --(BOOL)getBool:(size_t)columnId ndx:(size_t)ndx +-(float)getFloat:(size_t)col_ndx ndx:(size_t)ndx { - return _table->get_bool(columnId, ndx); + return _table->get_float(col_ndx, ndx); } --(void)setBool:(size_t)columnId ndx:(size_t)ndx value:(BOOL)value +-(void)setFloat:(size_t)col_ndx ndx:(size_t)ndx value:(float)value { if (_readOnly) - [NSException raise:@"Table is read only" format:@"Tried to set while read only ColumnId: %llu", (unsigned long long)columnId]; - _table->set_bool(columnId, ndx, value); + [NSException raise:@"Table is read only" format:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]; + _table->set_float(col_ndx, ndx, value); } --(time_t)getDate:(size_t)columnId ndx:(size_t)ndx +-(double)getDouble:(size_t)col_ndx ndx:(size_t)ndx { - return _table->get_date(columnId, ndx); + return _table->get_double(col_ndx, ndx); } --(void)setDate:(size_t)columnId ndx:(size_t)ndx value:(time_t)value +-(void)setDouble:(size_t)col_ndx ndx:(size_t)ndx value:(double)value { if (_readOnly) - [NSException raise:@"Table is read only" format:@"Tried to set while read only ColumnId: %llu", (unsigned long long)columnId]; - _table->set_date(columnId, ndx, value); + [NSException raise:@"Table is read only" format:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]; + _table->set_double(col_ndx, ndx, value); +} +-(time_t)getDate:(size_t)col_ndx ndx:(size_t)ndx +{ + return _table->get_date(col_ndx, ndx); } --(void)insertInt:(size_t)columnId ndx:(size_t)ndx value:(int64_t)value +-(void)setDate:(size_t)col_ndx ndx:(size_t)ndx value:(time_t)value { if (_readOnly) - [NSException raise:@"Table is read only" format:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)columnId]; - _table->insert_int(columnId, ndx, value); + [NSException raise:@"Table is read only" format:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]; + _table->set_date(col_ndx, ndx, value); } --(void)insertBool:(size_t)columnId ndx:(size_t)ndx value:(BOOL)value +-(void)insertBool:(size_t)col_ndx ndx:(size_t)ndx value:(BOOL)value { if (_readOnly) - [NSException raise:@"Table is read only" format:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)columnId]; - _table->insert_bool(columnId, ndx, value); + [NSException raise:@"Table is read only" format:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]; + _table->insert_bool(col_ndx, ndx, value); } --(void)insertDate:(size_t)columnId ndx:(size_t)ndx value:(time_t)value +-(void)insertInt:(size_t)col_ndx ndx:(size_t)ndx value:(int64_t)value { if (_readOnly) - [NSException raise:@"Table is read only" format:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)columnId]; - _table->insert_date(columnId, ndx, value); + [NSException raise:@"Table is read only" format:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]; + _table->insert_int(col_ndx, ndx, value); } --(void)insertString:(size_t)columnId ndx:(size_t)ndx value:(NSString *)value +-(void)insertFloat:(size_t)col_ndx ndx:(size_t)ndx value:(float)value { if (_readOnly) - [NSException raise:@"Table is read only" format:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)columnId]; - _table->insert_string(columnId, ndx, [value UTF8String]); + [NSException raise:@"Table is read only" format:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]; + _table->insert_float(col_ndx, ndx, value); } --(void)insertBinary:(size_t)columnId ndx:(size_t)ndx value:(void *)value len:(size_t)len +-(void)insertDouble:(size_t)col_ndx ndx:(size_t)ndx value:(double)value { if (_readOnly) - [NSException raise:@"Table is read only" format:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)columnId]; - _table->insert_binary(columnId, ndx, (const char*)value, len); + [NSException raise:@"Table is read only" format:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]; + _table->insert_double(col_ndx, ndx, value); +} +-(void)insertString:(size_t)col_ndx ndx:(size_t)ndx value:(NSString *)value +{ + if (_readOnly) + [NSException raise:@"Table is read only" format:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]; + _table->insert_string(col_ndx, ndx, [value UTF8String]); +} +-(void)insertBinary:(size_t)col_ndx ndx:(size_t)ndx value:(BinaryData *)value +{ + if (_readOnly) + [NSException raise:@"Table is read only" format:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]; + _table->insert_binary(col_ndx, ndx, [value getData], [value getSize]); +} +-(void)insertBinary:(size_t)col_ndx ndx:(size_t)ndx data:(const char *)data size:(size_t)size +{ + if (_readOnly) + [NSException raise:@"Table is read only" format:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]; + _table->insert_binary(col_ndx, ndx, data, size); +} +-(void)insertDate:(size_t)col_ndx ndx:(size_t)ndx value:(time_t)value +{ + if (_readOnly) + [NSException raise:@"Table is read only" format:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]; + _table->insert_date(col_ndx, ndx, value); } -(void)insertDone @@ -687,165 +715,229 @@ -(void)insertDone _table->insert_done(); } --(NSString *)getString:(size_t)columnId ndx:(size_t)ndx +-(NSString *)getString:(size_t)col_ndx ndx:(size_t)ndx { - return [NSString stringWithUTF8String:_table->get_string(columnId, ndx)]; + return [NSString stringWithUTF8String:_table->get_string(col_ndx, ndx)]; } --(void)setString:(size_t)columnId ndx:(size_t)ndx value:(NSString *)value +-(void)setString:(size_t)col_ndx ndx:(size_t)ndx value:(NSString *)value { - _table->set_string(columnId, ndx, [value UTF8String]); + _table->set_string(col_ndx, ndx, [value UTF8String]); } --(BinaryData *)getBinary:(size_t)columnId ndx:(size_t)ndx +-(BinaryData *)getBinary:(size_t)col_ndx ndx:(size_t)ndx { - return [[BinaryData alloc] initWithBinary:_table->get_binary(columnId, ndx)]; + return [[BinaryData alloc] initWithBinary:_table->get_binary(col_ndx, ndx)]; } --(void)setBinary:(size_t)columnId ndx:(size_t)ndx value:(void *)value len:(size_t)len +-(void)setBinary:(size_t)col_ndx ndx:(size_t)ndx value:(BinaryData *)value { if (_readOnly) - [NSException raise:@"Table is read only" format:@"Tried to set while read only ColumnId: %llu", (unsigned long long)columnId]; - _table->set_binary(columnId, ndx, (const char*)value, len); + [NSException raise:@"Table is read only" format:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]; + _table->set_binary(col_ndx, ndx, [value getData], [value getSize]); } --(size_t)getTableSize:(size_t)columnId ndx:(size_t)ndx +-(void)setBinary:(size_t)col_ndx ndx:(size_t)ndx data:(const char *)data size:(size_t)size { - return _table->get_subtable_size(columnId, ndx); + if (_readOnly) + [NSException raise:@"Table is read only" format:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]; + _table->set_binary(col_ndx, ndx, data, size); } --(void)insertSubtable:(size_t)columnId ndx:(size_t)ndx +-(size_t)getTableSize:(size_t)col_ndx ndx:(size_t)row_ndx +{ + return _table->get_subtable_size(col_ndx, row_ndx); +} + +-(void)insertSubtable:(size_t)col_ndx ndx:(size_t)row_ndx { if (_readOnly) - [NSException raise:@"Table is read only" format:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)columnId]; - _table->insert_subtable(columnId, ndx); + [NSException raise:@"Table is read only" format:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]; + _table->insert_subtable(col_ndx, row_ndx); } --(void)_insertSubtableCopy:(size_t)col_ndx row_ndx:(size_t)row_ndx subtable:(Table *)subtable +-(void)_insertSubtableCopy:(size_t)col_ndx row:(size_t)row_ndx subtable:(Table *)subtable { - [self insertSubtable:col_ndx ndx:row_ndx]; - /* FIXME: Perform table copying here, but only if 'subtable' is not 'nil'. */ - (void)subtable; + if (_readOnly) + [NSException raise:@"Table is read only" format:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]; + tightdb::LangBindHelper::insert_subtable(*_table, col_ndx, row_ndx, [subtable getTable]); } --(void)clearTable:(size_t)columnId ndx:(size_t)ndx +-(void)clearSubtable:(size_t)col_ndx ndx:(size_t)row_ndx { if (_readOnly) - [NSException raise:@"Table is read only" format:@"Tried to clear while read only ColumnId: %llu", (unsigned long long)columnId]; - _table->clear_subtable(columnId, ndx); + [NSException raise:@"Table is read only" format:@"Tried to clear while read only ColumnId: %llu", (unsigned long long)col_ndx]; + _table->clear_subtable(col_ndx, row_ndx); } --(OCMixed *)getMixed:(size_t)columnId ndx:(size_t)ndx +-(OCMixed *)getMixed:(size_t)col_ndx ndx:(size_t)row_ndx { - tightdb::Mixed tmp = _table->get_mixed(columnId, ndx); + tightdb::Mixed tmp = _table->get_mixed(col_ndx, row_ndx); OCMixed *mixed = [OCMixed mixedWithMixed:tmp]; if ([mixed getType] == tightdb_Table) { - [mixed setTable:[self getSubtable:columnId ndx:ndx]]; + [mixed setTable:[self getSubtable:col_ndx ndx:row_ndx]]; } return mixed; } --(TightdbDataType)getMixedType:(size_t)columnId ndx:(size_t)ndx +-(TightdbDataType)getMixedType:(size_t)col_ndx ndx:(size_t)row_ndx { - return (TightdbDataType)_table->get_mixed_type(columnId, ndx); + return (TightdbDataType)_table->get_mixed_type(col_ndx, row_ndx); } --(void)insertMixed:(size_t)columnId ndx:(size_t)ndx value:(OCMixed *)value +-(void)insertMixed:(size_t)col_ndx ndx:(size_t)row_ndx value:(OCMixed *)value { if (_readOnly) - [NSException raise:@"Table is read only" format:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)columnId]; - _table->insert_mixed(columnId, ndx, value.mixed); - // FIXME: Insert copy of subtable if type is table + [NSException raise:@"Table is read only" format:@"Tried to insert while read only ColumnId: %llu", (unsigned long long)col_ndx]; + 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); + } } --(void)setMixed:(size_t)columnId ndx:(size_t)ndx value:(OCMixed *)value +-(void)setMixed:(size_t)col_ndx ndx:(size_t)row_ndx value:(OCMixed *)value { if (_readOnly) - [NSException raise:@"Table is read only" format:@"Tried to set while read only ColumnId: %llu", (unsigned long long)columnId]; - _table->set_mixed(columnId, ndx, value.mixed); - // FIXME: Insert copy of subtable if type is table + [NSException raise:@"Table is read only" format:@"Tried to set while read only ColumnId: %llu", (unsigned long long)col_ndx]; + 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); + } } -(size_t)addColumn:(TightdbDataType)type name:(NSString *)name { return _table->add_column((tightdb::DataType)type, [name UTF8String]); } --(size_t)findBool:(size_t)columnId value:(BOOL)value +-(size_t)findBool:(size_t)col_ndx value:(BOOL)value +{ + return _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); +} +-(size_t)findFloat:(size_t)col_ndx value:(float)value { - return _table->find_first_bool(columnId, value); + return _table->find_first_float(col_ndx, value); } --(size_t)findInt:(size_t)columnId value:(int64_t)value +-(size_t)findDouble:(size_t)col_ndx value:(double)value { - return _table->find_first_int(columnId, value); + return _table->find_first_double(col_ndx, value); } --(size_t)findString:(size_t)columnId value:(NSString *)value +-(size_t)findString:(size_t)col_ndx value:(NSString *)value { - return _table->find_first_string(columnId, [value UTF8String]); + return _table->find_first_string(col_ndx, [value UTF8String]); } --(size_t)findBinary:(size_t)columnId value:(BinaryData *)value +-(size_t)findBinary:(size_t)col_ndx value:(BinaryData *)value { - return _table->find_first_binary(columnId, [value getData], [value getSize]); + return _table->find_first_binary(col_ndx, [value getData], [value getSize]); } --(size_t)findDate:(size_t)columnId value:(time_t)value +-(size_t)findDate:(size_t)col_ndx value:(time_t)value { - return _table->find_first_date(columnId, value); + return _table->find_first_date(col_ndx, value); } --(size_t)findMixed:(size_t)columnId value:(OCMixed *)value +-(size_t)findMixed:(size_t)col_ndx value:(OCMixed *)value { - static_cast(columnId); + static_cast(col_ndx); static_cast(value); [NSException raise:@"NotImplemented" format:@"Not implemented"]; // FIXME: Implement this! - // return _table->find_first_mixed(columnId, value); + // return _table->find_first_mixed(col_ndx, value); return 0; } --(TableView *)findAll:(TableView *)view column:(size_t)columnId value:(int64_t)value +-(TableView *)findAll:(TableView *)view column:(size_t)col_ndx value:(int64_t)value { - *view.tableView = _table->find_all_int(columnId, value); + *view.tableView = _table->find_all_int(col_ndx, value); return view; } --(BOOL)hasIndex:(size_t)columnId +-(BOOL)hasIndex:(size_t)col_ndx { - return _table->has_index(columnId); + return _table->has_index(col_ndx); } --(void)setIndex:(size_t)columnId +-(void)setIndex:(size_t)col_ndx { - _table->set_index(columnId); + _table->set_index(col_ndx); } -(void)optimize { _table->optimize(); } --(size_t)countInt:(size_t)columnId target:(int64_t)target +-(size_t)countInt:(size_t)col_ndx target:(int64_t)target { - return _table->count_int(columnId, target); + return _table->count_int(col_ndx, target); } - --(size_t)countString:(size_t)columnId target:(NSString *)target +-(size_t)countFloat:(size_t)col_ndx target:(float)target +{ + return _table->count_float(col_ndx, target); +} +-(size_t)countDouble:(size_t)col_ndx target:(double)target +{ + return _table->count_double(col_ndx, target); +} +-(size_t)countString:(size_t)col_ndx target:(NSString *)target { - return _table->count_string(columnId, [target UTF8String]); + return _table->count_string(col_ndx, [target UTF8String]); } --(int64_t)sum:(size_t)columnId +-(int64_t)sumInt:(size_t)col_ndx { - return _table->sum(columnId); + return _table->sum(col_ndx); +} +-(double)sumFloat:(size_t)col_ndx +{ + return _table->sum_float(col_ndx); +} +-(double)sumDouble:(size_t)col_ndx +{ + return _table->sum_double(col_ndx); } --(int64_t)maximum:(size_t)columnId +-(int64_t)maxInt:(size_t)col_ndx +{ + return _table->maximum(col_ndx); +} +-(float)maxFloat:(size_t)col_ndx +{ + return _table->maximum_float(col_ndx); +} +-(double)maxDouble:(size_t)col_ndx { - return _table->maximum(columnId); + return _table->maximum_double(col_ndx); } --(int64_t)minimum:(size_t)columnId +-(int64_t)minInt:(size_t)col_ndx +{ + return _table->minimum(col_ndx); +} +-(float)minFloat:(size_t)col_ndx { - return _table->minimum(columnId); + return _table->minimum_float(col_ndx); +} +-(double)minDouble:(size_t)col_ndx +{ + return _table->minimum_double(col_ndx); } --(double)average:(size_t)columnId +-(double)avgInt:(size_t)col_ndx +{ + return _table->average(col_ndx); +} +-(double)avgFloat:(size_t)col_ndx +{ + return _table->average_float(col_ndx); +} +-(double)avgDouble:(size_t)col_ndx { - return _table->average(columnId); + return _table->average_double(col_ndx); } -(BOOL)_addColumns @@ -899,6 +991,68 @@ -(TableView *)findAll:(int64_t)value TableView *view = [TableView tableViewWithTable:self.table]; return [self.table findAll:view column:self.column value:value]; } +-(int64_t)min +{ + return [self.table minInt:self.column]; +} +-(int64_t)max +{ + return [self.table maxInt:self.column]; +} +-(int64_t)sum +{ + return [self.table sumInt:self.column]; +} +-(double)avg +{ + return [self.table avgInt:self.column]; +} +@end + +@implementation OCColumnProxy_Float +-(size_t)find:(float)value +{ + return [self.table findFloat:self.column value:value]; +} +-(float)min +{ + return [self.table minFloat:self.column]; +} +-(float)max +{ + return [self.table maxFloat:self.column]; +} +-(double)sum +{ + return [self.table sumFloat:self.column]; +} +-(double)avg +{ + return [self.table avgFloat:self.column]; +} +@end + +@implementation OCColumnProxy_Double +-(size_t)find:(double)value +{ + return [self.table findDouble:self.column value:value]; +} +-(double)min +{ + return [self.table minDouble:self.column]; +} +-(double)max +{ + return [self.table maxDouble:self.column]; +} +-(double)sum +{ + return [self.table sumDouble:self.column]; +} +-(double)avg +{ + return [self.table avgDouble:self.column]; +} @end @implementation OCColumnProxy_String @@ -922,6 +1076,9 @@ -(size_t)find:(time_t)value } @end +@implementation OCColumnProxy_Subtable +@end + @implementation OCColumnProxy_Mixed -(size_t)find:(OCMixed *)value { diff --git a/src/tightdb/objc/test/Makefile b/src/tightdb/objc/test/Makefile index 6bcb4156fa..dbd2ec8509 100644 --- a/src/tightdb/objc/test/Makefile +++ b/src/tightdb/objc/test/Makefile @@ -2,7 +2,10 @@ TEST_PROGRAMS = unit-tests XCODE_HOME = $(shell xcode-select --print-path) -unit_tests_SOURCES = data_type.mm table.m group.m group_misc_2.m table_delete_all.m tutorial.m enumerator.m get_subtable.m subtable.m mixed.m shared_group.m +unit_tests_SOURCES = \ +data_type.mm table.m group.m group_misc_2.m table_delete_all.m tutorial.m enumerator.m \ +get_subtable.m subtable.m mixed.m query.m shared_group.m + unit_tests_CFLAGS = -Wno-comment -fobjc-arc -fobjc-abi-version=2 -F$(XCODE_HOME)/Library/Frameworks unit_tests_LDFLAGS = -bundle -fobjc-link-runtime -F$(XCODE_HOME)/Library/Frameworks -framework Cocoa -framework SenTestingKit unit_tests_LIBS = ../libtightdb-objc.a diff --git a/src/tightdb/objc/test/data_type.mm b/src/tightdb/objc/test/data_type.mm index e4f3e2c0cb..dd18c389b3 100644 --- a/src/tightdb/objc/test/data_type.mm +++ b/src/tightdb/objc/test/data_type.mm @@ -18,6 +18,8 @@ - (void)testDataType { STAssertEquals((int)tightdb_Bool, (int)tightdb::type_Bool, @"Bool"); STAssertEquals((int)tightdb_Int, (int)tightdb::type_Int, @"Int"); + STAssertEquals((int)tightdb_Float, (int)tightdb::type_Float, @"Float"); + STAssertEquals((int)tightdb_Double, (int)tightdb::type_Double, @"Double"); STAssertEquals((int)tightdb_String, (int)tightdb::type_String, @"String"); STAssertEquals((int)tightdb_Binary, (int)tightdb::type_Binary, @"Binary"); STAssertEquals((int)tightdb_Date, (int)tightdb::type_Date, @"Date"); diff --git a/src/tightdb/objc/test/enumerator.m b/src/tightdb/objc/test/enumerator.m index 6f2b3b02e2..191d9fc5fd 100644 --- a/src/tightdb/objc/test/enumerator.m +++ b/src/tightdb/objc/test/enumerator.m @@ -51,7 +51,7 @@ - (void)testTutorial } // Do a query, and get all matches as TableView - EnumPeopleTable_View *res = [[[[people getQuery].Hired equal:YES].Age between:20 to:30] findAll]; + EnumPeopleTable_View *res = [[[[people where].Hired equal:YES].Age between:20 to:30] findAll]; NSLog(@"View count: %zu", [res count]); // 2: Iterate over the resulting TableView for (EnumPeopleTable_Cursor *row in res) { @@ -60,7 +60,7 @@ - (void)testTutorial // 3: Iterate over query (lazy) - EnumPeopleTable_Query *q = [[people getQuery].Age equal:21]; + EnumPeopleTable_Query *q = [[people where].Age equal:21]; NSLog(@"Query lazy count: %zu", [q count]); for (EnumPeopleTable_Cursor *row in q) { NSLog(@"(Enum3) %@ is %lld years old.", row.Name, row.Age); diff --git a/src/tightdb/objc/test/group_misc_2.m b/src/tightdb/objc/test/group_misc_2.m index c1208c7b19..c5072352ad 100644 --- a/src/tightdb/objc/test/group_misc_2.m +++ b/src/tightdb/objc/test/group_misc_2.m @@ -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 getQuery].Hired equal:YES].Age between:20 to:30]; + MyTable2_Query *q = [[[table2 where].Hired equal:YES].Age between:20 to:30]; // Get number of matching entries NSLog(@"Query count: %zu", [q count]); @@ -120,11 +120,11 @@ - (void)testGroup_Misc2 } // Write same group to memory buffer - size_t len; - const char* const buffer = [group writeToMem:&len]; + size_t size; + const char* data = [group writeToMem:&size]; // Load a group from memory (and print contents) - Group *fromMem = [Group groupWithBuffer:buffer len:len]; + Group *fromMem = [Group groupWithBuffer:data size:size]; MyTable *memTable = [fromMem getTable:@"employees" withClass:[MyTable class]]; for (size_t i = 0; i < [memTable count]; i++) { // ??? cursor @@ -145,7 +145,7 @@ - (void)testQuery [table addFirst:8 Second:@"The quick brown fox"]; { - QueryTable_Query *q = [[table getQuery].First between:3 to:7]; // Between + QueryTable_Query *q = [[table where].First between:3 to:7]; // Between STAssertEquals((size_t)2, [q count], @"count != 2"); // STAssertEquals(9, [q.First sum]); // Sum STAssertEquals(4.5, [q.First avg], @"Avg!=4.5"); // Average @@ -153,31 +153,31 @@ - (void)testQuery // STAssertEquals(5, [q.First max]); // Maximum } { - QueryTable_Query *q = [[table getQuery].Second contains:@"quick" caseSensitive:NO]; // String contains + QueryTable_Query *q = [[table where].Second contains:@"quick" caseSensitive:NO]; // String contains STAssertEquals((size_t)1, [q count], @"count != 1"); } { - QueryTable_Query *q = [[table getQuery].Second beginsWith:@"The" caseSensitive:NO]; // String prefix + QueryTable_Query *q = [[table where].Second beginsWith:@"The" caseSensitive:NO]; // String prefix STAssertEquals((size_t)1, [q count], @"count != 1"); } { - QueryTable_Query *q = [[table getQuery].Second endsWith:@"The" caseSensitive:NO]; // String suffix + QueryTable_Query *q = [[table where].Second endsWith:@"The" caseSensitive:NO]; // String suffix STAssertEquals((size_t)0, [q count], @"count != 1"); } { - QueryTable_Query *q = [[[table getQuery].Second notEqual:@"a" caseSensitive:NO].Second notEqual:@"b" caseSensitive:NO]; // And + QueryTable_Query *q = [[[table where].Second notEqual:@"a" caseSensitive:NO].Second notEqual:@"b" caseSensitive:NO]; // And STAssertEquals((size_t)1, [q count], @"count != 1"); } { - QueryTable_Query *q = [[[[table getQuery].Second notEqual:@"a" caseSensitive:NO] or].Second notEqual:@"b" caseSensitive:NO]; // Or + QueryTable_Query *q = [[[[table where].Second notEqual:@"a" caseSensitive:NO] or].Second notEqual:@"b" caseSensitive:NO]; // Or STAssertEquals((size_t)4, [q count], @"count != 1"); } { - QueryTable_Query *q = [[[[[[[table getQuery].Second equal:@"a" caseSensitive:NO] group].First less:3] or].First greater:5] endgroup]; // Parentheses + QueryTable_Query *q = [[[[[[[table where].Second equal:@"a" caseSensitive:NO] group].First less:3] or].First greater:5] endgroup]; // Parentheses STAssertEquals((size_t)1, [q count], @"count != 1"); } { - QueryTable_Query *q = [[[[[table getQuery].Second equal:@"a" caseSensitive:NO].First less:3] or].First greater:5]; // No parenthesis + QueryTable_Query *q = [[[[[table where].Second equal:@"a" caseSensitive:NO].First less:3] or].First greater:5]; // No parenthesis STAssertEquals((size_t)2, [q count], @"count != 2"); TableView *tv = [q findAll]; STAssertEquals((size_t)2, [tv count], @"count != 2"); diff --git a/src/tightdb/objc/test/mixed.m b/src/tightdb/objc/test/mixed.m index be75c8323b..9d6c93b002 100644 --- a/src/tightdb/objc/test/mixed.m +++ b/src/tightdb/objc/test/mixed.m @@ -58,17 +58,17 @@ - (void)testMixedEqual const char* str1 = "Hello"; const char* str2 = "Goodbye"; - OCMixed *mixedBinary1 = [OCMixed mixedWithBinary:str1 length:strlen(str1)]; - OCMixed *mixedBinary2 = [OCMixed mixedWithBinary:str2 length:strlen(str2)]; - OCMixed *mixedBinary3 = [OCMixed mixedWithBinary:str2 length:strlen(str2)]; + OCMixed *mixedBinary1 = [OCMixed mixedWithBinary:str1 size:strlen(str1)]; + OCMixed *mixedBinary2 = [OCMixed mixedWithBinary:str2 size:strlen(str2)]; + OCMixed *mixedBinary3 = [OCMixed mixedWithBinary:str2 size:strlen(str2)]; STAssertEquals([mixedBinary1 isEqual:mixedBinary1], YES, @"Same mixed should be equal (7)"); STAssertEquals([mixedBinary2 isEqual:mixedBinary2], YES, @"Same mixed should be equal (8)"); STAssertEquals([mixedBinary2 isEqual:mixedBinary3], YES, @"Mixed with same binary data should be equal"); STAssertEquals([mixedBinary1 isEqual:mixedBinary2], NO, @"Mixed with different binary data should be different"); - OCMixed *mixedDate1 = [OCMixed mixedWithDate:[[OCDate alloc] initWithDate:nowTime]]; - OCMixed *mixedDate2 = [OCMixed mixedWithDate:[[OCDate alloc] initWithDate:nowTime+1]]; - OCMixed *mixedDate3 = [OCMixed mixedWithDate:[[OCDate alloc] initWithDate:nowTime+1]]; + OCMixed *mixedDate1 = [OCMixed mixedWithDate:nowTime]; + OCMixed *mixedDate2 = [OCMixed mixedWithDate:nowTime+1]; + OCMixed *mixedDate3 = [OCMixed mixedWithDate:nowTime+1]; STAssertEquals([mixedDate1 isEqual:mixedDate1], YES, @"Same mixed should be equal (9)"); STAssertEquals([mixedDate2 isEqual:mixedDate2], YES, @"Same mixed should be equal (10)"); STAssertEquals([mixedDate2 isEqual:mixedDate3], YES, @"Mixed with same timestamps should be equal"); @@ -130,18 +130,16 @@ - (void)testMixedEqual - (void)testMixed { time_t nowTime = [[NSDate date] timeIntervalSince1970]; - + SubMixedTable *tableSub = [[SubMixedTable alloc] init]; - + // Add some rows [tableSub addHired:YES Age:20]; [tableSub addHired:NO Age:21]; [tableSub addHired:YES Age:22]; [tableSub addHired:NO Age:43]; [tableSub addHired:YES Age:54]; - - Group *group = [Group group]; // Create new table in group MixedTable *table = [group getTable:@"MixedValues" withClass:[MixedTable class]]; @@ -153,15 +151,15 @@ - (void)testMixed [table addHired:YES Other:[OCMixed mixedWithString:@"Joergen"] Age:53]; [table addHired:YES Other:[OCMixed mixedWithString:@"Dave"] Age:54]; [table addHired:YES Other:mixedTable Age:54]; - OCMixed *mixedDate = [OCMixed mixedWithDate:[[OCDate alloc] initWithDate:nowTime]]; + OCMixed *mixedDate = [OCMixed mixedWithDate:nowTime]; [table addHired:YES Other:mixedDate Age:54]; - + // Test isequal - OCMixed *mixedDate2 = [OCMixed mixedWithDate:[[OCDate alloc] initWithDate:nowTime]]; - OCMixed *mixedDate3 = [OCMixed mixedWithDate:[[OCDate alloc] initWithDate:nowTime+1]]; + OCMixed *mixedDate2 = [OCMixed mixedWithDate:nowTime]; + OCMixed *mixedDate3 = [OCMixed mixedWithDate:nowTime+1]; STAssertEquals([mixedDate isEqual:mixedDate2], YES,@"Mixed dates should be equal"); STAssertEquals([mixedDate isEqual:mixedDate3], NO,@"Mixed dates should not be equal"); - + // Test cast and isClass Table *unknownTable = [mixedTable getTable]; NSLog(@"Is SubMixedTable type: %i", [unknownTable isClass:[SubMixedTable class]]); @@ -170,9 +168,9 @@ - (void)testMixed NSLog(@"TableSub Size: %lu", [tableSub count]); STAssertEquals([tableSub count], (size_t)5,@"Subtable should have 5 rows"); NSLog(@"Count int: %lu", [table countInt:2 target:50]); - NSLog(@"Max: %lld", [table maximum:2]); - NSLog(@"Avg: %.2f", [table average:2]); - + NSLog(@"Max: %lld", [table maxInt:2]); + NSLog(@"Avg: %.2f", [table avgInt:2]); + NSLog(@"MyTable Size: %lu", [table count]); int sumType = 0; for (size_t i = 0; i < [table count]; i++) { @@ -183,8 +181,8 @@ - (void)testMixed if ([cursor.Other getType] == tightdb_String) NSLog(@"StringMixed: %@", [cursor.Other getString]); else if ([cursor.Other getType] == tightdb_Date) { - NSLog(@"DateMixed: %ld", [[cursor.Other getDate] getDate]); - STAssertEquals(nowTime, [[cursor.Other getDate] getDate],@"Date should match what went in"); + NSLog(@"DateMixed: %ld", [cursor.Other getDate]); + STAssertEquals(nowTime, [cursor.Other getDate],@"Date should match what went in"); } else if ([cursor.Other getType] == tightdb_Table) { NSLog(@"TableMixed: %@", [cursor.Other getTable]); diff --git a/src/tightdb/objc/test/query.m b/src/tightdb/objc/test/query.m new file mode 100644 index 0000000000..b5ce35d28c --- /dev/null +++ b/src/tightdb/objc/test/query.m @@ -0,0 +1,78 @@ +// +// query.m +// TightDB +// + +#import + +#import + +TIGHTDB_TABLE_1(TestQuerySub, + Age, Int) + +TIGHTDB_TABLE_9(TestQueryAllTypes, + BoolCol, Bool, + IntCol, Int, + FloatCol, Float, + DoubleCol, Double, + StringCol, String, + BinaryCol, Binary, + DateCol, Date, + TableCol, TestQuerySub, + MixedCol, Mixed) + +@interface MACtestQuery : SenTestCase +@end +@implementation MACtestQuery + +- (void)testQuery +{ + TestQueryAllTypes *table = [[TestQueryAllTypes alloc] init]; + NSLog(@"Table: %@", table); + STAssertNotNil(table, @"Table is nil"); + + const char bin[4] = { 0, 1, 2, 3 }; + BinaryData *bin1 = [[BinaryData alloc] initWithData:bin size:sizeof bin / 2]; + BinaryData *bin2 = [[BinaryData alloc] initWithData:bin size:sizeof bin]; + time_t timeNow = [[NSDate date] timeIntervalSince1970]; +// TestQuerySub *subtab1 = [[TestQuerySub alloc] init]; + TestQuerySub *subtab2 = [[TestQuerySub alloc] init]; + [subtab2 addAge:100]; + OCMixed *mixInt1 = [OCMixed mixedWithInt64:1]; + OCMixed *mixSubtab = [OCMixed mixedWithTable:subtab2]; + + [table addBoolCol:NO IntCol:54 FloatCol:0.7 DoubleCol:0.8 StringCol:@"foo" + BinaryCol:bin1 DateCol:0 TableCol:nil MixedCol:mixInt1]; + + [table addBoolCol:YES IntCol:506 FloatCol:7.7 DoubleCol:8.8 StringCol:@"banach" + BinaryCol:bin2 DateCol:timeNow TableCol:subtab2 MixedCol:mixSubtab]; + + STAssertEquals([[[table where].BoolCol equal:NO] count], (size_t)1, @"BoolCol equal"); + STAssertEquals([[[table where].IntCol equal:54] count], (size_t)1, @"IntCol equal"); + STAssertEquals([[[table where].FloatCol equal:0.7f] count], (size_t)1, @"FloatCol equal"); + STAssertEquals([[[table where].DoubleCol equal:0.8] count], (size_t)1, @"DoubleCol equal"); + STAssertEquals([[[table where].StringCol equal:@"foo"] count], (size_t)1, @"StringCol equal"); +// STAssertEquals([[[table where].BinaryCol equal:bin1] count], (size_t)1, @"BinaryCol equal"); + STAssertEquals([[[table where].DateCol equal:0] count], (size_t)1, @"DateCol equal"); +// STAssertEquals([[[table where].TableCol equal:subtab1] count], (size_t)1, @"TableCol equal"); +// STAssertEquals([[[table where].MixedCol equal:mixInt1] count], (size_t)1, @"MixedCol equal"); + + TestQueryAllTypes_Query *query = [[table where].BoolCol equal:NO]; + + STAssertEquals([query.IntCol min], (int64_t)54, @"IntCol min"); + STAssertEquals([query.IntCol max], (int64_t)54, @"IntCol max"); + STAssertEquals([query.IntCol sum], (int64_t)54, @"IntCol sum"); + STAssertEquals([query.IntCol avg], 54.0, @"IntCol avg"); + + STAssertEquals([query.FloatCol min], 0.7f, @"FloatCol min"); + STAssertEquals([query.FloatCol max], 0.7f, @"FloatCol max"); + STAssertEquals([query.FloatCol sum], (double)0.7f, @"FloatCol sum"); + STAssertEquals([query.FloatCol avg], (double)0.7f, @"FloatCol avg"); + + STAssertEquals([query.DoubleCol min], 0.8, @"DoubleCol min"); + STAssertEquals([query.DoubleCol max], 0.8, @"DoubleCol max"); + STAssertEquals([query.DoubleCol sum], 0.8, @"DoubleCol sum"); + STAssertEquals([query.DoubleCol avg], 0.8, @"DoubleCol avg"); +} + +@end diff --git a/src/tightdb/objc/test/subtable.m b/src/tightdb/objc/test/subtable.m index 84d5d4c14c..381e75c994 100644 --- a/src/tightdb/objc/test/subtable.m +++ b/src/tightdb/objc/test/subtable.m @@ -10,13 +10,13 @@ #import #import -TIGHTDB_TABLE_2(TestTableSub, +TIGHTDB_TABLE_2(TestSubtableSub, Name, String, Age, Int) -TIGHTDB_TABLE_3(TestTableMain, +TIGHTDB_TABLE_3(TestSubtableMain, First, String, - Sub, TestTableSub, + Sub, TestSubtableSub, Second, Int) @interface MACTestSubtable : SenTestCase @@ -45,15 +45,15 @@ - (void)testSubtable Group *group = [Group group]; /* Create new table in group */ - TestTableMain *people = [group getTable:@"employees" withClass:[TestTableMain class]]; + TestSubtableMain *people = [group getTable:@"employees" withClass:[TestSubtableMain class]]; /* FIXME: Add support for specifying a subtable to the 'add' method. The subtable must then be copied into the parent table. */ [people addFirst:@"first" Sub:nil Second:8]; - TestTableMain_Cursor *cursor = [people objectAtIndex:0]; - TestTableSub *subtable = cursor.Sub; + TestSubtableMain_Cursor *cursor = [people objectAtIndex:0]; + TestSubtableSub *subtable = cursor.Sub; [subtable addName:@"name" Age:999]; STAssertEquals([subtable objectAtIndex:0].Age, (int64_t)999, @"Age should be 999"); diff --git a/src/tightdb/objc/test/table.m b/src/tightdb/objc/test/table.m index a4975c2f0c..02f44f26c4 100644 --- a/src/tightdb/objc/test/table.m +++ b/src/tightdb/objc/test/table.m @@ -2,39 +2,35 @@ // table.m // TightDB // -// Using lowlevel interface, test creation of creating two columns with two rows -// #import -#import +#import + +TIGHTDB_TABLE_1(TestTableSub, + Age, Int) + +TIGHTDB_TABLE_9(TestTableAllTypes, + BoolCol, Bool, + IntCol, Int, + FloatCol, Float, + DoubleCol, Double, + StringCol, String, + BinaryCol, Binary, + DateCol, Date, + TableCol, TestTableSub, + MixedCol, Mixed) @interface MACtestTable : SenTestCase @end @implementation MACtestTable -{ - Table *_table; -} -- (void)setUp +- (void)testTable { - [super setUp]; - - _table = [[Table alloc] init]; + Table *_table = [[Table alloc] init]; NSLog(@"Table: %@", _table); STAssertNotNil(_table, @"Table is nil"); -} - -- (void)tearDown -{ - // Tear-down code here. - [super tearDown]; - _table = nil; -} - -- (void)testTable -{ // 1. Add two columns [_table addColumn:tightdb_Int name:@"first"]; [_table addColumn:tightdb_Int name:@"second"]; @@ -59,4 +55,75 @@ - (void)testTable STFail(@"Second not 10"); } +- (void)testDataTypes +{ + TestTableAllTypes *table = [[TestTableAllTypes alloc] init]; + NSLog(@"Table: %@", table); + STAssertNotNil(table, @"Table is nil"); + + // Verify column types + STAssertEquals(tightdb_Bool, [table getColumnType:0], @"First column not bool"); + STAssertEquals(tightdb_Int, [table getColumnType:1], @"Second column not int"); + STAssertEquals(tightdb_Float, [table getColumnType:2], @"Third column not float"); + STAssertEquals(tightdb_Double, [table getColumnType:3], @"Fourth column not double"); + STAssertEquals(tightdb_String, [table getColumnType:4], @"Fifth column not string"); + STAssertEquals(tightdb_Binary, [table getColumnType:5], @"Sixth column not binary"); + STAssertEquals(tightdb_Date, [table getColumnType:6], @"Seventh column not date"); + STAssertEquals(tightdb_Table, [table getColumnType:7], @"Eighth column not table"); + STAssertEquals(tightdb_Mixed, [table getColumnType:8], @"Ninth column not mixed"); + + const char bin[4] = { 0, 1, 2, 3 }; + BinaryData *bin1 = [[BinaryData alloc] initWithData:bin size:sizeof bin / 2]; + BinaryData *bin2 = [[BinaryData alloc] initWithData:bin size:sizeof bin]; + time_t timeNow = [[NSDate date] timeIntervalSince1970]; + TestTableSub *subtab1 = [[TestTableSub alloc] init]; + TestTableSub *subtab2 = [[TestTableSub alloc] init]; + [subtab2 addAge:100]; + OCMixed *mixInt1 = [OCMixed mixedWithInt64:1]; + OCMixed *mixSubtab = [OCMixed mixedWithTable:subtab2]; + + [table addBoolCol:NO IntCol:54 FloatCol:0.7 DoubleCol:0.8 StringCol:@"foo" + BinaryCol:bin1 DateCol:0 TableCol:nil MixedCol:mixInt1]; + + [table addBoolCol:YES IntCol:506 FloatCol:7.7 DoubleCol:8.8 StringCol:@"banach" + BinaryCol:bin2 DateCol:timeNow TableCol:subtab2 MixedCol:mixSubtab]; + + TestTableAllTypes_Cursor *row1 = [table objectAtIndex:0]; + TestTableAllTypes_Cursor *row2 = [table objectAtIndex:1]; + + STAssertEquals(row1.BoolCol, NO, @"row1.BoolCol"); + STAssertEquals(row2.BoolCol, YES, @"row2.BoolCol"); + STAssertEquals(row1.IntCol, (int64_t)54, @"row1.IntCol"); + STAssertEquals(row2.IntCol, (int64_t)506, @"row2.IntCol"); + STAssertEquals(row1.FloatCol, 0.7f, @"row1.FloatCol"); + STAssertEquals(row2.FloatCol, 7.7f, @"row2.FloatCol"); + STAssertEquals(row1.DoubleCol, 0.8, @"row1.DoubleCol"); + STAssertEquals(row2.DoubleCol, 8.8, @"row2.DoubleCol"); + STAssertTrue([row1.StringCol isEqual:@"foo"], @"row1.StringCol"); + STAssertTrue([row2.StringCol isEqual:@"banach"], @"row2.StringCol"); + STAssertTrue([row1.BinaryCol isEqual:bin1], @"row1.BinaryCol"); + STAssertTrue([row2.BinaryCol isEqual:bin2], @"row2.BinaryCol"); + STAssertEquals(row1.DateCol, (time_t)0, @"row1.DateCol"); + STAssertEquals(row2.DateCol, timeNow, @"row2.DateCol"); + STAssertTrue([row1.TableCol isEqual:subtab1], @"row1.TableCol"); + STAssertTrue([row2.TableCol isEqual:subtab2], @"row2.TableCol"); + STAssertTrue([row1.MixedCol isEqual:mixInt1], @"row1.MixedCol"); + STAssertTrue([row2.MixedCol isEqual:mixSubtab], @"row2.MixedCol"); + + STAssertEquals([table.IntCol min], (int64_t)54, @"IntCol min"); + STAssertEquals([table.IntCol max], (int64_t)506, @"IntCol max"); + STAssertEquals([table.IntCol sum], (int64_t)560, @"IntCol sum"); + STAssertEquals([table.IntCol avg], 280.0, @"IntCol avg"); + + STAssertEquals([table.FloatCol min], 0.7f, @"FloatCol min"); + STAssertEquals([table.FloatCol max], 7.7f, @"FloatCol max"); + STAssertEquals([table.FloatCol sum], (double)0.7f + 7.7f, @"FloatCol sum"); + STAssertEquals([table.FloatCol avg], ((double)0.7f + 7.7f) / 2, @"FloatCol avg"); + + STAssertEquals([table.DoubleCol min], 0.8, @"DoubleCol min"); + STAssertEquals([table.DoubleCol max], 8.8, @"DoubleCol max"); + STAssertEquals([table.DoubleCol sum], 0.8 + 8.8, @"DoubleCol sum"); + STAssertEquals([table.DoubleCol avg], (0.8 + 8.8) / 2, @"DoubleCol avg"); +} + @end diff --git a/src/tightdb/objc/test/table_delete_all.m b/src/tightdb/objc/test/table_delete_all.m index 1b79416989..cc69351469 100644 --- a/src/tightdb/objc/test/table_delete_all.m +++ b/src/tightdb/objc/test/table_delete_all.m @@ -49,7 +49,7 @@ -(void)testTableDeleteAll break; } - [table insertBinary:6 ndx:i value:"binary" len:7]; + [table insertBinary:6 ndx:i data:"binary" size:7]; switch (i % 3) { case 0: [table insertMixed:7 ndx:i value:[OCMixed mixedWithBool:NO]]; diff --git a/src/tightdb/objc/test/tutorial.m b/src/tightdb/objc/test/tutorial.m index 947c920484..9d7e464283 100644 --- a/src/tightdb/objc/test/tutorial.m +++ b/src/tightdb/objc/test/tutorial.m @@ -115,7 +115,7 @@ - (void)testTutorial //------------------------------------------------------ // Create query (current employees between 20 and 30 years old) - PeopleTable_Query *q = [[[people getQuery].Hired equal:YES] // Implicit AND + PeopleTable_Query *q = [[[people where].Hired equal:YES] // Implicit AND .Age between:20 to:30]; // Get number of matching entries @@ -157,11 +157,11 @@ - (void)testTutorial } // Write same group to memory buffer - size_t len; - const char* const buffer = [group writeToMem:&len]; + size_t size; + const char* const data = [group writeToMem:&size]; // Load a group from memory (and print contents) - Group *fromMem = [Group groupWithBuffer:buffer len:len]; + Group *fromMem = [Group groupWithBuffer:data size:size]; PeopleTable *memTable = [fromMem getTable:@"employees" withClass:[PeopleTable class]]; for (size_t i = 0; i < [memTable count]; i++) { PeopleTable_Cursor *cursor = [memTable objectAtIndex:i]; diff --git a/src/tightdb/objc/tightdb.h b/src/tightdb/objc/tightdb.h index 0cba5d0ef5..a78a144602 100644 --- a/src/tightdb/objc/tightdb.h +++ b/src/tightdb/objc/tightdb.h @@ -40,19 +40,15 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName1, CType1) \ -(TableName##_Query *)parent; \ -(TableName##_View *)findAll; \ @end \ -@interface OCColumnProxy_##TableName : OCColumnProxy \ --(size_t)find:(NSString*)value; \ -@end \ @interface TableName : Table \ -@property(nonatomic, strong) OCColumnProxy_##CType1 *CName1; \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1; \ --(TableName##_Query *)getQuery; \ +TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1; \ +-(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1; \ +-(TableName##_Query *)where; \ -(TableName##_Cursor *)add; \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ -(TableName##_Cursor *)lastObject; \ @end \ -typedef TableName* TIGHTDB_TYPE_##TableName; \ @interface TableName##_View : TableView \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ @end @@ -128,23 +124,17 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName1, CType1) \ } \ @end \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ -@implementation OCColumnProxy_##TableName \ --(size_t)find:(NSString *)value \ -{ \ - return [self.table findString:self.column value:value]; \ -} \ -@end \ @implementation TableName \ { \ TableName##_Cursor *tmpCursor; \ } \ -@synthesize CName1 = _##CName1; \ +TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ \ -(id)_initRaw \ { \ self = [super _initRaw]; \ if (!self) return nil; \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ return self; \ } \ -(id)init \ @@ -153,21 +143,21 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ if (!self) return nil; \ if (![self _addColumns]) return nil; \ \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ return self; \ } \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 \ { \ const size_t ndx = [self count]; \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 \ +-(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ [self insertDone]; \ } \ --(TableName##_Query *)getQuery \ +-(TableName##_Query *)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ @@ -251,20 +241,16 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName2, CType2) \ -(TableName##_Query *)parent; \ -(TableName##_View *)findAll; \ @end \ -@interface OCColumnProxy_##TableName : OCColumnProxy \ --(size_t)find:(NSString*)value; \ -@end \ @interface TableName : Table \ -@property(nonatomic, strong) OCColumnProxy_##CType1 *CName1; \ -@property(nonatomic, strong) OCColumnProxy_##CType2 *CName2; \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2; \ --(TableName##_Query *)getQuery; \ +TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_DEF(CName2, CType2) \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2; \ +-(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2; \ +-(TableName##_Query *)where; \ -(TableName##_Cursor *)add; \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ -(TableName##_Cursor *)lastObject; \ @end \ -typedef TableName* TIGHTDB_TYPE_##TableName; \ @interface TableName##_View : TableView \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ @end @@ -346,25 +332,19 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName2, CType2) \ @end \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName2, CType2) \ -@implementation OCColumnProxy_##TableName \ --(size_t)find:(NSString *)value \ -{ \ - return [self.table findString:self.column value:value]; \ -} \ -@end \ @implementation TableName \ { \ TableName##_Cursor *tmpCursor; \ } \ -@synthesize CName1 = _##CName1; \ -@synthesize CName2 = _##CName2; \ +TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ \ -(id)_initRaw \ { \ self = [super _initRaw]; \ if (!self) return nil; \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ return self; \ } \ -(id)init \ @@ -373,24 +353,24 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName2, CType2) \ if (!self) return nil; \ if (![self _addColumns]) return nil; \ \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ return self; \ } \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 \ { \ const size_t ndx = [self count]; \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 \ +-(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ [self insertDone]; \ } \ --(TableName##_Query *)getQuery \ +-(TableName##_Query *)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ @@ -479,21 +459,17 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName3, CType3) \ -(TableName##_Query *)parent; \ -(TableName##_View *)findAll; \ @end \ -@interface OCColumnProxy_##TableName : OCColumnProxy \ --(size_t)find:(NSString*)value; \ -@end \ @interface TableName : Table \ -@property(nonatomic, strong) OCColumnProxy_##CType1 *CName1; \ -@property(nonatomic, strong) OCColumnProxy_##CType2 *CName2; \ -@property(nonatomic, strong) OCColumnProxy_##CType3 *CName3; \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3; \ --(TableName##_Query *)getQuery; \ +TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_DEF(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_DEF(CName3, CType3) \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3; \ +-(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 *)add; \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ -(TableName##_Cursor *)lastObject; \ @end \ -typedef TableName* TIGHTDB_TYPE_##TableName; \ @interface TableName##_View : TableView \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ @end @@ -581,27 +557,21 @@ TIGHTDB_CURSOR_PROPERTY_IMPL(CName3, CType3) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName2, CType2) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName3, CType3) \ -@implementation OCColumnProxy_##TableName \ --(size_t)find:(NSString *)value \ -{ \ - return [self.table findString:self.column value:value]; \ -} \ -@end \ @implementation TableName \ { \ TableName##_Cursor *tmpCursor; \ } \ -@synthesize CName1 = _##CName1; \ -@synthesize CName2 = _##CName2; \ -@synthesize CName3 = _##CName3; \ +TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName3, CType3) \ \ -(id)_initRaw \ { \ self = [super _initRaw]; \ if (!self) return nil; \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ return self; \ } \ -(id)init \ @@ -610,12 +580,12 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName3, CType3) \ if (!self) return nil; \ if (![self _addColumns]) return nil; \ \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ return self; \ } \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 \ { \ const size_t ndx = [self count]; \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ @@ -623,14 +593,14 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName3, CType3) \ TIGHTDB_COLUMN_INSERT(self, 2, ndx, CName3, CType3); \ [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 \ +-(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ TIGHTDB_COLUMN_INSERT(self, 2, ndx, CName3, CType3); \ [self insertDone]; \ } \ --(TableName##_Query *)getQuery \ +-(TableName##_Query *)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ @@ -724,22 +694,18 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName4, CType4) \ -(TableName##_Query *)parent; \ -(TableName##_View *)findAll; \ @end \ -@interface OCColumnProxy_##TableName : OCColumnProxy \ --(size_t)find:(NSString*)value; \ -@end \ @interface TableName : Table \ -@property(nonatomic, strong) OCColumnProxy_##CType1 *CName1; \ -@property(nonatomic, strong) OCColumnProxy_##CType2 *CName2; \ -@property(nonatomic, strong) OCColumnProxy_##CType3 *CName3; \ -@property(nonatomic, strong) OCColumnProxy_##CType4 *CName4; \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4; \ --(TableName##_Query *)getQuery; \ +TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_DEF(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_DEF(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_DEF(CName4, CType4) \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4; \ +-(void)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 *)add; \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ -(TableName##_Cursor *)lastObject; \ @end \ -typedef TableName* TIGHTDB_TYPE_##TableName; \ @interface TableName##_View : TableView \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ @end @@ -833,29 +799,23 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName1, CType1) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName2, CType2) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName3, CType3) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName4, CType4) \ -@implementation OCColumnProxy_##TableName \ --(size_t)find:(NSString *)value \ -{ \ - return [self.table findString:self.column value:value]; \ -} \ -@end \ @implementation TableName \ { \ TableName##_Cursor *tmpCursor; \ } \ -@synthesize CName1 = _##CName1; \ -@synthesize CName2 = _##CName2; \ -@synthesize CName3 = _##CName3; \ -@synthesize CName4 = _##CName4; \ +TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName4, CType4) \ \ -(id)_initRaw \ { \ self = [super _initRaw]; \ if (!self) return nil; \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ return self; \ } \ -(id)init \ @@ -864,13 +824,13 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName4, CType4) \ if (!self) return nil; \ if (![self _addColumns]) return nil; \ \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ return self; \ } \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 \ { \ const size_t ndx = [self count]; \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ @@ -879,7 +839,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName4, CType4) \ TIGHTDB_COLUMN_INSERT(self, 3, ndx, CName4, CType4); \ [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 \ +-(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 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -887,7 +847,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName4, CType4) \ TIGHTDB_COLUMN_INSERT(self, 3, ndx, CName4, CType4); \ [self insertDone]; \ } \ --(TableName##_Query *)getQuery \ +-(TableName##_Query *)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ @@ -986,23 +946,19 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName5, CType5) \ -(TableName##_Query *)parent; \ -(TableName##_View *)findAll; \ @end \ -@interface OCColumnProxy_##TableName : OCColumnProxy \ --(size_t)find:(NSString*)value; \ -@end \ @interface TableName : Table \ -@property(nonatomic, strong) OCColumnProxy_##CType1 *CName1; \ -@property(nonatomic, strong) OCColumnProxy_##CType2 *CName2; \ -@property(nonatomic, strong) OCColumnProxy_##CType3 *CName3; \ -@property(nonatomic, strong) OCColumnProxy_##CType4 *CName4; \ -@property(nonatomic, strong) OCColumnProxy_##CType5 *CName5; \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5; \ --(TableName##_Query *)getQuery; \ +TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_DEF(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_DEF(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_DEF(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_DEF(CName5, CType5) \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5; \ +-(void)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 *)add; \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ -(TableName##_Cursor *)lastObject; \ @end \ -typedef TableName* TIGHTDB_TYPE_##TableName; \ @interface TableName##_View : TableView \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ @end @@ -1102,31 +1058,25 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName2, CType2) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName3, CType3) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName4, CType4) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName5, CType5) \ -@implementation OCColumnProxy_##TableName \ --(size_t)find:(NSString *)value \ -{ \ - return [self.table findString:self.column value:value]; \ -} \ -@end \ @implementation TableName \ { \ TableName##_Cursor *tmpCursor; \ } \ -@synthesize CName1 = _##CName1; \ -@synthesize CName2 = _##CName2; \ -@synthesize CName3 = _##CName3; \ -@synthesize CName4 = _##CName4; \ -@synthesize CName5 = _##CName5; \ +TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName5, CType5) \ \ -(id)_initRaw \ { \ self = [super _initRaw]; \ if (!self) return nil; \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ return self; \ } \ -(id)init \ @@ -1135,14 +1085,14 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName5, CType5) \ if (!self) return nil; \ if (![self _addColumns]) return nil; \ \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ return self; \ } \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 \ { \ const size_t ndx = [self count]; \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ @@ -1152,7 +1102,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName5, CType5) \ TIGHTDB_COLUMN_INSERT(self, 4, ndx, CName5, CType5); \ [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 \ +-(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 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -1161,7 +1111,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName5, CType5) \ TIGHTDB_COLUMN_INSERT(self, 4, ndx, CName5, CType5); \ [self insertDone]; \ } \ --(TableName##_Query *)getQuery \ +-(TableName##_Query *)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ @@ -1265,24 +1215,20 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName6, CType6) \ -(TableName##_Query *)parent; \ -(TableName##_View *)findAll; \ @end \ -@interface OCColumnProxy_##TableName : OCColumnProxy \ --(size_t)find:(NSString*)value; \ -@end \ @interface TableName : Table \ -@property(nonatomic, strong) OCColumnProxy_##CType1 *CName1; \ -@property(nonatomic, strong) OCColumnProxy_##CType2 *CName2; \ -@property(nonatomic, strong) OCColumnProxy_##CType3 *CName3; \ -@property(nonatomic, strong) OCColumnProxy_##CType4 *CName4; \ -@property(nonatomic, strong) OCColumnProxy_##CType5 *CName5; \ -@property(nonatomic, strong) OCColumnProxy_##CType6 *CName6; \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6; \ --(TableName##_Query *)getQuery; \ +TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_DEF(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_DEF(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_DEF(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_DEF(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_DEF(CName6, CType6) \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6; \ +-(void)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 *)add; \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ -(TableName##_Cursor *)lastObject; \ @end \ -typedef TableName* TIGHTDB_TYPE_##TableName; \ @interface TableName##_View : TableView \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ @end @@ -1388,33 +1334,27 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName3, CType3) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName4, CType4) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName5, CType5) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName6, CType6) \ -@implementation OCColumnProxy_##TableName \ --(size_t)find:(NSString *)value \ -{ \ - return [self.table findString:self.column value:value]; \ -} \ -@end \ @implementation TableName \ { \ TableName##_Cursor *tmpCursor; \ } \ -@synthesize CName1 = _##CName1; \ -@synthesize CName2 = _##CName2; \ -@synthesize CName3 = _##CName3; \ -@synthesize CName4 = _##CName4; \ -@synthesize CName5 = _##CName5; \ -@synthesize CName6 = _##CName6; \ +TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName6, CType6) \ \ -(id)_initRaw \ { \ self = [super _initRaw]; \ if (!self) return nil; \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ return self; \ } \ -(id)init \ @@ -1423,15 +1363,15 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName6, CType6) \ if (!self) return nil; \ if (![self _addColumns]) return nil; \ \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ return self; \ } \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 \ { \ const size_t ndx = [self count]; \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ @@ -1442,7 +1382,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName6, CType6) \ TIGHTDB_COLUMN_INSERT(self, 5, ndx, CName6, CType6); \ [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 \ +-(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 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -1452,7 +1392,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName6, CType6) \ TIGHTDB_COLUMN_INSERT(self, 5, ndx, CName6, CType6); \ [self insertDone]; \ } \ --(TableName##_Query *)getQuery \ +-(TableName##_Query *)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ @@ -1561,25 +1501,21 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName7, CType7) \ -(TableName##_Query *)parent; \ -(TableName##_View *)findAll; \ @end \ -@interface OCColumnProxy_##TableName : OCColumnProxy \ --(size_t)find:(NSString*)value; \ -@end \ @interface TableName : Table \ -@property(nonatomic, strong) OCColumnProxy_##CType1 *CName1; \ -@property(nonatomic, strong) OCColumnProxy_##CType2 *CName2; \ -@property(nonatomic, strong) OCColumnProxy_##CType3 *CName3; \ -@property(nonatomic, strong) OCColumnProxy_##CType4 *CName4; \ -@property(nonatomic, strong) OCColumnProxy_##CType5 *CName5; \ -@property(nonatomic, strong) OCColumnProxy_##CType6 *CName6; \ -@property(nonatomic, strong) OCColumnProxy_##CType7 *CName7; \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7; \ --(TableName##_Query *)getQuery; \ +TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_DEF(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_DEF(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_DEF(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_DEF(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_DEF(CName6, CType6) \ +TIGHTDB_COLUMN_PROXY_DEF(CName7, CType7) \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7; \ +-(void)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 *)add; \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ -(TableName##_Cursor *)lastObject; \ @end \ -typedef TableName* TIGHTDB_TYPE_##TableName; \ @interface TableName##_View : TableView \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ @end @@ -1691,35 +1627,29 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName4, CType4) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName5, CType5) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName6, CType6) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName7, CType7) \ -@implementation OCColumnProxy_##TableName \ --(size_t)find:(NSString *)value \ -{ \ - return [self.table findString:self.column value:value]; \ -} \ -@end \ @implementation TableName \ { \ TableName##_Cursor *tmpCursor; \ } \ -@synthesize CName1 = _##CName1; \ -@synthesize CName2 = _##CName2; \ -@synthesize CName3 = _##CName3; \ -@synthesize CName4 = _##CName4; \ -@synthesize CName5 = _##CName5; \ -@synthesize CName6 = _##CName6; \ -@synthesize CName7 = _##CName7; \ +TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName6, CType6) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName7, CType7) \ \ -(id)_initRaw \ { \ self = [super _initRaw]; \ if (!self) return nil; \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ - _##CName7 = [[OCColumnProxy_##CType7 alloc] initWithTable:self column:6]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ return self; \ } \ -(id)init \ @@ -1728,16 +1658,16 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName7, CType7) \ if (!self) return nil; \ if (![self _addColumns]) return nil; \ \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ - _##CName7 = [[OCColumnProxy_##CType7 alloc] initWithTable:self column:6]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ return self; \ } \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 \ { \ const size_t ndx = [self count]; \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ @@ -1749,7 +1679,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName7, CType7) \ TIGHTDB_COLUMN_INSERT(self, 6, ndx, CName7, CType7); \ [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 \ +-(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 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -1760,7 +1690,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName7, CType7) \ TIGHTDB_COLUMN_INSERT(self, 6, ndx, CName7, CType7); \ [self insertDone]; \ } \ --(TableName##_Query *)getQuery \ +-(TableName##_Query *)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ @@ -1874,26 +1804,22 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName8, CType8) \ -(TableName##_Query *)parent; \ -(TableName##_View *)findAll; \ @end \ -@interface OCColumnProxy_##TableName : OCColumnProxy \ --(size_t)find:(NSString*)value; \ -@end \ @interface TableName : Table \ -@property(nonatomic, strong) OCColumnProxy_##CType1 *CName1; \ -@property(nonatomic, strong) OCColumnProxy_##CType2 *CName2; \ -@property(nonatomic, strong) OCColumnProxy_##CType3 *CName3; \ -@property(nonatomic, strong) OCColumnProxy_##CType4 *CName4; \ -@property(nonatomic, strong) OCColumnProxy_##CType5 *CName5; \ -@property(nonatomic, strong) OCColumnProxy_##CType6 *CName6; \ -@property(nonatomic, strong) OCColumnProxy_##CType7 *CName7; \ -@property(nonatomic, strong) OCColumnProxy_##CType8 *CName8; \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8; \ --(TableName##_Query *)getQuery; \ +TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_DEF(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_DEF(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_DEF(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_DEF(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_DEF(CName6, CType6) \ +TIGHTDB_COLUMN_PROXY_DEF(CName7, CType7) \ +TIGHTDB_COLUMN_PROXY_DEF(CName8, CType8) \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8; \ +-(void)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 *)add; \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ -(TableName##_Cursor *)lastObject; \ @end \ -typedef TableName* TIGHTDB_TYPE_##TableName; \ @interface TableName##_View : TableView \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ @end @@ -2011,37 +1937,31 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName5, CType5) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName6, CType6) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName7, CType7) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName8, CType8) \ -@implementation OCColumnProxy_##TableName \ --(size_t)find:(NSString *)value \ -{ \ - return [self.table findString:self.column value:value]; \ -} \ -@end \ @implementation TableName \ { \ TableName##_Cursor *tmpCursor; \ } \ -@synthesize CName1 = _##CName1; \ -@synthesize CName2 = _##CName2; \ -@synthesize CName3 = _##CName3; \ -@synthesize CName4 = _##CName4; \ -@synthesize CName5 = _##CName5; \ -@synthesize CName6 = _##CName6; \ -@synthesize CName7 = _##CName7; \ -@synthesize CName8 = _##CName8; \ +TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName6, CType6) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName7, CType7) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName8, CType8) \ \ -(id)_initRaw \ { \ self = [super _initRaw]; \ if (!self) return nil; \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ - _##CName7 = [[OCColumnProxy_##CType7 alloc] initWithTable:self column:6]; \ - _##CName8 = [[OCColumnProxy_##CType8 alloc] initWithTable:self column:7]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 7, CName8, CType8); \ return self; \ } \ -(id)init \ @@ -2050,17 +1970,17 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName8, CType8) \ if (!self) return nil; \ if (![self _addColumns]) return nil; \ \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ - _##CName7 = [[OCColumnProxy_##CType7 alloc] initWithTable:self column:6]; \ - _##CName8 = [[OCColumnProxy_##CType8 alloc] initWithTable:self column:7]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 7, CName8, CType8); \ return self; \ } \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 \ { \ const size_t ndx = [self count]; \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ @@ -2073,7 +1993,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName8, CType8) \ TIGHTDB_COLUMN_INSERT(self, 7, ndx, CName8, CType8); \ [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 \ +-(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 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -2085,7 +2005,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName8, CType8) \ TIGHTDB_COLUMN_INSERT(self, 7, ndx, CName8, CType8); \ [self insertDone]; \ } \ --(TableName##_Query *)getQuery \ +-(TableName##_Query *)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ @@ -2204,27 +2124,23 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName9, CType9) \ -(TableName##_Query *)parent; \ -(TableName##_View *)findAll; \ @end \ -@interface OCColumnProxy_##TableName : OCColumnProxy \ --(size_t)find:(NSString*)value; \ -@end \ @interface TableName : Table \ -@property(nonatomic, strong) OCColumnProxy_##CType1 *CName1; \ -@property(nonatomic, strong) OCColumnProxy_##CType2 *CName2; \ -@property(nonatomic, strong) OCColumnProxy_##CType3 *CName3; \ -@property(nonatomic, strong) OCColumnProxy_##CType4 *CName4; \ -@property(nonatomic, strong) OCColumnProxy_##CType5 *CName5; \ -@property(nonatomic, strong) OCColumnProxy_##CType6 *CName6; \ -@property(nonatomic, strong) OCColumnProxy_##CType7 *CName7; \ -@property(nonatomic, strong) OCColumnProxy_##CType8 *CName8; \ -@property(nonatomic, strong) OCColumnProxy_##CType9 *CName9; \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9; \ --(TableName##_Query *)getQuery; \ +TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_DEF(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_DEF(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_DEF(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_DEF(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_DEF(CName6, CType6) \ +TIGHTDB_COLUMN_PROXY_DEF(CName7, CType7) \ +TIGHTDB_COLUMN_PROXY_DEF(CName8, CType8) \ +TIGHTDB_COLUMN_PROXY_DEF(CName9, CType9) \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9; \ +-(void)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 *)add; \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ -(TableName##_Cursor *)lastObject; \ @end \ -typedef TableName* TIGHTDB_TYPE_##TableName; \ @interface TableName##_View : TableView \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ @end @@ -2348,39 +2264,33 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName6, CType6) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName7, CType7) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName8, CType8) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName9, CType9) \ -@implementation OCColumnProxy_##TableName \ --(size_t)find:(NSString *)value \ -{ \ - return [self.table findString:self.column value:value]; \ -} \ -@end \ @implementation TableName \ { \ TableName##_Cursor *tmpCursor; \ } \ -@synthesize CName1 = _##CName1; \ -@synthesize CName2 = _##CName2; \ -@synthesize CName3 = _##CName3; \ -@synthesize CName4 = _##CName4; \ -@synthesize CName5 = _##CName5; \ -@synthesize CName6 = _##CName6; \ -@synthesize CName7 = _##CName7; \ -@synthesize CName8 = _##CName8; \ -@synthesize CName9 = _##CName9; \ +TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName6, CType6) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName7, CType7) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName8, CType8) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName9, CType9) \ \ -(id)_initRaw \ { \ self = [super _initRaw]; \ if (!self) return nil; \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ - _##CName7 = [[OCColumnProxy_##CType7 alloc] initWithTable:self column:6]; \ - _##CName8 = [[OCColumnProxy_##CType8 alloc] initWithTable:self column:7]; \ - _##CName9 = [[OCColumnProxy_##CType9 alloc] initWithTable:self column:8]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 7, CName8, CType8); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 8, CName9, CType9); \ return self; \ } \ -(id)init \ @@ -2389,18 +2299,18 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName9, CType9) \ if (!self) return nil; \ if (![self _addColumns]) return nil; \ \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ - _##CName7 = [[OCColumnProxy_##CType7 alloc] initWithTable:self column:6]; \ - _##CName8 = [[OCColumnProxy_##CType8 alloc] initWithTable:self column:7]; \ - _##CName9 = [[OCColumnProxy_##CType9 alloc] initWithTable:self column:8]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 7, CName8, CType8); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 8, CName9, CType9); \ return self; \ } \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 \ { \ const size_t ndx = [self count]; \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ @@ -2414,7 +2324,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName9, CType9) \ TIGHTDB_COLUMN_INSERT(self, 8, ndx, CName9, CType9); \ [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 \ +-(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 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -2427,7 +2337,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName9, CType9) \ TIGHTDB_COLUMN_INSERT(self, 8, ndx, CName9, CType9); \ [self insertDone]; \ } \ --(TableName##_Query *)getQuery \ +-(TableName##_Query *)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ @@ -2551,28 +2461,24 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName10, CType10) \ -(TableName##_Query *)parent; \ -(TableName##_View *)findAll; \ @end \ -@interface OCColumnProxy_##TableName : OCColumnProxy \ --(size_t)find:(NSString*)value; \ -@end \ @interface TableName : Table \ -@property(nonatomic, strong) OCColumnProxy_##CType1 *CName1; \ -@property(nonatomic, strong) OCColumnProxy_##CType2 *CName2; \ -@property(nonatomic, strong) OCColumnProxy_##CType3 *CName3; \ -@property(nonatomic, strong) OCColumnProxy_##CType4 *CName4; \ -@property(nonatomic, strong) OCColumnProxy_##CType5 *CName5; \ -@property(nonatomic, strong) OCColumnProxy_##CType6 *CName6; \ -@property(nonatomic, strong) OCColumnProxy_##CType7 *CName7; \ -@property(nonatomic, strong) OCColumnProxy_##CType8 *CName8; \ -@property(nonatomic, strong) OCColumnProxy_##CType9 *CName9; \ -@property(nonatomic, strong) OCColumnProxy_##CType10 *CName10; \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10; \ --(TableName##_Query *)getQuery; \ +TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_DEF(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_DEF(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_DEF(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_DEF(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_DEF(CName6, CType6) \ +TIGHTDB_COLUMN_PROXY_DEF(CName7, CType7) \ +TIGHTDB_COLUMN_PROXY_DEF(CName8, CType8) \ +TIGHTDB_COLUMN_PROXY_DEF(CName9, CType9) \ +TIGHTDB_COLUMN_PROXY_DEF(CName10, CType10) \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10; \ +-(void)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 *)add; \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ -(TableName##_Cursor *)lastObject; \ @end \ -typedef TableName* TIGHTDB_TYPE_##TableName; \ @interface TableName##_View : TableView \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ @end @@ -2702,41 +2608,35 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName7, CType7) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName8, CType8) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName9, CType9) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName10, CType10) \ -@implementation OCColumnProxy_##TableName \ --(size_t)find:(NSString *)value \ -{ \ - return [self.table findString:self.column value:value]; \ -} \ -@end \ @implementation TableName \ { \ TableName##_Cursor *tmpCursor; \ } \ -@synthesize CName1 = _##CName1; \ -@synthesize CName2 = _##CName2; \ -@synthesize CName3 = _##CName3; \ -@synthesize CName4 = _##CName4; \ -@synthesize CName5 = _##CName5; \ -@synthesize CName6 = _##CName6; \ -@synthesize CName7 = _##CName7; \ -@synthesize CName8 = _##CName8; \ -@synthesize CName9 = _##CName9; \ -@synthesize CName10 = _##CName10; \ +TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName6, CType6) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName7, CType7) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName8, CType8) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName9, CType9) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName10, CType10) \ \ -(id)_initRaw \ { \ self = [super _initRaw]; \ if (!self) return nil; \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ - _##CName7 = [[OCColumnProxy_##CType7 alloc] initWithTable:self column:6]; \ - _##CName8 = [[OCColumnProxy_##CType8 alloc] initWithTable:self column:7]; \ - _##CName9 = [[OCColumnProxy_##CType9 alloc] initWithTable:self column:8]; \ - _##CName10 = [[OCColumnProxy_##CType10 alloc] initWithTable:self column:9]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 7, CName8, CType8); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 8, CName9, CType9); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 9, CName10, CType10); \ return self; \ } \ -(id)init \ @@ -2745,19 +2645,19 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName10, CType10) \ if (!self) return nil; \ if (![self _addColumns]) return nil; \ \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ - _##CName7 = [[OCColumnProxy_##CType7 alloc] initWithTable:self column:6]; \ - _##CName8 = [[OCColumnProxy_##CType8 alloc] initWithTable:self column:7]; \ - _##CName9 = [[OCColumnProxy_##CType9 alloc] initWithTable:self column:8]; \ - _##CName10 = [[OCColumnProxy_##CType10 alloc] initWithTable:self column:9]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 7, CName8, CType8); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 8, CName9, CType9); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 9, CName10, CType10); \ return self; \ } \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 \ { \ const size_t ndx = [self count]; \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ @@ -2772,7 +2672,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName10, CType10) \ TIGHTDB_COLUMN_INSERT(self, 9, ndx, CName10, CType10); \ [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 \ +-(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 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -2786,7 +2686,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName10, CType10) \ TIGHTDB_COLUMN_INSERT(self, 9, ndx, CName10, CType10); \ [self insertDone]; \ } \ --(TableName##_Query *)getQuery \ +-(TableName##_Query *)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ @@ -2915,29 +2815,25 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName11, CType11) \ -(TableName##_Query *)parent; \ -(TableName##_View *)findAll; \ @end \ -@interface OCColumnProxy_##TableName : OCColumnProxy \ --(size_t)find:(NSString*)value; \ -@end \ @interface TableName : Table \ -@property(nonatomic, strong) OCColumnProxy_##CType1 *CName1; \ -@property(nonatomic, strong) OCColumnProxy_##CType2 *CName2; \ -@property(nonatomic, strong) OCColumnProxy_##CType3 *CName3; \ -@property(nonatomic, strong) OCColumnProxy_##CType4 *CName4; \ -@property(nonatomic, strong) OCColumnProxy_##CType5 *CName5; \ -@property(nonatomic, strong) OCColumnProxy_##CType6 *CName6; \ -@property(nonatomic, strong) OCColumnProxy_##CType7 *CName7; \ -@property(nonatomic, strong) OCColumnProxy_##CType8 *CName8; \ -@property(nonatomic, strong) OCColumnProxy_##CType9 *CName9; \ -@property(nonatomic, strong) OCColumnProxy_##CType10 *CName10; \ -@property(nonatomic, strong) OCColumnProxy_##CType11 *CName11; \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11; \ --(TableName##_Query *)getQuery; \ +TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_DEF(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_DEF(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_DEF(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_DEF(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_DEF(CName6, CType6) \ +TIGHTDB_COLUMN_PROXY_DEF(CName7, CType7) \ +TIGHTDB_COLUMN_PROXY_DEF(CName8, CType8) \ +TIGHTDB_COLUMN_PROXY_DEF(CName9, CType9) \ +TIGHTDB_COLUMN_PROXY_DEF(CName10, CType10) \ +TIGHTDB_COLUMN_PROXY_DEF(CName11, CType11) \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11; \ +-(void)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 *)add; \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ -(TableName##_Cursor *)lastObject; \ @end \ -typedef TableName* TIGHTDB_TYPE_##TableName; \ @interface TableName##_View : TableView \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ @end @@ -3073,43 +2969,37 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName8, CType8) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName9, CType9) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName10, CType10) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName11, CType11) \ -@implementation OCColumnProxy_##TableName \ --(size_t)find:(NSString *)value \ -{ \ - return [self.table findString:self.column value:value]; \ -} \ -@end \ @implementation TableName \ { \ TableName##_Cursor *tmpCursor; \ } \ -@synthesize CName1 = _##CName1; \ -@synthesize CName2 = _##CName2; \ -@synthesize CName3 = _##CName3; \ -@synthesize CName4 = _##CName4; \ -@synthesize CName5 = _##CName5; \ -@synthesize CName6 = _##CName6; \ -@synthesize CName7 = _##CName7; \ -@synthesize CName8 = _##CName8; \ -@synthesize CName9 = _##CName9; \ -@synthesize CName10 = _##CName10; \ -@synthesize CName11 = _##CName11; \ +TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName6, CType6) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName7, CType7) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName8, CType8) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName9, CType9) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName10, CType10) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName11, CType11) \ \ -(id)_initRaw \ { \ self = [super _initRaw]; \ if (!self) return nil; \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ - _##CName7 = [[OCColumnProxy_##CType7 alloc] initWithTable:self column:6]; \ - _##CName8 = [[OCColumnProxy_##CType8 alloc] initWithTable:self column:7]; \ - _##CName9 = [[OCColumnProxy_##CType9 alloc] initWithTable:self column:8]; \ - _##CName10 = [[OCColumnProxy_##CType10 alloc] initWithTable:self column:9]; \ - _##CName11 = [[OCColumnProxy_##CType11 alloc] initWithTable:self column:10]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 7, CName8, CType8); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 8, CName9, CType9); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 9, CName10, CType10); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 10, CName11, CType11); \ return self; \ } \ -(id)init \ @@ -3118,20 +3008,20 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName11, CType11) \ if (!self) return nil; \ if (![self _addColumns]) return nil; \ \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ - _##CName7 = [[OCColumnProxy_##CType7 alloc] initWithTable:self column:6]; \ - _##CName8 = [[OCColumnProxy_##CType8 alloc] initWithTable:self column:7]; \ - _##CName9 = [[OCColumnProxy_##CType9 alloc] initWithTable:self column:8]; \ - _##CName10 = [[OCColumnProxy_##CType10 alloc] initWithTable:self column:9]; \ - _##CName11 = [[OCColumnProxy_##CType11 alloc] initWithTable:self column:10]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 7, CName8, CType8); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 8, CName9, CType9); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 9, CName10, CType10); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 10, CName11, CType11); \ return self; \ } \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11 \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 \ { \ const size_t ndx = [self count]; \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ @@ -3147,7 +3037,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName11, CType11) \ TIGHTDB_COLUMN_INSERT(self, 10, ndx, CName11, CType11); \ [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11 \ +-(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 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -3162,7 +3052,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName11, CType11) \ TIGHTDB_COLUMN_INSERT(self, 10, ndx, CName11, CType11); \ [self insertDone]; \ } \ --(TableName##_Query *)getQuery \ +-(TableName##_Query *)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ @@ -3296,30 +3186,26 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName12, CType12) \ -(TableName##_Query *)parent; \ -(TableName##_View *)findAll; \ @end \ -@interface OCColumnProxy_##TableName : OCColumnProxy \ --(size_t)find:(NSString*)value; \ -@end \ @interface TableName : Table \ -@property(nonatomic, strong) OCColumnProxy_##CType1 *CName1; \ -@property(nonatomic, strong) OCColumnProxy_##CType2 *CName2; \ -@property(nonatomic, strong) OCColumnProxy_##CType3 *CName3; \ -@property(nonatomic, strong) OCColumnProxy_##CType4 *CName4; \ -@property(nonatomic, strong) OCColumnProxy_##CType5 *CName5; \ -@property(nonatomic, strong) OCColumnProxy_##CType6 *CName6; \ -@property(nonatomic, strong) OCColumnProxy_##CType7 *CName7; \ -@property(nonatomic, strong) OCColumnProxy_##CType8 *CName8; \ -@property(nonatomic, strong) OCColumnProxy_##CType9 *CName9; \ -@property(nonatomic, strong) OCColumnProxy_##CType10 *CName10; \ -@property(nonatomic, strong) OCColumnProxy_##CType11 *CName11; \ -@property(nonatomic, strong) OCColumnProxy_##CType12 *CName12; \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11 CName12:(TIGHTDB_TYPE_##CType12)CName12; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11 CName12:(TIGHTDB_TYPE_##CType12)CName12; \ --(TableName##_Query *)getQuery; \ +TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_DEF(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_DEF(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_DEF(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_DEF(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_DEF(CName6, CType6) \ +TIGHTDB_COLUMN_PROXY_DEF(CName7, CType7) \ +TIGHTDB_COLUMN_PROXY_DEF(CName8, CType8) \ +TIGHTDB_COLUMN_PROXY_DEF(CName9, CType9) \ +TIGHTDB_COLUMN_PROXY_DEF(CName10, CType10) \ +TIGHTDB_COLUMN_PROXY_DEF(CName11, CType11) \ +TIGHTDB_COLUMN_PROXY_DEF(CName12, CType12) \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12; \ +-(void)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 *)add; \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ -(TableName##_Cursor *)lastObject; \ @end \ -typedef TableName* TIGHTDB_TYPE_##TableName; \ @interface TableName##_View : TableView \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ @end @@ -3461,45 +3347,39 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName9, CType9) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName10, CType10) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName11, CType11) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName12, CType12) \ -@implementation OCColumnProxy_##TableName \ --(size_t)find:(NSString *)value \ -{ \ - return [self.table findString:self.column value:value]; \ -} \ -@end \ @implementation TableName \ { \ TableName##_Cursor *tmpCursor; \ } \ -@synthesize CName1 = _##CName1; \ -@synthesize CName2 = _##CName2; \ -@synthesize CName3 = _##CName3; \ -@synthesize CName4 = _##CName4; \ -@synthesize CName5 = _##CName5; \ -@synthesize CName6 = _##CName6; \ -@synthesize CName7 = _##CName7; \ -@synthesize CName8 = _##CName8; \ -@synthesize CName9 = _##CName9; \ -@synthesize CName10 = _##CName10; \ -@synthesize CName11 = _##CName11; \ -@synthesize CName12 = _##CName12; \ +TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName6, CType6) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName7, CType7) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName8, CType8) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName9, CType9) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName10, CType10) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName11, CType11) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName12, CType12) \ \ -(id)_initRaw \ { \ self = [super _initRaw]; \ if (!self) return nil; \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ - _##CName7 = [[OCColumnProxy_##CType7 alloc] initWithTable:self column:6]; \ - _##CName8 = [[OCColumnProxy_##CType8 alloc] initWithTable:self column:7]; \ - _##CName9 = [[OCColumnProxy_##CType9 alloc] initWithTable:self column:8]; \ - _##CName10 = [[OCColumnProxy_##CType10 alloc] initWithTable:self column:9]; \ - _##CName11 = [[OCColumnProxy_##CType11 alloc] initWithTable:self column:10]; \ - _##CName12 = [[OCColumnProxy_##CType12 alloc] initWithTable:self column:11]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 7, CName8, CType8); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 8, CName9, CType9); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 9, CName10, CType10); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 10, CName11, CType11); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 11, CName12, CType12); \ return self; \ } \ -(id)init \ @@ -3508,21 +3388,21 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName12, CType12) \ if (!self) return nil; \ if (![self _addColumns]) return nil; \ \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ - _##CName7 = [[OCColumnProxy_##CType7 alloc] initWithTable:self column:6]; \ - _##CName8 = [[OCColumnProxy_##CType8 alloc] initWithTable:self column:7]; \ - _##CName9 = [[OCColumnProxy_##CType9 alloc] initWithTable:self column:8]; \ - _##CName10 = [[OCColumnProxy_##CType10 alloc] initWithTable:self column:9]; \ - _##CName11 = [[OCColumnProxy_##CType11 alloc] initWithTable:self column:10]; \ - _##CName12 = [[OCColumnProxy_##CType12 alloc] initWithTable:self column:11]; \ - return self; \ -} \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11 CName12:(TIGHTDB_TYPE_##CType12)CName12 \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 7, CName8, CType8); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 8, CName9, CType9); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 9, CName10, CType10); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 10, CName11, CType11); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 11, CName12, CType12); \ + return self; \ +} \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 \ { \ const size_t ndx = [self count]; \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ @@ -3539,7 +3419,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName12, CType12) \ TIGHTDB_COLUMN_INSERT(self, 11, ndx, CName12, CType12); \ [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11 CName12:(TIGHTDB_TYPE_##CType12)CName12 \ +-(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 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -3555,7 +3435,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName12, CType12) \ TIGHTDB_COLUMN_INSERT(self, 11, ndx, CName12, CType12); \ [self insertDone]; \ } \ --(TableName##_Query *)getQuery \ +-(TableName##_Query *)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ @@ -3694,31 +3574,27 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName13, CType13) \ -(TableName##_Query *)parent; \ -(TableName##_View *)findAll; \ @end \ -@interface OCColumnProxy_##TableName : OCColumnProxy \ --(size_t)find:(NSString*)value; \ -@end \ @interface TableName : Table \ -@property(nonatomic, strong) OCColumnProxy_##CType1 *CName1; \ -@property(nonatomic, strong) OCColumnProxy_##CType2 *CName2; \ -@property(nonatomic, strong) OCColumnProxy_##CType3 *CName3; \ -@property(nonatomic, strong) OCColumnProxy_##CType4 *CName4; \ -@property(nonatomic, strong) OCColumnProxy_##CType5 *CName5; \ -@property(nonatomic, strong) OCColumnProxy_##CType6 *CName6; \ -@property(nonatomic, strong) OCColumnProxy_##CType7 *CName7; \ -@property(nonatomic, strong) OCColumnProxy_##CType8 *CName8; \ -@property(nonatomic, strong) OCColumnProxy_##CType9 *CName9; \ -@property(nonatomic, strong) OCColumnProxy_##CType10 *CName10; \ -@property(nonatomic, strong) OCColumnProxy_##CType11 *CName11; \ -@property(nonatomic, strong) OCColumnProxy_##CType12 *CName12; \ -@property(nonatomic, strong) OCColumnProxy_##CType13 *CName13; \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11 CName12:(TIGHTDB_TYPE_##CType12)CName12 CName13:(TIGHTDB_TYPE_##CType13)CName13; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11 CName12:(TIGHTDB_TYPE_##CType12)CName12 CName13:(TIGHTDB_TYPE_##CType13)CName13; \ --(TableName##_Query *)getQuery; \ +TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_DEF(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_DEF(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_DEF(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_DEF(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_DEF(CName6, CType6) \ +TIGHTDB_COLUMN_PROXY_DEF(CName7, CType7) \ +TIGHTDB_COLUMN_PROXY_DEF(CName8, CType8) \ +TIGHTDB_COLUMN_PROXY_DEF(CName9, CType9) \ +TIGHTDB_COLUMN_PROXY_DEF(CName10, CType10) \ +TIGHTDB_COLUMN_PROXY_DEF(CName11, CType11) \ +TIGHTDB_COLUMN_PROXY_DEF(CName12, CType12) \ +TIGHTDB_COLUMN_PROXY_DEF(CName13, CType13) \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13; \ +-(void)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 *)add; \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ -(TableName##_Cursor *)lastObject; \ @end \ -typedef TableName* TIGHTDB_TYPE_##TableName; \ @interface TableName##_View : TableView \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ @end @@ -3866,47 +3742,41 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName10, CType10) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName11, CType11) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName12, CType12) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName13, CType13) \ -@implementation OCColumnProxy_##TableName \ --(size_t)find:(NSString *)value \ -{ \ - return [self.table findString:self.column value:value]; \ -} \ -@end \ @implementation TableName \ { \ TableName##_Cursor *tmpCursor; \ } \ -@synthesize CName1 = _##CName1; \ -@synthesize CName2 = _##CName2; \ -@synthesize CName3 = _##CName3; \ -@synthesize CName4 = _##CName4; \ -@synthesize CName5 = _##CName5; \ -@synthesize CName6 = _##CName6; \ -@synthesize CName7 = _##CName7; \ -@synthesize CName8 = _##CName8; \ -@synthesize CName9 = _##CName9; \ -@synthesize CName10 = _##CName10; \ -@synthesize CName11 = _##CName11; \ -@synthesize CName12 = _##CName12; \ -@synthesize CName13 = _##CName13; \ +TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName6, CType6) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName7, CType7) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName8, CType8) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName9, CType9) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName10, CType10) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName11, CType11) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName12, CType12) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName13, CType13) \ \ -(id)_initRaw \ { \ self = [super _initRaw]; \ if (!self) return nil; \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ - _##CName7 = [[OCColumnProxy_##CType7 alloc] initWithTable:self column:6]; \ - _##CName8 = [[OCColumnProxy_##CType8 alloc] initWithTable:self column:7]; \ - _##CName9 = [[OCColumnProxy_##CType9 alloc] initWithTable:self column:8]; \ - _##CName10 = [[OCColumnProxy_##CType10 alloc] initWithTable:self column:9]; \ - _##CName11 = [[OCColumnProxy_##CType11 alloc] initWithTable:self column:10]; \ - _##CName12 = [[OCColumnProxy_##CType12 alloc] initWithTable:self column:11]; \ - _##CName13 = [[OCColumnProxy_##CType13 alloc] initWithTable:self column:12]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 7, CName8, CType8); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 8, CName9, CType9); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 9, CName10, CType10); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 10, CName11, CType11); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 11, CName12, CType12); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 12, CName13, CType13); \ return self; \ } \ -(id)init \ @@ -3915,22 +3785,22 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName13, CType13) \ if (!self) return nil; \ if (![self _addColumns]) return nil; \ \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ - _##CName7 = [[OCColumnProxy_##CType7 alloc] initWithTable:self column:6]; \ - _##CName8 = [[OCColumnProxy_##CType8 alloc] initWithTable:self column:7]; \ - _##CName9 = [[OCColumnProxy_##CType9 alloc] initWithTable:self column:8]; \ - _##CName10 = [[OCColumnProxy_##CType10 alloc] initWithTable:self column:9]; \ - _##CName11 = [[OCColumnProxy_##CType11 alloc] initWithTable:self column:10]; \ - _##CName12 = [[OCColumnProxy_##CType12 alloc] initWithTable:self column:11]; \ - _##CName13 = [[OCColumnProxy_##CType13 alloc] initWithTable:self column:12]; \ - return self; \ -} \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11 CName12:(TIGHTDB_TYPE_##CType12)CName12 CName13:(TIGHTDB_TYPE_##CType13)CName13 \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 7, CName8, CType8); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 8, CName9, CType9); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 9, CName10, CType10); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 10, CName11, CType11); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 11, CName12, CType12); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 12, CName13, CType13); \ + return self; \ +} \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 \ { \ const size_t ndx = [self count]; \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ @@ -3948,7 +3818,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName13, CType13) \ TIGHTDB_COLUMN_INSERT(self, 12, ndx, CName13, CType13); \ [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11 CName12:(TIGHTDB_TYPE_##CType12)CName12 CName13:(TIGHTDB_TYPE_##CType13)CName13 \ +-(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 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -3965,7 +3835,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName13, CType13) \ TIGHTDB_COLUMN_INSERT(self, 12, ndx, CName13, CType13); \ [self insertDone]; \ } \ --(TableName##_Query *)getQuery \ +-(TableName##_Query *)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ @@ -4109,32 +3979,28 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName14, CType14) \ -(TableName##_Query *)parent; \ -(TableName##_View *)findAll; \ @end \ -@interface OCColumnProxy_##TableName : OCColumnProxy \ --(size_t)find:(NSString*)value; \ -@end \ @interface TableName : Table \ -@property(nonatomic, strong) OCColumnProxy_##CType1 *CName1; \ -@property(nonatomic, strong) OCColumnProxy_##CType2 *CName2; \ -@property(nonatomic, strong) OCColumnProxy_##CType3 *CName3; \ -@property(nonatomic, strong) OCColumnProxy_##CType4 *CName4; \ -@property(nonatomic, strong) OCColumnProxy_##CType5 *CName5; \ -@property(nonatomic, strong) OCColumnProxy_##CType6 *CName6; \ -@property(nonatomic, strong) OCColumnProxy_##CType7 *CName7; \ -@property(nonatomic, strong) OCColumnProxy_##CType8 *CName8; \ -@property(nonatomic, strong) OCColumnProxy_##CType9 *CName9; \ -@property(nonatomic, strong) OCColumnProxy_##CType10 *CName10; \ -@property(nonatomic, strong) OCColumnProxy_##CType11 *CName11; \ -@property(nonatomic, strong) OCColumnProxy_##CType12 *CName12; \ -@property(nonatomic, strong) OCColumnProxy_##CType13 *CName13; \ -@property(nonatomic, strong) OCColumnProxy_##CType14 *CName14; \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11 CName12:(TIGHTDB_TYPE_##CType12)CName12 CName13:(TIGHTDB_TYPE_##CType13)CName13 CName14:(TIGHTDB_TYPE_##CType14)CName14; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11 CName12:(TIGHTDB_TYPE_##CType12)CName12 CName13:(TIGHTDB_TYPE_##CType13)CName13 CName14:(TIGHTDB_TYPE_##CType14)CName14; \ --(TableName##_Query *)getQuery; \ +TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_DEF(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_DEF(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_DEF(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_DEF(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_DEF(CName6, CType6) \ +TIGHTDB_COLUMN_PROXY_DEF(CName7, CType7) \ +TIGHTDB_COLUMN_PROXY_DEF(CName8, CType8) \ +TIGHTDB_COLUMN_PROXY_DEF(CName9, CType9) \ +TIGHTDB_COLUMN_PROXY_DEF(CName10, CType10) \ +TIGHTDB_COLUMN_PROXY_DEF(CName11, CType11) \ +TIGHTDB_COLUMN_PROXY_DEF(CName12, CType12) \ +TIGHTDB_COLUMN_PROXY_DEF(CName13, CType13) \ +TIGHTDB_COLUMN_PROXY_DEF(CName14, CType14) \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14; \ +-(void)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 *)add; \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ -(TableName##_Cursor *)lastObject; \ @end \ -typedef TableName* TIGHTDB_TYPE_##TableName; \ @interface TableName##_View : TableView \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ @end @@ -4288,49 +4154,43 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName11, CType11) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName12, CType12) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName13, CType13) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName14, CType14) \ -@implementation OCColumnProxy_##TableName \ --(size_t)find:(NSString *)value \ -{ \ - return [self.table findString:self.column value:value]; \ -} \ -@end \ @implementation TableName \ { \ TableName##_Cursor *tmpCursor; \ } \ -@synthesize CName1 = _##CName1; \ -@synthesize CName2 = _##CName2; \ -@synthesize CName3 = _##CName3; \ -@synthesize CName4 = _##CName4; \ -@synthesize CName5 = _##CName5; \ -@synthesize CName6 = _##CName6; \ -@synthesize CName7 = _##CName7; \ -@synthesize CName8 = _##CName8; \ -@synthesize CName9 = _##CName9; \ -@synthesize CName10 = _##CName10; \ -@synthesize CName11 = _##CName11; \ -@synthesize CName12 = _##CName12; \ -@synthesize CName13 = _##CName13; \ -@synthesize CName14 = _##CName14; \ +TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName6, CType6) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName7, CType7) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName8, CType8) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName9, CType9) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName10, CType10) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName11, CType11) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName12, CType12) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName13, CType13) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName14, CType14) \ \ -(id)_initRaw \ { \ self = [super _initRaw]; \ if (!self) return nil; \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ - _##CName7 = [[OCColumnProxy_##CType7 alloc] initWithTable:self column:6]; \ - _##CName8 = [[OCColumnProxy_##CType8 alloc] initWithTable:self column:7]; \ - _##CName9 = [[OCColumnProxy_##CType9 alloc] initWithTable:self column:8]; \ - _##CName10 = [[OCColumnProxy_##CType10 alloc] initWithTable:self column:9]; \ - _##CName11 = [[OCColumnProxy_##CType11 alloc] initWithTable:self column:10]; \ - _##CName12 = [[OCColumnProxy_##CType12 alloc] initWithTable:self column:11]; \ - _##CName13 = [[OCColumnProxy_##CType13 alloc] initWithTable:self column:12]; \ - _##CName14 = [[OCColumnProxy_##CType14 alloc] initWithTable:self column:13]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 7, CName8, CType8); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 8, CName9, CType9); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 9, CName10, CType10); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 10, CName11, CType11); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 11, CName12, CType12); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 12, CName13, CType13); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 13, CName14, CType14); \ return self; \ } \ -(id)init \ @@ -4339,23 +4199,23 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName14, CType14) \ if (!self) return nil; \ if (![self _addColumns]) return nil; \ \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ - _##CName7 = [[OCColumnProxy_##CType7 alloc] initWithTable:self column:6]; \ - _##CName8 = [[OCColumnProxy_##CType8 alloc] initWithTable:self column:7]; \ - _##CName9 = [[OCColumnProxy_##CType9 alloc] initWithTable:self column:8]; \ - _##CName10 = [[OCColumnProxy_##CType10 alloc] initWithTable:self column:9]; \ - _##CName11 = [[OCColumnProxy_##CType11 alloc] initWithTable:self column:10]; \ - _##CName12 = [[OCColumnProxy_##CType12 alloc] initWithTable:self column:11]; \ - _##CName13 = [[OCColumnProxy_##CType13 alloc] initWithTable:self column:12]; \ - _##CName14 = [[OCColumnProxy_##CType14 alloc] initWithTable:self column:13]; \ - return self; \ -} \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11 CName12:(TIGHTDB_TYPE_##CType12)CName12 CName13:(TIGHTDB_TYPE_##CType13)CName13 CName14:(TIGHTDB_TYPE_##CType14)CName14 \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 7, CName8, CType8); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 8, CName9, CType9); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 9, CName10, CType10); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 10, CName11, CType11); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 11, CName12, CType12); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 12, CName13, CType13); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 13, CName14, CType14); \ + return self; \ +} \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 \ { \ const size_t ndx = [self count]; \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ @@ -4374,7 +4234,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName14, CType14) \ TIGHTDB_COLUMN_INSERT(self, 13, ndx, CName14, CType14); \ [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11 CName12:(TIGHTDB_TYPE_##CType12)CName12 CName13:(TIGHTDB_TYPE_##CType13)CName13 CName14:(TIGHTDB_TYPE_##CType14)CName14 \ +-(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 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -4392,7 +4252,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName14, CType14) \ TIGHTDB_COLUMN_INSERT(self, 13, ndx, CName14, CType14); \ [self insertDone]; \ } \ --(TableName##_Query *)getQuery \ +-(TableName##_Query *)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ @@ -4541,33 +4401,29 @@ TIGHTDB_QUERY_ACCESSOR_DEF(TableName, CName15, CType15) \ -(TableName##_Query *)parent; \ -(TableName##_View *)findAll; \ @end \ -@interface OCColumnProxy_##TableName : OCColumnProxy \ --(size_t)find:(NSString*)value; \ -@end \ @interface TableName : Table \ -@property(nonatomic, strong) OCColumnProxy_##CType1 *CName1; \ -@property(nonatomic, strong) OCColumnProxy_##CType2 *CName2; \ -@property(nonatomic, strong) OCColumnProxy_##CType3 *CName3; \ -@property(nonatomic, strong) OCColumnProxy_##CType4 *CName4; \ -@property(nonatomic, strong) OCColumnProxy_##CType5 *CName5; \ -@property(nonatomic, strong) OCColumnProxy_##CType6 *CName6; \ -@property(nonatomic, strong) OCColumnProxy_##CType7 *CName7; \ -@property(nonatomic, strong) OCColumnProxy_##CType8 *CName8; \ -@property(nonatomic, strong) OCColumnProxy_##CType9 *CName9; \ -@property(nonatomic, strong) OCColumnProxy_##CType10 *CName10; \ -@property(nonatomic, strong) OCColumnProxy_##CType11 *CName11; \ -@property(nonatomic, strong) OCColumnProxy_##CType12 *CName12; \ -@property(nonatomic, strong) OCColumnProxy_##CType13 *CName13; \ -@property(nonatomic, strong) OCColumnProxy_##CType14 *CName14; \ -@property(nonatomic, strong) OCColumnProxy_##CType15 *CName15; \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11 CName12:(TIGHTDB_TYPE_##CType12)CName12 CName13:(TIGHTDB_TYPE_##CType13)CName13 CName14:(TIGHTDB_TYPE_##CType14)CName14 CName15:(TIGHTDB_TYPE_##CType15)CName15; \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11 CName12:(TIGHTDB_TYPE_##CType12)CName12 CName13:(TIGHTDB_TYPE_##CType13)CName13 CName14:(TIGHTDB_TYPE_##CType14)CName14 CName15:(TIGHTDB_TYPE_##CType15)CName15; \ --(TableName##_Query *)getQuery; \ +TIGHTDB_COLUMN_PROXY_DEF(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_DEF(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_DEF(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_DEF(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_DEF(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_DEF(CName6, CType6) \ +TIGHTDB_COLUMN_PROXY_DEF(CName7, CType7) \ +TIGHTDB_COLUMN_PROXY_DEF(CName8, CType8) \ +TIGHTDB_COLUMN_PROXY_DEF(CName9, CType9) \ +TIGHTDB_COLUMN_PROXY_DEF(CName10, CType10) \ +TIGHTDB_COLUMN_PROXY_DEF(CName11, CType11) \ +TIGHTDB_COLUMN_PROXY_DEF(CName12, CType12) \ +TIGHTDB_COLUMN_PROXY_DEF(CName13, CType13) \ +TIGHTDB_COLUMN_PROXY_DEF(CName14, CType14) \ +TIGHTDB_COLUMN_PROXY_DEF(CName15, CType15) \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 CName15:(TIGHTDB_ARG_TYPE(CType15))CName15; \ +-(void)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 *)add; \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ -(TableName##_Cursor *)lastObject; \ @end \ -typedef TableName* TIGHTDB_TYPE_##TableName; \ @interface TableName##_View : TableView \ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \ @end @@ -4727,51 +4583,45 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName12, CType12) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName13, CType13) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName14, CType14) \ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName15, CType15) \ -@implementation OCColumnProxy_##TableName \ --(size_t)find:(NSString *)value \ -{ \ - return [self.table findString:self.column value:value]; \ -} \ -@end \ @implementation TableName \ { \ TableName##_Cursor *tmpCursor; \ } \ -@synthesize CName1 = _##CName1; \ -@synthesize CName2 = _##CName2; \ -@synthesize CName3 = _##CName3; \ -@synthesize CName4 = _##CName4; \ -@synthesize CName5 = _##CName5; \ -@synthesize CName6 = _##CName6; \ -@synthesize CName7 = _##CName7; \ -@synthesize CName8 = _##CName8; \ -@synthesize CName9 = _##CName9; \ -@synthesize CName10 = _##CName10; \ -@synthesize CName11 = _##CName11; \ -@synthesize CName12 = _##CName12; \ -@synthesize CName13 = _##CName13; \ -@synthesize CName14 = _##CName14; \ -@synthesize CName15 = _##CName15; \ +TIGHTDB_COLUMN_PROXY_IMPL(CName1, CType1) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName2, CType2) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName3, CType3) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName4, CType4) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName5, CType5) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName6, CType6) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName7, CType7) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName8, CType8) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName9, CType9) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName10, CType10) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName11, CType11) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName12, CType12) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName13, CType13) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName14, CType14) \ +TIGHTDB_COLUMN_PROXY_IMPL(CName15, CType15) \ \ -(id)_initRaw \ { \ self = [super _initRaw]; \ if (!self) return nil; \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ - _##CName7 = [[OCColumnProxy_##CType7 alloc] initWithTable:self column:6]; \ - _##CName8 = [[OCColumnProxy_##CType8 alloc] initWithTable:self column:7]; \ - _##CName9 = [[OCColumnProxy_##CType9 alloc] initWithTable:self column:8]; \ - _##CName10 = [[OCColumnProxy_##CType10 alloc] initWithTable:self column:9]; \ - _##CName11 = [[OCColumnProxy_##CType11 alloc] initWithTable:self column:10]; \ - _##CName12 = [[OCColumnProxy_##CType12 alloc] initWithTable:self column:11]; \ - _##CName13 = [[OCColumnProxy_##CType13 alloc] initWithTable:self column:12]; \ - _##CName14 = [[OCColumnProxy_##CType14 alloc] initWithTable:self column:13]; \ - _##CName15 = [[OCColumnProxy_##CType15 alloc] initWithTable:self column:14]; \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 7, CName8, CType8); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 8, CName9, CType9); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 9, CName10, CType10); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 10, CName11, CType11); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 11, CName12, CType12); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 12, CName13, CType13); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 13, CName14, CType14); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 14, CName15, CType15); \ return self; \ } \ -(id)init \ @@ -4780,24 +4630,24 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName15, CType15) \ if (!self) return nil; \ if (![self _addColumns]) return nil; \ \ - _##CName1 = [[OCColumnProxy_##CType1 alloc] initWithTable:self column:0]; \ - _##CName2 = [[OCColumnProxy_##CType2 alloc] initWithTable:self column:1]; \ - _##CName3 = [[OCColumnProxy_##CType3 alloc] initWithTable:self column:2]; \ - _##CName4 = [[OCColumnProxy_##CType4 alloc] initWithTable:self column:3]; \ - _##CName5 = [[OCColumnProxy_##CType5 alloc] initWithTable:self column:4]; \ - _##CName6 = [[OCColumnProxy_##CType6 alloc] initWithTable:self column:5]; \ - _##CName7 = [[OCColumnProxy_##CType7 alloc] initWithTable:self column:6]; \ - _##CName8 = [[OCColumnProxy_##CType8 alloc] initWithTable:self column:7]; \ - _##CName9 = [[OCColumnProxy_##CType9 alloc] initWithTable:self column:8]; \ - _##CName10 = [[OCColumnProxy_##CType10 alloc] initWithTable:self column:9]; \ - _##CName11 = [[OCColumnProxy_##CType11 alloc] initWithTable:self column:10]; \ - _##CName12 = [[OCColumnProxy_##CType12 alloc] initWithTable:self column:11]; \ - _##CName13 = [[OCColumnProxy_##CType13 alloc] initWithTable:self column:12]; \ - _##CName14 = [[OCColumnProxy_##CType14 alloc] initWithTable:self column:13]; \ - _##CName15 = [[OCColumnProxy_##CType15 alloc] initWithTable:self column:14]; \ - return self; \ -} \ --(void)add##CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11 CName12:(TIGHTDB_TYPE_##CType12)CName12 CName13:(TIGHTDB_TYPE_##CType13)CName13 CName14:(TIGHTDB_TYPE_##CType14)CName14 CName15:(TIGHTDB_TYPE_##CType15)CName15 \ + TIGHTDB_COLUMN_PROXY_INIT(self, 0, CName1, CType1); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 1, CName2, CType2); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 2, CName3, CType3); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 3, CName4, CType4); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 4, CName5, CType5); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 5, CName6, CType6); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 6, CName7, CType7); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 7, CName8, CType8); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 8, CName9, CType9); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 9, CName10, CType10); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 10, CName11, CType11); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 11, CName12, CType12); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 12, CName13, CType13); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 13, CName14, CType14); \ + TIGHTDB_COLUMN_PROXY_INIT(self, 14, CName15, CType15); \ + return self; \ +} \ +-(void)add##CName1:(TIGHTDB_ARG_TYPE(CType1))CName1 CName2:(TIGHTDB_ARG_TYPE(CType2))CName2 CName3:(TIGHTDB_ARG_TYPE(CType3))CName3 CName4:(TIGHTDB_ARG_TYPE(CType4))CName4 CName5:(TIGHTDB_ARG_TYPE(CType5))CName5 CName6:(TIGHTDB_ARG_TYPE(CType6))CName6 CName7:(TIGHTDB_ARG_TYPE(CType7))CName7 CName8:(TIGHTDB_ARG_TYPE(CType8))CName8 CName9:(TIGHTDB_ARG_TYPE(CType9))CName9 CName10:(TIGHTDB_ARG_TYPE(CType10))CName10 CName11:(TIGHTDB_ARG_TYPE(CType11))CName11 CName12:(TIGHTDB_ARG_TYPE(CType12))CName12 CName13:(TIGHTDB_ARG_TYPE(CType13))CName13 CName14:(TIGHTDB_ARG_TYPE(CType14))CName14 CName15:(TIGHTDB_ARG_TYPE(CType15))CName15 \ { \ const size_t ndx = [self count]; \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ @@ -4817,7 +4667,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName15, CType15) \ TIGHTDB_COLUMN_INSERT(self, 14, ndx, CName15, CType15); \ [self insertDone]; \ } \ --(void)insertAtIndex:(size_t)ndx CName1:(TIGHTDB_TYPE_##CType1)CName1 CName2:(TIGHTDB_TYPE_##CType2)CName2 CName3:(TIGHTDB_TYPE_##CType3)CName3 CName4:(TIGHTDB_TYPE_##CType4)CName4 CName5:(TIGHTDB_TYPE_##CType5)CName5 CName6:(TIGHTDB_TYPE_##CType6)CName6 CName7:(TIGHTDB_TYPE_##CType7)CName7 CName8:(TIGHTDB_TYPE_##CType8)CName8 CName9:(TIGHTDB_TYPE_##CType9)CName9 CName10:(TIGHTDB_TYPE_##CType10)CName10 CName11:(TIGHTDB_TYPE_##CType11)CName11 CName12:(TIGHTDB_TYPE_##CType12)CName12 CName13:(TIGHTDB_TYPE_##CType13)CName13 CName14:(TIGHTDB_TYPE_##CType14)CName14 CName15:(TIGHTDB_TYPE_##CType15)CName15 \ +-(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 \ { \ TIGHTDB_COLUMN_INSERT(self, 0, ndx, CName1, CType1); \ TIGHTDB_COLUMN_INSERT(self, 1, ndx, CName2, CType2); \ @@ -4836,7 +4686,7 @@ TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName15, CType15) \ TIGHTDB_COLUMN_INSERT(self, 14, ndx, CName15, CType15); \ [self insertDone]; \ } \ --(TableName##_Query *)getQuery \ +-(TableName##_Query *)where \ { \ return [[TableName##_Query alloc] initWithTable:self]; \ } \ diff --git a/src/tightdb/objc/tightdb.h.py b/src/tightdb/objc/tightdb.h.py index 5d5dc2791e..0a4f9f705f 100644 --- a/src/tightdb/objc/tightdb.h.py +++ b/src/tightdb/objc/tightdb.h.py @@ -60,32 +60,28 @@ -(TableName##_Query *)parent; \\ -(TableName##_View *)findAll; \\ @end \\ -@interface OCColumnProxy_##TableName : OCColumnProxy \\ --(size_t)find:(NSString*)value; \\ -@end \\ @interface TableName : Table \\ %for $j in range($num_cols) -@property(nonatomic, strong) OCColumnProxy_##CType${j+1} *CName${j+1}; \\ +TIGHTDB_COLUMN_PROXY_DEF(CName${j+1}, CType${j+1}) \\ %end for -(void)add##%slurp %for $j in range($num_cols) %if 0 < $j %echo ' ' %end if -CName${j+1}:(TIGHTDB_TYPE_##CType${j+1})CName${j+1}%slurp +CName${j+1}:(TIGHTDB_ARG_TYPE(CType${j+1}))CName${j+1}%slurp %end for ; \\ -(void)insertAtIndex:(size_t)ndx%slurp %for $j in range($num_cols) - CName${j+1}:(TIGHTDB_TYPE_##CType${j+1})CName${j+1}%slurp + CName${j+1}:(TIGHTDB_ARG_TYPE(CType${j+1}))CName${j+1}%slurp %end for ; \\ --(TableName##_Query *)getQuery; \\ +-(TableName##_Query *)where; \\ -(TableName##_Cursor *)add; \\ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \\ -(TableName##_Cursor *)lastObject; \\ @end \\ -typedef TableName* TIGHTDB_TYPE_##TableName; \\ @interface TableName##_View : TableView \\ -(TableName##_Cursor *)objectAtIndex:(size_t)ndx; \\ @end @@ -177,18 +173,12 @@ %for $j in range($num_cols) TIGHTDB_QUERY_ACCESSOR_IMPL(TableName, CName${j+1}, CType${j+1}) \\ %end for -@implementation OCColumnProxy_##TableName \\ --(size_t)find:(NSString *)value \\ -{ \\ - return [self.table findString:self.column value:value]; \\ -} \\ -@end \\ @implementation TableName \\ { \\ TableName##_Cursor *tmpCursor; \\ } \\ %for $j in range($num_cols) -@synthesize CName${j+1} = _##CName${j+1}; \\ +TIGHTDB_COLUMN_PROXY_IMPL(CName${j+1}, CType${j+1}) \\ %end for \\ -(id)_initRaw \\ @@ -196,7 +186,7 @@ self = [super _initRaw]; \\ if (!self) return nil; \\ %for $j in range($num_cols) - _##CName${j+1} = [[OCColumnProxy_##CType${j+1} alloc] initWithTable:self column:${j}]; \\ + TIGHTDB_COLUMN_PROXY_INIT(self, ${j}, CName${j+1}, CType${j+1}); \\ %end for return self; \\ } \\ @@ -207,13 +197,13 @@ if (![self _addColumns]) return nil; \\ \\ %for $j in range($num_cols) - _##CName${j+1} = [[OCColumnProxy_##CType${j+1} alloc] initWithTable:self column:${j}]; \\ + TIGHTDB_COLUMN_PROXY_INIT(self, ${j}, CName${j+1}, CType${j+1}); \\ %end for return self; \\ } \\ -(void)add##%slurp %for $j in range($num_cols) -CName${j+1}:(TIGHTDB_TYPE_##CType${j+1})CName${j+1} %slurp +CName${j+1}:(TIGHTDB_ARG_TYPE(CType${j+1}))CName${j+1} %slurp %end for \\ { \\ @@ -225,7 +215,7 @@ } \\ -(void)insertAtIndex:(size_t)ndx %slurp %for $j in range($num_cols) -CName${j+1}:(TIGHTDB_TYPE_##CType${j+1})CName${j+1} %slurp +CName${j+1}:(TIGHTDB_ARG_TYPE(CType${j+1}))CName${j+1} %slurp %end for \\ { \\ @@ -234,7 +224,7 @@ %end for [self insertDone]; \\ } \\ --(TableName##_Query *)getQuery \\ +-(TableName##_Query *)where \\ { \\ return [[TableName##_Query alloc] initWithTable:self]; \\ } \\