pianod2
multisource multiuser scriptable networked music player
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Filter::Operation Class Reference

Nodes for the filter parse tree. More...

#include <filter.h>

Collaboration diagram for Filter::Operation:
Collaboration graph
[legend]

Classes

union  value_t
 

Public Member Functions

 Operation ()
 
 ~Operation ()
 
std::string toString ()
 
 Operation (const Action _action, const Field _field)
 Construct a check or comparision. More...
 
 Operation (const Action action, std::unique_ptr< Filter::Operation > &&left, std::unique_ptr< Filter::Operation > &&right)
 
 Operation (const Action action, const Field field, const std::string &_value, const bool wildcard=false)
 Construct a string comparison. More...
 
 Operation (const Action action, const Field field, const long value)
 Construct a numeric comparison operation. More...
 
 Operation (const Action action, const Field field, const FilterRating value, const User *user)
 Construct a rating comparison. More...
 
 Operation (const Action action, const Field field, const MusicThingie::Type type)
 Construct a type comparision. More...
 
 Operation (const Operation &)=delete
 
Operationoperator= (const Operation &)=delete
 
 Operation (Operation &&from)
 Move-construct an operation. More...
 
Operationoperator= (Operation &&from)
 Move-assign an operation. More...
 
template<typename DiffType >
bool applyOperation (DiffType diff) const
 Apply operation to difference, yielding truth. More...
 
bool numericCheck (long compare_to) const
 Perform a numeric comparision. More...
 
bool stringCheck (const std::string &compare_to) const
 Check if string value matches filter comparison. More...
 
bool genreCheck (const std::string &list) const
 Check if a genre/genre list matches the filter comparison. More...
 
bool evaluate (const PianodPlaylist *playlist) const
 Determine if a playlist matches a filter. More...
 
bool evaluate (const PianodArtist *artist) const
 Determine if an artist (or artist components of an album or song) match a filter. More...
 
bool evaluate (const PianodAlbum *album) const
 Determine if an album (or album components of a song) match a filter. More...
 
bool evaluate (const PianodSong *track) const
 Determine if a song matches a filter. More...
 

Static Public Member Functions

static bool isNumericOperator (Action action)
 Check if an operation applies to numeric values. More...
 
static bool isStringOperator (Action action)
 Check if an operation applies to strings. More...
 
static bool isStringField (Field field)
 Check if a field contains string values. More...
 
static MusicThingie::Type getTypeFromField (const Filter::Field field)
 Get the music thingie type corresponding to a field name. More...
 

Private Member Functions

void clear ()
 Release value in an operation node. More...
 

Private Attributes

Field field = Field::Invalid
 For comparison operations, the field to match. More...
 
Action action = Action::Noop
 The operation: and/or, comparison type, etc. More...
 
bool invert = false
 Apply not operator to result of action. More...
 
union Filter::Operation::value_t value
 

Friends

class Query::List
 
Op Filter::parseNegation (const char **const command)
 

Detailed Description

Nodes for the filter parse tree.

Constructor & Destructor Documentation

◆ Operation() [1/9]

Filter::Operation::Operation ( )
inline

◆ ~Operation()

Filter::Operation::~Operation ( )
inline
Here is the call graph for this function:

◆ Operation() [2/9]

Filter::Operation::Operation ( const Action  _action,
const Field  _field 
)
inline

Construct a check or comparision.

Parameters
_actionThe manner of comparison: equal, not equal, etc.
_fieldThe field on which to compare or test.

◆ Operation() [3/9]

Filter::Operation::Operation ( const Action  action,
std::unique_ptr< Filter::Operation > &&  left,
std::unique_ptr< Filter::Operation > &&  right 
)

◆ Operation() [4/9]

Filter::Operation::Operation ( const Action  _action,
const Field  _field,
const std::string &  _value,
const bool  wildcard = false 
)

Construct a string comparison.

Parameters
_actionThe manner of comparison.
_fieldThe field to compare.
_valueThe value to compare to.
wildcardIf true, _value need only match the start of string.
Here is the call graph for this function:

◆ Operation() [5/9]

Filter::Operation::Operation ( const Action  _action,
const Field  _field,
const long  _value 
)

Construct a numeric comparison operation.

Parameters
_actionThe manner of comparison.
_fieldThe field to compare.
_valueThe value to compare to.
Here is the call graph for this function:

◆ Operation() [6/9]

Filter::Operation::Operation ( const Action  _action,
const Field  _field,
const FilterRating  rating,
const User user 
)

Construct a rating comparison.

Parameters
_actionThe manner of comparison.
_fieldThe field to compare to.
ratingThe value to compare to.
userThe user to apply the comparison to, if applicable.
Here is the call graph for this function:

◆ Operation() [7/9]

Filter::Operation::Operation ( const Action  _action,
const Field  _field,
const MusicThingie::Type  _type 
)

Construct a type comparision.

Parameters
_actionThe manner of comparison.
_fieldThe field to compare to: always Field::Type.
_typeThe type to compare to.

◆ Operation() [8/9]

Filter::Operation::Operation ( const Operation )
delete

◆ Operation() [9/9]

Filter::Operation::Operation ( Operation &&  from)

Move-construct an operation.

Member Function Documentation

◆ applyOperation()

template<typename DiffType >
bool Filter::Operation::applyOperation ( DiffType  diff) const

Apply operation to difference, yielding truth.

Parameters
diffDifference between two items, or 0 for equal.
Returns
True if A op B.
Here is the caller graph for this function:

◆ clear()

void Filter::Operation::clear ( )
private

Release value in an operation node.

Does not reset the node; invoking this twice will double-release unless the values have been replaced.

Here is the caller graph for this function:

◆ evaluate() [1/4]

bool Filter::Operation::evaluate ( const PianodAlbum album) const

Determine if an album (or album components of a song) match a filter.

Here is the call graph for this function:

◆ evaluate() [2/4]

bool Filter::Operation::evaluate ( const PianodArtist artist) const

Determine if an artist (or artist components of an album or song) match a filter.

Here is the call graph for this function:

◆ evaluate() [3/4]

bool Filter::Operation::evaluate ( const PianodPlaylist playlist) const

Determine if a playlist matches a filter.

Here is the call graph for this function:

◆ evaluate() [4/4]

bool Filter::Operation::evaluate ( const PianodSong track) const

Determine if a song matches a filter.

Here is the call graph for this function:

◆ genreCheck()

bool Filter::Operation::genreCheck ( const std::string &  list) const

Check if a genre/genre list matches the filter comparison.

Parameters
listA genre or list separated by commas, slashes and plus.
Here is the call graph for this function:

◆ getTypeFromField()

MusicThingie::Type Filter::Operation::getTypeFromField ( const Filter::Field  field)
static

Get the music thingie type corresponding to a field name.

Parameters
fieldThe field to get the type of.
Returns
A MusicThingie Type for the object type.
Exceptions
InvalidValueif the field has no associated MusicThingie type.
Here is the caller graph for this function:

◆ isNumericOperator()

bool Filter::Operation::isNumericOperator ( Action  action)
static

Check if an operation applies to numeric values.

Parameters
actionThe operation to check.
Returns
True if the operation can be used on numbers, false otherwise.
Here is the caller graph for this function:

◆ isStringField()

bool Filter::Operation::isStringField ( Field  field)
static

Check if a field contains string values.

Parameters
fieldThe field to check.
Returns
True if the field is string, false otherwise.
Here is the caller graph for this function:

◆ isStringOperator()

bool Filter::Operation::isStringOperator ( Action  action)
static

Check if an operation applies to strings.

Parameters
actionThe operation to check.
Returns
True if the operation can be used on strings, false otherwise.
Here is the caller graph for this function:

◆ numericCheck()

bool Filter::Operation::numericCheck ( long  compare_to) const
inline

Perform a numeric comparision.

Parameters
compare_toValue being compared. Zero is null, so always false.
Returns
True if values compare according to action, false otherwise.
Here is the call graph for this function:

◆ operator=() [1/2]

Operation& Filter::Operation::operator= ( const Operation )
delete

◆ operator=() [2/2]

Filter::Operation & Filter::Operation::operator= ( Operation &&  from)

Move-assign an operation.

◆ stringCheck()

bool Filter::Operation::stringCheck ( const std::string &  compare_to) const

Check if string value matches filter comparison.

Parameters
compare_toThe string to check against.
Here is the call graph for this function:

◆ toString()

std::string Filter::Operation::toString ( )
Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ Filter::parseNegation

Op Filter::parseNegation ( const char **const  command)
friend

◆ Query::List

friend class Query::List
friend

Member Data Documentation

◆ action

Action Filter::Operation::action = Action::Noop
private

The operation: and/or, comparison type, etc.

◆ field

Field Filter::Operation::field = Field::Invalid
private

For comparison operations, the field to match.

◆ invert

bool Filter::Operation::invert = false
private

Apply not operator to result of action.

◆ value

union Filter::Operation::value_t Filter::Operation::value
private

The documentation for this class was generated from the following files: