13 using namespace swift::misc::physical_quantities;
17 namespace swift::misc::aviation
19 QString CSelcal::convertToQString(
bool )
const {
return m_code; }
24 for (
QChar c : selcalCandidate)
26 if (CSelcal::isValidCharacter(c)) { s += c; }
28 return CSelcal::isValidCode(s) ? s :
QString();
31 bool CSelcal::equalsString(
const QString &code)
const
33 if (code.
isEmpty())
return false;
40 if (!CSelcal::isValidCode(m_code))
return f;
42 for (
int pos = 0; pos < m_code.length(); pos++) { f.
append(CSelcal::audioFrequencyEquivalent(m_code.at(pos))); }
48 static const QString valid =
"ABCDEFGHJKLMPQRS";
54 bool CSelcal::isValidCode(
const QString &code)
56 if (code.
length() != 4)
return false;
59 if ((p1 = CSelcal::validCharacters().indexOf(codeUpper.
at(0))) < 0)
return false;
60 if ((p2 = CSelcal::validCharacters().indexOf(codeUpper.
at(1))) < 0)
return false;
61 if ((p3 = CSelcal::validCharacters().indexOf(codeUpper.
at(2))) < 0)
return false;
62 if ((p4 = CSelcal::validCharacters().indexOf(codeUpper.
at(3))) < 0)
return false;
63 if (p1 >= p2 || p3 >= p4)
return false;
64 if (p1 == p3 || p2 == p3 || p2 == p4 || p3 == p4)
71 int pos = CSelcal::validCharacters().indexOf(c);
73 Q_ASSERT(CSelcal::audioFrequencyEquivalents().size() > pos);
74 return CSelcal::audioFrequencyEquivalents()[pos];
96 for (
int p1 = 0; p1 < (CSelcal::validCharacters().length() - 1); p1++)
98 for (
int p2 = p1 + 1; p2 < CSelcal::validCharacters().length(); p2++)
101 pair.
append(CSelcal::validCharacters().at(p1)).append(CSelcal::validCharacters().at(p2));
111 static const QStringList allCodePairs = private_ns::selcalCodePairs();
static CFrequencyUnit Hz()
Hertz.
char32_t toUpper(char32_t ucs4)
void append(QList< T > &&value)
void reserve(qsizetype size)
QString & append(QChar ch)
const QChar at(qsizetype position) const const
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
qsizetype length() const const
QString toUpper() const const
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.