XmmsClient
Functions
CollectionParser

Generate a collection structure from a string pattern. More...

Functions

int xmmsv_coll_parse (const char *pattern, xmmsv_t **coll)
 Try to parse the given pattern to produce a collection structure. More...
 
int xmmsv_coll_parse_custom (const char *pattern, xmmsv_coll_parse_tokens_f parse_f, xmmsv_coll_parse_build_f build_f, xmmsv_t **coll)
 Try to parse the given pattern to produce a collection structure, using custom token-parsing and collection-building functions. More...
 
xmmsv_coll_token_txmmsv_coll_default_parse_tokens (const char *str, const char **newpos)
 The default token parser. More...
 
xmmsv_txmmsv_coll_default_parse_build (xmmsv_coll_token_t *tokens)
 Default collection structure builder. More...
 

Detailed Description

Generate a collection structure from a string pattern.

The grammar of the default parser is the following:

S         := OPERATION
EXPR      := POSSEQ | IDSEQ | FILTER | TOKEN_GROUP_OPEN OPERATION TOKEN_GROUP_CLOSE | UNARYOP
PROP      := TOKEN_PROP_LONG | TOKEN_PROP_SHORT
INTVAL    := INTEGER | SEQUENCE
STRVAL    := STRING | PATTERN
POSSEQ    := INTVAL
IDSEQ     := TOKEN_SYMBOL_ID INTVAL
OPERATION := ANDOP
UNAOP     := TOKEN_OPSET_NOT EXPR | TOKEN_REFERENCE STRING
ANDOP     := OROP ANDOP | OROP TOKEN_OPSET_AND ANDOP | OROP
OROP      := EXPR TOKEN_OPSET_OR OROP | EXPR
FILTER    := UNAFILTER | BINFILTER | STRVAL
UNAFILTER := TOKEN_OPFIL_HAS PROP
BINFILTER := PROP TOKEN_OPFIL_EQUALS STRING | PROP TOKEN_OPFIL_MATCH STRVAL |
             PROP TOKEN_OPFIL_SMALLER INTEGER | PROP TOKEN_OPFIL_GREATER INTEGER |
             TOKEN_OPFIL_EQUALS STRING | TOKEN_OPFIL_MATCH STRVAL

Function Documentation

xmmsv_t* xmmsv_coll_default_parse_build ( xmmsv_coll_token_t tokens)

Default collection structure builder.

Parameters
tokensThe chained list of tokens.
Returns
The corresponding collection structure.

Referenced by xmmsv_coll_parse().

xmmsv_coll_token_t* xmmsv_coll_default_parse_tokens ( const char *  str,
const char **  newpos 
)

The default token parser.

Parameters
strThe string to parse for a token.
newposThe position in the string after the found token.
Returns
The token found in the string.

Referenced by xmmsv_coll_parse().

int xmmsv_coll_parse ( const char *  pattern,
xmmsv_t **  coll 
)

Try to parse the given pattern to produce a collection structure.

Parameters
patternThe string to generate a collection from.
collThe pointer to which the collection will be saved.
Returns
TRUE if the parsing succeeded, false otherwise.
int xmmsv_coll_parse_custom ( const char *  pattern,
xmmsv_coll_parse_tokens_f  parse_f,
xmmsv_coll_parse_build_f  build_f,
xmmsv_t **  coll 
)

Try to parse the given pattern to produce a collection structure, using custom token-parsing and collection-building functions.

This can be used to extend the default syntax of the parser.

New token ids can be used, starting from XMMS_COLLECTION_TOKEN_CUSTOM upwards.

Parameters
patternThe string to generate a collection from.
parse_fThe parsing function used to generate a list of tokens from the pattern string.
build_fThe building function that produces the collection structure from the list of tokens.
collThe pointer to which the collection will be saved.
Returns
TRUE if the parsing succeeded, false otherwise.

Referenced by xmmsv_coll_parse().