[protobuf] How to get a field object using name in proto3 like MutableExtension

2021-11-10 Thread Mihir Thakkar
Hello everyone,

Intro: My company is in the process of migrating schemas from proto2 to 
proto3. I am eliminating extensions as they are not supported. 

Question: I am wondering if it is possible to get a field object using it's 
name.

Example: In proto2, my current code looks like this:

*> Foo.proto*
message Foo {
message Bar {
unint32 a = 1;
}
extend Foo {
Bar b = 1;
}
}

*> in C++*
*Foo::Bar b_val = foo.MutableExtension(Foo::b);*

Now in proto3, I could do this:

*> Foo.proto*
syntax="proto3";
message Foo {
message Bar {
unint32 a = 1;
}
Bar b = 1;
}

*> in C++*
*Foo::Bar b_val = foo.mutable_b();*

However, I want to use the name Foo::b to get a Foo::Bar object. Is there a 
way to do this? If there is, which one is recommended?

Thanks,
Mihir

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/4b958fe0-5ec9-4fd9-99a9-cf096e6ff289n%40googlegroups.com.


Re: [protobuf] can protobuf3 be used with protobuf2?

2020-02-03 Thread Mihir Thakkar
I am trying to use proto2 on client-side and proto3 on server-side. My 
schema files use extensions, and I am assuming this is still true so I 
cannot do it?
Can anybody confirm?

On Thursday, April 28, 2016 at 6:18:12 PM UTC-4, Feng Xiao wrote:
>
>
>
> On Tue, Apr 26, 2016 at 7:04 PM, Bo Gao > 
> wrote:
>
>> suppose server side is updating into protobuf3, but client side still use 
>> protobuf2, can then communicate will?
>>
> Yes, as long as you only use proto3 features, they are wire compatible.
>  
>
>> -- 
>> 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 prot...@googlegroups.com .
>> To post to this group, send email to prot...@googlegroups.com 
>> .
>> 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/68b4c932-3d9a-4a71-bb36-dff4988b75b0%40googlegroups.com.