Study Dungeon  1.0.0
A group project for COSC345
Functions
deck.cpp File Reference

Functions and classes relating to flashcards. More...

#include "deck.h"

Functions

CardDifficulty strToCardDifficulty (const std::string &difficultyStr)
 Converts a string into the CardDifficulty enum. More...
 
std::string cardDifficultyToStr (const CardDifficulty &difficulty)
 Converts the card difficulty from enum to a string. More...
 
FlashCardDeck readFlashCardDeck (fs::path deck_file)
 
bool writeFlashCardDeck (const FlashCardDeck &deck, fs::path filename)
 
bool writeFlashCardDeckWithChecks (const FlashCardDeck &deck, fs::path filename, bool force_overwrite=false)
 
std::vector< FlashCardDeckloadFlashCardDecks (fs::path deck_dir_path)
 
std::vector< FlashCardDeckcreateExampleDecks ()
 Create example deck files. More...
 
std::filesystem::path createDeckFilename (std::filesystem::path deck_dir)
 Prompt the user for name of the file to save the deckfile to. More...
 
bool updateDeckFile (FlashCardDeck &deck_to_update)
 Updates an existing FlashCardDeck on file. More...
 

Detailed Description

Functions and classes relating to flashcards.

Author
Green Alligators
Version
1.0.0
Date
2024-08-23

Function Documentation

◆ cardDifficultyToStr()

std::string cardDifficultyToStr ( const CardDifficulty difficulty)

Converts the card difficulty from enum to a string.

Parameters
difficultyThe CardDifficulty
Returns
std::string

◆ createDeckFilename()

std::filesystem::path createDeckFilename ( std::filesystem::path  deck_dir)

Prompt the user for name of the file to save the deckfile to.

Parameters
deck_dirDirectory to append the filename to
Returns
std::filesystem::path

◆ createExampleDecks()

std::vector<FlashCardDeck> createExampleDecks ( )

Create example deck files.

A helper function that will create some example deck files if no decks exist.

Returns
A vector of the example FlashCardDecks

◆ readFlashCardDeck()

FlashCardDeck readFlashCardDeck ( fs::path  deck_file)

The flashcard deck to store the flashcards in as read from the file

◆ strToCardDifficulty()

CardDifficulty strToCardDifficulty ( const std::string &  difficultyStr)

Converts a string into the CardDifficulty enum.

"EASY" -> EASY "MEDIUM" -> MEDIUM "HARD" -> HARD Anything else is converted to UNKNOWN

Parameters
difficultyStrThe card difficulty as a string
Returns
CardDifficulty

◆ updateDeckFile()

bool updateDeckFile ( FlashCardDeck deck_to_update)

Updates an existing FlashCardDeck on file.

Parameters
deck_to_updateFlashCardDeck to write to file
Returns
true update was successful
false update was unsuccesssful