-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathusefulStuff.cpp
More file actions
44 lines (39 loc) · 918 Bytes
/
usefulStuff.cpp
File metadata and controls
44 lines (39 loc) · 918 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "stdafx.h"
#include "usefulStuff.hpp"
string capStr(string capMe) {
// Get everything in this string into capital letters
for_each(capMe.begin(), capMe.end(), [&](char& c) {
c = toupper(c);
});
return capMe;
}
char charThis(string yesThis) {
if (yesThis == "") {
yesThis = "X";
}
char* intoThis = new char[yesThis.size() + 1];
strcpy_s(intoThis, yesThis.size() + 1, yesThis.c_str());
return *intoThis;
}
time_t getTime() {
return time(NULL);
}
COLORREF stringToColor(string color) {
int rgb[3]{ 0, 0, 0 };
if (color.length() == 9) {
string buf = color;
for (int i = 0; i < 3; i++) {
buf.resize(3);
rgb[i] = stoi(buf);
color.erase(0, 3);
buf = color;
}
}
COLORREF colorCode = RGB(rgb[0], rgb[1], rgb[2]);
return colorCode;
}
bool isNumber(const string& s)
{
return !s.empty() && find_if(s.begin(),
s.end(), [](unsigned char c) { return !isdigit(c); }) == s.end();
}