I'm trying to do the following:
// Set up:
Message* foo = new Foo;
const Descriptor* descriptor = foo->GetDescriptor();
const FieldDescriptor* my_int_field = descriptor->FindFieldByName("my_int32"
);
foo->ParseFromString(data);
const Reflection* reflection = foo->GetReflection();
// This fails:
*const int32* ptr_to_int_field = &(reflection->GetInt32(*foo,
my_int32_field));*
Since reflection->GetInt32() returns a temporary, this fails. Same for all
the Get* methods.
My problem would be solved if Reflection exposed, from
GeneratedMessageReflection,
template <typename Type>
inline Type* MutableField(Message* message,
const FieldDescriptor* field) const;
But it does not, and cannot be hacked to do so without mucking in the
implementation class.
Is there a decent way to get a pointer to an arbitrary simple field (not
repeated, not a message type), for a message type known only at run time?
Is there a hard reason why the Reflection::Get*() methods don't return a
reference?
Thanks.
-Matthew
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.