Helper functions for callsign analysis

This commit is contained in:
Bill Somerville 2020-11-11 16:22:57 +00:00
parent 714a71c43a
commit dd954be1ab
No known key found for this signature in database
GPG Key ID: D864B06D1E81618F
2 changed files with 13 additions and 0 deletions

View File

@ -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)

View File

@ -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);
}