swift
Loading...
Searching...
No Matches
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"
21
22SWIFT_DECLARE_SEQUENCE_MIXINS(swift::misc, CCountry, CCountryList)
23
24namespace 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() = default;
39
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
72Q_DECLARE_METATYPE(swift::misc::CCountryList)
74
75#endif // SWIFT_MISC_COUNTRYLIST_H
Generic ordered container with value semantics.
Definition collection.h:113
Value object encapsulating a list of countries.
Definition countrylist.h:32
static CCountryList fromDatabaseJson(const QJsonArray &array)
From our database JSON format.
CCountry findFirstByAlias(const QString &alias) const
Find first by alias.
CSequence()=default
Default constructor.
CCountry findBestMatchByCountryName(const QString &candidate) const
Find "best match" by country.
QStringList toIso3List(bool sorted=false) const
All ISO 3 codes.
CCountry findByIsoCode(const QString &isoCode) const
Find by ISO code.
QStringList toIsoNameList(bool sorted=false) const
ISO/name string list.
QStringList toNameList(bool sorted=false) const
Name string list.
QStringList toIsoList(bool sorted=false) const
All ISO codes.
QStringList toNameIsoList(bool sorted=false) const
Name/ISO string list.
CCountryList()=default
Default constructor.
CSequence()=default
Default constructor.
Q_REQUIRED_RESULT CSequence sorted(Predicate p) const
Definition sequence.h:610
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...
#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.