Unity Scopes API
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 #pragma once
20 
21 #include <unity/scopes/Variant.h>
22 #include <string>
23 #include <vector>
24 #include <memory>
25 #include <tuple>
26 
27 namespace unity
28 {
29 
30 namespace scopes
31 {
32 
33 namespace internal
34 {
35 class VariantBuilderImpl;
36 }
37 
62 {
63 public:
65  virtual ~VariantBuilder();
66 
70  //{@
71  VariantBuilder(VariantBuilder const& other);
73 
74  VariantBuilder& operator=(VariantBuilder const& other);
75  VariantBuilder& operator=(VariantBuilder&& other);
77 
92  void add_tuple(std::initializer_list<std::pair<std::string, Variant>> const& tuple);
93 
100  void add_tuple(std::vector<std::pair<std::string, Variant>> const& tuple);
101 
109  Variant end();
110 
111 private:
112  std::unique_ptr<internal::VariantBuilderImpl> p;
113 };
114 
115 } // namespace scopes
116 
117 } // namespace unity
Simple variant class that can hold an integer, boolean, string, double, dictionary, array or null value.
Definition: Variant.h:57
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:61
Top-level namespace for all things Unity-related.
Definition: Version.h:49
Variant end()
Retrieves a completed variant.
Definition: VariantBuilder.cpp:62
Definition: ActionMetadata.h:31