55
55
vec_strings.push_back("a");
56
56
Glib::Variant<std::vector<std::string> > variant_vec_strings =
57
57
Glib::Variant<std::vector<std::string> >::create(vec_strings);
61
61
typedef std::pair<Glib::ustring, Glib::ustring> TypeDictEntry;
120
120
" in the variant are: " << value << '.' << std::endl;
123
//std::vector< std::map< Glib::ustring, Glib::Variant<int> > >
124
typedef std::map< Glib::ustring, Glib::Variant<int> > ComplexDictType;
126
ComplexDictType complex_dict1;
127
ComplexDictType complex_dict2;
129
for(int i = 0; i < 10; i++)
131
// Convert integer i to string.
132
std::stringstream ss;
135
Glib::ustring s = "String " + ss.str();
137
Glib::Variant<int> v = Glib::Variant<int>::create(i);
139
complex_dict1.insert(
140
std::pair< Glib::ustring, Glib::Variant<int> >("Map 1 " + s, v));
142
complex_dict2.insert(
143
std::pair< Glib::ustring, Glib::Variant<int> >("Map 2 " + s, v));
146
typedef std::vector< std::map< Glib::ustring, Glib::Variant<int> > >
149
ComplexVecType complex_vector;
150
complex_vector.push_back(complex_dict1);
151
complex_vector.push_back(complex_dict2);
153
Glib::Variant<ComplexVecType> complex_variant =
154
Glib::Variant<ComplexVecType>::create(complex_vector);
156
// This will output the type string aa{sv}.
157
ostr << "The type string of the variant containing a vector of "
158
"dictionaries is: " << std::endl << complex_variant.get_type_string() <<
159
"." << std::endl << std::endl;
161
ComplexVecType copy_complex_vector = complex_variant.get();
163
for(guint i = 0; i < copy_complex_vector.size(); i++)
165
ostr << "Printing dictionary # " << i + 1 << ":" << std::endl;
167
ComplexDictType map = copy_complex_vector[i];
169
for(ComplexDictType::const_iterator iter = map.begin();
170
iter != map.end(); iter++)
172
std::pair< Glib::ustring, Glib::Variant<int> > entry = *iter;
173
ostr << entry.first << " -> " << entry.second.get() << "." << std::endl;
123
178
test_variant_floating();
124
179
test_dynamic_cast();