mirror of
https://github.com/zeldaret/oot.git
synced 2025-08-23 07:21:19 +00:00
* Updated config file * Added missing files * Temporarily removed asm_processor changes. * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "96ffc1e62" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "96ffc1e62" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "179af7d11" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "179af7d11" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * Cleanup and fixes. * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "50ad2fe78" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "50ad2fe78" git-subrepo: version: "0.4.3" origin: "???" commit: "???" * Makefile fix * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "b9120803e" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "b9120803e" git-subrepo: version: "0.4.3" origin: "???" commit: "???" Co-authored-by: Jack Walker <7463599+Jack-Walker@users.noreply.github.com>
95 lines
2 KiB
C++
95 lines
2 KiB
C++
#pragma once
|
|
|
|
#include <numeric>
|
|
#include <stdarg.h>
|
|
#include <string.h>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
class StringHelper
|
|
{
|
|
public:
|
|
static std::vector<std::string> Split(std::string s, const std::string& delimiter)
|
|
{
|
|
std::vector<std::string> result;
|
|
|
|
size_t pos = 0;
|
|
std::string token;
|
|
|
|
while ((pos = s.find(delimiter)) != std::string::npos)
|
|
{
|
|
token = s.substr(0, pos);
|
|
result.push_back(token);
|
|
s.erase(0, pos + delimiter.length());
|
|
}
|
|
|
|
if (s.length() != 0)
|
|
result.push_back(s);
|
|
|
|
return result;
|
|
}
|
|
|
|
static std::string Strip(std::string s, const std::string& delimiter)
|
|
{
|
|
size_t pos = 0;
|
|
std::string token;
|
|
|
|
while ((pos = s.find(delimiter)) != std::string::npos)
|
|
{
|
|
token = s.substr(0, pos);
|
|
s.erase(pos, pos + delimiter.length());
|
|
}
|
|
|
|
return s;
|
|
}
|
|
|
|
static std::string Replace(std::string str, const std::string& from, const std::string& to)
|
|
{
|
|
size_t start_pos = str.find(from);
|
|
|
|
if (start_pos == std::string::npos)
|
|
return str;
|
|
|
|
str.replace(start_pos, from.length(), to);
|
|
return str;
|
|
}
|
|
|
|
static bool StartsWith(const std::string& s, const std::string& input)
|
|
{
|
|
return s.rfind(input, 0) == 0;
|
|
}
|
|
|
|
static bool Contains(const std::string& s, const std::string& input)
|
|
{
|
|
return s.find(input) != std::string::npos;
|
|
}
|
|
|
|
static bool EndsWith(const std::string& s, const std::string& input)
|
|
{
|
|
int32_t inputLen = strlen(input.c_str());
|
|
return s.rfind(input) == (s.size() - inputLen);
|
|
}
|
|
|
|
static std::string Sprintf(const char* format, ...)
|
|
{
|
|
char buffer[32768];
|
|
// char buffer[2048];
|
|
std::string output = "";
|
|
va_list va;
|
|
|
|
va_start(va, format);
|
|
vsprintf(buffer, format, va);
|
|
va_end(va);
|
|
|
|
output = buffer;
|
|
return output;
|
|
}
|
|
|
|
static std::string Implode(std::vector<std::string>& elements, const char* const separator)
|
|
{
|
|
return std::accumulate(std::begin(elements), std::end(elements), std::string(),
|
|
[separator](std::string& ss, std::string& s) {
|
|
return ss.empty() ? s : ss + separator + s;
|
|
});
|
|
}
|
|
};
|