From 505b23afc68ecbb63b8f0a7d44c0b0ad063d5cfd Mon Sep 17 00:00:00 2001 From: Arturs Artamonovs Date: Thu, 24 Sep 2026 11:02:35 +0100 Subject: rearrange source, move common parts to framework --- ADSBDecoderFramework/ADSBRegEx.swift | 87 ++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 ADSBDecoderFramework/ADSBRegEx.swift (limited to 'ADSBDecoderFramework/ADSBRegEx.swift') diff --git a/ADSBDecoderFramework/ADSBRegEx.swift b/ADSBDecoderFramework/ADSBRegEx.swift new file mode 100644 index 0000000..2841467 --- /dev/null +++ b/ADSBDecoderFramework/ADSBRegEx.swift @@ -0,0 +1,87 @@ +// +// ADSBRegEx.swift +// ADSBDecoder +// +// Created by Jacky Jack on 30/06/2024. +// + +import Foundation +import RegexBuilder +/* +let matchADSBLong = Regex { + Anchor.startOfLine + "*" + + Repeat( + CharacterClass( + ("a"..."f"), + ("0"..."9") + ) + ,count:28) + + ";" +}*/ +class MatchADSBLong { + let matchADSBLong = Regex { + Anchor.startOfLine + "*" + + Repeat( + CharacterClass( + ("a"..."f"), + ("0"..."9") + ) + ,count:28) + + ";" + } + + func prefixMatch(_ line: String) -> Regex.RegexOutput>.Match? { + do { + if let match = try matchADSBLong.prefixMatch(in: line) { + return match + } + } catch { + return nil + } + return nil + } +} + +/* +let matchADSBShort = Regex { + Anchor.startOfLine + "*" + Repeat( + CharacterClass( + ("a"..."f"), + ("0"..."9") + ) + ,count:14) + ";" +}*/ + +class MatchADSBShort { + let matchADSBShort = Regex { + Anchor.startOfLine + "*" + Repeat( + CharacterClass( + ("a"..."f"), + ("0"..."9") + ) + ,count:14) + ";" + } + + func prefixMatch(_ line: String) -> Regex.RegexOutput>.Match? { + do { + if let match = try matchADSBShort.prefixMatch(in: line) { + return match + } + } catch { + return nil + } + return nil + } +} -- cgit v1.2.3