swift
Loading...
Searching...
No Matches
variantlist.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2014 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
4#include "misc/variantlist.h"
5
6#include <algorithm>
7
8SWIFT_DEFINE_SEQUENCE_MIXINS(swift::misc, CVariant, CVariantList)
9
10namespace swift::misc
11{
13 extern int qMetaTypeId_CVariantList; // defined in variant.cpp
14
16
17 CVariantList::CVariantList(const QVariantList &other)
18 {
19 std::copy(other.begin(), other.end(), std::back_inserter(*this));
20 }
21
22 CVariantList::CVariantList(QVariantList &&other)
23 {
24 std::move(other.begin(), other.end(), std::back_inserter(*this));
25 }
26
28 {
31 [](const CVariantList &list) { return list.toVector(); });
33 [](const QVector<CVariant> &list) { return CSequence(list); });
34 qMetaTypeId_CVariantList = qMetaTypeId<CVariantList>();
35 }
36
37 bool CVariantList::matches(const CVariant &event) const
38 {
39 return containsBy([&](const CVariant &pattern) { return pattern.matches(event); });
40 }
41} // namespace swift::misc
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
Definition variant.h:69
bool matches(const CVariant &event) const
If this is an event subscription, return true if it matches the given event.
CSequence()=default
Default constructor.
bool matches(const CVariant &event) const
True if any element of the list matches the given event.
static void registerMetadata()
Register metadata.
CVariantList()=default
Default constructor.
static void registerMetadata()
Register metadata.
Free functions in swift::misc.
bool registerConverter()
#define SWIFT_DEFINE_SEQUENCE_MIXINS(Namespace, T, List)
Explicit template definition of mixins for a CSequence subclass.
Definition sequence.h:63