Thanks for your repsonse Feng!

 We've ended up doing exactly that in Scala, actually.

Regards,
Philipp

Op vrijdag 5 augustus 2016 20:23:30 UTC+2 schreef Feng Xiao:
>
>
>
> On Thu, Aug 4, 2016 at 5:47 AM, Philipp Weissenbacher <
> philipp.we...@gmail.com <javascript:>> wrote:
>
>> Hi all,
>>
>> We are currently implementing a testing library. One goal is to allow the 
>> client to test sending and receiving ProtoBuf messages.
>> For this, we need a generic way to create them, without requiring the 
>> client to supply the generated proxy classes.
>> This means MyType.getDefaultInstance() (as suggested here 
>> <https://groups.google.com/forum/#!searchin/protobuf/generic%7Csort:relevance/protobuf/w3enqjfLQ4k/fRtI_WjlwxcJ>)
>>  
>> would not work.
>>
>> So, is there a generic way to create ProtoBuf messages (e.g. from .proto 
>> files) at runtime?
>>
> If you are using C++, you can use the Importer class:
>
> https://github.com/google/protobuf/blob/master/src/google/protobuf/compiler/importer.h#L148
>
> to parse .proto files to FileDescriptor and then use DynamicMessage to 
> create message instances:
>
> https://github.com/google/protobuf/blob/master/src/google/protobuf/dynamic_message.h#L118
>
> After that you can parse/serialize and manipulate the message instances 
> using the reflection API:
>
> https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.message#Reflection
>
>  
>
>>
>> BTW, we're using Scala/Java and protobuf2.
>>
>> Sincerely,
>> Philipp
>>
>> -- 
>> 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+u...@googlegroups.com <javascript:>.
>> To post to this group, send email to prot...@googlegroups.com 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/protobuf.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to