pianod2
multisource multiuser scriptable networked music player
Public Member Functions | Private Types | List of all members
RatingLookup Class Reference

String to rating conversion. More...

#include <ratings.h>

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

Public Member Functions

bool tryGetPrecise (const char *s, float *rating) const noexcept
 Retrieve the enumerator corresponding to text name. More...
 
bool tryGetPrecise (const std::string &s, float *rating) const noexcept
 
float getPrecise (const char *s) const
 Get a precise rating, accepting either a rating string or number. More...
 
float getPrecise (const std::string &s) const
 
virtual const RATING_LOOKUPget (const char *s) const noexcept override
 Retrieve the enumerator corresponding to text name. More...
 
- Public Member Functions inherited from LookupTable< Rating, RATING_LOOKUP >
 LookupTable ()=delete
 
 LookupTable (const LookupTable< Rating, RATING_LOOKUP > &)=delete
 
 LookupTable (const LookupTable< Rating, RATING_LOOKUP > &&)=delete
 
 LookupTable (const RATING_LOOKUP *tab)
 Initialize the lookup table from an array. More...
 
 LookupTable (const std::initializer_list< RATING_LOOKUP > tab)
 Initialize the lookup table from an initializer list. More...
 
 ~LookupTable ()
 
const RATING_LOOKUPget (const Rating id) const
 Retrieve a table entry by the enumerator of an entry. More...
 
const Rating operator[] (const char *s) const
 Retrieve the enumerator corresponding to text name. More...
 
const Rating operator[] (const std::string &s) const
 Retrieve the enumerator corresponding to text name. More...
 
const char * operator[] (const Rating id) const
 Retrieve the text name of an enumerator. More...
 
const bool tryGetValue (const char *s, Rating *value) const
 Retrieve the enumerator corresponding to a text value. More...
 
const bool tryGetValue (const std::string &s, Rating *value) const
 
const RATING_LOOKUPbegin () const
 
const RATING_LOOKUPend () const
 

Private Types

typedef LookupTable< Rating, RATING_LOOKUPbase_class
 

Detailed Description

String to rating conversion.

The standard Lookup functions use the ratings enumeration values, which requires rounding, suitable for storage. The Precise variations return unrounded star-range ratings (0 < rating ≤ 5), suitable for working with averages.

Member Typedef Documentation

◆ base_class

Member Function Documentation

◆ get()

const RATING_LOOKUP * RatingLookup::get ( const char *  s) const
overridevirtualnoexcept

Retrieve the enumerator corresponding to text name.

Parameters
sThe text name
Returns
Pointer to table entry, or NULL if not found.

Reimplemented from LookupTable< Rating, RATING_LOOKUP >.

Here is the call graph for this function:

◆ getPrecise() [1/2]

float RatingLookup::getPrecise ( const char *  s) const

Get a precise rating, accepting either a rating string or number.

Parameters
sA string containing a rating.
Returns
The rating in the star-rating range.
Exceptions
E_INVALIDif the value is out of range, not a rating, or otherwise invalid.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPrecise() [2/2]

float RatingLookup::getPrecise ( const std::string &  s) const
inline
Here is the call graph for this function:

◆ tryGetPrecise() [1/2]

bool RatingLookup::tryGetPrecise ( const char *  s,
float *  rating 
) const
noexcept

Retrieve the enumerator corresponding to text name.

Parameters
sThe text of the rating.
rating[out] The parsed rating.
Returns
True if the value was a valid rating, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryGetPrecise() [2/2]

bool RatingLookup::tryGetPrecise ( const std::string &  s,
float *  rating 
) const
inlinenoexcept
Here is the call graph for this function:

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