Contains useful helper functions.
More...
#include <algorithm>
#include <chrono>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <random>
#include <sstream>
#include <string>
#include <vector>
#include <windows.h>
Go to the source code of this file.
|
| | key |
| | mapping of character codes recieved by getch on key press to their keyboard name for easy reference.
|
| |
Contains useful helper functions.
- Author
- Green Alligators
- Version
- 1.0.0
- Date
- 2024-08-08
- Copyright
- Copyright (c) 2024
◆ clearScreen()
Clears the screen.
Credit: SirEnder125 on cplusplus.com
◆ convertAsciiArtToLines()
| std::vector<std::string> convertAsciiArtToLines |
( |
const std::string & |
asciiArt | ) |
|
Vectorises a string on the newline character.
- Parameters
-
| asciiArt | String of an ASCII artwork to be vectorised |
- Returns
- std::vector<std::string>
◆ enableVirtualTerminal()
| bool enableVirtualTerminal |
( |
| ) |
|
enables the virtual terminal processing mode
sets the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag so that virtual terminal sequences will be interpreted by the console to display colour and formatting
◆ getRandomEncouragingQuote()
| std::string getRandomEncouragingQuote |
( |
| ) |
|
Get a Random Encouraging Quote.
- Returns
- std::string
◆ getRandomPhrase()
| std::string getRandomPhrase |
( |
| ) |
|
Get a Random Phrase.
- Returns
- std::string
◆ getRandomPositiveQuote()
| std::string getRandomPositiveQuote |
( |
| ) |
|
Get a Random Positive Quote.
- Returns
- std::string
◆ isValidDeckFileName()
| bool isValidDeckFileName |
( |
const std::string & |
name | ) |
|
Checks if name for deckfile meets naming requirements.
Deck filenames should only contain [A-Za-z0-9] characters
- Parameters
-
- Returns
- true is a valid file name for a deck
-
false is not a valid file name a deck
◆ pause()
◆ readInANSICodes()
| std::vector<std::vector<int> > readInANSICodes |
( |
std::string |
filename | ) |
|
reads a file of integers (0-255) that will be used to create ANSI colours
- Parameters
-
| filename | the file containing whitespace separated integers representing ANSI colours |
- Returns
- std::vector<std::vector<int>>
◆ steadyClockToString()
| std::string steadyClockToString |
( |
const std::chrono::steady_clock::time_point & |
start_time | ) |
|
Gives the number of seconds past since the time point as "X seconds since start".
- Parameters
-
| start_time | a timepoint to turn into a string |
- Returns
- std::string
◆ timeComplete()
| bool timeComplete |
( |
const std::chrono::time_point< std::chrono::steady_clock > & |
start_time, |
|
|
const int & |
duration_secs |
|
) |
| |
Determines if the number of seconds has elapased since a start time.
- Parameters
-
| start_time | the time to count number of seconds from |
| duration_secs | time period to check has elapsed |
- Returns
- true for the duration having passed since the start time, otherwise false.
◆ timeRemainingMins()
| int timeRemainingMins |
( |
const std::chrono::time_point< std::chrono::steady_clock > & |
start_time, |
|
|
const int & |
duration_mins |
|
) |
| |
Used to display the time remaining to users. To determine the actual end the session use timeComplete()
- Parameters
-
| start_time | The time the timer started |
| duration_mins | the period in minutes to check how much from the start time is remaining |
- Returns
- int
◆ yesNoPrompt()
Prompts the user to enter [Yy] for yes and [Nn] for no.
- Returns
- true for [Yy]
-
false for [Nn]
◆ isTestMode
used to toggle between simulated input (true) and user input (false)