TheCOSCGameProject  1.0
toolkit.h
Go to the documentation of this file.
1 
8 #ifndef TOOLKIT_H
9 #define TOOLKIT_H
10 
11 #include <iostream>
12 #include <fstream>
13 #include <sstream>
14 #include <string>
15 #include <vector>
16 #include <chrono>
17 
18 #ifdef _WIN32
19 #include <windows.h>
20 
26 void SetConsoleSize(int width, int height);
27 
28 #else
29 #include <sys/ioctl.h>
30 #include <unistd.h>
31 #include <termios.h>
32 
38 void SetTerminalSize(int height, int width);
39 
40 #endif
41 
46 void delay(int milliseconds);
47 
54 void typePrint(const std::string &content, int delayTime = 15, const std::string &color = "\033[36m");
55 
61 std::string getFileContent(std::string fileName);
62 
69 std::vector<std::string> split(const std::string &str, char delimiter);
70 
75 void clear(int limit);
76 
81 std::string getUserInputLine();
82 
87 std::string getUserInputToken();
88 
95 int generateRandomNumber(int low, int high);
96 
102 int stringToInt(const std::string &str);
103 
110 std::string repeatString(const std::string &str, int count);
111 
117 std::string toLowerCase(const std::string &str);
118 
123 int readInt();
124 
128 void disableInput();
129 
133 void enableInput();
134 
138 void waitForEnter();
139 
145 std::string toUpperCase(const std::string &input);
146 
147 std::vector<int> getDist(std::vector<std::string> vector);
148 
149 #endif // TOOLKIT_H
void disableInput()
Disable user input.
Definition: toolkit.cpp:57
void SetTerminalSize(int height, int width)
Set the terminal size on non-Windows systems.
Definition: toolkit.cpp:32
std::vector< std::string > split(const std::string &str, char delimiter)
Split a string by a delimiter.
Definition: toolkit.cpp:134
int generateRandomNumber(int low, int high)
Generate a random number between two values.
Definition: toolkit.cpp:191
void delay(int milliseconds)
Mimic a delay in milliseconds.
Definition: toolkit.cpp:44
std::string getUserInputToken()
Get a single word or token of user input.
Definition: toolkit.cpp:177
std::string repeatString(const std::string &str, int count)
Repeat a string a specified number of times.
Definition: toolkit.cpp:234
std::string toLowerCase(const std::string &str)
Convert a string to lowercase.
Definition: toolkit.cpp:253
int stringToInt(const std::string &str)
Convert a string to an integer.
Definition: toolkit.cpp:208
void clear(int limit)
Clear the console up to a certain limit.
Definition: toolkit.cpp:153
int readInt()
Read an integer from user input.
Definition: toolkit.cpp:266
std::string getFileContent(std::string fileName)
Read the content of a file and return it as a string.
Definition: toolkit.cpp:114
void waitForEnter()
Wait for the user to press Enter.
Definition: toolkit.cpp:310
std::vector< int > getDist(std::vector< std::string > vector)
Definition: toolkit.cpp:332
std::string toUpperCase(const std::string &input)
Convert a string to uppercase.
Definition: toolkit.cpp:325
void typePrint(const std::string &content, int delayTime=15, const std::string &color="\3[36m")
Print text with a typing effect.
Definition: toolkit.cpp:98
void enableInput()
Enable user input.
Definition: toolkit.cpp:76
std::string getUserInputLine()
Get a full line of user input.
Definition: toolkit.cpp:166