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/util/BidirectionalUnorderedMap.h"
10
11// auto generated forward declare list
12// clang-format off
13class ListTag;
14class SemVersion;
15namespace Json { class Value; }
16// clang-format on
17
18namespace Util {
19// functions
20// NOLINTBEGIN
21MCNAPI ::std::string base64_decode(::std::string const& encoded_string);
22
23MCNAPI ::std::string base64_encode(uchar const* bytes_to_encode, uint64 in_len, bool pad);
24
25MCNAPI ::std::string base64url_decode(::std::string encoded);
26
27MCNAPI ::std::string base64url_encode(::std::string str);
28
29MCNAPI ::std::string ensureNamespace(::std::string const& id, ::std::string_view defaultNamespace);
30
31MCNAPI bool equalIgnoreCase(::std::string_view lhs, ::std::string_view rhs);
32
33MCNAPI ::std::string formatTickDuration(int ticks);
34
35MCNAPI ::std::string fromHex(::std::string_view input);
36
37MCNAPI ::BidirectionalUnorderedMap<int, uint64> generateHashMapFromListTag(::ListTag const& enumValues);
38
39MCNAPI ::std::string generateRandomId(int modifier);
40
41MCNAPI uint hashCodeAsUtf16(::std::string_view sv);
42
43MCNAPI bool isValidNamespaceFormat(::std::string_view name);
44
45MCNAPI bool isValidUTF8(::std::string_view content);
46
47MCNAPI bool isVanillaNamespace(::std::string const& identifier);
48
49MCNAPI void loadGameVersion(::SemVersion& version, ::Json::Value const& versionNode);
50
51MCNAPI void normalizeLineEndings(::std::string& str);
52
53MCNAPI ::std::string removeChars(::std::string str, ::std::string const& characters);
54
55MCNAPI ::std::string removeIllegalChars(::std::string str);
56
57MCNAPI ::std::string removeTrailingSpaces(::std::string const& str);
58
59MCNAPI ::std::istream& safeGetline(::std::istream& inputStream, ::std::string& outString);
60
61MCNAPI ::std::vector<::std::string> split(::std::string_view view, char delim);
62
63MCNAPI ::std::vector<::std::string> splitAndDiscardEmpty(::std::string const& str, char delim);
64
65MCNAPI ::std::vector<::std::string> splitLines(
66 ::std::string const& str,
67 ::std::vector<::std::string> const& delims,
68 bool includeDelimCharsInResult,
69 bool includeEmptyLines,
70 ::std::istream& (*fnGetline)(::std::istream&, ::std::string&)
71);
72
73MCNAPI ::std::vector<::std::string>& splitString(::std::string_view s, char delim, ::std::vector<::std::string>& elems);
74
75MCNAPI ::std::vector<::std::string_view>&
76splitStringAsViews(::std::string_view s, char delim, ::std::vector<::std::string_view>& elems);
77
78MCNAPI ::std::vector<::std::string_view> splitToViews(::std::string_view view, char delim);
79
80MCNAPI ::std::string
81stringReplace(::std::string str, ::buffer_span<::std::pair<::std::string_view, ::std::string_view>> replacements);
82
83MCNAPI ::std::string& stringReplace(::std::string& s, ::std::string const& src, ::std::string const& dst, int maxCount);
84
85MCNAPI ::std::string
86stringReplaceCopy(::std::string const& s, ::std::string const& src, ::std::string const& dst, int maxCount);
87
88MCNAPI ::std::string stringTrim(::std::string const& s);
89
90MCNAPI ::std::string stringTrim(::std::string const& s, ::std::string const& chars);
91
92MCNAPI bool toBool(::std::string const& input, bool& destination);
93
94MCNAPI ::std::string toCamelCase(::std::string const& src, char delimiter);
95
96MCNAPI ::Util::NumberConversionResult toIntWithMinMax(::std::string_view inputStr, int& destination, int min, int max);
97
98MCNAPI ::std::string toLower(::std::string_view inString);
99
100MCNAPI ::std::string toStringWithPaddedZeroes(uint number, uchar digitCount);
101
102MCNAPI ::std::string toUpper(::std::string_view inString);
103
104MCNAPI int utf8len(::std::string_view str);
105
106MCNAPI ::std::string utf8substring(::std::string const& str, int startIndex, int endIndex);
107
108MCNAPI bool validateIdentifier(
109 ::std::string const& id,
110 ::LogArea logArea,
111 bool allowMinecraftNamespace,
112 ::std::pair<::std::string, ::std::string>* idNameOut
113);
114
115MCNAPI bool validateIdentifierChunk(::std::string const& chunk, ::LogArea logArea);
116// NOLINTEND
117
118// static variables
119// NOLINTBEGIN
120MCNAPI ::std::string const& EMPTY_GUID();
121
122MCNAPI ::std::string const& EMPTY_STRING();
123
124MCNAPI ::std::string const& HEX_CHARS();
125
126MCNAPI ::std::string const& NEW_LINE();
127// NOLINTEND
128
129} // namespace Util
Definition Value.h:16
Definition ListTag.h:12
Definition SemVersion.h:16
Definition buffer_span.h:6