LeviLamina
Loading...
Searching...
No Matches
Util.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/debug/log/LogArea.h"
7#include "mc/deps/core/utility/NumberConversionResult.h"
8#include "mc/deps/core/utility/buffer_span.h"
9#include "mc/platform/brstd/flat_set.h"
10#include "mc/util/BidirectionalUnorderedMap.h"
11
12// auto generated forward declare list
13// clang-format off
14class GameVersion;
15class I18n;
16class ListTag;
17class SemVersion;
18namespace Json { class Value; }
19namespace Util { struct string_hash; }
20// clang-format on
21
22namespace Util {
23// functions
24// NOLINTBEGIN
25#ifdef LL_PLAT_C
26MCNAPI void _breakIntoWordsAndFindProfanity(
27 ::std::string_view str,
28 ::std::vector<::std::pair<int, int>> const& originalStrIndexes,
29 ::brstd::flat_set<char, ::std::less<char>, ::std::vector<char>> const& escapeChars,
30 ::std::set<::std::pair<int, int>>& profanityLocations,
31 ::std::unordered_map<::std::string, int, ::Util::string_hash, ::std::equal_to<void>> const& exactMap,
32 ::std::unordered_set<::std::string, ::Util::string_hash, ::std::equal_to<void>> const& containsSet
33);
34
35MCNAPI void _recordProfanityLocationInWord(
36 ::std::string_view word,
37 ::std::vector<::std::pair<int, int>> const& originalStrIndexes,
38 int start,
39 int end,
40 ::std::set<::std::pair<int, int>>& profanityLocations,
41 ::std::unordered_map<::std::string, int, ::Util::string_hash, ::std::equal_to<void>> const& exactMap,
42 ::std::unordered_set<::std::string, ::Util::string_hash, ::std::equal_to<void>> const& containsSet
43);
44#endif
45
46MCNAPI ::std::string base64_decode(::std::string const& encoded_string);
47
48MCNAPI ::std::string base64_encode(uchar const* bytes_to_encode, uint64 in_len, bool pad);
49
50MCNAPI ::std::string base64url_decode(::std::string encoded);
51
52MCNAPI ::std::string base64url_encode(::std::string str);
53
54MCNAPI ::std::string caseFold(::std::string_view str);
55
56#ifdef LL_PLAT_S
57MCNAPI ::std::string commaSeparatedListFromVector(::std::vector<::std::string> const& stringVector);
58#endif
59
60#ifdef LL_PLAT_C
61MCNAPI bool containsUnicodeChar(::std::string const& str);
62
63MCNAPI uint64 createObfuscated64BitIntegerFromXboxLiveID(::std::string const& input);
64#endif
65
66MCNAPI ::std::string ensureNamespace(::std::string const& id, ::std::string_view defaultNamespace);
67
68#ifdef LL_PLAT_C
69MCNAPI bool equalIgnoreCase(::std::string_view lhs, ::std::string_view rhs);
70
71MCNAPI ::std::string filterProfanityFromString(
72 ::std::string_view inputStr,
73 ::std::unordered_map<::std::string, int, ::Util::string_hash, ::std::equal_to<void>> const& profanityExactMap,
74 ::std::unordered_set<::std::string, ::Util::string_hash, ::std::equal_to<void>> const& profanityContainsSet
75);
76
77MCNAPI ::std::string findLastColorCode(::std::string_view s, bool includeResetCode);
78
79MCNAPI ::std::set<::std::pair<int, int>> findProfanityInString(
80 ::std::string_view inputStr,
81 ::std::unordered_map<::std::string, int, ::Util::string_hash, ::std::equal_to<void>> const& exactMap,
82 ::std::unordered_set<::std::string, ::Util::string_hash, ::std::equal_to<void>> const& containsSet
83);
84#endif
85
86MCNAPI ::std::string formatTickDuration(int ticks);
87
88MCNAPI ::std::string fromHex(::std::string_view input);
89
90MCNAPI ::BidirectionalUnorderedMap<int, uint64> generateHashMapFromListTag(::ListTag const& enumValues);
91
92MCNAPI ::std::string generateRandomId(int modifier);
93
94#ifdef LL_PLAT_C
95MCNAPI ::std::string getActiveFormattingCodes(::std::string const& str);
96
97MCNAPI ::std::string getFilesizeString(uint64 filesize);
98
99MCNAPI ::std::string getFilesizeString(uint64 filesize, ::I18n& loc);
100
101MCNAPI ::std::string getLocalizedStoreDisplayName(::std::string const& storeId);
102#endif
103
104MCNAPI ::std::string_view getNameWithoutNamespace(::std::string_view name);
105
106#ifdef LL_PLAT_C
107MCNAPI ::std::string getPackDataDownloadProgressString(
108 uint64 downloadedDataSize,
109 uint64 totalDownloadDataSize,
110 ::std::string (*getFileSizeString)(uint64)
111);
112
113MCNAPI ::std::string getPackDownloadProgressString(uint64 downloadedPacks, uint64 packsToDownload);
114
115MCNAPI ::std::string getVirtualCurrencyStringTTS(uint amount);
116#endif
117
118MCNAPI bool isValidNamespaceFormat(::std::string_view name);
119
120MCNAPI bool isValidUTF8(::std::string_view content);
121
122MCNAPI bool isVanillaNamespace(::std::string const& identifier);
123
124#ifdef LL_PLAT_C
125MCNAPI void loadGameVersion(::GameVersion& version, ::Json::Value const& versionNode);
126#endif
127
128MCNAPI void loadGameVersion(::SemVersion& version, ::Json::Value const& versionNode);
129
130MCNAPI void normalizeLineEndings(::std::string& str);
131
132MCNAPI ::std::string removeChars(::std::string str, ::std::string const& characters);
133
134MCNAPI ::std::string removeFormattingAndColorCodes(::std::string const& input, bool redactObfuscatedText);
135
136MCNAPI ::std::string removeIllegalChars(::std::string str);
137
138#ifdef LL_PLAT_S
139MCNAPI ::std::string removeTrailingSpaces(::std::string const& str);
140#endif
141
142#ifdef LL_PLAT_C
143MCNAPI void replaceUtf8CharactersWithAscii(
144 ::std::string& target,
145 ::std::vector<::std::pair<::std::string, char>> const& translateMap
146);
147#endif
148
149MCNAPI ::std::istream& safeGetline(::std::istream& inputStream, ::std::string& outString);
150
151#ifdef LL_PLAT_C
152MCNAPI ::std::string safeString(char const* text);
153
154MCNAPI ::std::string simpleFormat(::std::string const& format, ::std::vector<::std::string> const& parameters);
155#endif
156
157MCNAPI ::std::vector<::std::string> split(::std::string_view view, char delim);
158
159MCNAPI ::std::vector<::std::string> splitAndDiscardEmpty(::std::string_view str, char delim);
160
161#ifdef LL_PLAT_C
162MCNAPI ::std::vector<::std::string> splitAndDiscardEmpty(
163 ::std::string const& str,
164 ::std::vector<::std::string> const& delims,
165 bool includeDelimCharsInResult
166);
167
168MCNAPI ::std::vector<::std::string>
169splitLines(::std::string const& content, ::std::istream& (*fnGetline)(::std::istream&, ::std::string&));
170#endif
171
172MCNAPI ::std::vector<::std::string> splitLines(
173 ::std::string const& str,
174 ::std::vector<::std::string> const& delims,
175 bool includeDelimCharsInResult,
176 bool includeEmptyLines,
177 ::std::istream& (*fnGetline)(::std::istream&, ::std::string&)
178);
179
180MCNAPI ::std::vector<::std::string>& splitString(::std::string_view s, char delim, ::std::vector<::std::string>& elems);
181
182MCNAPI ::std::vector<::std::string_view>&
183splitStringAsViews(::std::string_view s, char delim, ::std::vector<::std::string_view>& elems);
184
185MCNAPI ::std::vector<::std::string_view> splitToViews(::std::string_view view, char delim);
186
187MCNAPI bool startsWith(::std::string_view str, ::std::string_view starts);
188
189MCNAPI bool stringContains(::std::string const& s, char character);
190
191#ifdef LL_PLAT_C
192MCNAPI bool stringIsInVector(::std::vector<::std::string> const& stringVector, ::std::string const& searchString);
193
194MCNAPI ::std::string
195stringReplace(::std::string str, ::buffer_span<::std::pair<::std::string_view, ::std::string_view>> replacements);
196#endif
197
198MCNAPI ::std::string& stringReplace(::std::string& s, ::std::string const& src, ::std::string const& dst, int maxCount);
199
200MCNAPI ::std::string
201stringReplaceCopy(::std::string const& s, ::std::string const& src, ::std::string const& dst, int maxCount);
202
203MCNAPI ::std::string stringTrim(::std::string const& s);
204
205MCNAPI ::std::string stringTrim(::std::string const& s, ::std::string const& chars);
206
207MCNAPI bool toBool(::std::string const& input, bool& destination);
208
209MCNAPI ::std::string toCamelCase(::std::string const& src, char delimiter);
210
211MCNAPI ::std::string toHex(::std::string_view input);
212
213MCNAPI ::Util::NumberConversionResult toIntWithMinMax(::std::string_view inputStr, int& destination, int min, int max);
214
215#ifdef LL_PLAT_C
216MCNAPI ::std::string toLocalizedString(float f, int precision);
217
218MCNAPI ::std::string toLocalizedString(
219 float f,
220 int precision,
221 ::std::string const& digitGroupSeparator,
222 ::std::string const& decimalSeparator
223);
224
225MCNAPI ::std::string toLower(char const* inString);
226#endif
227
228MCNAPI ::std::string toLower(::std::string_view inString);
229
230#ifdef LL_PLAT_C
231MCNAPI bool toSafeNumber(::std::string const& str, uint& output);
232
233MCNAPI ::std::string toString(::std::basic_string_view<wchar_t, ::std::char_traits<wchar_t>> inputStr);
234#endif
235
236MCNAPI ::std::string toStringWithPaddedZeroes(uint number, uchar digitCount);
237
238MCNAPI int utf8len(::std::string_view str);
239
240MCNAPI ::std::string utf8substring(::std::string const& str, int startIndex, int endIndex);
241
242#ifdef LL_PLAT_C
243MCNAPI ::std::vector<::std::string> utf8substringCharacters(::std::string const& str, int startIndex, int endIndex);
244#endif
245
246MCNAPI bool validateIdentifier(
247 ::std::string const& id,
248 ::LogArea logArea,
249 bool allowMinecraftNamespace,
250 ::std::pair<::std::string, ::std::string>* idNameOut
251);
252
253MCNAPI bool validateIdentifierChunk(::std::string const& chunk, ::LogArea logArea);
254// NOLINTEND
255
256// static variables
257// NOLINTBEGIN
258MCNAPI ::std::string const& EMPTY_GUID();
259
260MCNAPI ::std::string const& EMPTY_STRING();
261
262MCNAPI ::std::string const& HEX_CHARS();
263
264MCNAPI ::std::string const& NEW_LINE();
265// NOLINTEND
266
267} // namespace Util
Definition GameVersion.h:10
Definition I18n.h:19
Definition Value.h:16
Definition ListTag.h:19
Definition SemVersion.h:15
Definition string_hash.h:7