Files
ImHex-Patterns/includes/libstd/string.pat
WerWolv 4eff8460ba includes: Added pattern language standard library (#19)
* libstd: Initial standard library work

bit operations, fixed point, numeric limits and math functions

* libstd: Added ctype, rustint, stdint and string library, expand bit, fxpt and math library

* patterns: Drastically improve ELF pattern

* patterns: Added atmosphere AFE2

* patterns: tabs -> spaces

* patterns: Added archive file pattern
2021-09-30 12:55:42 +02:00

30 lines
754 B
Plaintext

namespace std::string {
fn to_string(auto x) {
return std::format("{}", x);
};
fn starts_with(str string, str part) {
return std::string::substr(string, 0, std::string::length(part)) == part;
};
fn ends_with(str string, str part) {
return std::string::substr(string, std::string::length(string) - std::string::length(part), std::string::length(part)) == part;
};
fn contains(str a, str b) {
s32 a_len, b_len;
a_len = std::string::length(a);
b_len = std::string::length(b);
s32 i;
while (i < a_len - b_len) {
if (std::string::substr(a, i, b_len) == b)
return true;
i = i + 1;
}
return false;
};
}