Go to the source code of this file.
◆ OOParseRolesFromString()
static NSDictionary * OOParseRolesFromString |
( |
NSString * | string | ) |
|
Definition at line 290 of file GetMetadataForFile.m.
291{
292 NSMutableDictionary *result =
nil;
293 NSArray *tokens =
nil;
295 NSString *role =
nil;
296 float probability;
297 NSScanner *scanner =
nil;
298
299
300 if (
string ==
nil)
return nil;
301
305
306 result = [NSMutableDictionary dictionaryWithCapacity:
count];
307
308
309 for (i = 0; i !=
count; ++i)
310 {
311 role = [tokens objectAtIndex:i];
312
313 probability = 1.0f;
314 if ([role rangeOfString:@"("].location != NSNotFound)
315 {
316 scanner = [[NSScanner alloc] initWithString:role];
317 [scanner scanUpToString:@"(" intoString:&role];
318 [scanner scanString:@"(" intoString:NULL];
319 if (![scanner scanFloat:&probability]) probability = 1.0f;
320
321 }
322
323
324 if (0 <= probability && ![role hasPrefix:@"["])
325 {
326 [result setObject:[NSNumber numberWithFloat:probability] forKey:role];
327 }
328 }
329
330 if ([result
count] == 0) result =
nil;
331 return result;
332}
References count, nil, and ScanTokensFromString().