Re: [protobuf] Enumerating a variable's fields and setting them

2021-06-22 Thread 'Adam Cozzette' via Protocol Buffers
I think the easiest thing would be that wherever you're now storing a google::protobuf::FieldDescriptor*, you can also store a google::protobuf::Message* pointing to the parent message. On Tue, Jun 22, 2021 at 10:41 AM J G wrote: > Hi Adam, > > Yes, the HealthReport variable is the parent, and

Re: [protobuf] Enumerating a variable's fields and setting them

2021-06-22 Thread 'Adam Cozzette' via Protocol Buffers
So is it correct that HealthReport is the top-level message type and HardwareComponent is nested somewhere within that? I think what you're trying to do is doable, but when you call reflection->SetString(), you have to pass the immediate parent message containing the field, not the top-level

Re: [protobuf] Enumerating a variable's fields and setting them

2021-06-22 Thread J G
Hi again Adam, and thank you for taking the time to help me. Maybe I haven't explained what I am trying to do properly. I have a protobuf variable, which itself is composed of more nested variables. I am enumerating the fields of the variable. Where the item is a leaf, the field is a simple

Re: [protobuf] Enumerating a variable's fields and setting them

2021-06-22 Thread 'Adam Cozzette' via Protocol Buffers
Here's how you could set that nested field in your example (this code is untested so may not work exactly, but should be pretty close): const FieldDescriptor* health_report_field = parent.GetDescriptor()->FindFieldByName("healthreport"); Message* health_report =

Re: [protobuf] Enumerating a variable's fields and setting them

2021-06-22 Thread J G
Hi Adam, Yes, the HealthReport variable is the parent, and it contains a HardwareComponent variable, but I am enumerating the from the parent, meaning I am trying to not hard-code the structure of the contained items. So how would I obtain a pointer to the message for each leaf without

Re: [protobuf] Enumerating a variable's fields and setting them

2021-06-22 Thread J G
Hi Adam, OK, but would I need to know the fields in the message ahead of time? That is what I am trying to avoid. The paths of the nested messages are in a table, such as "healthreport/os/version", 3 So the healthreport variable is allocated, and it contains a component called os, which

Re: [protobuf] Enumerating a variable's fields and setting them

2021-06-22 Thread J G
Hello again, Adam, If I understand you correctly, the key would be to obtain the mutable-message (by name) for the child from the parent as I descend the tree. It think that would work! Thank you very much for your light, I'm a newbie to protobuf and this demystifies part of it. I'll see if I

Re: [protobuf] Enumerating a variable's fields and setting them

2021-06-22 Thread 'Adam Cozzette' via Protocol Buffers
I think the reason this is getting tricky is because you're trying to traverse the descriptors first and then look at the message tree afterward. I would expect it to be much easier if you traverse the message and look at the descriptors at the same time. On Tue, Jun 22, 2021 at 10:58 AM J G

Re: [protobuf] Enumerating a variable's fields and setting them

2021-06-22 Thread J G
Hi Adam, That works for the first iteration, but I descend the tree like so: bool enumpb( const char * pszpath, ENUMPROTOPROC f, const google::protobuf::Descriptor * d, uintptr_t param ) { std::string path = pszpath; for ( int i = 0; i < d->field_count(); i++ ) { auto field

[protobuf] A question about syntax declaration warnings.

2021-06-22 Thread Gobot1234
Hi, I was just wondering why when no syntax declaration is found in a protobuf file the warning is put straight on to the std::err using GOOGLE_LOG and not able to be handled using io::ErrorCollector.AddWarning in compiler::Parser::Parse. Thanks, James. -- You received this message because

Re: [protobuf] Protobuf-java and Protobuf-javalite

2021-06-22 Thread 'Matthew Perkins' via Protocol Buffers
Firebase is using: protobuf-javalite:3.14.0 On Tuesday, June 22, 2021 at 5:12:02 PM UTC-5 Derek Perez wrote: > Can you tell what version of protobuf firebase is pulling in? I wonder if > we can get one or the other updated? > > On Tue, Jun 22, 2021 at 2:53 PM 'Matthew Perkins' via Protocol

Re: [protobuf] Protobuf-java and Protobuf-javalite

2021-06-22 Thread 'Matthew Perkins' via Protocol Buffers
I did. But it's not a version number issue, its a lite vs full issue. On Tuesday, June 22, 2021 at 5:27:18 PM UTC-5 Derek Perez wrote: > Have you tried reaching out to firebase to see if they can release a > version w/ updated deps? They are pretty far behind. > > On Tue, Jun 22, 2021 at 3:21

Re: [protobuf] Protobuf-java and Protobuf-javalite

2021-06-22 Thread 'Matthew Perkins' via Protocol Buffers
Makes sense. Thanks for the assistance. On Tuesday, June 22, 2021 at 5:33:10 PM UTC-5 Derek Perez wrote: > Ah right, I see. > > OK, yeah your best option is to get the other dependency to move to lite > or drop it. If this is a mobile project you'll definitely wanna stay with > lite for

Re: [protobuf] Protobuf-java and Protobuf-javalite

2021-06-22 Thread 'Derek Perez' via Protocol Buffers
Ah right, I see. OK, yeah your best option is to get the other dependency to move to lite or drop it. If this is a mobile project you'll definitely wanna stay with lite for performance reasons. On Tue, Jun 22, 2021 at 3:29 PM 'Matthew Perkins' via Protocol Buffers < protobuf@googlegroups.com>

[protobuf] Protobuf-java and Protobuf-javalite

2021-06-22 Thread 'Matthew Perkins' via Protocol Buffers
Hi guys, We have an android app that we're attempting to use Firebase in, but a dependency we use is using protobuf-java causing conflicts with Firebase and it's inclusion of protobuf-javalite. We've found some suggestions but nothing really consistent. We can get the application to build and

Re: [protobuf] Protobuf-java and Protobuf-javalite

2021-06-22 Thread 'Derek Perez' via Protocol Buffers
Have you tried reaching out to firebase to see if they can release a version w/ updated deps? They are pretty far behind. On Tue, Jun 22, 2021 at 3:21 PM 'Matthew Perkins' via Protocol Buffers < protobuf@googlegroups.com> wrote: > Attached is the build error I'm encountering > > On Tuesday, June

Re: [protobuf] Protobuf-java and Protobuf-javalite

2021-06-22 Thread 'Derek Perez' via Protocol Buffers
Can you tell what version of protobuf firebase is pulling in? I wonder if we can get one or the other updated? On Tue, Jun 22, 2021 at 2:53 PM 'Matthew Perkins' via Protocol Buffers < protobuf@googlegroups.com> wrote: > Hi guys, > > We have an android app that we're attempting to use Firebase

Re: [protobuf] Protobuf-java and Protobuf-javalite

2021-06-22 Thread 'Matthew Perkins' via Protocol Buffers
Attached is the build error I'm encountering On Tuesday, June 22, 2021 at 5:15:44 PM UTC-5 Matthew Perkins wrote: > Firebase is using: protobuf-javalite:3.14.0 > > On Tuesday, June 22, 2021 at 5:12:02 PM UTC-5 Derek Perez wrote: > >> Can you tell what version of protobuf firebase is pulling in?

Re: [protobuf] Enumerating a variable's fields and setting them

2021-06-22 Thread J G
Hello Adam, OK, I understand, so I've tried this, but I get an error. void my_set_value( class healthreport * r, const char * defaultvalue, const google::protobuf::FieldDescriptor * descriptor ) { auto reflection = r->report->GetReflection(); switch( descriptor->type() ) {

Re: [protobuf] Enumerating a variable's fields and setting them

2021-06-22 Thread 'Adam Cozzette' via Protocol Buffers
It looks to me like r->report points to a vafmsg.HealthReport but the field descriptor refers to a field in another message (vafmsg.HardwareComponent). On Tue, Jun 22, 2021 at 7:42 AM J G wrote: > Hello Adam, > > OK, I understand, so I've tried this, but I get an error. > > void my_set_value(