--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
I would be greatful if you share these parts :)
Pavel
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
query ::= query-part | query "." query-part
query-part ::= field-name | field-name "[" selector "]"
selector ::= number | attr-query
attr-query ::= field-name "=" field-value
field-value ::= number | '"' text '"'
field-name ::= text
Here is form with extended predicates that I'd like to see:
query ::= query-part | query "." query-part
query-part ::= field-name | field-name "[" selector "]"
selector ::= number | attr-query
attr-query ::= attr-match | "!" attr-query | "(" attr-query ") | \
attr-query "or" attr-query | attr-query "and" attr-query
attr-match ::= field-name | field-name "=" field-value
field-value ::= number | '"' text '"'
field-name ::= text
Is it acceptable? I'll try to create python implementation of last form.
Pavel
Pavel
P.S. Added list to CC to return thread back there.
--
[1] http://psha.org.ru/git?p=psha/pbpath;a=summary
[2] http://psha.org.ru/git?p=psha/pbpath;a=tree;f=tests;hb=HEAD