Nikhil K
Nikhil K

Reputation: 31

How to store large buffer/array (char/int) using protocol buffer in cpp...?

Is there any way to store array using google protocol buffer in cpp without using repeated. I need to store and send buffer (of size 640x480x2) consisting image data. Also how to store uint16_t array data using protocol buffer..?

Upvotes: 2

Views: 1888

Answers (1)

Tezirg
Tezirg

Reputation: 1639

  • In protobuf repeated = array. I don't see why you cannot use repeated uint32 img = field_num
  • If you really want to store into a byte array, you can try pb.set_mybytearray( std::string( data, data_length ) );

  • Protobuf does not support uint16 : https://developers.google.com/protocol-buffers/docs/reference/proto3-spec#fields. I'd recommend to use the uint32 type. Given that protobuf encodes values into varint the message will not contain 2 bytes of zeros.

Upvotes: 1

Related Questions