diff --git a/Radio.cpp b/Radio.cpp index e5b34c35d..56b943739 100644 --- a/Radio.cpp +++ b/Radio.cpp @@ -14,10 +14,16 @@ namespace Radio double constexpr MHz_factor {1.e6}; int constexpr frequency_precsion {6}; + // valid callsign alphabet + QRegularExpression callsign_alphabet_re {R"(^[A-Z0-9/]{3,11}$)"}; + // very loose validation - callsign must contain a letter next to // a number QRegularExpression valid_callsign_regexp {R"(\d[[:alpha:]]|[[:alpha:]]\d)"}; + // standard callsign + QRegularExpression strict_standard_callsign_re {R"(^([A-Z][0-9]?|[0-9][A-Z])[0-9][A-Z]{0,3}$)"}; + // suffixes that are often used and should not be interpreted as a // DXCC Entity prefix used as a suffix QRegularExpression non_prefix_suffix {R"(\A([0-9AMPQR]|QRP|F[DF]|[AM]M|L[HT]|LGT)\z)"}; @@ -112,6 +118,12 @@ namespace Radio return callsign.contains ('/'); } + bool is_77bit_nonstandard_callsign (QString const& callsign) + { + return callsign.contains (callsign_alphabet_re) + && !callsign.contains (strict_standard_callsign_re); + } + // split on first '/' and return the larger portion or the whole if // there is no '/' QString base_callsign (QString callsign) diff --git a/Radio.hpp b/Radio.hpp index e63abf4b8..4cc549b8b 100644 --- a/Radio.hpp +++ b/Radio.hpp @@ -53,6 +53,7 @@ namespace Radio // bool UDP_EXPORT is_callsign (QString const&); bool UDP_EXPORT is_compound_callsign (QString const&); + bool is_77bit_nonstandard_callsign (QString const&); QString UDP_EXPORT base_callsign (QString); QString UDP_EXPORT effective_prefix (QString); }