aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/StringHelpers.h
blob: 609fdf5afa9edd150e2c25c6219ede4f63cf18a2 (plain)
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
#pragma once
using namespace std;

wstring toLower(const wstring& a);
wstring trimString(const wstring& a);
wstring replaceAll(const wstring& in, const wstring& replace, const wstring& with);

bool equalsIgnoreCase(const wstring& a, const wstring& b);
// 4J-PB - for use in the ::toString 
template <class T> std::wstring _toString(T t)
{
	std::wostringstream oss;
	oss << std::dec << t;
	return oss.str();
}
template <class T> T _fromString(const std::wstring& s)
{
    std::wistringstream stream (s);
    T t;
    stream >> t;
    return t;
}
template <class T> T _fromHEXString(const std::wstring& s)
{
    std::wistringstream stream (s);
    T t;
    stream >> std::hex >> t;
    return t;
}

wstring convStringToWstring(const string& converting);
const char *wstringtofilename(const wstring& name);
wstring filenametowstring(const char *name);

std::vector<std::wstring> &stringSplit(const std::wstring &s, wchar_t delim, std::vector<std::wstring> &elems);
std::vector<std::wstring> stringSplit(const std::wstring &s, wchar_t delim);

void stripWhitespaceForHtml(wstring &string, bool bRemoveNewline=true);
wstring escapeXML(const wstring &in);
wstring parseXMLSpecials(const wstring &in);