Unity Scopes API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
VariantBuilder.h
1 /*
2  * Copyright (C) 2013 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: Pawel Stolowski <pawel.stolowski@canonical.com>
17  */
18 
19 #ifndef UNITY_SCOPES_VARIANTBUILDER_H
20 #define UNITY_SCOPES_VARIANTBUILDER_H
21 
22 #include <unity/scopes/Variant.h>
23 #include <string>
24 #include <vector>
25 #include <memory>
26 #include <tuple>
27 
28 namespace unity
29 {
30 
31 namespace scopes
32 {
33 
34 namespace internal
35 {
36 class VariantBuilderImpl;
37 }
38 
63 {
64 public:
66  virtual ~VariantBuilder();
67 
71  //{@
72  VariantBuilder(VariantBuilder const& other);
74 
75  VariantBuilder& operator=(VariantBuilder const& other);
76  VariantBuilder& operator=(VariantBuilder&& other);
78 
93  void add_tuple(std::initializer_list<std::pair<std::string, Variant>> const& tuple);
94 
101  void add_tuple(std::vector<std::pair<std::string, Variant>> const& tuple);
102 
110  Variant end();
111 
112 private:
113  std::unique_ptr<internal::VariantBuilderImpl> p;
114 };
115 
116 } // namespace scopes
117 
118 } // namespace unity
119 
120 #endif
Simple variant class that can hold an integer, boolean, string, double, dictionary, array or null value.
Definition: Variant.h:58
void add_tuple(std::initializer_list< std::pair< std::string, Variant >> const &tuple)
Adds a tuple of key-value pairs to an array.
Definition: VariantBuilder.cpp:52
Helper class for creating and populating Variant containers.
Definition: VariantBuilder.h:62
Variant end()
Retrieves a completed variant.
Definition: VariantBuilder.cpp:62