|
pianod2
multisource multiuser scriptable networked music player
|
Track data filter. More...
#include <filter.h>


Classes | |
| class | DisallowedOperator |
| Error for filter expressions trying to use a relational operation incorrectly. More... | |
| class | InvalidValue |
| Error for filter expression containing an invalid value. More... | |
| class | Operation |
| Nodes for the filter parse tree. More... | |
| class | ParseError |
| Error for generic filter syntax/parse errors. More... | |
Public Types | |
| enum class | Field { Invalid = 0 , Id , Artist , Album , Type , Genre , Playlist , Title , Search , Name , Year , Duration , Lastplay , Track , Rating , Played , Heard , Rated , UserRating , False , Compilation , Count } |
| Fields on which comparisons can be done by the filter. More... | |
| enum class | Action { Noop , And , Or , LessThan , LessEqual , Equal , NotEqual , GreaterThan , GreaterEqual , Match } |
| Filter operations; each node in the parse tree has one action indicating how to proceed. More... | |
| using | DuplicationFlags = EnumeratedArray< Field, bool > |
| using | FilterRating = float |
Public Member Functions | |
| Filter (void) | |
| Filter (const Filter &)=default | |
| Filter (Filter &&from_filter)=default | |
| Filter (const std::string &expression) | |
| Create a new filter from an expression. More... | |
| Filter (const MusicThingie *thing, const MusicThingie::Type type=MusicThingie::Type(0), const DuplicationFlags &manner=DuplicationFlags(true)) | |
| Create a new filter. More... | |
| Filter & | operator= (const std::string &expression) |
| Assign a new expression to a filter. More... | |
| Filter & | operator= (const Filter &filter)=default |
| Filter & | operator= (Filter &&from_filter)=default |
| virtual | ~Filter () |
| Destroy a filter. More... | |
| template<typename MusicThing > | |
| bool | matches (const MusicThing *thing) const |
| Check if a filter matches a song, album, artist or playlist. More... | |
| bool | canPersist (void) const |
| std::string | toString () const |
| Get a filter's expression. More... | |
| template<> | |
| bool | matches (const MusicThingie *thing) const |
| Specialization for matching to determine the type of thing being tested by the filter expression at run-time. More... | |
| template<> | |
| bool | matches (const MusicThingie *thing) const |
Static Public Attributes | |
| static const unsigned | FieldCount = static_cast <unsigned> (Field::Count) |
| static const Filter | All |
| Selects all tracks. More... | |
| static const Filter | None |
| Selects nothing. More... | |
Protected Types | |
| using | Op = std::unique_ptr< Operation > |
| Container for Operation, to ensure instances are cleaned up. More... | |
Protected Member Functions | |
| const char * | skipWhitespace (const char **const command) |
| std::string | gatherString (const char **const command, const char *error_reason) |
| Gather a string, either quoted or not, processing quote characters. More... | |
| Op | parseParenthesis (const char **const command) |
| Handle (parenthesis in an expression). More... | |
| Op | parseComparison (const char **const command) |
| Handle comparison or other base operator in expression. More... | |
| Op | parseSearch (const char **const command) |
| Handle bare search term in expression. More... | |
| Op | parseNegation (const char **const command) |
| Handle negation operator, then choose parenthesis or a comparison. More... | |
| Op | parseOr (const char **const command) |
| Handle binary OR, either as | or ||. More... | |
| Op | parseAnd (const char **const command) |
| Handle binary AND, either as & or &&. More... | |
Protected Attributes | |
| std::shared_ptr< Operation > | parsetree |
| bool | persistable = true |
| Not true if user referenced or other problematic expressions. More... | |
Friends | |
| class | Constraints |
| class | Query::Details |
| class | Query::List |
Track data filter.
Created from a logical statement describing match criteria, the track filter can then be used to test if a track/song, album, artist or playlist matches the criteria.
| using Filter::DuplicationFlags = EnumeratedArray<Field, bool> |
| using Filter::FilterRating = float |
|
protected |
Container for Operation, to ensure instances are cleaned up.
|
strong |
Filter operations; each node in the parse tree has one action indicating how to proceed.
| Enumerator | |
|---|---|
| Noop | |
| And | |
| Or | |
| LessThan | |
| LessEqual | |
| Equal | |
| NotEqual | |
| GreaterThan | |
| GreaterEqual | |
| Match | |
|
strong |
|
inline |
|
default |
|
default |
| Filter::Filter | ( | const std::string & | expr | ) |
Create a new filter from an expression.
| expr | The expression for the filter. |
| CommandError | indicating nature of syntax or semantic errors. bad_alloc may also be thrown. |

| Filter::Filter | ( | const MusicThingie * | thing, |
| const MusicThingie::Type | type = MusicThingie::Type (0), |
||
| const DuplicationFlags & | manner = DuplicationFlags (true) |
||
| ) |
Create a new filter.
| thing | Criteria for the new filter. |
| type | The type of filter to create. Songs can create song, album, or artist filters; albums can create album or artist filters. |
| manner | Flags indicating what criteria to include in the filter. |

|
virtual |
Destroy a filter.
|
inline |

|
protected |
Gather a string, either quoted or not, processing quote characters.
| command | The point in the command being parsed at which to gather. |
| error_reason | A message to include in a ParseError should there be no string to gather. |


|
inline |
Check if a filter matches a song, album, artist or playlist.
| thing | The item to compare. |

| bool Filter::matches | ( | const MusicThingie * | thing | ) | const |
Specialization for matching to determine the type of thing being tested by the filter expression at run-time.
| thing | A thing to compare. |

| bool Filter::matches | ( | const MusicThingie * | thing | ) | const |
| Filter & Filter::operator= | ( | const std::string & | expr | ) |
Assign a new expression to a filter.
| expr | The new expression. |
|
protected |
Handle binary AND, either as & or &&.
| command | The point in the command being parsed. On return, updated to reflect expression portions consumed. |


|
protected |
Handle comparison or other base operator in expression.
| command | The point in the command being parsed. On return, updated to reflect expression portions consumed. |


|
protected |
Handle negation operator, then choose parenthesis or a comparison.
| command | The point in the command being parsed. On return, updated to reflect expression portions consumed. |


|
protected |
Handle binary OR, either as | or ||.
| command | The point in the command being parsed. On return, updated to reflect expression portions consumed. |


|
protected |
Handle (parenthesis in an expression).
| command | The point in the command being parsed. On return, updated to reflect expression portions consumed. |


|
protected |
Handle bare search term in expression.
This is identified by a quote (either ' or ") where we expect a comparison term in the expression.
| command | The point in the command being parsed. On return, updated to reflect expression portions consumed. |


|
inlineprotected |

| std::string Filter::toString | ( | ) | const |
Get a filter's expression.

|
friend |
|
friend |
|
friend |
|
static |
Selects all tracks.
|
static |
|
static |
Selects nothing.
|
protected |
|
protected |
Not true if user referenced or other problematic expressions.