TextFormat and unknown fields

217 views
Skip to first unread message

m.and...@gmail.com

unread,
Aug 14, 2008, 12:53:22 PM8/14/08
to Protocol Buffers
Hallo everybody,

shouldn't TextFormat::Parse accept unknown fields in the same way as
Message::ParseFromIstream does?

Currently it fails with " Error parsing text-format *** Message type
*** has no field named ***" message.

best regards,
Micha

Kenton Varda

unread,
Aug 14, 2008, 4:44:33 PM8/14/08
to m.and...@gmail.com, Protocol Buffers
TextFormat isn't really intended to be used in this way.  TextFormat is intended to facilitate communication between software and human programmers.  Communication between two pieces of software should always be done in binary format.  There's almost never a need to parse unknown fields in text written by a human.

m.and...@gmail.com

unread,
Aug 15, 2008, 4:08:50 AM8/15/08
to Protocol Buffers
yes, i understand that, but since i use protocol buffers anyway i
thought i might just as well use them for saving/loading parameters
from config files.

In such case:

a) files must be human readable and changable
b) some obsolete parameters might be removed, but i still want old
config files to be readable by new version of the program

regards,
Micha

On Aug 14, 10:44 pm, "Kenton Varda" <ken...@google.com> wrote:
> TextFormat isn't really intended to be used in this way. TextFormat is
> intended to facilitate communication between software and human programmers.
> Communication between two pieces of software should always be done in
> binary format. There's almost never a need to parse unknown fields in text
> written by a human.
>

Kenton Varda

unread,
Aug 15, 2008, 12:37:37 PM8/15/08
to m.and...@gmail.com, Protocol Buffers
Oh, I misunderstood your question slightly.  I thought you were talking about the numeric tag/value pairs you get when you use TextFormat to print a message that contains unknown fields.  You mean that you think TextFormat should skip named fields if the name is unknown.

The problem with this is that TextFormat would no longer be able to detect misspelled names and similar errors in the input.  We decided that strong error-checking is more important than ignoring unknown fields when parsing text format.

That said, I could be convinced to add an option to TextFormat::Parser which would change this behavior.
Reply all
Reply to author
Forward
0 new messages