소스 검색

Changed some methods to properties. Hello 2011.

August Mueller 14 년 전
부모
커밋
c9c2637200
5개의 변경된 파일31개의 추가작업 그리고 147개의 파일을 삭제
  1. 3 0
      CHANGES_AND_TODO_LIST.txt
  2. 12 30
      src/FMDatabase.h
  3. 10 82
      src/FMDatabase.m
  4. 3 2
      src/FMResultSet.h
  5. 3 33
      src/FMResultSet.m

+ 3 - 0
CHANGES_AND_TODO_LIST.txt

@@ -3,6 +3,9 @@ Zip, nada, zilch.  Got any ideas?
 
 If you would like to contribute some code- awesome!  I just ask that you make it conform to the coding conventions already set in here, and to add a couple of tests for your new code to fmdb.m.  And of course, the code should be of general use to more than just a couple of folks.  Send your patches to gus@flyingmeat.com.
 
+2011.06.22
+    Changed some methods to properties.  Hello 2011.
+
 2011.04.09
 	Added a method to validate a SQL statement.
 	Added a method to retrieve the number of columns in a result set.

+ 12 - 30
src/FMDatabase.h

@@ -19,6 +19,15 @@
 }
 
 
+@property (assign) BOOL inTransaction;
+@property (assign) BOOL traceExecution;
+@property (assign) BOOL checkedOut;
+@property (assign) int busyRetryTimeout;
+@property (assign) BOOL crashOnErrors;
+@property (assign) BOOL logsErrors;
+@property (retain) NSMutableDictionary *cachedStatements;
+
+
 + (id)databaseWithPath:(NSString*)inPath;
 - (id)initWithPath:(NSString*)inPath;
 
@@ -62,33 +71,13 @@
 - (BOOL)beginTransaction;
 - (BOOL)beginDeferredTransaction;
 
-- (BOOL)logsErrors;
-- (void)setLogsErrors:(BOOL)flag;
-
-- (BOOL)crashOnErrors;
-- (void)setCrashOnErrors:(BOOL)flag;
-
 - (BOOL)inUse;
 - (void)setInUse:(BOOL)value;
 
-- (BOOL)inTransaction;
-- (void)setInTransaction:(BOOL)flag;
-
-- (BOOL)traceExecution;
-- (void)setTraceExecution:(BOOL)flag;
-
-- (BOOL)checkedOut;
-- (void)setCheckedOut:(BOOL)flag;
-
-- (int)busyRetryTimeout;
-- (void)setBusyRetryTimeout:(int)newBusyRetryTimeout;
 
 - (BOOL)shouldCacheStatements;
 - (void)setShouldCacheStatements:(BOOL)value;
 
-- (NSMutableDictionary *)cachedStatements;
-- (void)setCachedStatements:(NSMutableDictionary *)value;
-
 
 + (NSString*)sqliteLibVersion;
 
@@ -102,19 +91,12 @@
     long useCount;
 }
 
+@property (assign) long useCount;
+@property (retain) NSString *query;
+@property (assign) sqlite3_stmt *statement;
 
 - (void)close;
 - (void)reset;
 
-- (sqlite3_stmt *)statement;
-- (void)setStatement:(sqlite3_stmt *)value;
-
-- (NSString *)query;
-- (void)setQuery:(NSString *)value;
-
-- (long)useCount;
-- (void)setUseCount:(long)value;
-
-
 @end
 

+ 10 - 82
src/FMDatabase.m

@@ -2,6 +2,13 @@
 #import "unistd.h"
 
 @implementation FMDatabase
+@synthesize inTransaction;
+@synthesize cachedStatements;
+@synthesize logsErrors;
+@synthesize crashOnErrors;
+@synthesize busyRetryTimeout;
+@synthesize checkedOut;
+@synthesize traceExecution;
 
 + (id)databaseWithPath:(NSString*)aPath {
     return [[[self alloc] initWithPath:aPath] autorelease];
@@ -798,19 +805,7 @@ - (BOOL)beginTransaction {
     return b;
 }
 
-- (BOOL)logsErrors {
-    return logsErrors;
-}
-- (void)setLogsErrors:(BOOL)flag {
-    logsErrors = flag;
-}
 
-- (BOOL)crashOnErrors {
-    return crashOnErrors;
-}
-- (void)setCrashOnErrors:(BOOL)flag {
-    crashOnErrors = flag;
-}
 
 - (BOOL)inUse {
     return inUse || inTransaction;
@@ -820,35 +815,6 @@ - (void)setInUse:(BOOL)b {
     inUse = b;
 }
 
-- (BOOL)inTransaction {
-    return inTransaction;
-}
-- (void)setInTransaction:(BOOL)flag {
-    inTransaction = flag;
-}
-
-- (BOOL)traceExecution {
-    return traceExecution;
-}
-- (void)setTraceExecution:(BOOL)flag {
-    traceExecution = flag;
-}
-
-- (BOOL)checkedOut {
-    return checkedOut;
-}
-- (void)setCheckedOut:(BOOL)flag {
-    checkedOut = flag;
-}
-
-
-- (int)busyRetryTimeout {
-    return busyRetryTimeout;
-}
-- (void)setBusyRetryTimeout:(int)newBusyRetryTimeout {
-    busyRetryTimeout = newBusyRetryTimeout;
-}
-
 
 - (BOOL)shouldCacheStatements {
     return shouldCacheStatements;
@@ -867,23 +833,15 @@ - (void)setShouldCacheStatements:(BOOL)value {
     }
 }
 
-- (NSMutableDictionary *)cachedStatements {
-    return cachedStatements;
-}
-
-- (void)setCachedStatements:(NSMutableDictionary *)value {
-    if (cachedStatements != value) {
-        [cachedStatements release];
-        cachedStatements = [value retain];
-    }
-}
-
 
 @end
 
 
 
 @implementation FMStatement
+@synthesize statement;
+@synthesize query;
+@synthesize useCount;
 
 - (void)finalize {
     [self close];
@@ -896,7 +854,6 @@ - (void)dealloc {
     [super dealloc];
 }
 
-
 - (void)close {
     if (statement) {
         sqlite3_finalize(statement);
@@ -910,35 +867,6 @@ - (void)reset {
     }
 }
 
-- (sqlite3_stmt *)statement {
-    return statement;
-}
-
-- (void)setStatement:(sqlite3_stmt *)value {
-    statement = value;
-}
-
-- (NSString *)query {
-    return query;
-}
-
-- (void)setQuery:(NSString *)value {
-    if (query != value) {
-        [query release];
-        query = [value retain];
-    }
-}
-
-- (long)useCount {
-    return useCount;
-}
-
-- (void)setUseCount:(long)value {
-    if (useCount != value) {
-        useCount = value;
-    }
-}
-
 - (NSString*)description {
     return [NSString stringWithFormat:@"%@ %d hit(s) for query %@", [super description], useCount, query];
 }

+ 3 - 2
src/FMResultSet.h

@@ -25,13 +25,14 @@
     BOOL columnNamesSetup;
 }
 
+@property (retain) NSString *query;
+@property (retain) NSMutableDictionary *columnNameToIndexMap;
+@property (retain) FMStatement *statement;
 
 + (id)resultSetWithStatement:(FMStatement *)statement usingParentDatabase:(FMDatabase*)aDB;
 
 - (void)close;
 
-- (NSString *)query;
-- (void)setQuery:(NSString *)value;
 
 - (FMStatement *)statement;
 - (void)setStatement:(FMStatement *)value;

+ 3 - 33
src/FMResultSet.m

@@ -13,6 +13,9 @@ - (void)setColumnNameToIndexMap:(NSMutableDictionary *)value;
 @end
 
 @implementation FMResultSet
+@synthesize query;
+@synthesize columnNameToIndexMap;
+@synthesize statement;
 
 + (id)resultSetWithStatement:(FMStatement *)statement usingParentDatabase:(FMDatabase*)aDB {
     
@@ -372,37 +375,4 @@ - (void)setParentDB:(FMDatabase *)newDb {
 }
 
 
-- (NSString *)query {
-    return query;
-}
-
-- (void)setQuery:(NSString *)value {
-    [value retain];
-    [query release];
-    query = value;
-}
-
-- (NSMutableDictionary *)columnNameToIndexMap {
-    return columnNameToIndexMap;
-}
-
-- (void)setColumnNameToIndexMap:(NSMutableDictionary *)value {
-    [value retain];
-    [columnNameToIndexMap release];
-    columnNameToIndexMap = value;
-}
-
-- (FMStatement *)statement {
-    return statement;
-}
-
-- (void)setStatement:(FMStatement *)value {
-    if (statement != value) {
-        [statement release];
-        statement = [value retain];
-    }
-}
-
-
-
 @end