Unity Scopes API
QVariantBuilder.h
1 /*
2  * Copyright (C) 2015 Canonical Ltd
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Xavi Garcia <xavi.garcia.mena@canonical.com>
17  */
18 
19 #pragma once
20 
21 #ifndef _ENABLE_QT_EXPERIMENTAL_
22 #error You should define _ENABLE_QT_EXPERIMENTAL_ in order to use this experimental header file.
23 #endif
24 
25 #include <QtCore/QPair>
26 #include <QtCore/QString>
27 #pragma GCC diagnostic push
28 #pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
29 #include <QtCore/QVariant>
30 #pragma GCC diagnostic pop
31 #include <QtCore/QVector>
32 
33 #include <memory>
34 
35 namespace unity
36 {
37 
38 namespace scopes
39 {
40 
41 namespace qt
42 {
43 
44 namespace internal
45 {
46 class QVariantBuilderImpl;
47 }
48 
72 class QVariantBuilder final
73 {
74 public:
76  virtual ~QVariantBuilder();
77 
81  //{@
82  QVariantBuilder(QVariantBuilder const& other);
84 
85  QVariantBuilder& operator=(QVariantBuilder const& other);
86  QVariantBuilder& operator=(QVariantBuilder&& other);
88 
103  void add_tuple(std::initializer_list<QPair<QString, QVariant>> const& tuple);
104 
111  void add_tuple(QVector<QPair<QString, QVariant>> const& tuple);
112 
120  QVariant end();
121 
122 private:
124  QVariantBuilder(internal::QVariantBuilderImpl* impl);
125  std::unique_ptr<internal::QVariantBuilderImpl> p;
126  friend class internal::QVariantBuilderImpl;
128 };
129 } // namespace qt
130 
131 } // namespace scopes
132 
133 } // namespace unity
QVariant end()
Retrieves a completed variant.
Definition: QVariantBuilder.cpp:63
Top-level namespace for all things Unity-related.
Definition: Version.h:49
Definition: ActionMetadata.h:31
Helper class for creating and populating QVariant containers.
Definition: QVariantBuilder.h:72
void add_tuple(std::initializer_list< QPair< QString, QVariant >> const &tuple)
Adds a tuple of key-value pairs to an array.
Definition: QVariantBuilder.cpp:53