Delete some unused string functions

This commit is contained in:
Henrik Rydgård 2020-09-29 00:41:32 +02:00
parent 536d881626
commit 30ecde5bc9
5 changed files with 3 additions and 77 deletions

View file

@ -34,33 +34,12 @@ std::string LineNumberString(const std::string &str) {
return output.str();
}
void StringTrimEndNonAlphaNum(char *str) {
ssize_t n = strlen(str);
while (!isalnum(str[n]) && n >= 0) {
str[n--] = '\0';
}
}
void SkipSpace(const char **ptr) {
while (**ptr && isspace(**ptr)) {
(*ptr)++;
}
}
void StringUpper(char *str) {
while (*str) {
*str = toupper(*str);
str++;
}
}
void StringUpper(char *str, int len) {
while (len--) {
*str = toupper(*str);
str++;
}
}
void DataToHexString(const uint8_t *data, size_t size, std::string *output) {
Buffer buffer;
for (size_t i = 0; i < size; i++) {
@ -140,11 +119,6 @@ std::string StringFromInt(int value)
return temp;
}
std::string StringFromBool(bool value)
{
return value ? "True" : "False";
}
// Turns " hej " into "hej". Also handles tabs.
std::string StripSpaces(const std::string &str)
{
@ -167,27 +141,6 @@ std::string StripQuotes(const std::string& s)
return s;
}
// For Debugging. Read out an u8 array.
std::string ArrayToString(const uint8_t *data, uint32_t size, int line_len, bool spaces)
{
std::ostringstream oss;
oss << std::setfill('0') << std::hex;
for (int line = 0; size; ++data, --size)
{
oss << std::setw(2) << (int)*data;
if (line_len == ++line)
{
oss << '\n';
line = 0;
}
else if (spaces)
oss << ' ';
}
return oss.str();
}
void SplitString(const std::string& str, const char delim, std::vector<std::string>& output)
{
size_t next = 0;
@ -243,9 +196,3 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st
}
return result;
}
int strcmpIgnore(std::string str1, std::string str2, std::string ignorestr1, std::string ignorestr2) {
str1 = ReplaceAll(str1, ignorestr1, ignorestr2);
str2 = ReplaceAll(str2, ignorestr1, ignorestr2);
return strcmp(str1.c_str(),str2.c_str());
}

View file

@ -13,16 +13,6 @@
#include <strings.h>
#endif
// Dumb wrapper around itoa, providing a buffer. Declare this on the stack.
class ITOA {
public:
char buffer[16];
const char *p(int i) {
sprintf(buffer, "%i", i);
return &buffer[0];
}
};
// Useful for shaders with error messages..
std::string LineNumberString(const std::string &str);
@ -62,9 +52,6 @@ inline void StringToHexString(const std::string &data, std::string *output) {
std::string StringFromFormat(const char* format, ...);
std::string StringFromInt(int value);
std::string StringFromBool(bool value);
std::string ArrayToString(const uint8_t *data, uint32_t size, int line_len = 20, bool spaces = true);
std::string StripSpaces(const std::string &s);
std::string StripQuotes(const std::string &s);
@ -75,10 +62,4 @@ void GetQuotedStrings(const std::string& str, std::vector<std::string>& output);
std::string ReplaceAll(std::string input, const std::string& src, const std::string& dest);
// Compare two strings, ignore the difference between the ignorestr1 and the ignorestr2 in str1 and str2.
int strcmpIgnore(std::string str1, std::string str2, std::string ignorestr1, std::string ignorestr2);
void StringTrimEndNonAlphaNum(char *str);
void SkipSpace(const char **ptr);
void StringUpper(char *str);
void StringUpper(char *str, int len);

View file

@ -52,7 +52,7 @@ public:
void Set(const char* key, bool newValue, bool defaultValue);
void Set(const char* key, bool newValue) {
Set(key, StringFromBool(newValue).c_str());
Set(key, newValue ? "True" : "False");
}
void Set(const char* key, const std::vector<std::string>& newValues);

View file

@ -162,9 +162,8 @@ void View::PersistData(PersistStatus status, std::string anonId, PersistMap &sto
break;
}
ITOA stringify;
for (int i = 0; i < (int)tweens_.size(); ++i) {
tweens_[i]->PersistData(status, tag + "/" + stringify.p((int)i), storage);
tweens_[i]->PersistData(status, tag + "/" + StringFromInt(i), storage);
}
}

View file

@ -70,9 +70,8 @@ void ViewGroup::PersistData(PersistStatus status, std::string anonId, PersistMap
tag = anonId;
}
ITOA stringify;
for (size_t i = 0; i < views_.size(); i++) {
views_[i]->PersistData(status, tag + "/" + stringify.p((int)i), storage);
views_[i]->PersistData(status, tag + "/" + StringFromInt((int)i), storage);
}
}