pianod2
multisource multiuser scriptable networked music player
Public Member Functions | Private Attributes | Friends | List of all members
PermutedFilter Class Reference

Permuted filter, like Filter but constructed from a string. More...

#include <filter.h>

Inheritance diagram for PermutedFilter:
Inheritance graph
[legend]
Collaboration diagram for PermutedFilter:
Collaboration graph
[legend]

Public Member Functions

 PermutedFilter (const std::string &phrase, Field search_target=Field::Search)
 Create a new permuted filter from a single phrase. More...
 
 PermutedFilter (const std::vector< std::string > &phrases, Field search_target=Field::Search)
 Create a permuted filter from a several phrases. More...
 
- Public Member Functions inherited from Filter
 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...
 
Filteroperator= (const std::string &expression)
 Assign a new expression to a filter. More...
 
Filteroperator= (const Filter &filter)=default
 
Filteroperator= (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
 

Private Attributes

std::vector< std::string > phrases
 
const Field target_field
 

Friends

class Query::List
 

Additional Inherited Members

- Public Types inherited from Filter
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
 
- Static Public Attributes inherited from Filter
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 inherited from Filter
using Op = std::unique_ptr< Operation >
 Container for Operation, to ensure instances are cleaned up. More...
 
- Protected Member Functions inherited from Filter
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 inherited from Filter
std::shared_ptr< Operationparsetree
 
bool persistable = true
 Not true if user referenced or other problematic expressions. More...
 

Detailed Description

Permuted filter, like Filter but constructed from a string.

The filter matches track data containing all words in the string.

Constructor & Destructor Documentation

◆ PermutedFilter() [1/2]

PermutedFilter::PermutedFilter ( const std::string &  query,
Field  search_target = Field::Search 
)

Create a new permuted filter from a single phrase.

Parameters
queryThe search text to permute. "Mary's Little Lamb" permuted is equivalent to the expression: search =~ "Mary's" && search =~ "Little" && search =~ "Lamb".
search_targetThe field to match on.
Exceptions
invalid_argumentif the expression is invalid. (For a permuted expression, this simply means there are no words.)
Here is the call graph for this function:

◆ PermutedFilter() [2/2]

PermutedFilter::PermutedFilter ( const std::vector< std::string > &  phrasez,
Field  search_target = Field::Search 
)

Create a permuted filter from a several phrases.

The resulting filter matches permutations of any of any of the phrases.

Parameters
phrasezThe strings permute.
search_targetThe field to match on.
Exceptions
invalid_argumentif the expression is invalid.
Here is the call graph for this function:

Friends And Related Function Documentation

◆ Query::List

friend class Query::List
friend

Member Data Documentation

◆ phrases

std::vector<std::string> PermutedFilter::phrases
private

◆ target_field

const Field PermutedFilter::target_field
private

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