-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCSVFileParser.h
107 lines (76 loc) · 3 KB
/
CSVFileParser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//
// CSVFileParser.h
// CSV Touch
//
// Created by Simon Wigzell on 03/06/2008.
// Copyright 2008 Ozymandias. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "OzymandiasAdditions.h"
#import "CSVRow.h"
#define DEFAULT_ENCODING 0
@interface CSVFileParser : NSObject {
}
@property (nonatomic, strong) NSMutableArray<CSVRow*> *parsedItems;
@property (nonatomic, strong) NSMutableArray *columnNames;
@property (nonatomic, strong) NSMutableIndexSet *predefineHiddenColumns; // Just used temporary, for a newly downloaded file
@property (nonatomic, assign) int *rawShownColumnIndexes;
@property (nonatomic, strong) NSMutableArray *shownColumnIndexes;
@property (nonatomic, copy) NSString *filePath;
@property (nonatomic, copy) NSString *URL;
@property (nonatomic, copy) NSDate *downloadDate;
@property (nonatomic, readonly) NSString *rawString;
@property (nonatomic, copy) NSString *problematicRow;
@property (nonatomic, assign) BOOL hasBeenParsed;
@property (nonatomic, assign) BOOL hasBeenDownloaded;
@property (nonatomic, assign) BOOL hasFailedToDownload;
@property BOOL isSorted;
@property (nonatomic, assign) NSUInteger iconIndex;
@property (nonatomic, assign) BOOL hideAddress;
// All currently avaialbe files sorted using file name
+ (NSMutableArray *) files;
+ (void) removeAllFiles;
+ (void) removeFile:(CSVFileParser *)parser;
+ (void) removeFileWithName:(NSString *) name;
+ (BOOL) fileExistsWithURL:(NSString *)URL;
+ (void) saveColumnNames;
+ (CSVFileParser *) addParserWithRawData:(NSData *)data forFilePath:(NSString *)path fileURL:(NSString *)URL;
+ (void) loadParserFromFilePath:(NSString *)path;
+ (CSVFileParser *) existingParserForName:(NSString *)name;
+ (void) resetClearingOfDownloadFlagsTimer;
+ (void) clearAllDownloadFlags;
+ (void) fixedWidthSettingsChangedUsingUI;
- (void) saveToFile;
- (NSData *) fileRawData;;
- (void) parseIfNecessary;
- (void) reparseIfParsed;
- (void) invalidateShortDescriptions;
- (NSMutableArray *)shownColumnNames;
// Updates the hidden/shown stuff
- (void) updateColumnsInfo;
- (void) updateColumnsInfoWithShownColumns:(NSArray *)shown;
// Will show all columns
- (void) resetColumnsInfo;
// Convenience
- (BOOL) hiddenColumnsExist;
- (void) encodingUpdated;
- (NSString *) fileName;
- (NSUInteger) stringLength;
- (BOOL) downloadedLocally;
- (unichar) delimiter;
- (NSString *) parseErrorString;
+ (NSArray *) allowedFileEncodings; // NSUIntegers
+ (NSArray *) allowedFileEncodingNames;
@end
@interface CSVFileParser (OzyTableViewProtocol) <OzyTableViewObject>
- (NSString *) defaultTableViewDescription;
- (NSComparisonResult) compareFileName:(CSVFileParser *)fp;
@end
@interface CSVFileParser (Preferences)
+ (void) setFileEncoding:(NSStringEncoding)encoding forFile:(NSString *)fileName;
+ (void) removeFileEncodingForFile:(NSString *) fileName;
// Returns an actual good encoding
+ (NSStringEncoding) getEncodingForFile:(NSString *)fileName;
// Returns the actual setting, i.e. possibly DEFAULT_ENCODING
+ (NSUInteger) getEncodingSettingForFile:(NSString *)fileName;
@end