• R/O
  • HTTP
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

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

iSightを使ってBooklog,MediaMarkerインポート用CSVファイルを生成するアプリ


Commit MetaInfo

修订版9d9cd92214c46ec293ddf301d09383716939947f (tree)
时间2011-03-01 00:57:08
作者masakih <masakih@user...>
Commitermasakih

Log Message

[New] MediaMarkerExporterを追加。役割の意味を逆転。

更改概述

差异

--- a/BEBooklogBooksExporter.m
+++ b/BEBooklogBooksExporter.m
@@ -11,63 +11,4 @@
1111
1212
1313 @implementation BEBooklogBooksExporter
14-- (NSString *)statusNameWithBook:(MyBookInformation *)book
15-{
16- NSString *result = nil;
17- switch([book.status intValue]) {
18- case 0:
19- result = NSLocalizedString(@"MIDOKU", @"MIDOKU");
20- break;
21- case 1:
22- result = @"-";
23- break;
24- case 2:
25- result = NSLocalizedString(@"DOKUCHUU", @"DOKUCHUU");
26- break;
27- case 3:
28- result = NSLocalizedString(@"DOKURYOU", @"DOKURYOU");
29- break;
30- case 4:
31- result = @"=";
32- break;
33- default:
34- return @"";
35- }
36- return result;
37-}
38-- (BOOL)exportToURL:(NSURL *)url
39-{
40- NSMutableArray *array = [NSMutableArray array];
41- NSDateFormatter *dateFormatter01 = [[[NSDateFormatter alloc] init] autorelease];
42- [dateFormatter01 setDateFormat:@"YYYY/MM/dd' 'HH':'mm"];
43- NSDateFormatter *dateFormatter02 = [[[NSDateFormatter alloc] init] autorelease];
44- [dateFormatter02 setDateFormat:@"YYYY/MM/dd"];
45- for(MyBookInformation *book in books) {
46- NSString *line = [NSString stringWithFormat:@"\"%@\",\"%@\",\"%@\",\"%@\",\"%@\",\"%@\",\"%@\",\"%@\"",
47- doubleQuoteQuotedString(book.category),
48- doubleQuoteQuotedString(book.asin),
49- doubleQuoteQuotedString([dateFormatter01 stringFromDate:book.registerDate]),
50- doubleQuoteQuotedString(tagsString(book.tags)),
51- doubleQuoteQuotedString(book.review),
52- doubleQuoteQuotedString([book.rating stringValue]),
53- doubleQuoteQuotedString([self statusNameWithBook:book]),
54- doubleQuoteQuotedString([dateFormatter02 stringFromDate:book.readDate])];
55- [array addObject:line];
56- }
57- if([array count] == 0) return NO;
58-
59- NSString *lines = [array componentsJoinedByString:@"\r\n"];
60- NSError *error = nil;
61- BOOL isOK = NO;
62- isOK = [lines writeToURL:url atomically:YES encoding:NSShiftJISStringEncoding error:&error];
63- if(!isOK) {
64- NSString *errorString = nil;
65- if(error) {
66- errorString = [error localizedDescription];
67- }
68- NSLog(@"Error exporting -> %@", errorString);
69- return NO;
70- }
71- return YES;
72-}
7314 @end
--- /dev/null
+++ b/BEMediaMarkerBooksExporter.h
@@ -0,0 +1,13 @@
1+//
2+// BEMediaMarkerBooksExporter.h
3+// BooksExporter
4+//
5+// Created by Hori,Masaki on 11/03/01.
6+// Copyright 2011 masakih. All rights reserved.
7+//
8+
9+#import <Cocoa/Cocoa.h>
10+#import "BEBooksExporter.h"
11+
12+@interface BEMediaMarkerBooksExporter : BEBooksExporter
13+@end
--- /dev/null
+++ b/BEMediaMarkerBooksExporter.m
@@ -0,0 +1,74 @@
1+//
2+// BEMediaMarkerBooksExporter.m
3+// BooksExporter
4+//
5+// Created by Hori,Masaki on 11/03/01.
6+// Copyright 2011 masakih. All rights reserved.
7+//
8+
9+#import "BEMediaMarkerBooksExporter.h"
10+#import "MyBookInformation.h"
11+
12+
13+@implementation BEMediaMarkerBooksExporter
14+- (NSString *)statusNameWithBook:(MyBookInformation *)book
15+{
16+ NSString *result = nil;
17+ switch([book.status intValue]) {
18+ case 0:
19+ result = NSLocalizedString(@"MIDOKU", @"MIDOKU");
20+ break;
21+ case 1:
22+ result = @"-";
23+ break;
24+ case 2:
25+ result = NSLocalizedString(@"DOKUCHUU", @"DOKUCHUU");
26+ break;
27+ case 3:
28+ result = NSLocalizedString(@"DOKURYOU", @"DOKURYOU");
29+ break;
30+ case 4:
31+ result = @"=";
32+ break;
33+ default:
34+ return @"";
35+ }
36+ return result;
37+}
38+- (BOOL)exportToURL:(NSURL *)url
39+{
40+ NSMutableArray *array = [NSMutableArray array];
41+ NSDateFormatter *dateFormatter01 = [[[NSDateFormatter alloc] init] autorelease];
42+ [dateFormatter01 setDateFormat:@"YYYY/MM/dd' 'HH':'mm"];
43+ NSDateFormatter *dateFormatter02 = [[[NSDateFormatter alloc] init] autorelease];
44+ [dateFormatter02 setDateFormat:@"YYYY/MM/dd"];
45+ for(MyBookInformation *book in books) {
46+ NSString *line = [NSString stringWithFormat:@"\"%@\",\"%@\",\"%@\",\"%@\",\"%@\",\"%@\",\"%@\",\"%@\"",
47+ doubleQuoteQuotedString(book.category),
48+ doubleQuoteQuotedString(book.asin),
49+ doubleQuoteQuotedString([dateFormatter01 stringFromDate:book.registerDate]),
50+ doubleQuoteQuotedString(tagsString(book.tags)),
51+ doubleQuoteQuotedString(book.review),
52+ doubleQuoteQuotedString([book.rating stringValue]),
53+ doubleQuoteQuotedString([self statusNameWithBook:book]),
54+ doubleQuoteQuotedString([dateFormatter02 stringFromDate:book.readDate])];
55+ [array addObject:line];
56+ }
57+ if([array count] == 0) return NO;
58+
59+ NSString *lines = [array componentsJoinedByString:@"\r\n"];
60+ NSError *error = nil;
61+ BOOL isOK = NO;
62+ isOK = [lines writeToURL:url atomically:YES encoding:NSShiftJISStringEncoding error:&error];
63+ if(!isOK) {
64+ NSString *errorString = nil;
65+ if(error) {
66+ errorString = [error localizedDescription];
67+ }
68+ NSLog(@"Error exporting -> %@", errorString);
69+ return NO;
70+ }
71+ return YES;
72+}
73+
74+@end