swift
platformset.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #include "misc/platformset.h"
7 
8 #include <QDBusMetaType>
9 #include <QString>
10 
11 #include "misc/containerbase.h"
12 
13 SWIFT_DEFINE_COLLECTION_MIXINS(swift::misc, CPlatform, CPlatformSet)
14 
15 namespace swift::misc
16 {
18 
19  CPlatformSet::CPlatformSet(const CCollection<CPlatform> &other) : CCollection<CPlatform>(other) {}
20 
21  QStringList CPlatformSet::getPlatformNames() const
22  {
23  QStringList names;
24  for (const CPlatform &p : *this) { names.append(p.getPlatformName()); }
25  return names;
26  }
27 
28  CPlatformSet CPlatformSet::matchesAny(CPlatform::Platform platform) const
29  {
30  CPlatformSet set;
31  for (const CPlatform &p : *this)
32  {
33  if (!p.matchesAny(platform)) continue;
34  set.insert(p);
35  }
36  return set;
37  }
38 
39  CPlatformSet CPlatformSet::exactMatch(CPlatform::Platform platform) const
40  {
41  CPlatformSet set;
42  for (const CPlatform &p : *this)
43  {
44  if (p.getPlatform() != platform) continue;
45  set.insert(p);
46  }
47  return set;
48  }
49 
50  bool CPlatformSet::containsName(const QString &platformName) const
51  {
52  return this->contains(&CPlatform::getPlatformName, platformName);
53  }
54 
55  const CPlatformSet &CPlatformSet::allPlatforms()
56  {
57  static const CPlatformSet platforms({ CPlatform::win32Platform(), CPlatform::win64Platform(),
58  CPlatform::linuxPlatform(), CPlatform::macOSPlatform() });
59  return platforms;
60  }
61 
62  void CPlatformSet::registerMetadata()
63  {
64  qRegisterMetaType<swift::misc::CSequence<CPlatform>>();
65  qDBusRegisterMetaType<swift::misc::CSequence<CPlatform>>();
66  qRegisterMetaType<swift::misc::CCollection<CPlatform>>();
67  qDBusRegisterMetaType<swift::misc::CCollection<CPlatform>>();
68  qRegisterMetaType<CPlatformSet>();
69  qDBusRegisterMetaType<CPlatformSet>();
70  registerMetaValueType<CPlatformSet>();
71  }
72 } // namespace swift::misc
73 
CPlatformSet()
Default constructor.
#define SWIFT_DEFINE_COLLECTION_MIXINS(Namespace, T, Set)
Explicit template definition of mixins for a CCollection subclass.
Definition: collection.h:63
Free functions in swift::misc.