rodecomp/Source/Utility/Text/StringUtil.cpp
ragnarok-clanker a54776c4be Decompile 5 functions in Source/Utility/Text/StringUtil.cpp, Source/Utility/Text/StringUtil.h
Batch #3559 by eAthena: 0 byte-identical, 5 confirmed by peer review.

- fn_02757 CountCharacters: logic confirmed by peer review
- fn_02758 ContainsText: logic confirmed by peer review
- fn_02761 IsNullOrEmpty: logic confirmed by peer review
- fn_02762 RemoveAll: logic confirmed by peer review
- fn_02763 ReplaceAll: logic confirmed by peer review

Peer-reviewed-by: superintelligence
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
Adds to the build: Source/Utility/Text/StringUtil.cpp
2026-10-29 22:46:20 +00:00

52 lines
1.3 KiB
C++

#include "Utility/Text/StringUtil.h"
#include <cstring>
// OFFSET: 0x0058A4D0
// FUNCTION: fn_02757
int CountCharacters(WORD codePage, const char* text, const char* end) {
if (text == nullptr) {
return 0;
}
int count = 0;
while (*text != '\0' && (end == nullptr || text < end)) {
text = CharNextExA(codePage, text, 0);
if (end != nullptr && text > end) {
break;
}
++count;
}
return count;
}
// OFFSET: 0x0058A620
// FUNCTION: fn_02758
bool ContainsText(const std::string& text, std::string_view pattern) {
return text.find(pattern.data(), 0, pattern.size()) != std::string::npos;
}
// OFFSET: 0x0058AAF0
// FUNCTION: fn_02761
bool IsNullOrEmpty(const char* text) {
return text == nullptr || std::strlen(text) == 0;
}
// OFFSET: 0x0058AC30
// FUNCTION: fn_02762
int RemoveAll(std::string& text, std::string_view pattern) {
return ReplaceAll(text, pattern, "");
}
// OFFSET: 0x0058AC60
// FUNCTION: fn_02763
int ReplaceAll(std::string& text, std::string_view pattern, std::string_view replacement) {
int count = 0;
std::size_t position = 0;
while ((position = text.find(pattern.data(), position, pattern.size())) != std::string::npos) {
text.replace(position, pattern.size(), replacement.data(), replacement.size());
position += replacement.size();
++count;
}
return count;
}