mirror of
https://github.com/zxing/zxing.git
synced 2024-11-11 21:44:07 -08:00
ee44225e3d
git-svn-id: https://zxing.googlecode.com/svn/trunk@478 59b500cc-1b3d-0410-9834-0bbf25fbcc57
48 lines
1.1 KiB
Objective-C
48 lines
1.1 KiB
Objective-C
//
|
|
// EmailDoCoMoResultParser.m
|
|
// ZXing
|
|
//
|
|
// Created by Christian Brunschen on 25/06/2008.
|
|
// Copyright 2008 Google Inc. All rights reserved.
|
|
//
|
|
|
|
#import "EmailDoCoMoResultParser.h"
|
|
#import "EmailParsedResult.h"
|
|
|
|
bool LooksLikeAnEmailAddress(NSString *s) {
|
|
if ([s rangeOfString:@"@"].location == NSNotFound) {
|
|
return false;
|
|
}
|
|
if ([s rangeOfString:@"."].location == NSNotFound) {
|
|
return false;
|
|
}
|
|
if ([s rangeOfCharacterFromSet:[NSCharacterSet whitespaceCharacterSet]].location != NSNotFound) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
@implementation EmailDoCoMoResultParser
|
|
|
|
+ (ParsedResult *)parsedResultForString:(NSString *)s {
|
|
NSRange foundRange = [s rangeOfString:@"MATMSG:"];
|
|
if (foundRange.location == NSNotFound) {
|
|
return nil;
|
|
}
|
|
|
|
NSString *to = [s fieldWithPrefix:@"TO:"];
|
|
if (to == nil) {
|
|
return nil;
|
|
}
|
|
|
|
EmailParsedResult *result = [[EmailParsedResult alloc] init];
|
|
result.to = to;
|
|
result.subject = [s fieldWithPrefix:@"SUB:"];
|
|
result.body = [s fieldWithPrefix:@"BODY:"];
|
|
|
|
return [result autorelease];
|
|
}
|
|
|
|
@end
|