libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
StringHelper.h
Go to the documentation of this file.
1#pragma once
2
3#include <algorithm>
4#include <cstdarg>
5#include <cstring>
6#include <numeric>
7#include <string>
8#include <string_view>
9#include <vector>
10#include <cstdint>
11
21class StringHelper {
22 public:
29 static std::vector<std::string> Split(std::string s, const std::string& delimiter);
30
37 static std::vector<std::string_view> Split(std::string_view s, const std::string& delimiter);
38
45 static std::string Strip(std::string s, const std::string& delimiter);
46
54 static std::string Replace(std::string str, const std::string& from, const std::string& to);
55
62 static void ReplaceOriginal(std::string& str, const std::string& from, const std::string& to);
63
69 static bool StartsWith(const std::string& s, const std::string& input);
70
76 static bool Contains(const std::string& s, const std::string& input);
77
83 static bool EndsWith(const std::string& s, const std::string& input);
84
91 static std::string Sprintf(const char* format, ...);
92
99 static std::string Implode(const std::vector<std::string>& elements, const char* const separator);
100
107 static int64_t StrToL(const std::string& str, int32_t base = 10);
108
113 static std::string BoolStr(bool b);
114
119 static bool HasOnlyDigits(const std::string& str);
120
125 static bool IsValidHex(std::string_view str);
126
131 static bool IsValidHex(const std::string& str);
132
137 static bool IsValidOffset(std::string_view str);
138
143 static bool IsValidOffset(const std::string& str);
144
151 static bool IEquals(const std::string& a, const std::string& b);
152
158 static std::vector<uint8_t> HexToBytes(const std::string& hex);
159
165 static std::string BytesToHex(const std::vector<unsigned char>& bytes);
166};