![]() |
pianod2
multisource multiuser scriptable networked music player
|
Functions and types for parsing and interpreting predicates. More...
Classes | |
struct | Predicate |
Enumerations | |
enum | MANNER { MANNER::NAME, MANNER::ID, MANNER::WHERE, MANNER::LIKE, MANNER::SOURCE } |
Manners in which predicates may be specified. More... | |
Functions | |
void | construct_predicate_parsers (PianodParser *parser) |
static Predicate | getFullPredicate (const PianodConnection &conn, const Parsnip::Data &predicate, Filter::Field field) |
Parse a command's predicate and return a matching filter. More... | |
std::unique_ptr< Filter > | getPredicate (const PianodConnection &conn, const Parsnip::Data &predicate, Filter::Field field) |
Return just the filter portion of a predicate, for external use. More... | |
static ThingieList | getPredicateIdItems (const Parsnip::Data &predicate) |
Specialization for getting things by ID. More... | |
static ThingieList | getPartialSpecifiedThings (Predicate &pred, SearchRange search_what) |
Gather a list of assorted things specified by a predicate, which must be present. More... | |
ThingieList | getSpecifiedThings (const PianodConnection &conn, const Parsnip::Data &predicate, SearchRange search_what) |
Gather a list of assorted things specified by a predicate. More... | |
MusicThingie * | getSpecifiedThing (const PianodConnection &conn, const Parsnip::Data &predicate) |
Interpret a request for an unspecified type of thing and return it. More... | |
static PlaylistList | getSpecifiedPlaylistsById (const Parsnip::Data &predicate) |
Get playlist items by id. More... | |
PlaylistList | getSpecifiedPlaylists (const PianodConnection &conn, const Parsnip::Data &predicate) |
Interpret a list of playlists specified by a predicate. More... | |
PianodPlaylist * | getSpecifiedPlaylist (const PianodConnection &conn, const Parsnip::Data &predicate) |
Gather a request for a single playlist and return it. More... | |
SongList | getSpecifiedSongs (const PianodConnection &conn, const Parsnip::Data &predicate, SearchRange search_what) |
Interpret a list of songs specified by a predicate. More... | |
PianodSong * | getSpecifiedSong (const PianodConnection &conn, const Parsnip::Data &predicate) |
Gather a request for a single song and return it. More... | |
bool | havePredicate (const Parsnip::Data &options) |
Check for presence of a predicate. More... | |
Variables | |
const LookupTable< MANNER > | PredicateManners ({ { "name", MANNER::NAME }, { "id", MANNER::ID }, { "where", MANNER::WHERE }, { "like", MANNER::LIKE } }) |
Lookup table for manner names to enumeration. More... | |
const LookupTable< Filter::Field > | SearchFields ({ { "any", Filter::Field::Search }, { "artist", Filter::Field::Artist }, { "album", Filter::Field::Album }, { "song", Filter::Field::Title }, { "playlist", Filter::Field::Playlist }, { "genre", Filter::Field::Genre } }) |
Lookup table for optional type to filter field. More... | |
Functions and types for parsing and interpreting predicates.
|
strong |
void Predicate::construct_predicate_parsers | ( | PianodParser * | parser | ) |
|
static |
Parse a command's predicate and return a matching filter.
Predicate forms are:
ID {id} ...
(exact match on 1 or more IDs)NAME {name} ...
(exact match on 1 or more names)[type] LIKE {text} ...
(permuted on text
) If type
was not specified, each word matches any text field; otherwise, the words must match on the specified field.WHERE {expression} ...
(logical filter expression)SOURCE TYPE {type} NAME {name} {manner} {expression} ...
Executes one of the other manners of predicates against a specific source.This function requires the command be defined with the following named fields:
manner
- to match the predicate keywordexpression
- the start of the predicate parametertype
(optional) - the optional type for LIKE. Tag names vary slightly for playlist predicates. (It is a syntax error if other predicates have this.) conn | The connection for which the predicate is evaluated. |
predicate | Details from the parsed predicate. |
field | The field to use for name searches and the 'like' default. |
|
static |
Gather a list of assorted things specified by a predicate, which must be present.
This differs from the standard call in that when querying the media manager, it does not consider a single source's inability to complete a query as a failure.
pred | The predicate, including source and filter. |
search_what | Specifies manner of search. |
CommandError | if no matching things are found. |
Query::impossible | If no sources could handle the query. |
std::unique_ptr< Filter > Predicate::getPredicate | ( | const PianodConnection & | conn, |
const Parsnip::Data & | predicate, | ||
Filter::Field | field | ||
) |
Return just the filter portion of a predicate, for external use.
|
static |
Specialization for getting things by ID.
predicate | The predicate options. |
CommandError | if the ID does not match any item. |
PianodPlaylist * Predicate::getSpecifiedPlaylist | ( | const PianodConnection & | conn, |
const Parsnip::Data & | predicate | ||
) |
Gather a request for a single playlist and return it.
Predicate must be present.
CommandError | if no playlists or multiple playlists are found. |
PlaylistList Predicate::getSpecifiedPlaylists | ( | const PianodConnection & | conn, |
const Parsnip::Data & | predicate | ||
) |
Interpret a list of playlists specified by a predicate.
conn | The connection for which the predicate is being interpreted. |
predicate | The predicate options. |
CommandError | if no matching playlists are found. |
|
static |
Get playlist items by id.
predicate | The predicate options. |
PianodSong * Predicate::getSpecifiedSong | ( | const PianodConnection & | conn, |
const Parsnip::Data & | predicate | ||
) |
Gather a request for a single song and return it.
Predicate must be present.
CommandError | if no songs or multiple songs are found. |
SongList Predicate::getSpecifiedSongs | ( | const PianodConnection & | conn, |
const Parsnip::Data & | predicate, | ||
SearchRange | search_what | ||
) |
Interpret a list of songs specified by a predicate.
conn | The connection for which the predicate is being interpreted. |
predicate | The predicate options. |
search_what | Specifies manner of search. |
CommandError | if no matching songs are found. |
MusicThingie * Predicate::getSpecifiedThing | ( | const PianodConnection & | conn, |
const Parsnip::Data & | predicate | ||
) |
Interpret a request for an unspecified type of thing and return it.
Predicate must be present.
CommandError | if no things or multiple things are found. |
ThingieList Predicate::getSpecifiedThings | ( | const PianodConnection & | conn, |
const Parsnip::Data & | predicate, | ||
SearchRange | search_what | ||
) |
Gather a list of assorted things specified by a predicate.
The predicate must be present.
conn | The connection for which the predicate is being interpreted. |
predicate | The predicate options. |
search_what | Nature of items to search for (requestable, etc). |
CommandError | if no matching things are found. |
|
inline |
Check for presence of a predicate.
const LookupTable<MANNER> Predicate::PredicateManners({ { "name", MANNER::NAME }, { "id", MANNER::ID }, { "where", MANNER::WHERE }, { "like", MANNER::LIKE } }) |
Lookup table for manner names to enumeration.
const LookupTable<Filter::Field> Predicate::SearchFields({ { "any", Filter::Field::Search }, { "artist", Filter::Field::Artist }, { "album", Filter::Field::Album }, { "song", Filter::Field::Title }, { "playlist", Filter::Field::Playlist }, { "genre", Filter::Field::Genre } }) |
Lookup table for optional type to filter field.