swift
variantlist.h
Go to the documentation of this file.
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 
5 
6 #ifndef SWIFT_MISC_VARIANTLIST_H
7 #define SWIFT_MISC_VARIANTLIST_H
8 
9 #include <iterator>
10 
11 #include <QMetaType>
12 #include <QVariantList>
13 
14 #include "misc/collection.h"
15 #include "misc/sequence.h"
16 #include "misc/swiftmiscexport.h"
17 #include "misc/variant.h"
18 
19 SWIFT_DECLARE_SEQUENCE_MIXINS(swift::misc, CVariant, CVariantList)
20 
21 namespace swift::misc
22 {
28  class SWIFT_MISC_EXPORT CVariantList : public CSequence<CVariant>, public swift::misc::mixin::MetaType<CVariantList>
29  {
30  public:
33 
36 
38  CVariantList(const CSequence &other);
39 
41  CVariantList(const QVariantList &other);
42 
44  CVariantList(QVariantList &&other);
45 
47  template <typename T>
48  T to() const
49  {
50  return CVariant::from(*this).template to<T>();
51  }
52 
54  template <typename T>
55  static CVariantList from(const T &list)
56  {
57  return CVariant::from(list).template to<CVariantList>();
58  }
59 
61  static void registerMetadata();
62 
64  bool matches(const CVariant &event) const;
65  };
66 } // namespace swift::misc
67 
68 Q_DECLARE_METATYPE(swift::misc::CVariantList)
70 
71 #endif // SWIFT_MISC_VARIANTLIST_H
Generic ordered container with value semantics.
Definition: collection.h:107
Generic sequential container with value semantics.
Definition: sequence.h:86
CSequence()=default
Default constructor.
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
Definition: variant.h:66
static CVariant from(T &&value)
Synonym for fromValue().
Definition: variant.h:147
Value object encapsulating a list of variants.
Definition: variantlist.h:29
CVariantList()
Default constructor.
Definition: variantlist.h:35
static CVariantList from(const T &list)
Convert from a sequence type by converting all elements.
Definition: variantlist.h:55
T to() const
Convert to a sequence type by converting all elements.
Definition: variantlist.h:48
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.
void registerMetadata()
Register all relevant metadata in 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.