diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2023-05-07 15:22:54 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2023-05-07 15:22:54 +0200 |
| commit | fdb4633d3e9158e457d57e820df6e1efb4df39c2 (patch) | |
| tree | 176cad99cb9befc0a65a7af02561019e811814de /Map/MapParser/Strategies/EdgeParserStrategy.swift | |
| parent | 75a0e4509a70055851b085f3f7293ae1cf48164c (diff) | |
Update to support notes + new style2.0.0
Diffstat (limited to 'Map/MapParser/Strategies/EdgeParserStrategy.swift')
| -rw-r--r-- | Map/MapParser/Strategies/EdgeParserStrategy.swift | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/Map/MapParser/Strategies/EdgeParserStrategy.swift b/Map/MapParser/Strategies/EdgeParserStrategy.swift deleted file mode 100644 index 0df1ff4..0000000 --- a/Map/MapParser/Strategies/EdgeParserStrategy.swift +++ /dev/null @@ -1,32 +0,0 @@ -import Foundation - -struct EdgeParserStrategy: MapParserStrategy { - private let regex = MapParsingPatterns.edge - - func canHandle(line: String) -> Bool { - let range = NSRange(location: 0, length: line.utf16.count) - let matches = regex.matches(in: String(line), options: [], range: range) - return matches.count > 0 && matches[0].numberOfRanges == 4 - } - - func handle(index: Int, line: String, vertices: [String: Vertex]) -> (Any.Type, Any) { - let range = NSRange(location: 0, length: line.utf16.count) - let matches = regex.matches(in: String(line), options: [], range: range) - - let match = matches[0] - let arrowhead = String(line[Range(match.range(at: 2), in: line)!]) == ">" - let vertexA = String(line[Range(match.range(at: 1), in: line)!]) - let vertexB = String(line[Range(match.range(at: 3), in: line)!]) - - if let origin = vertices[vertexA] { - if let destination = vertices[vertexB] { - let edge = MapEdge( - id: index, origin: origin.position, destination: destination.position, - arrowhead: arrowhead) - return (MapEdge.self, edge) - } - } - - return (NSObject.self, NSObject()) // No matching object - } -} |