-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutil.cpp
More file actions
33 lines (29 loc) · 731 Bytes
/
util.cpp
File metadata and controls
33 lines (29 loc) · 731 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
#include "stdafx.h"
#include "util.h"
void toLowerCase(std::string & text)
{
for (unsigned i = 0; i < text.length(); i++)
text[i] = (char)tolower(text[i]);
}
void toUpperCase(std::string & text)
{
for (unsigned i = 0; i < text.length(); i++)
text[i] = (char)toupper(text[i]);
}
std::string toString(long t)
{
std::ostringstream stream;
stream << t;
return std::string(stream.str());
}
std::string getNameFromDirectory(const std::string& dir)
{
return std::string(
std::find_if(dir.rbegin(), dir.rend(), [](char c) {return c == '\\' || c == '/'; }).base(),
dir.end());
}
wchar_t charToWchar(unsigned char c)
{
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
return converter.from_bytes(c)[0];
}