swift
Loading...
Searching...
No Matches
selcal.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_MISC_AVIATION_SELCAL_H
7#define SWIFT_MISC_AVIATION_SELCAL_H
8
9#include <QChar>
10#include <QList>
11#include <QMetaType>
12#include <QString>
13
14#include "misc/metaclass.h"
16#include "misc/valueobject.h"
17
18SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::aviation, CSelcal)
19namespace swift::misc::physical_quantities
20{
21 class CFrequency;
22}
23namespace swift::misc::aviation
24{
30 class SWIFT_MISC_EXPORT CSelcal : public CValueObject<CSelcal>
31 {
32 public:
34 CSelcal() = default;
35
37 CSelcal(const QString &code) : m_code(unifyCode(code)) {}
38
40 CSelcal(const char *code) : m_code(unifyCode(code)) {}
41
43 bool isValid() const { return isValidCode(m_code); }
44
46 const QString &getCode() const { return m_code; }
47
50 QList<physical_quantities::CFrequency> getFrequencies() const;
51
53 bool equalsString(const QString &code) const;
54
56 QString convertToQString(bool i18n = false) const;
57
59 static const QString &validCharacters();
60
62 static bool isValidCharacter(QChar c);
63
65 static bool isValidCode(const QString &code);
66
68 static const QStringList &codePairs();
69
71 static QString unifyCode(const QString &selcalCandidate);
72
73 private:
75 static const physical_quantities::CFrequency &audioFrequencyEquivalent(QChar c);
76
78 static const QList<physical_quantities::CFrequency> &audioFrequencyEquivalents();
79
80 QString m_code;
81
83 CSelcal,
84 SWIFT_METAMEMBER(code));
85 };
86} // namespace swift::misc::aviation
87
88Q_DECLARE_METATYPE(swift::misc::aviation::CSelcal)
89
90#endif // SWIFT_MISC_AVIATION_SELCAL_H
Value object for SELCAL.
Definition selcal.h:31
static QString unifyCode(const QString &selcalCandidate)
Unify SELCAL code by removing illegal characters.
Definition selcal.cpp:21
bool isValid() const
Is valid?
Definition selcal.h:43
CSelcal()=default
Default constructor.
CSelcal(const char *code)
Constructor needed to disambiguate implicit conversion from string literal.
Definition selcal.h:40
CSelcal(const QString &code)
Constructor.
Definition selcal.h:37
const QString & getCode() const
Get SELCAL code.
Definition selcal.h:46
static bool isValidCode(const QString &code)
Valid SELCAL code?
Definition selcal.cpp:60
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition metaclass.h:72
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition metaclass.h:52
#define SWIFT_MISC_EXPORT
Export a class or function from the library.
#define SWIFT_DECLARE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template declaration of mixins for a CValueObject subclass to be placed near the top of the ...
Definition valueobject.h:65