Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert into a protobuf map in c++?

For the following Maps unable to insert into the Map

map<string, double> doubleProps = 4;
map<string, int32> intProps = 5;
map<string,string> stringProps=6;

Here are the following which I have tried , but its not working

doubleProps["key"]="value" //doesn't work
*(doubleProps["key"]).insert("value") //doesn't work
doubleProps.insert("key","value")
like image 507
Rai Bose Avatar asked Jan 29 '26 08:01

Rai Bose


1 Answers

This is the way to insert into a map in protobuf object in c++

(*mutable_stringprops())["key"]=value

https://developers.google.com/protocol-buffers/docs/reference/cpp-generated#map-fields

like image 68
deepg Avatar answered Jan 31 '26 21:01

deepg