Re: Printing out unset fields

2009-04-15 Thread Joe

Awesome, that'll do it.  Thanks!

Joe


On Apr 15, 6:03 am, Kevin Weil  wrote:
> ... and once you have the FieldDescriptor, you can call hasDefaultValue and
> getDefaultValue to fill in values for unset fields with defaults.
>
> Kevin
>
> On Tue, Apr 14, 2009 at 8:06 PM, Kenton Varda  wrote:
> > The descriptor itself contains a list of all of the defined fields for the
> > type.  E.g.:
> >   const Descriptor* type = message->GetDescriptor();
> >   for (int i = 0; i < type->field_count(); i++) {
> >     const FieldDescriptor* field = type->field(i);
> >     // handle field
> >   }
>
> > On Tue, Apr 14, 2009 at 6:09 PM, Joe  wrote:
>
> >> I'm using the TextFormat provided by protocol buffers to read in and
> >> print out messages in ... text format.  I have a lot of optional
> >> fields with defaults in my .proto file.  When I do a
> >> TextFormat::Print, only set values are printed.  I'd like
> >> TextFormat::Print to also print unset values.  Am I crazy?
>
> >> I tried to figure out a way to do this using the reflection API, but
> >> it seems to only provide a way to list the set fields of a message.
> >> Is there any other way to do this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~--~~~~--~~--~--~---



Re: Printing out unset fields

2009-04-15 Thread Kevin Weil
... and once you have the FieldDescriptor, you can call hasDefaultValue and
getDefaultValue to fill in values for unset fields with defaults.

Kevin

On Tue, Apr 14, 2009 at 8:06 PM, Kenton Varda  wrote:

> The descriptor itself contains a list of all of the defined fields for the
> type.  E.g.:
>   const Descriptor* type = message->GetDescriptor();
>   for (int i = 0; i < type->field_count(); i++) {
> const FieldDescriptor* field = type->field(i);
> // handle field
>   }
>
> On Tue, Apr 14, 2009 at 6:09 PM, Joe  wrote:
>
>>
>> I'm using the TextFormat provided by protocol buffers to read in and
>> print out messages in ... text format.  I have a lot of optional
>> fields with defaults in my .proto file.  When I do a
>> TextFormat::Print, only set values are printed.  I'd like
>> TextFormat::Print to also print unset values.  Am I crazy?
>>
>> I tried to figure out a way to do this using the reflection API, but
>> it seems to only provide a way to list the set fields of a message.
>> Is there any other way to do this?
>>
>>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~--~~~~--~~--~--~---



Re: Printing out unset fields

2009-04-14 Thread Kenton Varda
The descriptor itself contains a list of all of the defined fields for the
type.  E.g.:
  const Descriptor* type = message->GetDescriptor();
  for (int i = 0; i < type->field_count(); i++) {
const FieldDescriptor* field = type->field(i);
// handle field
  }

On Tue, Apr 14, 2009 at 6:09 PM, Joe  wrote:

>
> I'm using the TextFormat provided by protocol buffers to read in and
> print out messages in ... text format.  I have a lot of optional
> fields with defaults in my .proto file.  When I do a
> TextFormat::Print, only set values are printed.  I'd like
> TextFormat::Print to also print unset values.  Am I crazy?
>
> I tried to figure out a way to do this using the reflection API, but
> it seems to only provide a way to list the set fields of a message.
> Is there any other way to do this?
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~--~~~~--~~--~--~---