3 struct BlockerParserStrategy: MapParserStrategy {
4 private let regex = MapParsingPatterns.blocker
6 func canHandle(line: String) -> Bool {
7 let range = NSRange(location: 0, length: line.utf16.count)
8 let matches = regex.matches(in: String(line), options: [], range: range)
9 return matches.count > 0 && matches[0].numberOfRanges == 3
12 func handle(index: Int, line: String, vertices: [String: Vertex]) -> (Any.Type, Any) {
13 let range = NSRange(location: 0, length: line.utf16.count)
14 let matches = regex.matches(in: String(line), options: [], range: range)
16 let match = matches[0]
17 let vertexA = String(line[Range(match.range(at: 2), in: line)!])
19 if let vertex = vertices[vertexA] {
20 let blocker = Blocker(id: index, position: vertex.position)
21 return (Blocker.self, blocker)
24 return (NSObject.self, NSObject()) // No matching object