33 #include <google/protobuf/map_field.h>
34 #include <google/protobuf/message.h>
35 #include <gtest/gtest.h>
38 #include <google/protobuf/port_def.inc>
44 : base_descriptor_(base_descriptor) {
46 std::string package = base_descriptor->file()->package();
48 map_enum_foo_ =
pool->FindEnumValueByName(package +
".MAP_ENUM_FOO");
49 map_enum_bar_ =
pool->FindEnumValueByName(package +
".MAP_ENUM_BAR");
50 map_enum_baz_ =
pool->FindEnumValueByName(package +
".MAP_ENUM_BAZ");
52 foreign_c_ =
pool->FindFieldByName(package +
".ForeignMessage.c");
53 map_int32_int32_key_ =
54 pool->FindFieldByName(package +
".TestMap.MapInt32Int32Entry.key");
55 map_int32_int32_val_ =
56 pool->FindFieldByName(package +
".TestMap.MapInt32Int32Entry.value");
57 map_int64_int64_key_ =
58 pool->FindFieldByName(package +
".TestMap.MapInt64Int64Entry.key");
59 map_int64_int64_val_ =
60 pool->FindFieldByName(package +
".TestMap.MapInt64Int64Entry.value");
61 map_uint32_uint32_key_ =
62 pool->FindFieldByName(package +
".TestMap.MapUint32Uint32Entry.key");
63 map_uint32_uint32_val_ =
64 pool->FindFieldByName(package +
".TestMap.MapUint32Uint32Entry.value");
65 map_uint64_uint64_key_ =
66 pool->FindFieldByName(package +
".TestMap.MapUint64Uint64Entry.key");
67 map_uint64_uint64_val_ =
68 pool->FindFieldByName(package +
".TestMap.MapUint64Uint64Entry.value");
69 map_sint32_sint32_key_ =
70 pool->FindFieldByName(package +
".TestMap.MapSint32Sint32Entry.key");
71 map_sint32_sint32_val_ =
72 pool->FindFieldByName(package +
".TestMap.MapSint32Sint32Entry.value");
73 map_sint64_sint64_key_ =
74 pool->FindFieldByName(package +
".TestMap.MapSint64Sint64Entry.key");
75 map_sint64_sint64_val_ =
76 pool->FindFieldByName(package +
".TestMap.MapSint64Sint64Entry.value");
77 map_fixed32_fixed32_key_ =
78 pool->FindFieldByName(package +
".TestMap.MapFixed32Fixed32Entry.key");
79 map_fixed32_fixed32_val_ =
80 pool->FindFieldByName(package +
".TestMap.MapFixed32Fixed32Entry.value");
81 map_fixed64_fixed64_key_ =
82 pool->FindFieldByName(package +
".TestMap.MapFixed64Fixed64Entry.key");
83 map_fixed64_fixed64_val_ =
84 pool->FindFieldByName(package +
".TestMap.MapFixed64Fixed64Entry.value");
85 map_sfixed32_sfixed32_key_ =
86 pool->FindFieldByName(package +
".TestMap.MapSfixed32Sfixed32Entry.key");
87 map_sfixed32_sfixed32_val_ =
pool->FindFieldByName(
88 package +
".TestMap.MapSfixed32Sfixed32Entry.value");
89 map_sfixed64_sfixed64_key_ =
90 pool->FindFieldByName(package +
".TestMap.MapSfixed64Sfixed64Entry.key");
91 map_sfixed64_sfixed64_val_ =
pool->FindFieldByName(
92 package +
".TestMap.MapSfixed64Sfixed64Entry.value");
93 map_int32_float_key_ =
94 pool->FindFieldByName(package +
".TestMap.MapInt32FloatEntry.key");
95 map_int32_float_val_ =
96 pool->FindFieldByName(package +
".TestMap.MapInt32FloatEntry.value");
97 map_int32_double_key_ =
98 pool->FindFieldByName(package +
".TestMap.MapInt32DoubleEntry.key");
99 map_int32_double_val_ =
100 pool->FindFieldByName(package +
".TestMap.MapInt32DoubleEntry.value");
102 pool->FindFieldByName(package +
".TestMap.MapBoolBoolEntry.key");
104 pool->FindFieldByName(package +
".TestMap.MapBoolBoolEntry.value");
105 map_string_string_key_ =
106 pool->FindFieldByName(package +
".TestMap.MapStringStringEntry.key");
107 map_string_string_val_ =
108 pool->FindFieldByName(package +
".TestMap.MapStringStringEntry.value");
109 map_int32_bytes_key_ =
110 pool->FindFieldByName(package +
".TestMap.MapInt32BytesEntry.key");
111 map_int32_bytes_val_ =
112 pool->FindFieldByName(package +
".TestMap.MapInt32BytesEntry.value");
113 map_int32_enum_key_ =
114 pool->FindFieldByName(package +
".TestMap.MapInt32EnumEntry.key");
115 map_int32_enum_val_ =
116 pool->FindFieldByName(package +
".TestMap.MapInt32EnumEntry.value");
117 map_int32_foreign_message_key_ =
pool->FindFieldByName(
118 package +
".TestMap.MapInt32ForeignMessageEntry.key");
119 map_int32_foreign_message_val_ =
pool->FindFieldByName(
120 package +
".TestMap.MapInt32ForeignMessageEntry.value");
157 EXPECT_FALSE(map_int32_foreign_message_key_ ==
nullptr);
158 EXPECT_FALSE(map_int32_foreign_message_val_ ==
nullptr);
160 std::vector<const FieldDescriptor*> all_map_descriptors = {
161 map_int32_int32_key_,
162 map_int32_int32_val_,
163 map_int64_int64_key_,
164 map_int64_int64_val_,
165 map_uint32_uint32_key_,
166 map_uint32_uint32_val_,
167 map_uint64_uint64_key_,
168 map_uint64_uint64_val_,
169 map_sint32_sint32_key_,
170 map_sint32_sint32_val_,
171 map_sint64_sint64_key_,
172 map_sint64_sint64_val_,
173 map_fixed32_fixed32_key_,
174 map_fixed32_fixed32_val_,
175 map_fixed64_fixed64_key_,
176 map_fixed64_fixed64_val_,
177 map_sfixed32_sfixed32_key_,
178 map_sfixed32_sfixed32_val_,
179 map_sfixed64_sfixed64_key_,
180 map_sfixed64_sfixed64_val_,
181 map_int32_float_key_,
182 map_int32_float_val_,
183 map_int32_double_key_,
184 map_int32_double_val_,
187 map_string_string_key_,
188 map_string_string_val_,
189 map_int32_bytes_key_,
190 map_int32_bytes_val_,
193 map_int32_foreign_message_key_,
194 map_int32_foreign_message_val_};
196 GOOGLE_CHECK(fdesc->containing_type() !=
nullptr) << fdesc->name();
197 if (fdesc->name() ==
"key") {
198 EXPECT_EQ(fdesc->containing_type()->map_key(), fdesc);
201 EXPECT_EQ(fdesc->containing_type()->map_value(), fdesc);
209 result = base_descriptor_->FindFieldByName(
name);
214 void MapReflectionTester::SetMapFieldsViaReflection(
Message*
message) {
215 const Reflection* reflection =
message->GetReflection();
216 Message* sub_message =
nullptr;
217 Message* sub_foreign_message =
nullptr;
220 sub_message = reflection->AddMessage(
message,
F(
"map_int32_int32"));
221 sub_message->GetReflection()->SetInt32(sub_message, map_int32_int32_key_, 0);
222 sub_message->GetReflection()->SetInt32(sub_message, map_int32_int32_val_, 0);
224 sub_message = reflection->AddMessage(
message,
F(
"map_int64_int64"));
225 sub_message->GetReflection()->SetInt64(sub_message, map_int64_int64_key_, 0);
226 sub_message->GetReflection()->SetInt64(sub_message, map_int64_int64_val_, 0);
228 sub_message = reflection->AddMessage(
message,
F(
"map_uint32_uint32"));
229 sub_message->GetReflection()->SetUInt32(sub_message, map_uint32_uint32_key_,
231 sub_message->GetReflection()->SetUInt32(sub_message, map_uint32_uint32_val_,
234 sub_message = reflection->AddMessage(
message,
F(
"map_uint64_uint64"));
235 sub_message->GetReflection()->SetUInt64(sub_message, map_uint64_uint64_key_,
237 sub_message->GetReflection()->SetUInt64(sub_message, map_uint64_uint64_val_,
240 sub_message = reflection->AddMessage(
message,
F(
"map_sint32_sint32"));
241 sub_message->GetReflection()->SetInt32(sub_message, map_sint32_sint32_key_,
243 sub_message->GetReflection()->SetInt32(sub_message, map_sint32_sint32_val_,
246 sub_message = reflection->AddMessage(
message,
F(
"map_sint64_sint64"));
247 sub_message->GetReflection()->SetInt64(sub_message, map_sint64_sint64_key_,
249 sub_message->GetReflection()->SetInt64(sub_message, map_sint64_sint64_val_,
252 sub_message = reflection->AddMessage(
message,
F(
"map_fixed32_fixed32"));
253 sub_message->GetReflection()->SetUInt32(sub_message, map_fixed32_fixed32_key_,
255 sub_message->GetReflection()->SetUInt32(sub_message, map_fixed32_fixed32_val_,
258 sub_message = reflection->AddMessage(
message,
F(
"map_fixed64_fixed64"));
259 sub_message->GetReflection()->SetUInt64(sub_message, map_fixed64_fixed64_key_,
261 sub_message->GetReflection()->SetUInt64(sub_message, map_fixed64_fixed64_val_,
264 sub_message = reflection->AddMessage(
message,
F(
"map_sfixed32_sfixed32"));
265 sub_message->GetReflection()->SetInt32(sub_message,
266 map_sfixed32_sfixed32_key_, 0);
267 sub_message->GetReflection()->SetInt32(sub_message,
268 map_sfixed32_sfixed32_val_, 0);
270 sub_message = reflection->AddMessage(
message,
F(
"map_sfixed64_sfixed64"));
271 sub_message->GetReflection()->SetInt64(sub_message,
272 map_sfixed64_sfixed64_key_, 0);
273 sub_message->GetReflection()->SetInt64(sub_message,
274 map_sfixed64_sfixed64_val_, 0);
276 sub_message = reflection->AddMessage(
message,
F(
"map_int32_float"));
277 sub_message->GetReflection()->SetInt32(sub_message, map_int32_float_key_, 0);
278 sub_message->GetReflection()->SetFloat(sub_message, map_int32_float_val_,
281 sub_message = reflection->AddMessage(
message,
F(
"map_int32_double"));
282 sub_message->GetReflection()->SetInt32(sub_message, map_int32_double_key_, 0);
283 sub_message->GetReflection()->SetDouble(sub_message, map_int32_double_val_,
286 sub_message = reflection->AddMessage(
message,
F(
"map_bool_bool"));
287 sub_message->GetReflection()->SetBool(sub_message, map_bool_bool_key_,
false);
288 sub_message->GetReflection()->SetBool(sub_message, map_bool_bool_val_,
false);
290 sub_message = reflection->AddMessage(
message,
F(
"map_string_string"));
291 sub_message->GetReflection()->SetString(sub_message, map_string_string_key_,
293 sub_message->GetReflection()->SetString(sub_message, map_string_string_val_,
296 sub_message = reflection->AddMessage(
message,
F(
"map_int32_bytes"));
297 sub_message->GetReflection()->SetInt32(sub_message, map_int32_bytes_key_, 0);
298 sub_message->GetReflection()->SetString(sub_message, map_int32_bytes_val_,
301 sub_message = reflection->AddMessage(
message,
F(
"map_int32_enum"));
302 sub_message->GetReflection()->SetInt32(sub_message, map_int32_enum_key_, 0);
303 sub_message->GetReflection()->SetEnum(sub_message, map_int32_enum_val_,
306 sub_message = reflection->AddMessage(
message,
F(
"map_int32_foreign_message"));
307 sub_message->GetReflection()->SetInt32(sub_message,
308 map_int32_foreign_message_key_, 0);
309 sub_foreign_message = sub_message->GetReflection()->MutableMessage(
310 sub_message, map_int32_foreign_message_val_,
nullptr);
311 sub_foreign_message->GetReflection()->SetInt32(sub_foreign_message,
315 sub_message = reflection->AddMessage(
message,
F(
"map_int32_int32"));
316 sub_message->GetReflection()->SetInt32(sub_message, map_int32_int32_key_, 1);
317 sub_message->GetReflection()->SetInt32(sub_message, map_int32_int32_val_, 1);
319 sub_message = reflection->AddMessage(
message,
F(
"map_int64_int64"));
320 sub_message->GetReflection()->SetInt64(sub_message, map_int64_int64_key_, 1);
321 sub_message->GetReflection()->SetInt64(sub_message, map_int64_int64_val_, 1);
323 sub_message = reflection->AddMessage(
message,
F(
"map_uint32_uint32"));
324 sub_message->GetReflection()->SetUInt32(sub_message, map_uint32_uint32_key_,
326 sub_message->GetReflection()->SetUInt32(sub_message, map_uint32_uint32_val_,
329 sub_message = reflection->AddMessage(
message,
F(
"map_uint64_uint64"));
330 sub_message->GetReflection()->SetUInt64(sub_message, map_uint64_uint64_key_,
332 sub_message->GetReflection()->SetUInt64(sub_message, map_uint64_uint64_val_,
335 sub_message = reflection->AddMessage(
message,
F(
"map_sint32_sint32"));
336 sub_message->GetReflection()->SetInt32(sub_message, map_sint32_sint32_key_,
338 sub_message->GetReflection()->SetInt32(sub_message, map_sint32_sint32_val_,
341 sub_message = reflection->AddMessage(
message,
F(
"map_sint64_sint64"));
342 sub_message->GetReflection()->SetInt64(sub_message, map_sint64_sint64_key_,
344 sub_message->GetReflection()->SetInt64(sub_message, map_sint64_sint64_val_,
347 sub_message = reflection->AddMessage(
message,
F(
"map_fixed32_fixed32"));
348 sub_message->GetReflection()->SetUInt32(sub_message, map_fixed32_fixed32_key_,
350 sub_message->GetReflection()->SetUInt32(sub_message, map_fixed32_fixed32_val_,
353 sub_message = reflection->AddMessage(
message,
F(
"map_fixed64_fixed64"));
354 sub_message->GetReflection()->SetUInt64(sub_message, map_fixed64_fixed64_key_,
356 sub_message->GetReflection()->SetUInt64(sub_message, map_fixed64_fixed64_val_,
359 sub_message = reflection->AddMessage(
message,
F(
"map_sfixed32_sfixed32"));
360 sub_message->GetReflection()->SetInt32(sub_message,
361 map_sfixed32_sfixed32_key_, 1);
362 sub_message->GetReflection()->SetInt32(sub_message,
363 map_sfixed32_sfixed32_val_, 1);
365 sub_message = reflection->AddMessage(
message,
F(
"map_sfixed64_sfixed64"));
366 sub_message->GetReflection()->SetInt64(sub_message,
367 map_sfixed64_sfixed64_key_, 1);
368 sub_message->GetReflection()->SetInt64(sub_message,
369 map_sfixed64_sfixed64_val_, 1);
371 sub_message = reflection->AddMessage(
message,
F(
"map_int32_float"));
372 sub_message->GetReflection()->SetInt32(sub_message, map_int32_float_key_, 1);
373 sub_message->GetReflection()->SetFloat(sub_message, map_int32_float_val_,
376 sub_message = reflection->AddMessage(
message,
F(
"map_int32_double"));
377 sub_message->GetReflection()->SetInt32(sub_message, map_int32_double_key_, 1);
378 sub_message->GetReflection()->SetDouble(sub_message, map_int32_double_val_,
381 sub_message = reflection->AddMessage(
message,
F(
"map_bool_bool"));
382 sub_message->GetReflection()->SetBool(sub_message, map_bool_bool_key_,
true);
383 sub_message->GetReflection()->SetBool(sub_message, map_bool_bool_val_,
true);
385 sub_message = reflection->AddMessage(
message,
F(
"map_string_string"));
386 sub_message->GetReflection()->SetString(sub_message, map_string_string_key_,
388 sub_message->GetReflection()->SetString(sub_message, map_string_string_val_,
391 sub_message = reflection->AddMessage(
message,
F(
"map_int32_bytes"));
392 sub_message->GetReflection()->SetInt32(sub_message, map_int32_bytes_key_, 1);
393 sub_message->GetReflection()->SetString(sub_message, map_int32_bytes_val_,
396 sub_message = reflection->AddMessage(
message,
F(
"map_int32_enum"));
397 sub_message->GetReflection()->SetInt32(sub_message, map_int32_enum_key_, 1);
398 sub_message->GetReflection()->SetEnum(sub_message, map_int32_enum_val_,
401 sub_message = reflection->AddMessage(
message,
F(
"map_int32_foreign_message"));
402 sub_message->GetReflection()->SetInt32(sub_message,
403 map_int32_foreign_message_key_, 1);
404 sub_foreign_message = sub_message->GetReflection()->MutableMessage(
405 sub_message, map_int32_foreign_message_val_,
nullptr);
406 sub_foreign_message->GetReflection()->SetInt32(sub_foreign_message,
410 void MapReflectionTester::SetMapFieldsViaMapReflection(
Message*
message) {
411 const Reflection* reflection =
message->GetReflection();
413 Message* sub_foreign_message =
nullptr;
415 MapValueConstRef map_val_const;
419 map_key.SetInt32Value(0);
421 map_key, &map_val_const));
424 map_val.SetInt32Value(0);
426 map_key.SetInt64Value(0);
428 map_key, &map_val_const));
431 map_val.SetInt64Value(0);
433 map_key.SetUInt32Value(0);
435 map_key, &map_val_const));
437 message,
F(
"map_uint32_uint32"), map_key, &map_val));
438 map_val.SetUInt32Value(0);
440 map_key.SetUInt64Value(0);
442 message,
F(
"map_uint64_uint64"), map_key, &map_val));
443 map_val.SetUInt64Value(0);
445 map_key.SetInt32Value(0);
447 message,
F(
"map_sint32_sint32"), map_key, &map_val));
448 map_val.SetInt32Value(0);
450 map_key.SetInt64Value(0);
452 message,
F(
"map_sint64_sint64"), map_key, &map_val));
453 map_val.SetInt64Value(0);
455 map_key.SetUInt32Value(0);
457 message,
F(
"map_fixed32_fixed32"), map_key, &map_val));
458 map_val.SetUInt32Value(0);
460 map_key.SetUInt64Value(0);
462 message,
F(
"map_fixed64_fixed64"), map_key, &map_val));
463 map_val.SetUInt64Value(0);
465 map_key.SetInt32Value(0);
467 message,
F(
"map_sfixed32_sfixed32"), map_key, &map_val));
468 map_val.SetInt32Value(0);
470 map_key.SetInt64Value(0);
472 message,
F(
"map_sfixed64_sfixed64"), map_key, &map_val));
473 map_val.SetInt64Value(0);
475 map_key.SetInt32Value(0);
478 map_val.SetFloatValue(0.0);
480 map_key.SetInt32Value(0);
483 map_val.SetDoubleValue(0.0);
485 map_key.SetBoolValue(
false);
490 map_val.SetBoolValue(
false);
492 map_key.SetStringValue(
"0");
494 map_key, &map_val_const));
496 message,
F(
"map_string_string"), map_key, &map_val));
497 map_val.SetStringValue(
"0");
499 map_key.SetInt32Value(0);
501 map_key, &map_val_const));
504 map_val.SetStringValue(
"0");
506 map_key.SetInt32Value(0);
508 map_key, &map_val_const));
511 map_val.SetEnumValue(map_enum_bar_->number());
513 map_key.SetInt32Value(0);
515 *
message,
F(
"map_int32_foreign_message"), map_key, &map_val_const));
517 message,
F(
"map_int32_foreign_message"), map_key, &map_val));
518 sub_foreign_message = map_val.MutableMessageValue();
519 sub_foreign_message->GetReflection()->SetInt32(sub_foreign_message,
523 map_key.SetInt32Value(1);
526 map_val.SetInt32Value(1);
530 map_key.SetInt64Value(1);
533 map_val.SetInt64Value(1);
537 map_key.SetUInt32Value(1);
538 reflection->InsertOrLookupMapValue(
message,
F(
"map_uint32_uint32"), map_key,
540 map_val.SetUInt32Value(1);
542 map_key.SetUInt64Value(1);
543 reflection->InsertOrLookupMapValue(
message,
F(
"map_uint64_uint64"), map_key,
545 map_val.SetUInt64Value(1);
547 map_key.SetInt32Value(1);
548 reflection->InsertOrLookupMapValue(
message,
F(
"map_sint32_sint32"), map_key,
550 map_val.SetInt32Value(1);
552 map_key.SetInt64Value(1);
553 reflection->InsertOrLookupMapValue(
message,
F(
"map_sint64_sint64"), map_key,
555 map_val.SetInt64Value(1);
557 map_key.SetUInt32Value(1);
558 reflection->InsertOrLookupMapValue(
message,
F(
"map_fixed32_fixed32"), map_key,
560 map_val.SetUInt32Value(1);
562 map_key.SetUInt64Value(1);
563 reflection->InsertOrLookupMapValue(
message,
F(
"map_fixed64_fixed64"), map_key,
565 map_val.SetUInt64Value(1);
567 map_key.SetInt32Value(1);
568 reflection->InsertOrLookupMapValue(
message,
F(
"map_sfixed32_sfixed32"),
570 map_val.SetInt32Value(1);
572 map_key.SetInt64Value(1);
573 reflection->InsertOrLookupMapValue(
message,
F(
"map_sfixed64_sfixed64"),
575 map_val.SetInt64Value(1);
577 map_key.SetInt32Value(1);
578 reflection->InsertOrLookupMapValue(
message,
F(
"map_int32_float"), map_key,
580 map_val.SetFloatValue(1.0);
582 map_key.SetInt32Value(1);
583 reflection->InsertOrLookupMapValue(
message,
F(
"map_int32_double"), map_key,
585 map_val.SetDoubleValue(1.0);
587 map_key.SetBoolValue(
true);
588 reflection->InsertOrLookupMapValue(
message,
F(
"map_bool_bool"), map_key,
590 map_val.SetBoolValue(
true);
592 map_key.SetStringValue(
"1");
593 reflection->InsertOrLookupMapValue(
message,
F(
"map_string_string"), map_key,
595 map_val.SetStringValue(
"1");
597 map_key.SetInt32Value(1);
598 reflection->InsertOrLookupMapValue(
message,
F(
"map_int32_bytes"), map_key,
600 map_val.SetStringValue(
"1");
602 map_key.SetInt32Value(1);
603 reflection->InsertOrLookupMapValue(
message,
F(
"map_int32_enum"), map_key,
605 map_val.SetEnumValue(map_enum_baz_->number());
607 map_key.SetInt32Value(1);
609 message,
F(
"map_int32_foreign_message"), map_key, &map_val));
610 sub_foreign_message = map_val.MutableMessageValue();
611 sub_foreign_message->GetReflection()->SetInt32(sub_foreign_message,
615 void MapReflectionTester::GetMapValueViaMapReflection(
617 MapValueRef* map_val) {
618 const Reflection* reflection =
message->GetReflection();
623 Message* MapReflectionTester::GetMapEntryViaReflection(
625 const Reflection* reflection =
message->GetReflection();
626 return reflection->MutableRepeatedMessage(
message,
F(field_name),
index);
631 const Reflection* reflection =
message->GetReflection();
632 return reflection->MapBegin(
message,
F(field_name));
637 const Reflection* reflection =
message->GetReflection();
638 return reflection->MapEnd(
message,
F(field_name));
647 void MapReflectionTester::ClearMapFieldsViaReflection(
Message*
message) {
669 void MapReflectionTester::ModifyMapFieldsViaReflection(
Message*
message) {
670 const Reflection* reflection =
message->GetReflection();
676 map_key.SetInt32Value(1);
679 map_val.SetInt32Value(2);
681 map_key.SetInt64Value(1);
684 map_val.SetInt64Value(2);
686 map_key.SetUInt32Value(1);
688 message,
F(
"map_uint32_uint32"), map_key, &map_val));
689 map_val.SetUInt32Value(2);
691 map_key.SetUInt64Value(1);
692 reflection->InsertOrLookupMapValue(
message,
F(
"map_uint64_uint64"), map_key,
694 map_val.SetUInt64Value(2);
696 map_key.SetInt32Value(1);
697 reflection->InsertOrLookupMapValue(
message,
F(
"map_sint32_sint32"), map_key,
699 map_val.SetInt32Value(2);
701 map_key.SetInt64Value(1);
702 reflection->InsertOrLookupMapValue(
message,
F(
"map_sint64_sint64"), map_key,
704 map_val.SetInt64Value(2);
706 map_key.SetUInt32Value(1);
707 reflection->InsertOrLookupMapValue(
message,
F(
"map_fixed32_fixed32"), map_key,
709 map_val.SetUInt32Value(2);
711 map_key.SetUInt64Value(1);
712 reflection->InsertOrLookupMapValue(
message,
F(
"map_fixed64_fixed64"), map_key,
714 map_val.SetUInt64Value(2);
716 map_key.SetInt32Value(1);
717 reflection->InsertOrLookupMapValue(
message,
F(
"map_sfixed32_sfixed32"),
719 map_val.SetInt32Value(2);
721 map_key.SetInt64Value(1);
722 reflection->InsertOrLookupMapValue(
message,
F(
"map_sfixed64_sfixed64"),
724 map_val.SetInt64Value(2);
726 map_key.SetInt32Value(1);
727 reflection->InsertOrLookupMapValue(
message,
F(
"map_int32_float"), map_key,
729 map_val.SetFloatValue(2.0);
731 map_key.SetInt32Value(1);
732 reflection->InsertOrLookupMapValue(
message,
F(
"map_int32_double"), map_key,
734 map_val.SetDoubleValue(2.0);
736 map_key.SetBoolValue(
true);
737 reflection->InsertOrLookupMapValue(
message,
F(
"map_bool_bool"), map_key,
739 map_val.SetBoolValue(
false);
741 map_key.SetStringValue(
"1");
742 reflection->InsertOrLookupMapValue(
message,
F(
"map_string_string"), map_key,
744 map_val.SetStringValue(
"2");
746 map_key.SetInt32Value(1);
747 reflection->InsertOrLookupMapValue(
message,
F(
"map_int32_bytes"), map_key,
749 map_val.SetStringValue(
"2");
751 map_key.SetInt32Value(1);
752 reflection->InsertOrLookupMapValue(
message,
F(
"map_int32_enum"), map_key,
754 map_val.SetEnumValue(map_enum_foo_->number());
756 map_key.SetInt32Value(1);
758 message,
F(
"map_int32_foreign_message"), map_key, &map_val));
759 sub_foreign_message = map_val.MutableMessageValue();
760 sub_foreign_message->GetReflection()->SetInt32(sub_foreign_message,
764 void MapReflectionTester::RemoveLastMapsViaReflection(
Message*
message) {
765 const Reflection* reflection =
message->GetReflection();
767 std::vector<const FieldDescriptor*>
output;
769 for (
int i = 0;
i <
output.size(); ++
i) {
771 if (!
field->is_repeated())
continue;
776 void MapReflectionTester::ReleaseLastMapsViaReflection(
Message*
message) {
777 const Reflection* reflection =
message->GetReflection();
779 std::vector<const FieldDescriptor*>
output;
781 for (
int i = 0;
i <
output.size(); ++
i) {
783 if (!
field->is_repeated())
continue;
784 if (
field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE)
continue;
788 <<
"ReleaseLast returned nullptr for: " <<
field->name();
793 void MapReflectionTester::SwapMapsViaReflection(
Message*
message) {
794 const Reflection* reflection =
message->GetReflection();
795 std::vector<const FieldDescriptor*>
output;
797 for (
int i = 0;
i <
output.size(); ++
i) {
799 if (!
field->is_repeated())
continue;
804 void MapReflectionTester::MutableUnknownFieldsOfMapFieldsViaReflection(
806 const Reflection* reflection =
message->GetReflection();
807 Message* sub_message =
nullptr;
809 sub_message = reflection->AddMessage(
message,
F(
"map_int32_int32"));
810 EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=
812 sub_message = reflection->AddMessage(
message,
F(
"map_int64_int64"));
813 EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=
815 sub_message = reflection->AddMessage(
message,
F(
"map_uint32_uint32"));
816 EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=
818 sub_message = reflection->AddMessage(
message,
F(
"map_uint64_uint64"));
819 EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=
821 sub_message = reflection->AddMessage(
message,
F(
"map_sint32_sint32"));
822 EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=
824 sub_message = reflection->AddMessage(
message,
F(
"map_sint64_sint64"));
825 EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=
827 sub_message = reflection->AddMessage(
message,
F(
"map_fixed32_fixed32"));
828 EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=
830 sub_message = reflection->AddMessage(
message,
F(
"map_fixed64_fixed64"));
831 EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=
833 sub_message = reflection->AddMessage(
message,
F(
"map_sfixed32_sfixed32"));
834 EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=
836 sub_message = reflection->AddMessage(
message,
F(
"map_sfixed64_sfixed64"));
837 EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=
839 sub_message = reflection->AddMessage(
message,
F(
"map_int32_float"));
840 EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=
842 sub_message = reflection->AddMessage(
message,
F(
"map_int32_double"));
843 EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=
845 sub_message = reflection->AddMessage(
message,
F(
"map_bool_bool"));
846 EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=
848 sub_message = reflection->AddMessage(
message,
F(
"map_string_string"));
849 EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=
851 sub_message = reflection->AddMessage(
message,
F(
"map_int32_bytes"));
852 EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=
854 sub_message = reflection->AddMessage(
message,
F(
"map_int32_enum"));
855 EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=
857 sub_message = reflection->AddMessage(
message,
F(
"map_int32_foreign_message"));
858 EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=
862 void MapReflectionTester::ExpectMapFieldsSetViaReflection(
865 const Reflection* reflection =
message.GetReflection();
868 MapValueConstRef map_value_const_ref;
891 std::map<int32_t, int32_t>
map;
894 for (
int i = 0;
i < 2;
i++) {
895 const internal::MapFieldBase& map_field =
896 reflection->GetRaw<internal::MapFieldBase>(
message,
897 F(
"map_int32_int32"));
898 if (map_field.IsRepeatedFieldValid()) {
901 &reflection->GetRepeatedMessage(
message,
F(
"map_int32_int32"),
i);
902 int32_t key = sub_message->GetReflection()->GetInt32(
903 *sub_message, map_int32_int32_key_);
904 int32_t val = sub_message->GetReflection()->GetInt32(
905 *sub_message, map_int32_int32_val_);
909 map_key.SetInt32Value(
i);
911 reflection->ContainsMapKey(
message,
F(
"map_int32_int32"), map_key));
913 map_key, &map_value_const_ref));
919 std::map<int64_t, int64_t>
map;
922 for (
int i = 0;
i < 2;
i++) {
923 const internal::MapFieldBase& map_field =
924 reflection->GetRaw<internal::MapFieldBase>(
message,
925 F(
"map_int64_int64"));
926 if (map_field.IsRepeatedFieldValid()) {
929 &reflection->GetRepeatedMessage(
message,
F(
"map_int64_int64"),
i);
930 int64_t key = sub_message->GetReflection()->GetInt64(
931 *sub_message, map_int64_int64_key_);
932 int64_t val = sub_message->GetReflection()->GetInt64(
933 *sub_message, map_int64_int64_val_);
937 map_key.SetInt64Value(
i);
939 reflection->ContainsMapKey(
message,
F(
"map_int64_int64"), map_key));
941 map_key, &map_value_const_ref));
947 std::map<uint32_t, uint32_t>
map;
950 for (
int i = 0;
i < 2;
i++) {
951 const internal::MapFieldBase& map_field =
952 reflection->GetRaw<internal::MapFieldBase>(
message,
953 F(
"map_uint32_uint32"));
954 if (map_field.IsRepeatedFieldValid()) {
957 &reflection->GetRepeatedMessage(
message,
F(
"map_uint32_uint32"),
i);
958 uint32_t key = sub_message->GetReflection()->GetUInt32(
959 *sub_message, map_uint32_uint32_key_);
960 uint32_t val = sub_message->GetReflection()->GetUInt32(
961 *sub_message, map_uint32_uint32_val_);
965 map_key.SetUInt32Value(
i);
969 map_key, &map_value_const_ref));
975 std::map<uint64_t, uint64_t>
map;
978 for (
int i = 0;
i < 2;
i++) {
979 const internal::MapFieldBase& map_field =
980 reflection->GetRaw<internal::MapFieldBase>(
message,
981 F(
"map_uint64_uint64"));
982 if (map_field.IsRepeatedFieldValid()) {
985 &reflection->GetRepeatedMessage(
message,
F(
"map_uint64_uint64"),
i);
986 uint64_t key = sub_message->GetReflection()->GetUInt64(
987 *sub_message, map_uint64_uint64_key_);
988 uint64_t val = sub_message->GetReflection()->GetUInt64(
989 *sub_message, map_uint64_uint64_val_);
993 map_key.SetUInt64Value(
i);
997 map_key, &map_value_const_ref));
1003 std::map<int32_t, int32_t>
map;
1006 for (
int i = 0;
i < 2;
i++) {
1007 const internal::MapFieldBase& map_field =
1008 reflection->GetRaw<internal::MapFieldBase>(
message,
1009 F(
"map_sint32_sint32"));
1010 if (map_field.IsRepeatedFieldValid()) {
1013 &reflection->GetRepeatedMessage(
message,
F(
"map_sint32_sint32"),
i);
1014 int32_t key = sub_message->GetReflection()->GetInt32(
1015 *sub_message, map_sint32_sint32_key_);
1016 int32_t val = sub_message->GetReflection()->GetInt32(
1017 *sub_message, map_sint32_sint32_val_);
1021 map_key.SetInt32Value(
i);
1022 EXPECT_EQ(
true, reflection->ContainsMapKey(
1023 message,
F(
"map_sint32_sint32"), map_key));
1025 map_key, &map_value_const_ref));
1031 std::map<int64_t, int64_t>
map;
1034 for (
int i = 0;
i < 2;
i++) {
1035 const internal::MapFieldBase& map_field =
1036 reflection->GetRaw<internal::MapFieldBase>(
message,
1037 F(
"map_sint64_sint64"));
1038 if (map_field.IsRepeatedFieldValid()) {
1041 &reflection->GetRepeatedMessage(
message,
F(
"map_sint64_sint64"),
i);
1042 int64_t key = sub_message->GetReflection()->GetInt64(
1043 *sub_message, map_sint64_sint64_key_);
1044 int64_t val = sub_message->GetReflection()->GetInt64(
1045 *sub_message, map_sint64_sint64_val_);
1049 map_key.SetInt64Value(
i);
1050 EXPECT_EQ(
true, reflection->ContainsMapKey(
1051 message,
F(
"map_sint64_sint64"), map_key));
1053 map_key, &map_value_const_ref));
1059 std::map<uint32_t, uint32_t>
map;
1062 for (
int i = 0;
i < 2;
i++) {
1063 const internal::MapFieldBase& map_field =
1064 reflection->GetRaw<internal::MapFieldBase>(
message,
1065 F(
"map_fixed32_fixed32"));
1066 if (map_field.IsRepeatedFieldValid()) {
1068 sub_message = &reflection->GetRepeatedMessage(
1070 uint32_t key = sub_message->GetReflection()->GetUInt32(
1071 *sub_message, map_fixed32_fixed32_key_);
1072 uint32_t val = sub_message->GetReflection()->GetUInt32(
1073 *sub_message, map_fixed32_fixed32_val_);
1077 map_key.SetUInt32Value(
i);
1078 EXPECT_EQ(
true, reflection->ContainsMapKey(
1079 message,
F(
"map_fixed32_fixed32"), map_key));
1081 message,
F(
"map_fixed32_fixed32"), map_key, &map_value_const_ref));
1087 std::map<uint64_t, uint64_t>
map;
1090 for (
int i = 0;
i < 2;
i++) {
1091 const internal::MapFieldBase& map_field =
1092 reflection->GetRaw<internal::MapFieldBase>(
message,
1093 F(
"map_fixed64_fixed64"));
1094 if (map_field.IsRepeatedFieldValid()) {
1096 sub_message = &reflection->GetRepeatedMessage(
1098 uint64_t key = sub_message->GetReflection()->GetUInt64(
1099 *sub_message, map_fixed64_fixed64_key_);
1100 uint64_t val = sub_message->GetReflection()->GetUInt64(
1101 *sub_message, map_fixed64_fixed64_val_);
1105 map_key.SetUInt64Value(
i);
1106 EXPECT_EQ(
true, reflection->ContainsMapKey(
1107 message,
F(
"map_fixed64_fixed64"), map_key));
1109 message,
F(
"map_fixed64_fixed64"), map_key, &map_value_const_ref));
1115 std::map<int32_t, int32_t>
map;
1118 for (
int i = 0;
i < 2;
i++) {
1119 const internal::MapFieldBase& map_field =
1120 reflection->GetRaw<internal::MapFieldBase>(
1121 message,
F(
"map_sfixed32_sfixed32"));
1122 if (map_field.IsRepeatedFieldValid()) {
1124 sub_message = &reflection->GetRepeatedMessage(
1125 message,
F(
"map_sfixed32_sfixed32"),
i);
1126 int32_t key = sub_message->GetReflection()->GetInt32(
1127 *sub_message, map_sfixed32_sfixed32_key_);
1128 int32_t val = sub_message->GetReflection()->GetInt32(
1129 *sub_message, map_sfixed32_sfixed32_val_);
1133 map_key.SetInt32Value(
i);
1134 EXPECT_EQ(
true, reflection->ContainsMapKey(
1135 message,
F(
"map_sfixed32_sfixed32"), map_key));
1137 F(
"map_sfixed32_sfixed32"),
1138 map_key, &map_value_const_ref));
1144 std::map<int64_t, int64_t>
map;
1147 for (
int i = 0;
i < 2;
i++) {
1148 const internal::MapFieldBase& map_field =
1149 reflection->GetRaw<internal::MapFieldBase>(
1150 message,
F(
"map_sfixed64_sfixed64"));
1151 if (map_field.IsRepeatedFieldValid()) {
1153 sub_message = &reflection->GetRepeatedMessage(
1154 message,
F(
"map_sfixed64_sfixed64"),
i);
1155 int64_t key = sub_message->GetReflection()->GetInt64(
1156 *sub_message, map_sfixed64_sfixed64_key_);
1157 int64_t val = sub_message->GetReflection()->GetInt64(
1158 *sub_message, map_sfixed64_sfixed64_val_);
1162 map_key.SetInt64Value(
i);
1163 EXPECT_EQ(
true, reflection->ContainsMapKey(
1164 message,
F(
"map_sfixed64_sfixed64"), map_key));
1166 F(
"map_sfixed64_sfixed64"),
1167 map_key, &map_value_const_ref));
1173 std::map<int32_t, float>
map;
1176 for (
int i = 0;
i < 2;
i++) {
1177 const internal::MapFieldBase& map_field =
1178 reflection->GetRaw<internal::MapFieldBase>(
message,
1179 F(
"map_int32_float"));
1180 if (map_field.IsRepeatedFieldValid()) {
1183 &reflection->GetRepeatedMessage(
message,
F(
"map_int32_float"),
i);
1184 int32_t key = sub_message->GetReflection()->GetInt32(
1185 *sub_message, map_int32_float_key_);
1186 float val = sub_message->GetReflection()->GetFloat(
1187 *sub_message, map_int32_float_val_);
1191 map_key.SetInt32Value(
i);
1192 EXPECT_EQ(
true, reflection->ContainsMapKey(
1193 message,
F(
"map_int32_float"), map_key));
1195 map_key, &map_value_const_ref));
1201 std::map<int32_t, double>
map;
1204 for (
int i = 0;
i < 2;
i++) {
1205 const internal::MapFieldBase& map_field =
1206 reflection->GetRaw<internal::MapFieldBase>(
message,
1207 F(
"map_int32_double"));
1208 if (map_field.IsRepeatedFieldValid()) {
1211 &reflection->GetRepeatedMessage(
message,
F(
"map_int32_double"),
i);
1212 int32_t key = sub_message->GetReflection()->GetInt32(
1213 *sub_message, map_int32_double_key_);
1214 double val = sub_message->GetReflection()->GetDouble(
1215 *sub_message, map_int32_double_val_);
1219 map_key.SetInt32Value(
i);
1220 EXPECT_EQ(
true, reflection->ContainsMapKey(
1221 message,
F(
"map_int32_double"), map_key));
1223 map_key, &map_value_const_ref));
1229 std::map<bool, bool>
map;
1232 std::vector<bool>
keys = {
false,
true};
1233 std::vector<bool>
vals = {
false,
true};
1234 for (
int i = 0;
i < 2;
i++) {
1235 const internal::MapFieldBase& map_field =
1236 reflection->GetRaw<internal::MapFieldBase>(
message,
1237 F(
"map_bool_bool"));
1238 if (map_field.IsRepeatedFieldValid()) {
1241 &reflection->GetRepeatedMessage(
message,
F(
"map_bool_bool"),
i);
1242 bool key = sub_message->GetReflection()->GetBool(*sub_message,
1243 map_bool_bool_key_);
1244 bool val = sub_message->GetReflection()->GetBool(*sub_message,
1245 map_bool_bool_val_);
1249 map_key.SetBoolValue(
keys[
i]);
1253 map_key, &map_value_const_ref));
1259 std::map<std::string, std::string>
map;
1262 std::vector<std::string>
keys = {
"0",
"1"};
1263 std::vector<std::string>
vals = {
"0",
"1"};
1264 for (
int i = 0;
i < 2;
i++) {
1265 const internal::MapFieldBase& map_field =
1266 reflection->GetRaw<internal::MapFieldBase>(
message,
1267 F(
"map_string_string"));
1268 if (map_field.IsRepeatedFieldValid()) {
1271 &reflection->GetRepeatedMessage(
message,
F(
"map_string_string"),
i);
1273 *sub_message, map_string_string_key_);
1274 std::string val = sub_message->GetReflection()->GetString(
1275 *sub_message, map_string_string_val_);
1279 map_key.SetStringValue(
keys[
i]);
1280 EXPECT_EQ(
true, reflection->ContainsMapKey(
1281 message,
F(
"map_string_string"), map_key));
1283 map_key, &map_value_const_ref));
1289 std::map<int32_t, std::string>
map;
1292 for (
int i = 0;
i < 2;
i++) {
1293 const internal::MapFieldBase& map_field =
1294 reflection->GetRaw<internal::MapFieldBase>(
message,
1295 F(
"map_int32_bytes"));
1296 if (map_field.IsRepeatedFieldValid()) {
1299 &reflection->GetRepeatedMessage(
message,
F(
"map_int32_bytes"),
i);
1300 int32_t key = sub_message->GetReflection()->GetInt32(
1301 *sub_message, map_int32_bytes_key_);
1302 std::string val = sub_message->GetReflection()->GetString(
1303 *sub_message, map_int32_bytes_val_);
1307 map_key.SetInt32Value(
i);
1308 EXPECT_EQ(
true, reflection->ContainsMapKey(
1309 message,
F(
"map_int32_bytes"), map_key));
1311 map_key, &map_value_const_ref));
1317 std::map<int32_t, const EnumValueDescriptor*>
map;
1318 map[0] = map_enum_bar_;
1319 map[1] = map_enum_baz_;
1320 for (
int i = 0;
i < 2;
i++) {
1321 const internal::MapFieldBase& map_field =
1322 reflection->GetRaw<internal::MapFieldBase>(
message,
1323 F(
"map_int32_enum"));
1324 if (map_field.IsRepeatedFieldValid()) {
1327 &reflection->GetRepeatedMessage(
message,
F(
"map_int32_enum"),
i);
1328 int32_t key = sub_message->GetReflection()->GetInt32(
1329 *sub_message, map_int32_enum_key_);
1331 *sub_message, map_int32_enum_val_);
1335 map_key.SetInt32Value(
i);
1339 map_key, &map_value_const_ref));
1340 EXPECT_EQ(map_value_const_ref.GetEnumValue(),
map[
i]->number());
1345 std::map<int32_t, int32_t>
map;
1348 for (
int i = 0;
i < 2;
i++) {
1349 const internal::MapFieldBase& map_field =
1350 reflection->GetRaw<internal::MapFieldBase>(
1351 message,
F(
"map_int32_foreign_message"));
1352 if (map_field.IsRepeatedFieldValid()) {
1354 sub_message = &reflection->GetRepeatedMessage(
1355 message,
F(
"map_int32_foreign_message"),
i);
1356 int32_t key = sub_message->GetReflection()->GetInt32(
1357 *sub_message, map_int32_foreign_message_key_);
1358 const Message& foreign_message =
1359 sub_message->GetReflection()->GetMessage(
1360 *sub_message, map_int32_foreign_message_val_);
1361 int32_t val = foreign_message.GetReflection()->GetInt32(foreign_message,
1366 map_key.SetInt32Value(
i);
1367 EXPECT_EQ(
true, reflection->ContainsMapKey(
1368 message,
F(
"map_int32_foreign_message"), map_key));
1370 F(
"map_int32_foreign_message"),
1371 map_key, &map_value_const_ref));
1372 const Message& foreign_message = map_value_const_ref.GetMessageValue();
1373 EXPECT_EQ(foreign_message.GetReflection()->GetInt32(foreign_message,
1381 void MapReflectionTester::ExpectMapFieldsSetViaReflectionIterator(
1385 const Reflection* reflection =
message->GetReflection();
1406 std::map<int32_t, int32_t>
map;
1410 for (MapIterator
iter = reflection->MapBegin(
message,
F(
"map_int32_int32"));
1411 iter != reflection->MapEnd(
message,
F(
"map_int32_int32"));
1416 message->SerializeToString(&serialized);
1420 iter.GetValueRef().GetInt32Value());
1425 std::map<int64_t, int64_t>
map;
1428 for (MapIterator
iter = reflection->MapBegin(
message,
F(
"map_int64_int64"));
1431 iter.GetValueRef().GetInt64Value());
1435 std::map<uint32_t, uint32_t>
map;
1438 for (MapIterator
iter =
1439 reflection->MapBegin(
message,
F(
"map_uint32_uint32"));
1442 iter.GetValueRef().GetUInt32Value());
1446 std::map<uint64_t, uint64_t>
map;
1449 for (MapIterator
iter =
1450 reflection->MapBegin(
message,
F(
"map_uint64_uint64"));
1453 iter.GetValueRef().GetUInt64Value());
1457 std::map<int32_t, int32_t>
map;
1460 for (MapIterator
iter =
1461 reflection->MapBegin(
message,
F(
"map_sint32_sint32"));
1464 iter.GetValueRef().GetInt32Value());
1468 std::map<int64_t, int64_t>
map;
1471 for (MapIterator
iter =
1472 reflection->MapBegin(
message,
F(
"map_sint64_sint64"));
1475 iter.GetValueRef().GetInt64Value());
1479 std::map<uint32_t, uint32_t>
map;
1482 for (MapIterator
iter =
1483 reflection->MapBegin(
message,
F(
"map_fixed32_fixed32"));
1484 iter != reflection->MapEnd(
message,
F(
"map_fixed32_fixed32"));
1487 iter.GetValueRef().GetUInt32Value());
1491 std::map<uint64_t, uint64_t>
map;
1494 for (MapIterator
iter =
1495 reflection->MapBegin(
message,
F(
"map_fixed64_fixed64"));
1496 iter != reflection->MapEnd(
message,
F(
"map_fixed64_fixed64"));
1499 iter.GetValueRef().GetUInt64Value());
1503 std::map<int32_t, int32_t>
map;
1506 for (MapIterator
iter =
1507 reflection->MapBegin(
message,
F(
"map_sfixed32_sfixed32"));
1508 iter != reflection->MapEnd(
message,
F(
"map_sfixed32_sfixed32"));
1511 iter.GetValueRef().GetInt32Value());
1515 std::map<int32_t, float>
map;
1518 for (MapIterator
iter = reflection->MapBegin(
message,
F(
"map_int32_float"));
1521 iter.GetValueRef().GetFloatValue());
1525 std::map<int32_t, double>
map;
1528 for (MapIterator
iter =
1529 reflection->MapBegin(
message,
F(
"map_int32_double"));
1532 iter.GetValueRef().GetDoubleValue());
1536 std::map<bool, bool>
map;
1539 for (MapIterator
iter = reflection->MapBegin(
message,
F(
"map_bool_bool"));
1542 iter.GetValueRef().GetBoolValue());
1546 std::map<std::string, std::string>
map;
1550 for (MapIterator
iter =
1551 reflection->MapBegin(
message,
F(
"map_string_string"));
1552 iter != reflection->MapEnd(
message,
F(
"map_string_string"));
1557 message->SerializeToString(&serialized);
1561 iter.GetValueRef().GetStringValue());
1566 std::map<int32_t, std::string>
map;
1569 for (MapIterator
iter = reflection->MapBegin(
message,
F(
"map_int32_bytes"));
1572 iter.GetValueRef().GetStringValue());
1576 std::map<int32_t, const EnumValueDescriptor*>
map;
1577 map[0] = map_enum_bar_;
1578 map[1] = map_enum_baz_;
1579 for (MapIterator
iter = reflection->MapBegin(
message,
F(
"map_int32_enum"));
1582 iter.GetValueRef().GetEnumValue());
1586 std::map<int32_t, int32_t>
map;
1590 for (MapIterator
iter =
1591 reflection->MapBegin(
message,
F(
"map_int32_foreign_message"));
1592 iter != reflection->MapEnd(
message,
F(
"map_int32_foreign_message"));
1597 message->SerializeToString(&serialized);
1600 const Message& sub_message =
iter.GetValueRef().GetMessageValue();
1602 sub_message.GetReflection()->GetInt32(sub_message, foreign_c_));
1608 void MapReflectionTester::ExpectClearViaReflection(
const Message&
message) {
1609 const Reflection* reflection =
message.GetReflection();
1632 void MapReflectionTester::ExpectClearViaReflectionIterator(
Message*
message) {
1633 const Reflection* reflection =
message->GetReflection();
1635 reflection->MapEnd(
message,
F(
"map_int32_int32")));
1637 reflection->MapEnd(
message,
F(
"map_int64_int64")));
1639 reflection->MapEnd(
message,
F(
"map_uint32_uint32")));
1641 reflection->MapEnd(
message,
F(
"map_uint64_uint64")));
1643 reflection->MapEnd(
message,
F(
"map_sint32_sint32")));
1645 reflection->MapEnd(
message,
F(
"map_sint64_sint64")));
1647 reflection->MapEnd(
message,
F(
"map_fixed32_fixed32")));
1649 reflection->MapEnd(
message,
F(
"map_fixed64_fixed64")));
1651 reflection->MapEnd(
message,
F(
"map_sfixed32_sfixed32")));
1653 reflection->MapEnd(
message,
F(
"map_sfixed64_sfixed64")));
1655 reflection->MapEnd(
message,
F(
"map_int32_float")));
1657 reflection->MapEnd(
message,
F(
"map_int32_double")));
1659 reflection->MapEnd(
message,
F(
"map_bool_bool")));
1661 reflection->MapEnd(
message,
F(
"map_string_string")));
1663 reflection->MapEnd(
message,
F(
"map_int32_bytes")));
1665 reflection->MapEnd(
message,
F(
"map_int32_enum")));
1667 reflection->MapEnd(
message,
F(
"map_int32_foreign_message")));
1673 #include <google/protobuf/port_undef.inc>