-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctions.cpp
More file actions
executable file
·28 lines (26 loc) · 902 Bytes
/
Functions.cpp
File metadata and controls
executable file
·28 lines (26 loc) · 902 Bytes
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
#include "Functions.hpp"
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;
}