On Tue, Jul 2, 2013 at 10:32 AM, <proto...@googlecode.com> wrote:

>
> Comment #2 on issue 527 by guillaum...@gmail.com: C++: Descriptor is set
> to null when loading more than one file.
> http://code.google.com/p/**protobuf/issues/detail?id=527<http://code.google.com/p/protobuf/issues/detail?id=527>
>
> WRITE
> fstream output(charPath, ios::out | ios::trunc | ios::binary);
> if (!reportHeader.**SerializeToOstream(&output))
> {
>         cerr << "Failed to write protocol buffer." << endl;
>         return -1;
> }
>
> READ
> fstream in(inPath, ios::in | ios::binary);
> if (!deserializedReportHeader.**ParseFromIstream(&in))
> {
>         cerr << "Failed to parse proto." << endl;
>         exit(1);
> }
>
> And I get the descriptor using
> const Descriptor* descriptor = pMessage->GetDescriptor();
> int a = descriptor->field_count();
>
You were probably mistaking descriptor->field_count() as the number of
fields set?
To get a list of fields set, you should use
message->GetReflection()->ListFields().


>
> Does that help?
>
>
> --
> You received this message because this project is configured to send all
> issue notifications to this address.
> You may adjust your notification preferences at:
> https://code.google.com/**hosting/settings<https://code.google.com/hosting/settings>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to 
> protobuf+unsubscribe@**googlegroups.com<protobuf%2bunsubscr...@googlegroups.com>
> .
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at 
> http://groups.google.com/**group/protobuf<http://groups.google.com/group/protobuf>
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
> .
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to