swift
airporticaocode.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_AIRPORTICAOCODE_H
7 #define SWIFT_MISC_AVIATION_AIRPORTICAOCODE_H
8 
9 #include <tuple>
10 
11 #include <QMetaType>
12 #include <QString>
13 
14 #include "misc/metaclass.h"
15 #include "misc/propertyindexref.h"
16 #include "misc/swiftmiscexport.h"
17 #include "misc/valueobject.h"
18 
19 SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::aviation, CAirportIcaoCode)
20 
21 namespace swift::misc::aviation
22 {
24  class SWIFT_MISC_EXPORT CAirportIcaoCode : public CValueObject<CAirportIcaoCode>
25  {
26  public:
29 
31  CAirportIcaoCode(const QString &icaoCode) : m_icaoCode(CAirportIcaoCode::unifyAirportCode(icaoCode)) {}
32 
34  CAirportIcaoCode(const char *icaoCode) : m_icaoCode(CAirportIcaoCode::unifyAirportCode(icaoCode)) {}
35 
37  bool isEmpty() const { return this->m_icaoCode.isEmpty(); }
38 
40  bool hasValidIcaoCode(bool strict) const;
41 
43  const QString &asString() const { return this->m_icaoCode; }
44 
46  QString getIcaoCode() const { return m_icaoCode; }
47 
49  bool equalsString(const QString &icaoCode) const;
50 
52  static QString unifyAirportCode(const QString &icaoCode);
53 
55  static bool isValidIcaoDesignator(const QString &icaoCode, bool strict);
56 
58  static bool containsNumbers(const QString &icaoCode);
59 
61  QString convertToQString(bool i18n = false) const;
62 
64  QVariant propertyByIndex(CPropertyIndexRef index) const;
65 
67  void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
68 
70  int comparePropertyByIndex(CPropertyIndexRef index, const CAirportIcaoCode &compareValue) const;
71 
73  static bool validCodeLength(int l, bool strict);
74 
75  private:
76  QString m_icaoCode;
77 
81  };
82 } // namespace swift::misc::aviation
83 
85 
86 #endif // SWIFT_MISC_AVIATION_AIRPORTICAOCODE_H
Non-owning reference to a CPropertyIndex with a subset of its features.
Mix of the most commonly used mixin classes.
Definition: valueobject.h:114
Value object encapsulating information of airport ICAO data.
CAirportIcaoCode(const char *icaoCode)
Constructor, needed to disambiguate implicit conversion from string literal.
QString getIcaoCode() const
Get ICAO code.
const QString & asString() const
Get code.
CAirportIcaoCode(const QString &icaoCode)
Constructor.
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition: metaclass.h:73
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition: metaclass.h:53
@ CaseInsensitiveComparison
Element will be compared case insensitively (must be a QString)
Definition: metaclass.h:207
#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