lundi 30 décembre 2019

Assign RepeatedPtrField to repeated field in a protobuf message

I have a RepeatedPtrField<M::Table> and a protobuf message M as:

message M {
  message Table {
    optional string guid = 1;
    optional int64 schema_version = 2;
    optional int64 data_version = 3;
    repeated Column column = 4;
  }
  repeated Table table = 1;
}

How to I create a instance of M having the contents of RepeatedPtrField. I can write a for loop to copy data explicitly, but I am currently looking for something more concise, preferably using std::move() like optimization.

Aucun commentaire:

Enregistrer un commentaire