00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef JDDATABASEMANAGER_H
00010 #define JDDATABASEMANAGER_H
00011
00012 #import <Foundation/Foundation.h>
00013 #import <sqlite3.h>
00014
00015 #define DATABASEDEBUGON 0
00016
00019 enum JDDATATYPE {
00020 JDDATA_STRING,
00021 JDDATA_INTEGER,
00022 JDDATA_TEXT,
00023 JDDATA_REAL,
00024 JDDATA_RAWSTRING
00025 };
00026
00028 enum JDATAORDER {
00029 JDATAORDER_ASC,
00030 JDATAORDER_DESC
00031 };
00032
00033 @interface JDFieldArray : NSArray
00034
00035 -(BOOL) addGetField:(NSString *)fieldName withType:(enum JDDATATYPE)dataType;
00036
00037 -(BOOL) addSetField:(NSString *)fieldName
00038 withValue:(NSObject *)value withType:(enum JDDATATYPE)dataType;
00039
00040 -(unsigned long) size;
00041
00042 -(NSString *) getFieldAt:(unsigned long)index;
00043
00044 -(NSObject *) getValueAt:(unsigned long)index;
00045
00046 -(long) getTypeAt: (unsigned long)index;
00047
00048 -(NSObject *) getValueFor:(NSString *)field;
00049
00050 -(void) changeValueFor:(NSString *)field toObject:(NSObject *)object;
00051
00052 -(NSInteger) count;
00053
00054 @end
00055
00056
00057 @interface JDDatabaseManager : NSObject
00058 -(instancetype)initWithDatabaseFilename:(NSString *)dbFilename;
00059
00060
00061
00062 -(instancetype)init;
00063
00064 -(sqlite3 *)getAppCoreDB;
00065
00066 -(sqlite3 *)getDatabase: (NSString *)databaseName;
00067
00068 -(BOOL) setAppCoreEntry: (NSString *)opt withValue:(NSString *)value
00069 andEnable:(BOOL)enabled;
00070
00071 -(BOOL) addAppCoreEntry: (NSString *)opt withValue:(NSString *)value
00072 andEnable:(BOOL)enabled;
00073
00074 -(NSString *) getAppCoreEntry: (NSString *)opt;
00075
00076 -(BOOL) removeAppCoreDatabase;
00077
00078 -(BOOL) removeDatabase: (NSString *)databaseName;
00079
00080 -(BOOL) createTable: (NSString *)tableName withFields:(NSArray *)fields;
00081
00082 -(BOOL) setEntries:(JDFieldArray *)opts
00083 inTable:(NSString *)table
00084 whereField:(NSString *)field
00085 isEqualTo:(NSObject *)testObj
00086 ofType:(enum JDDATATYPE)dataType;
00087
00088 -(BOOL) setEntries:(JDFieldArray *)opts
00089 inTable:(NSString *)table
00090 whereField:(NSString *)field
00091 isEqualTo:(NSObject *)testObj
00092 ofType:(enum JDDATATYPE)dataType
00093 withID:(NSNumber *)entryID;
00094
00095 -(BOOL) addEntries: (JDFieldArray *)opts inTable:(NSString *)table;
00096
00097 -(NSMutableArray *) getEntries:(JDFieldArray *)opts inTable:(NSString *)table;
00098
00099 -(NSMutableArray *) getEntries: (JDFieldArray *)opts
00100 inTable:(NSString *)table
00101 whereField:(NSString *)field
00102 isEqualTo:(NSObject *)testObj
00103 ofType:(enum JDDATATYPE)dataType;
00104
00105 -(NSMutableArray *) getEntries: (JDFieldArray *)opts
00106 inTable:(NSString *)table
00107 whereField:(NSString *)field
00108 isEqualTo:(NSObject *)testObj
00109 ofType:(enum JDDATATYPE)dataType
00110 withLimit:(int)limit;
00111
00112
00113 -(NSMutableArray *) getEntries: (JDFieldArray *)opts
00114 inTable:(NSString *)table
00115 whereField:(NSString *)field
00116 isEqualTo:(NSObject *)testObj
00117 ofType:(enum JDDATATYPE)dataType
00118 withLimit:(int)limit
00119 withOrder:(enum JDATAORDER)orderType
00120 orderColumn:(NSString *)orderColumn
00121 groupColumn:(NSString *)groupColumn;
00122
00123 -(NSMutableArray *)getEntries:(JDFieldArray *)opts
00124 inTable:(NSString *)table
00125 whereField:(NSString *)field
00126 isEqualTo:(NSObject *)equalObj
00127 ofType:(enum JDDATATYPE)equalType
00128 isLikeTo:(NSObject *)likeObj
00129 ofType:(enum JDDATATYPE)likeType;
00130
00131
00132
00133 extern NSString * const AppCoreDB;
00134
00135 @end
00136
00137 #endif