Unity Scopes Qt library
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 #include <QtCore/QPair>
22 #include <QtCore/QString>
23 #pragma GCC diagnostic push
24 #pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
25 #include <QtCore/QVariant>
26 #pragma GCC diagnostic pop
27 #include <QtCore/QVector>
28 
29 #include <memory>
30 
31 namespace unity
32 {
33 
34 namespace scopes
35 {
36 
37 namespace qt
38 {
39 
40 namespace internal
41 {
42 class QVariantBuilderImpl;
43 }
44 
67 class QVariantBuilder final
68 {
69 public:
71  virtual ~QVariantBuilder();
72 
76  //{@
77  QVariantBuilder(QVariantBuilder const& other);
79 
80  QVariantBuilder& operator=(QVariantBuilder const& other);
81  QVariantBuilder& operator=(QVariantBuilder&& other);
83 
98  // void add_tuple(std::initializer_list<QPair<QString, QVariant>> const& tuple);
99 
106  void add_tuple(QVector<QPair<QString, QVariant>> const& tuple);
107 
115  QVariant end();
116 
117 private:
119  QVariantBuilder(internal::QVariantBuilderImpl* impl);
120  std::unique_ptr<internal::QVariantBuilderImpl> p;
121  friend class internal::QVariantBuilderImpl;
123 };
124 } // namespace qt
125 
126 } // namespace scopes
127 
128 } // namespace unity
void add_tuple(QVector< QPair< QString, QVariant >> const &tuple)
Adds a tuple of key-value pairs to an array.
Definition: HttpAsyncReader.h:39
Helper class for creating and populating QVariant containers.
Definition: QVariantBuilder.h:67
QVariant end()
Retrieves a completed variant.