Repository: realm/realm-swift
File: src/tightdb/objc/TDBTable.h (C/C++)

Code before:
#import <Foundation/Foundation.h>

#include <tightdb/objc/TDBType.h>

@class TDBBinary;
@class TDBView;
@class TDBQuery;
@class TDBDescriptor;
@class TDBRow;
@class TDBMixed;

/****************	  TDBTable		****************/

@interface TDBTable: NSObject <NSFastEnumeration>

@property (nonatomic, readonly) NSUInteger rowCount;
@property (nonatomic, readonly) NSUInteger columnCount;
@property (nonatomic, readonly) TDBDescriptor *descriptor;

/* Initializers for standalone tables */
-(instancetype)init;

/* Working with columns */
-(NSUInteger)addColumnWithName:(NSString *)name andType:(TDBType)type;
-(void)removeColumnWithIndex:(NSUInteger)colIndex;
-(NSString *)columnNameOfColumn:(NSUInteger)colIndex;
-(NSUInteger)indexOfColumnWithName:(NSString *)name;
-(TDBType)columnTypeOfColumn:(NSUInteger)colIndex;

/* Getting and setting individual rows (uses object subscripting) */
-(TDBRow *)objectAtIndexedSubscript:(NSUInteger)rowIndex;
-(TDBRow *)rowAtIndex:(NSUInteger)rowIndex;
-(TDBRow *)lastRow;
-(TDBRow *)firstRow;
-(void)setObject:(id)newValue atIndexedSubscript:(NSUInteger)rowIndex;

/* Appending rows to end of table */
-(TDBRow *)addEmptyRow;
-(BOOL)appendRow:(NSObject *)data;

/* Inserting rows at specific positions */
-(TDBRow *)insertEmptyRowAtIndex:(NSUInteger)rowIndex;
-(BOOL)insertRow:(id)anObject atRowIndex:(NSUInteger)rowIndex;

/* Removing rows */
-(BOOL)removeAllRows;
-(BOOL)removeRowAtIndex:(NSUInteger)rowIndex;
-(BOOL)removeLastRow;

/* Queries */
-(TDBQuery *)where;

Review comment (refactor):
Or if you created a TDBColumn object, you could remove this selector completely along with columnTypeOfColumn. They would then be members of the column object.


Code after:
#import <Foundation/Foundation.h>

#include <tightdb/objc/TDBType.h>

@class TDBBinary;
@class TDBView;
@class TDBQuery;
@class TDBDescriptor;
@class TDBRow;
@class TDBMixed;

/****************	  TDBTable		****************/

@interface TDBTable: NSObject <NSFastEnumeration>

@property (nonatomic, readonly) NSUInteger rowCount;
@property (nonatomic, readonly) NSUInteger columnCount;
@property (nonatomic, readonly) TDBDescriptor *descriptor;

// Initializers for standalone tables
-(instancetype)init;

// Working with columns
-(NSUInteger)addColumnWithName:(NSString *)name andType:(TDBType)type;
-(void)removeColumnWithIndex:(NSUInteger)colIndex;
-(NSString *)columnNameOfColumn:(NSUInteger)colIndex;
-(NSUInteger)indexOfColumnWithName:(NSString *)name;
-(TDBType)columnTypeOfColumn:(NSUInteger)colIndex;

// Getting and setting individual rows (uses object subscripting)
-(TDBRow *)objectAtIndexedSubscript:(NSUInteger)rowIndex;
-(TDBRow *)rowAtIndex:(NSUInteger)rowIndex;
-(TDBRow *)lastRow;
-(TDBRow *)firstRow;
-(void)setObject:(id)newValue atIndexedSubscript:(NSUInteger)rowIndex;

// Appending rows to end of table
-(TDBRow *)addEmptyRow;
-(BOOL)appendRow:(NSObject *)data;

// Inserting rows at specific positions
-(TDBRow *)insertEmptyRowAtIndex:(NSUInteger)rowIndex;
-(BOOL)insertRow:(id)anObject atRowIndex:(NSUInteger)rowIndex;

// Removing rows
-(BOOL)removeAllRows;
-(BOOL)removeRowAtIndex:(NSUInteger)rowIndex;
-(BOOL)removeLastRow;

// Queries
-(TDBQuery *)where;