#import <Foundation/Foundation.h>
#import <sqlite3.h>
@class SFSQLiteStatement;
typedef SInt64 SFSQLiteRowID;
@class SFSQLite;
NSArray *SFSQLiteJournalSuffixes(void);
typedef NS_ENUM(NSInteger, SFSQLiteSynchronousMode) {
SFSQLiteSynchronousModeOff = 0,
SFSQLiteSynchronousModeNormal = 1, SFSQLiteSynchronousModeFull = 2
};
@protocol SFSQLiteDelegate
@property (nonatomic, readonly) SInt32 userVersion;
- (BOOL)migrateDatabase:(SFSQLite *)db fromVersion:(SInt32)version;
@end
@interface SFSQLite : NSObject {
id<SFSQLiteDelegate> _delegate;
NSString* _path;
NSString* _schema;
NSString* _schemaVersion;
NSMutableDictionary* _statementsBySQL;
NSString* _objectClassPrefix;
SFSQLiteSynchronousMode _synchronousMode;
SInt32 _userVersion;
sqlite3* _db;
NSUInteger _openCount;
NSDateFormatter* _dateFormatter;
#if DEBUG
NSMutableDictionary* _unitTestOverrides;
#endif
BOOL _hasMigrated;
BOOL _shouldVacuum;
BOOL _corrupt;
BOOL _traced;
}
- (instancetype)initWithPath:(NSString *)path schema:(NSString *)schema;
@property (nonatomic, readonly, strong) NSString *path;
@property (nonatomic, readonly, strong) NSString *schema;
@property (nonatomic, readonly, strong) NSString *schemaVersion;
@property (nonatomic, strong) NSString *objectClassPrefix;
@property (nonatomic, assign) SInt32 userVersion;
@property (nonatomic, assign) SFSQLiteSynchronousMode synchronousMode;
@property (nonatomic, readonly) BOOL isOpen;
@property (nonatomic, readonly) BOOL hasMigrated;
@property (nonatomic, assign) BOOL shouldVacuum; @property (nonatomic, assign) BOOL traced;
@property (nonatomic, strong) id<SFSQLiteDelegate> delegate;
#if DEBUG
@property (nonatomic, strong) NSDictionary* unitTestOverrides;
#endif
- (void)open;
- (BOOL)openWithError:(NSError **)error;
- (void)close;
- (void)remove;
- (void)begin;
- (void)end;
- (void)rollback;
- (void)analyze;
- (void)vacuum;
- (void)raise:(NSString *)format, ... NS_FORMAT_FUNCTION(1, 2);
- (SFSQLiteRowID)lastInsertRowID;
- (int)changes;
- (void)executeSQL:(NSString *)format, ... NS_FORMAT_FUNCTION(1, 2);
- (void)executeSQL:(NSString *)format arguments:(va_list)args NS_FORMAT_FUNCTION(1, 0);
- (SFSQLiteStatement *)statementForSQL:(NSString *)SQL;
- (void)removeAllStatements;
- (NSArray *)allTableNames;
- (void)dropAllTables;
- (NSString *)propertyForKey:(NSString *)key;
- (void)setProperty:(NSString *)value forKey:(NSString *)key;
- (NSDate *)datePropertyForKey:(NSString *)key;
- (void)setDateProperty:(NSDate *)value forKey:(NSString *)key;
- (void)removePropertyForKey:(NSString *)key;
- (NSDate *)creationDate;
- (NSArray *)selectAllFrom:(NSString *)tableName where:(NSString *)whereSQL bindings:(NSArray *)bindings;
- (NSArray *)select:(NSArray *)columns from:(NSString *)tableName;
- (NSArray *)select:(NSArray *)columns from:(NSString *)tableName where:(NSString *)whereSQL bindings:(NSArray *)bindings;
- (void)select:(NSArray *)columns from:(NSString *)tableName where:(NSString *)whereSQL bindings:(NSArray *)bindings orderBy:(NSArray *)orderBy limit:(NSNumber *)limit block:(void (^)(NSDictionary *resultDictionary, BOOL *stop))block;
- (void)selectFrom:(NSString *)tableName where:(NSString *)whereSQL bindings:(NSArray *)bindings orderBy:(NSArray *)orderBy limit:(NSNumber *)limit block:(void (^)(NSDictionary *resultDictionary, BOOL *stop))block;
- (NSUInteger)selectCountFrom:(NSString *)tableName where:(NSString *)whereSQL bindings:(NSArray *)bindings;
- (SFSQLiteRowID)insertOrReplaceInto:(NSString *)tableName values:(NSDictionary *)valuesByColumnName;
- (void)deleteFrom:(NSString *)tableName where:(NSString *)whereSQL bindings:(NSArray *)bindings;
- (void)update:(NSString *)tableName set:(NSString *)setSQL where:(NSString *)whereSQL bindings:(NSArray *)whereBindings limit:(NSNumber *)limit;
- (void)deleteFrom:(NSString *)tableName matchingValues:(NSDictionary *)valuesByColumnName;
- (NSSet<NSString*> *)columnNamesForTable:(NSString*)tableName;
- (SInt32)dbUserVersion;
@end