We don't have a formal spec of it or anything, but from what I can
tell we evolved the same syntax as the internal Google effort.  No
frills, just a sequence of N field names separated by dots (.). I'll
try to write out the rules in English, but I might mess this up since
I'm just doing it from memory...

The 1st through N-1th field can be:

  a required/optional Message field_name
  a repeated Message field_name subscripted by [INDEX|
SUBFIELD_NAME=value]

and the Nth field could be:

  a repeated field_name subscripted by [INDEX|SUBFIELD_NAME=value]
  a required, optional, or repeated field_name

INDEX is any integer, where values >=0 indicate the sequence number of
the element in the repeated field, or <0 in which case it counts from
the last item, Python-style, so [-1] is the last element.

SUBFIELD_NAME can be any [required|optional] [string|int*] field in
the field_name Message.

Does that make sense?  Sorry it's not a formal syntax, I never took
that class. ;)  I just wrote the parser directly, using
boost::tokenizer.

If you do write up the formal syntax, please post it!

Scott

On Dec 18, 2:21 am, Pavel Shramov <shra...@mexmat.net> wrote:
> On Fri, Dec 04, 2009 at 02:17:33PM -0800, Scott Stafford wrote:
> > Hi -
>
> > We built a simplifiedXPath-like syntax (and implementation for C++)
> > to control the Reflection interface via strings.  For instance,
> ... skip ...
> > PBPath::GetInt32( myMessage, "field2[id=50].field3[1]" );
>
> > would search myMessage.field2() for a message with id()==50, then get
> > the second element of Substructure.field3() and return it.
>
> May You share details about query syntax?
>
> > Is this something people would be interested in if I cleaned it up for
> > release as a separate library?  Is there any interest in me submitting
> > a patch to build it in to the protobuf library directly in some form?
> > If so, what form?
> > The implementation involves digesting thexpath-like string into a
> > protobuf object that contains field ids and so on.
>
> So You have formal (protobuf) description of this syntax?
>
> I would be greatful if you share these parts :)
>
>                                 Pavel

--

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@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.


Reply via email to