What is the return value of ParseFromIStream()? My guess is false. Are you making sure to open your files in binary mode? You *must* pass the ios::binary flag when opening, otherwise newline conversion will corrupt the file.
Are you writing anything else to the file other than your protobuf? Protobufs are not self-delimiting so if you do this, you must do something like write the size first so that you can make sure to read and parse only that many bytes. On Thu, Jan 28, 2010 at 9:59 AM, iWalsh <iain.d.wa...@googlemail.com> wrote: > Hi > I've created some logging functionality for a project I'm working > on. It creates a series of LogEvents for different system events. > > Here's part of the message definition: > > message Log { > message LogEvent { > message NetInfo { > optional string ip_address > =1; > optional string login > =2; > optional bytes mac > =3; > optional bool wireless > =4; > optional string ssid > =5; > enum wlessSecEnum { > NOAUTH =0; > WEP =1; > WPAPSK_TKIP =2; > WPAPSK_AES =3; > UNSUPPORTED =4; > } > optional wlessSecEnum wless_security =6; > enum ipconfigEnum { > DHCP =0; > STATIC =1; > PPPOE =2; > } > optional wlessSecEnum wless_security =6; > enum ipconfigEnum { > DHCP =0; > STATIC =1; > PPPOE =2; > } > optional ipconfigEnum ip_config > =7; > optional string default_route > =8; > optional string primary_DNS > =9; > optional string secondary_DNS > =10; > optional bool proxy > =11; > > } > optional sfixed64 timestamp > =3; > optional string productId > =4; > optional string detail > =5; > optional NetInfo netDetail > =9; > } > > repeated LogEvent events > =1; > optional string version > =2; > optional sfixed64 writetimestamp > =3; > } > > > Sorry for the convoluted structure. Anyway it serialises to a file > correctly, it's in a correct state then I use the SerializeToOstream() > method to write to a file. The file from inspection has all the data > and lots of events after the net connection event. So I know it's > correct as the strings are readable in notepad++. > > However when I try to read back from the file using ParseFromIstream() > I get a properly constructed Log message. However all the fields after > the NetInfo.mac are set to defaults, and all the repeated LogEvents > after that one are missing. I know they're in the serialised file but > I can't parse them back in. > > I've tried doing mac as a string, bytes, making sure there are no null > characters etc. However nothing seems to fix it. > > Any help would be appreciated. > > Regards > > Iain > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To post to this group, send email to proto...@googlegroups.com. > To unsubscribe from this group, send email to > protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@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 proto...@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.