• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

あれとこれのコンバータ


Commit MetaInfo

Revision8ece8bbf421226ddce3c4f26df1acff3c279292f (tree)
Time2011-12-03 17:21:11
Authormasakih <masakih@user...>
Commitermasakih

Log Message

Treat source code

ソースコードの整理。

Change Summary

Incremental Difference

--- a/BathyScapheDataConverter/BSDCAppDelegate.m
+++ b/BathyScapheDataConverter/BSDCAppDelegate.m
@@ -71,11 +71,21 @@
7171 return bathyscapheSupportFolderPath;
7272 }
7373
74+
75+- (void)loggingIfNeeded
76+{
77+ SQLiteDB *db = [[DatabaseManager defaultManager]databaseForCurrentThread];
78+ if([db lastErrorID] != SQLITE_OK) {
79+ NSLog(@"%@", [db lastError]);
80+ }
81+}
82+
7483 - (void)updateTime
7584 {
7685 NSDate *now = [NSDate dateWithTimeIntervalSinceNow:0.0];
7786 panel.progressTime = [NSDate dateWithTimeIntervalSince1970:[now timeIntervalSinceDate:startTime] - [[NSTimeZone systemTimeZone] secondsFromGMT]];
7887 }
88+
7989 - (SQLiteReservedQuery *)sqlForInsertion
8090 {
8191 static SQLiteReservedQuery *query = nil;
@@ -141,11 +151,6 @@
141151 return;
142152 }
143153
144-// NSString *sql = [NSString stringWithFormat:@"INSERT INTO %@ ( %@, %@, %@, %@, %@, %@, %@, %@ ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?)",
145-// ThreadInfoTableName,
146-// BoardIDColumn, ThreadIDColumn, ThreadNameColumn, NumberOfAllColumn, NumberOfReadColumn, ModifiedDateColumn, ThreadStatusColumn,
147-// IsDatOchiColumn];
148-
149154 SQLiteReservedQuery *sqlForInsertion = [self sqlForInsertion];
150155 [sqlForInsertion cursorWithFormat:
151156 F_Int F_NSString F_NSString F_NSNumberOfInt F_NSNumberOfInt F_NSNumberOfDouble F_NSNumberOfInt F_NSNumberOfInt,
@@ -191,12 +196,26 @@
191196 }
192197 }
193198
194-- (void)loggingIfNeeded
199+- (void)convertBoardHistories:(NSArray *)boards
195200 {
196- SQLiteDB *db = [[DatabaseManager defaultManager]databaseForCurrentThread];
197- if([db lastErrorID] != SQLITE_OK) {
198- NSLog(@"%@", [db lastError]);
201+ panel.message = @"Converting board histories ...";
202+ DatabaseManager *dm = [DatabaseManager defaultManager];
203+ NSString *sql = [NSString stringWithFormat:@"INSERT INTO %@ (%@, %@, %@) VALUES (?, ?, ?);",
204+ BoardInfoHistoryTableName,
205+ BoardIDColumn, BoardNameColumn, BoardURLColumn];
206+ SQLiteReservedQuery *query = [[SQLiteReservedQuery alloc] initWithQuery:sql
207+ usingSQLiteDB:[[DatabaseManager defaultManager] databaseForCurrentThread]];
208+ for(BSBoardInformationObject *board in boards) {
209+ [self updateTime];
210+ NSUInteger boardID = [dm boardIDForURLString:board.boardURL];
211+ for(BSBoardHistoryObject *hist in board.histories) {
212+ [self updateTime];
213+ [query cursorWithFormat:F_Int F_NSString F_NSString,
214+ boardID, hist.boardName, hist.boardURL];
215+ [self loggingIfNeeded];
216+ }
199217 }
218+ [query release];
200219 }
201220
202221 - (void)doConvertToSQLite
@@ -224,25 +243,7 @@
224243 [self updateTime];
225244
226245 pool = [[NSAutoreleasePool alloc] init];
227- panel.message = @"Converting board histories ...";
228- DatabaseManager *dm = [DatabaseManager defaultManager];
229- NSString *sql = [NSString stringWithFormat:@"INSERT INTO %@ (%@, %@, %@) VALUES (?, ?, ?);",
230- BoardInfoHistoryTableName,
231- BoardIDColumn, BoardNameColumn, BoardURLColumn];
232- SQLiteReservedQuery *query = [[SQLiteReservedQuery alloc] initWithQuery:sql
233- usingSQLiteDB:[[DatabaseManager defaultManager] databaseForCurrentThread]];
234- for(BSBoardInformationObject *board in boards) {
235- [self updateTime];
236- NSUInteger boardID = [dm boardIDForURLString:board.boardURL];
237- for(BSBoardHistoryObject *hist in board.histories) {
238- [self updateTime];
239- [query cursorWithFormat:F_Int F_NSString F_NSString,
240- boardID, hist.boardName, hist.boardURL];
241- [self loggingIfNeeded];
242- }
243- }
244- [query release];
245-
246+ [self convertBoardHistories:boards];
246247 panel.amount = 0;
247248 panel.count = 0;
248249 [pool release];