SWI-Prolog / contrib-protobufs

An interface to Google Protocol Buffers (protobuf)
7 stars 7 forks source link

"Map" has no special support #12

Open kamahen opened 3 years ago

kamahen commented 3 years ago

"Map" has no special support. You can do "map" fields, but it's a bit klunky; instead of something like this:

'.MapMessage'{number_ints: _{one:1, two:2}}

you need to do

'.MapMessage'{number_ints:[
    '.MapMessage.NumberIntsEntry'{key:"two",value:2},
    '.MapMessage.NumberIntsEntry'{key:"one",value:1}]}

There are a few reasons for not supporting "map" right now. The biggest one is: what representation should be done for the map?

For the short term, the best solution is probably a "helper" predicate that translates between the various representations and the protobuf "map". This shouldn't be difficult to write, but I don't feel like doing it until it's actually needed.

kamahen commented 3 years ago

Partial support added with https://github.com/SWI-Prolog/contrib-protobufs/commit/a4f806c5385520ebf36b25f465921d1db2e27b6a