File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -186,10 +186,11 @@ class RFL_API Writer {
186186 template <class T >
187187 OutputVarType add_value_to_map (const std::string_view& _name, const T& _var,
188188 OutputMapType* _parent) const {
189- auto entries =
190- OutputArrayType{_parent->val_ .get (" entries" ).as <capnp::DynamicList>()};
189+ auto entries = OutputArrayType{
190+ .val_ = _parent->val_ .get (" entries" ).as <capnp::DynamicList>(),
191+ .ix_ = _parent->ix_ ++};
191192 auto new_entry = add_object_to_array (2 , &entries);
192- add_value_to_object (" key" , _name, &new_entry);
193+ add_value_to_object (" key" , std::string ( _name) , &new_entry);
193194 return add_value_to_object (" value" , _var, &new_entry);
194195 }
195196
Original file line number Diff line number Diff line change 1+ #include < map>
2+ #include < rfl.hpp>
3+ #include < string>
4+
5+ #include " write_and_read.hpp"
6+
7+ namespace test_map_value_types {
8+
9+ struct PersonWithStringMap {
10+ rfl::Rename<" firstName" , std::string> first_name;
11+ std::map<std::string, std::string> nicknames;
12+ };
13+
14+ TEST (capnproto, test_map_with_string_values) {
15+ auto nicknames = std::map<std::string, std::string>();
16+ nicknames[" Bart" ] = " El Barto" ;
17+ nicknames[" Lisa" ] = " Lis" ;
18+ nicknames[" Maggie" ] = " Mags" ;
19+
20+ const auto homer = PersonWithStringMap{.first_name = " Homer" ,
21+ .nicknames = std::move (nicknames)};
22+
23+ write_and_read (homer);
24+ }
25+ } // namespace test_map_value_types
You can’t perform that action at this time.
0 commit comments