Protocol Buffer Repeated 对应类型为
::google::protobuf::RepeatedPtrField
如果想要遍历该类型,可以使用 iterator
typedef ::google::protobuf::RepeatedPtrField<Person> ptrf;// classmates is repeated type
ptrf *clsmates = school.mutable_classmates(); for (ptrf::iterator it = clsmates->begin(); it != clsmates->end(); ++it)
{it->set_name("xxx"); // name is a field in Personit->set_age(18);
}/**// SchoolMember.pb
message SchoolMember
{repeated Person classmates = 1;...
}message Person
{required string name = 1;required uint32 age = 2;
}*/