This shouldn't happen.. That means your unfiltered C also contains uninitialized messages.. Did you add new required fields in your .proto file (or change optional to required)?
On Wed, Jun 8, 2011 at 5:55 AM, ksamdev <samvel.khalat...@gmail.com> wrote: > Hi, > > I've got nested messages like: > > message A > { > required double value = 1; > } > > message B > { > required A a = 1; > } > > message C > { > repeated B entries = 1; > } > > The C object is saved in file and may have any number of B entries. > However, now I'd like to save a copy of C in a different file with B's that > match some criteria, e.g. > > ... > C original; > // Read object from file > > C *copy = new C(); > typedef ::google::protobuf::RepeatedPtrField<B> Bs; > > for(Bs::const_iterator b = c->entries().begin(); > c->entries().end() != b; > ++b) > { > if (b->a().value() < 5) > continue; > > // Copy B entry and add it to the Filtered C > B *entry = copy->add_entries(); > *entry = *b; > } > // save copy > > Sometimes it happens that I get the error message upon reading filtered C: > > libprotobuf ERROR google/protobuf/message_lite.cc:123] Can't parse message > of type "C" because it is missing required fields: entries[0].A > > It seems that deep copy of nested repeated messages failed for some reason. > Any ideas how to fix this? > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/protobuf/-/WmZZUDM2ZDR0ZmNK. > To post to this group, send email to protobuf@googlegroups.com. > To unsubscribe from this group, send email to > protobuf+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/protobuf?hl=en. > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.