Provides lookup and convenience functions for querying cards and their printings. More...
#include <card_database_querier.h>
Public Member Functions | |
| CardDatabaseQuerier (QObject *parent, const CardDatabase *db, const ICardPreferenceProvider *prefs) | |
| Constructs a CardDatabaseQuerier. | |
| CardInfoPtr | getCardInfo (const QString &cardName) const |
| Retrieves a card by its exact name. | |
| QList< CardInfoPtr > | getCardInfos (const QStringList &cardNames) const |
| Retrieves multiple cards by their exact names. | |
| CardInfoPtr | getCardBySimpleName (const QString &cardName) const |
| Retrieves a card using simplified name matching. | |
| CardInfoPtr | lookupCardByName (const QString &name) const |
| Looks up a card using exact name first, then simplified matching as fallback. | |
| ExactCard | getCard (const CardRef &cardRef) const |
| Converts a CardRef into an ExactCard. | |
| QList< ExactCard > | getCards (const QList< CardRef > &cardRefs) const |
| Resolves multiple CardRefs into ExactCards. | |
| ExactCard | guessCard (const CardRef &cardRef) const |
| Attempts a more flexible card lookup using both simple name matching and CardRef rules. | |
| ExactCard | getRandomCard () const |
| Returns a random card from the database using the preferred printing. | |
| ExactCard | getCardFromSameSet (const QString &cardName, const PrintingInfo &otherPrinting) const |
| Returns a printing of a card from the same set as another given printing when possible. | |
| ExactCard | getPreferredCard (const QString &cardName) const |
| Returns the preferred printing of a card based on user preferences and set priority. | |
| ExactCard | getPreferredCard (const CardInfoPtr &cardInfo) const |
| Returns the preferred printing of a card based on user preferences and set priority. | |
| bool | isPreferredPrinting (const CardRef &cardRef) const |
| Checks whether the CardRef refers to the preferred printing. | |
| PrintingInfo | getPreferredPrinting (const QString &cardName) const |
| Returns the preferred printing for the given card name. | |
| PrintingInfo | getPreferredPrinting (const CardInfoPtr &cardInfo) const |
| Returns the preferred printing for the given card. | |
| QString | getPreferredPrintingProviderId (const QString &cardName) const |
| Returns the providerId of the preferred printing. | |
| PrintingInfo | getSpecificPrinting (const CardRef &cardRef) const |
| Retrieves a specific printing referenced by CardRef. | |
| PrintingInfo | getSpecificPrinting (const QString &cardName, const QString &setCode, const QString &collectorNumber) const |
| Searches for a specific printing by set code and collector number. | |
| PrintingInfo | findPrintingWithId (const CardInfoPtr &card, const QString &providerId) const |
| Searches for a printing that matches a given providerId. | |
| QStringList | getAllMainCardTypes () const |
| Returns a list of all main card types present in the database. | |
| QMap< QString, int > | getAllMainCardTypesWithCount () const |
| Returns a mapping of main card types to their occurrence counts. | |
| QMap< QString, int > | getAllSubCardTypesWithCount () const |
| Returns a mapping of card subtypes to their occurrence counts. | |
Private Attributes | |
| const CardDatabase * | db |
| Card database used for all lookups. | |
| const ICardPreferenceProvider * | prefs |
| Preference provider for preferred printings. | |
Provides lookup and convenience functions for querying cards and their printings.
The CardDatabaseQuerier class offers various lookup helpers for retrieving card information (e.g., CardInfoPtr, ExactCard, and PrintingInfo) from a CardDatabase. It also applies user printing preferences via ICardPreferenceProvider when determining preferred printings.
|
explicit |
Constructs a CardDatabaseQuerier.
| parent | Parent QObject. |
| db | Pointer to the CardDatabase used for lookups. |
| prefs | Pointer to card preference provider which supplies user-preference for printings. |
|
nodiscard |
Searches for a printing that matches a given providerId.
| card | Card to search. |
| providerId | Provider identifier to match. |
Finds the PrintingInfo in the cardInfo that has the given uuid field.
| cardInfo | The CardInfo to search |
| providerId | The uuid to look for |
|
nodiscard |
Returns a list of all main card types present in the database.
|
nodiscard |
Returns a mapping of main card types to their occurrence counts.
|
nodiscard |
Returns a mapping of card subtypes to their occurrence counts.
Converts a CardRef into an ExactCard.
If the providerId is empty, the preferred printing is used. If providerId exists but cannot be found, an ExactCard with an empty PrintingInfo is returned.
| cardRef | Card reference with name and optional providerId. |
Looks up the card corresponding to the CardRef. If the providerId is empty, will default to the preferred printing. If providerId is given but not found, the PrintingInfo will be empty.
| cardRef | The card to look up. |
|
nodiscard |
Retrieves a card using simplified name matching.
The name is automatically normalized, so callers do not need to simplify it.
| cardName | A (possibly simplified or misspelled) card name. |
|
nodiscard |
Returns a printing of a card from the same set as another given printing when possible.
If no matching printing exists, falls back to a standard lookup.
| cardName | Card to retrieve. |
| otherPrinting | Printing to match the set against. |
|
nodiscard |
Retrieves a card by its exact name.
| cardName | Exact card name. |
Looks up the cardInfo corresponding to the cardName.
| cardName | The card name to look up |
|
nodiscard |
Retrieves multiple cards by their exact names.
Failed lookups are skipped and not included in the result.
| cardNames | List of exact card names. |
Looks up the cardInfos for a list of card names.
| cardNames | The card names to look up |
|
nodiscard |
Resolves multiple CardRefs into ExactCards.
Failed entries are not included in the result.
| cardRefs | List of card references. |
Looks up the cards corresponding to the CardRefs. If the providerId is empty, will default to the preferred printing. If providerId is given but not found, the PrintingInfo will be empty.
| cardRefs | The cards to look up. If providerId is empty for an entry, will default to the preferred printing for that entry. If providerId is given but not found, the PrintingInfo will be empty for that entry. |
|
nodiscard |
Returns the preferred printing of a card based on user preferences and set priority.
| cardInfo | Card information object. |
Gets the card representing the preferred printing of the cardInfo
| cardInfo | The cardInfo to find the preferred printing for |
|
nodiscard |
Returns the preferred printing of a card based on user preferences and set priority.
| cardName | Name of the card. |
Gets the card representing the preferred printing of the cardInfo
| cardName | The cardName to find the preferred card and printing for |
|
nodiscard |
Returns the preferred printing for the given card.
| cardInfo | Card information object. |
|
nodiscard |
Returns the preferred printing for the given card name.
| cardName | Card name. |
|
nodiscard |
Returns the providerId of the preferred printing.
| cardName | Card name. |
|
nodiscard |
Returns a random card from the database using the preferred printing.
|
nodiscard |
Retrieves a specific printing referenced by CardRef.
| cardRef | Card reference including providerId. |
|
nodiscard |
Searches for a specific printing by set code and collector number.
| cardName | Card name to search. |
| setCode | Set (short) code to match. |
| collectorNumber | Collector number. If empty, any printing from the set is returned. |
Attempts a more flexible card lookup using both simple name matching and CardRef rules.
If providerId is missing, uses preferred printing. If lookup fails, attempts simplified name.
| cardRef | Card reference to resolve. |
Looks up the card by CardRef, simplifying the name if required. If the providerId is empty, will default to the preferred printing. If providerId is given but not found, the PrintingInfo will be empty.
| cardRef | The card to look up. |
|
nodiscard |
Checks whether the CardRef refers to the preferred printing.
| cardRef | Card reference to test. |
|
nodiscard |
Looks up a card using exact name first, then simplified matching as fallback.
| name | Raw card name input. |
|
private |
Card database used for all lookups.
|
private |
Preference provider for preferred printings.