swift
countrylist.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2015 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_COUNTRYLIST_H
7 #define SWIFT_MISC_COUNTRYLIST_H
8 
9 #include <tuple>
10 
11 #include <QJsonArray>
12 #include <QMetaType>
13 #include <QString>
14 #include <QStringList>
15 
16 #include "misc/collection.h"
17 #include "misc/country.h"
19 #include "misc/sequence.h"
20 #include "misc/swiftmiscexport.h"
21 
22 SWIFT_DECLARE_SEQUENCE_MIXINS(swift::misc, CCountry, CCountryList)
23 
24 namespace swift::misc
25 {
29  public CSequence<CCountry>,
30  public db::IDatastoreObjectList<CCountry, CCountryList, QString>,
31  public mixin::MetaType<CCountryList>
32  {
33  public:
36 
38  CCountryList();
39 
41  CCountryList(const CSequence<CCountry> &other);
42 
44  CCountry findByIsoCode(const QString &isoCode) const;
45 
47  CCountry findBestMatchByCountryName(const QString &candidate) const;
48 
50  CCountry findFirstByAlias(const QString &alias) const;
51 
53  QStringList toIsoNameList(bool sorted = false) const;
54 
56  QStringList toNameIsoList(bool sorted = false) const;
57 
59  QStringList toNameList(bool sorted = false) const;
60 
62  QStringList toIsoList(bool sorted = false) const;
63 
65  QStringList toIso3List(bool sorted = false) const;
66 
68  static CCountryList fromDatabaseJson(const QJsonArray &array);
69  };
70 } // namespace swift::misc
71 
72 Q_DECLARE_METATYPE(swift::misc::CCountryList)
74 
75 #endif // SWIFT_MISC_COUNTRYLIST_H
Generic ordered container with value semantics.
Definition: collection.h:107
Value object encapsulating a list of countries.
Definition: countrylist.h:32
Generic sequential container with value semantics.
Definition: sequence.h:86
CSequence()=default
Default constructor.
List of objects read from database. Such objects should implement.
CRTP class template from which a derived class can inherit common methods dealing with the metatype o...
Definition: mixinmetatype.h:29
#define SWIFT_MISC_DECLARE_USING_MIXIN_METATYPE(DERIVED)
When a derived class and a base class both inherit from mixin::MetaType, the derived class uses this ...
Free functions in swift::misc.
#define SWIFT_DECLARE_SEQUENCE_MIXINS(Namespace, T, List)
Explicit template declaration of mixins for a CSequence subclass to be placed near the top of the hea...
Definition: sequence.h:62
#define SWIFT_MISC_EXPORT
Export a class or function from the library.