mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-24 11:36:34 +00:00
refactor: unglob std::wstring
This commit is contained in:
@@ -1,28 +1,28 @@
|
||||
#include "../Build/stdafx.h"
|
||||
|
||||
wstring toLower(const wstring& a)
|
||||
std::wstring toLower(const std::wstring& a)
|
||||
{
|
||||
wstring out = wstring(a);
|
||||
std::wstring out = std::wstring(a);
|
||||
std::transform(out.begin(), out.end(), out.begin(), ::tolower);
|
||||
return out;
|
||||
}
|
||||
|
||||
wstring trimString(const wstring& a)
|
||||
std::wstring trimString(const std::wstring& a)
|
||||
{
|
||||
wstring b;
|
||||
std::wstring b;
|
||||
int start = (int)a.find_first_not_of(L" \t\n\r");
|
||||
int end = (int)a.find_last_not_of(L" \t\n\r");
|
||||
if( start == wstring::npos ) start = 0;
|
||||
if( end == wstring::npos ) end = (int)a.size()-1;
|
||||
if( start == std::wstring::npos ) start = 0;
|
||||
if( end == std::wstring::npos ) end = (int)a.size()-1;
|
||||
b = a.substr(start,(end-start)+1);
|
||||
return b;
|
||||
}
|
||||
|
||||
wstring replaceAll(const wstring& in, const wstring& replace, const wstring& with)
|
||||
std::wstring replaceAll(const std::wstring& in, const std::wstring& replace, const std::wstring& with)
|
||||
{
|
||||
wstring out = in;
|
||||
std::wstring out = in;
|
||||
size_t pos = 0;
|
||||
while( ( pos = out.find(replace, pos) ) != wstring::npos )
|
||||
while( ( pos = out.find(replace, pos) ) != std::wstring::npos )
|
||||
{
|
||||
out.replace( pos, replace.length(), with );
|
||||
pos++;
|
||||
@@ -30,26 +30,26 @@ wstring replaceAll(const wstring& in, const wstring& replace, const wstring& wit
|
||||
return out;
|
||||
}
|
||||
|
||||
bool equalsIgnoreCase(const wstring& a, const wstring& b)
|
||||
bool equalsIgnoreCase(const std::wstring& a, const std::wstring& b)
|
||||
{
|
||||
bool out;
|
||||
wstring c = toLower(a);
|
||||
wstring d = toLower(b);
|
||||
std::wstring c = toLower(a);
|
||||
std::wstring d = toLower(b);
|
||||
out = c.compare(d) == 0;
|
||||
return out;
|
||||
}
|
||||
|
||||
wstring convStringToWstring(const string& converting)
|
||||
std::wstring convStringToWstring(const string& converting)
|
||||
{
|
||||
wstring converted(converting.length(), L' ');
|
||||
std::wstring converted(converting.length(), L' ');
|
||||
copy(converting.begin(), converting.end(), converted.begin());
|
||||
return converted;
|
||||
}
|
||||
|
||||
// Convert for filename wstrings to a straight character pointer for Xbox APIs. The returned string is only valid until
|
||||
// Convert for filename std::wstrings to a straight character pointer for Xbox APIs. The returned string is only valid until
|
||||
// this function is called again, and it isn't thread-safe etc. as I'm just storing the returned name in a local static
|
||||
// to save having to clear it up everywhere this is used.
|
||||
const char *wstringtofilename(const wstring& name)
|
||||
const char *wstringtofilename(const std::wstring& name)
|
||||
{
|
||||
static char buf[256];
|
||||
assert(name.length()<256);
|
||||
@@ -68,7 +68,7 @@ const char *wstringtofilename(const wstring& name)
|
||||
return buf;
|
||||
}
|
||||
|
||||
wstring filenametowstring(const char *name)
|
||||
std::wstring filenametowstring(const char *name)
|
||||
{
|
||||
return convStringToWstring(name);
|
||||
}
|
||||
@@ -93,7 +93,7 @@ std::vector<std::wstring> stringSplit(const std::wstring &s, wchar_t delim)
|
||||
|
||||
bool BothAreSpaces(wchar_t lhs, wchar_t rhs) { return (lhs == rhs) && (lhs == L' '); }
|
||||
|
||||
void stripWhitespaceForHtml(wstring &string, bool bRemoveNewline)
|
||||
void stripWhitespaceForHtml(std::wstring &string, bool bRemoveNewline)
|
||||
{
|
||||
// Strip newline chars
|
||||
if(bRemoveNewline)
|
||||
@@ -110,9 +110,9 @@ void stripWhitespaceForHtml(wstring &string, bool bRemoveNewline)
|
||||
string = trimString(string);
|
||||
}
|
||||
|
||||
wstring escapeXML(const wstring &in)
|
||||
std::wstring escapeXML(const std::wstring &in)
|
||||
{
|
||||
wstring out = in;
|
||||
std::wstring out = in;
|
||||
out = replaceAll(out, L"&", L"&");
|
||||
//out = replaceAll(out, L"\"", L""");
|
||||
//out = replaceAll(out, L"'", L"'");
|
||||
@@ -121,9 +121,9 @@ wstring escapeXML(const wstring &in)
|
||||
return out;
|
||||
}
|
||||
|
||||
wstring parseXMLSpecials(const wstring &in)
|
||||
std::wstring parseXMLSpecials(const std::wstring &in)
|
||||
{
|
||||
wstring out = in;
|
||||
std::wstring out = in;
|
||||
out = replaceAll(out, L"&", L"&");
|
||||
//out = replaceAll(out, L"\"", L""");
|
||||
//out = replaceAll(out, L"'", L"'");
|
||||
|
||||
Reference in New Issue
Block a user