|
Study Dungeon
1.0.0
A group project for COSC345
|
Functions and classes relating to flashcards. More...
#include "util.h"#include <algorithm>#include <filesystem>#include <fstream>#include <iostream>#include <string>#include <windows.h>Go to the source code of this file.
Data Structures | |
| class | FlashCard |
| This structure holds the information for each flashcard. More... | |
| class | FlashCardDeck |
| Class that defines a "deck" of flashcards. More... | |
Enumerations | |
| enum | CardDifficulty { UNKNOWN = 0 , EASY = 1 , MEDIUM = 2 , HARD = 3 } |
| The possible difficulties for a flashcard. More... | |
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... | |
| std::vector< FlashCardDeck > | loadFlashCardDecks (std::filesystem::path deck_dir_path) |
| Load the decks from files stored with the ".deck" extension inside decks/. More... | |
| FlashCardDeck | readFlashCardDeck (std::filesystem::path deck_file) |
| For a given deck file, read the contents in to create all the cards. More... | |
| bool | writeFlashCardDeck (const FlashCardDeck &deck, std::filesystem::path filename) |
| Write a deck of flashcards to disk. More... | |
| bool | writeFlashCardDeckWithChecks (const FlashCardDeck &deck, std::filesystem::path filename, bool force_overwrite) |
| Write a deck of flashcards to disk. More... | |
| std::vector< FlashCardDeck > | createExampleDecks () |
| 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... | |
Functions and classes relating to flashcards.
These functions are involved with the parsing of files to create flashcards which are then converted into a deck. Cards are also parsed to text and written to file to save them.
| enum CardDifficulty |
The possible difficulties for a flashcard.
possible values: EASY (1), MEDIUM (2), and HARD (3) \showenumvalues
| std::string cardDifficultyToStr | ( | const CardDifficulty & | difficulty | ) |
Converts the card difficulty from enum to a string.
| difficulty | The CardDifficulty |
| std::filesystem::path createDeckFilename | ( | std::filesystem::path | deck_dir | ) |
Prompt the user for name of the file to save the deckfile to.
| deck_dir | Directory to append the filename to |
| std::vector<FlashCardDeck> createExampleDecks | ( | ) |
Create example deck files.
A helper function that will create some example deck files if no decks exist.
| std::vector<FlashCardDeck> loadFlashCardDecks | ( | std::filesystem::path | deck_dir_path | ) |
Load the decks from files stored with the ".deck" extension inside decks/.
Will iterate through all files within the path directory that have a .deck suffix. each deck file will be parsed and turned into a FlashCardDeck. All FlashCardDecks are added into a vector and returned.
| deck_path | Path on the file system to a directory where the deck files are located. |
| FlashCardDeck readFlashCardDeck | ( | std::filesystem::path | deck_file | ) |
For a given deck file, read the contents in to create all the cards.
| deck_file | The path to the file containing the deck information |
| 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
| difficultyStr | The card difficulty as a string |
| bool updateDeckFile | ( | FlashCardDeck & | deck_to_update | ) |
Updates an existing FlashCardDeck on file.
| deck_to_update | FlashCardDeck to write to file |
| bool writeFlashCardDeck | ( | const FlashCardDeck & | deck, |
| std::filesystem::path | filename | ||
| ) |
Write a deck of flashcards to disk.
This will check the parent directory exists and write to a file. It does perform the additional checks on the filename that writeFlashCardWithChecks does
| deck | The FlashCard deck to be written to file |
| filename | The file path for the deck file |
| bool writeFlashCardDeckWithChecks | ( | const FlashCardDeck & | deck, |
| std::filesystem::path | filename, | ||
| bool | force_overwrite | ||
| ) |
Write a deck of flashcards to disk.
The standard location will be in Decks/ located with the executable and use a suffix of ".deck". This method checks
| deck | The FlashCard deck to be written to file |
| filename | The file path for the deck file |
| force_overwrite | (default false) skip the overwrite confimration prompt |