-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctions.cpp
More file actions
executable file
·44 lines (39 loc) · 1.18 KB
/
Functions.cpp
File metadata and controls
executable file
·44 lines (39 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "Functions.hpp"
#include <cctype>
bool functions::stringIsInt(std::string string) {
if (string.length() == 0)
return false;
for (int i = 0; i < string.length(); i++) {
if (isdigit(string[i]) == false) {
return false;
}
}
return true;
}
std::vector<std::string> functions::splitString(std::string string, std::string seperator) {
std::vector<std::string> returnString;
std::string modString = string;
bool seperatorLeft = true;
while (seperatorLeft) {
if (modString.find(seperator) == std::string::npos) {
seperatorLeft = false;
returnString.push_back(modString);
break;
}
returnString.push_back(modString.substr(0, modString.find(seperator)));
modString = modString.substr(modString.find(seperator) + seperator.size(), modString.length());
}
return returnString;
}
bool functions::stringToBool(std::string string) {
if (string == "1")
return true;
if (string == "0")
return false;
for (auto& charcther : string) {
charcther = tolower(charcther);
}
if (string == "true")
return true;
return false;
}