mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
[iphone/ZXingWidget] ZXingWidget alignment with what is used in Barcodes. This was not committed before by mistake.
git-svn-id: https://zxing.googlecode.com/svn/trunk@1665 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
82b2edd5a7
commit
29dce2a397
|
@ -10,11 +10,11 @@
|
||||||
#import "ResultParser.h"
|
#import "ResultParser.h"
|
||||||
|
|
||||||
@interface UniversalResultParser : ResultParser {
|
@interface UniversalResultParser : ResultParser {
|
||||||
NSMutableArray *parsers;
|
//NSMutableArray *parsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property(nonatomic,retain) NSMutableArray *parsers;
|
//@property(nonatomic,retain) NSMutableArray *parsers;
|
||||||
|
|
||||||
- (id) initWithDefaultParsers;
|
+ (void)initWithDefaultParsers;
|
||||||
- (ParsedResult *)resultForString:(NSString *)theString;
|
+ (ParsedResult *)parsedResultForString:(NSString *)theString;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -20,17 +20,31 @@
|
||||||
#import "TextResultParser.h"
|
#import "TextResultParser.h"
|
||||||
|
|
||||||
@implementation UniversalResultParser
|
@implementation UniversalResultParser
|
||||||
@synthesize parsers;
|
static NSMutableArray *sTheResultParsers = nil;
|
||||||
|
//@synthesize parsers;
|
||||||
|
|
||||||
- (void)addParserClass:(Class)klass {
|
//static NSMutableSet *sResultParsers = nil;
|
||||||
[self.parsers addObject:klass];
|
+(void) load {
|
||||||
|
[self initWithDefaultParsers];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithDefaultParsers {
|
+ (void)addParserClass:(Class)klass {
|
||||||
NSMutableArray *set = [[NSMutableArray alloc] initWithCapacity:11];
|
[sTheResultParsers addObject:klass];
|
||||||
self.parsers = set;
|
}
|
||||||
[set release];
|
|
||||||
|
+ (void) initWithDefaultParsers {
|
||||||
|
// NSMutableArray *set = [[NSMutableArray alloc] initWithCapacity:11];
|
||||||
|
// self.parsers = set;
|
||||||
|
// [set release];
|
||||||
|
//
|
||||||
|
|
||||||
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
@synchronized(self) {
|
||||||
|
if (!sTheResultParsers) {
|
||||||
|
sTheResultParsers = [[NSMutableArray alloc] init];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[pool release];
|
||||||
[self addParserClass:[SMSResultParser class]];
|
[self addParserClass:[SMSResultParser class]];
|
||||||
[self addParserClass:[TelResultParser class]];
|
[self addParserClass:[TelResultParser class]];
|
||||||
[self addParserClass:[SMSTOResultParser class]];
|
[self addParserClass:[SMSTOResultParser class]];
|
||||||
|
@ -42,14 +56,13 @@
|
||||||
[self addParserClass:[BookmarkDoCoMoResultParser class]];
|
[self addParserClass:[BookmarkDoCoMoResultParser class]];
|
||||||
[self addParserClass:[GeoResultParser class]];
|
[self addParserClass:[GeoResultParser class]];
|
||||||
[self addParserClass:[TextResultParser class]];
|
[self addParserClass:[TextResultParser class]];
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ParsedResult *)resultForString:(NSString *)s {
|
+ (ParsedResult *)parsedResultForString:(NSString *)s {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
NSLog(@"parsing result:\n<<<\n%@\n>>>\n", s);
|
NSLog(@"parsing result:\n<<<\n%@\n>>>\n", s);
|
||||||
#endif
|
#endif
|
||||||
for (Class c in parsers) {
|
for (Class c in sTheResultParsers) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
NSLog(@"trying %@", NSStringFromClass(c));
|
NSLog(@"trying %@", NSStringFromClass(c));
|
||||||
#endif
|
#endif
|
||||||
|
@ -66,7 +79,6 @@
|
||||||
|
|
||||||
|
|
||||||
-(void)dealloc {
|
-(void)dealloc {
|
||||||
[parsers release];
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in a new issue