Google protocol buffers and stl vectors, maps, and raising general pointers

Are google protocol buffers supported to support stl vectors, maps, and raising common pointers? I have some objects that heavily use stl containers like maps , vectors , as well as boost::shared_ptr . I want to use google protocol buffers to serialize these objects over the network on different machines.

I want to know if goob protobuf supports these containers? Also, if I use apache thrift instead, would it be better? I only need to serialize / de-serialize the data and not need the network transport that apache trift offers. In addition, Apache thrift, which does not have proper documentation, lets me go.

+4
source share
1 answer

Protocol buffers directly process a small number of constructs; vectors are well matched with the "repeating" type of element, but as presented in C ++ through the "add" methods, you don’t (AFAIK) just pass the vector to it. See "Re-nested Message Fields" here for more information.

Re displays; there is no built-in mechanism for this, but a key / value pair is easily represented in .proto (usually the key value = 1, value = 2), and then it is processed through "reuse".

The shared_ptr itself hardly makes sense in a serialized file. But an object can be treated (presumably) as a message.

Please note that the DTO layer is generated in the Google C ++ version, so you may need to map between them and any existing object model. This is usually pretty trivial.

For some languages ​​/ platforms, there are protobuffs that work against existing object models.

(sorry, I can not comment on thrift - I am not familiar with it)

+7
source

Source: https://habr.com/ru/post/1338219/


All Articles