|
Cuberite
A lightweight, fast and extensible game server for Minecraft
|
Go to the documentation of this file.
25 template <
typename... Args>
28 return vPrintf(a_Dst, a_Format, fmt::make_printf_args(a_Args...));
33 extern AString vPrintf(
const char * a_Format, fmt::printf_args a_ArgList);
34 template <
typename... Args>
37 return vPrintf(a_Format, fmt::make_printf_args(a_Args...));
43 template <
typename... Args>
46 return vAppendPrintf(a_Dst, a_Format, fmt::make_printf_args(a_Args...));
132 extern short GetBEShort(
const std::byte * a_Mem);
135 extern unsigned short GetBEUShort(
const char * a_Mem);
138 extern int GetBEInt(
const std::byte * a_Mem);
173 bool positive =
true;
179 else if (a_str[0] ==
'-')
186 for (
size_t size = a_str.size(); i < size; i++)
188 if ((a_str[i] <
'0') || (a_str[i] >
'9'))
192 if (std::numeric_limits<T>::max() / 10 < result)
197 T digit =
static_cast<T
>(a_str[i] -
'0');
198 if (std::numeric_limits<T>::max() - digit < result)
208 if (!std::numeric_limits<T>::is_signed)
213 for (
size_t size = a_str.size(); i < size; i++)
215 if ((a_str[i] <
'0') || (a_str[i] >
'9'))
219 if (std::numeric_limits<T>::min() / 10 > result)
224 T digit =
static_cast<T
>(a_str[i] -
'0');
225 if (std::numeric_limits<T>::min() + digit > result)
242 template <
typename T>
246 auto itr = a_Map.find(a_Key);
247 if (itr == a_Map.end())
254 if (!StringToInteger<T>(itr->second, res))
AString & AppendPrintf(AString &a_Dst, const char *a_Format, const Args &... a_Args)
bool SplitZeroTerminatedStrings(const AString &a_Strings, AStringVector &a_Output)
Splits a string that has embedded \0 characters, on those characters.
std::map< AString, AString > AStringMap
A string dictionary, used for key-value pairs.
bool IsOnlyWhitespace(const AString &a_String)
Returns true if only whitespace characters are present in the string.
AString & vAppendPrintf(AString &a_Dst, const char *a_Format, fmt::printf_args a_ArgList)
Add the formated string to the existing data in the string.
AStringVector MergeStringVectors(const AStringVector &a_Strings1, const AStringVector &a_Strings2)
Merges the two vectors of strings, removing duplicate entries from the second vector.
short GetBEShort(const std::byte *a_Mem)
Reads two bytes from the specified memory location and interprets them as BigEndian short.
size_t RateCompareString(const AString &s1, const AString &s2)
Case-insensitive string comparison that returns a rating of equal-ness between [0 - s1....
int GetBEInt(const std::byte *a_Mem)
Reads four bytes from the specified memory location and interprets them as BigEndian int.
AString URLEncode(const AString &a_Text)
URL-encodes the given string.
AString & InPlaceLowercase(AString &s)
In-place string conversion to lowercase.
AString & InPlaceUppercase(AString &s)
In-place string conversion to uppercase.
void ReplaceString(AString &iHayStack, const AString &iNeedle, const AString &iReplaceWith)
Replaces each occurence of iNeedle in iHayStack with iReplaceWith.
bool StringToFloat(const AString &a_String, float &a_Num)
Converts a string into a float.
std::u16string UTF8ToRawBEUTF16(const AString &a_String)
Converts a UTF-8 string into a UTF-16 BE string.
std::list< AString > AStringList
AString & CreateHexDump(AString &a_Out, const void *a_Data, size_t a_Size, size_t a_BytesPerLine)
Creates a nicely formatted HEX dump of the given memory block.
AStringVector StringSplitWithQuotes(const AString &str, const AString &delim)
Split the string at any of the listed delimiters.
AString StrToLower(const AString &s)
Returns a lower-cased copy of the string.
void SetBEInt(std::byte *a_Mem, Int32 a_Value)
Writes four bytes to the specified memory location so that they interpret as BigEndian int.
AStringVector StringSplit(const AString &str, const AString &delim)
Split the string at any of the listed delimiters.
int NoCaseCompare(const AString &s1, const AString &s2)
Case-insensitive string comparison.
bool StringToInteger(const AString &a_str, T &a_Num)
Parses any integer type.
std::pair< bool, AString > URLDecode(const AString &a_String)
URL-Decodes the given string.
AString ReplaceAllCharOccurrences(const AString &a_String, char a_From, char a_To)
Replaces all occurrences of char a_From inside a_String with char a_To.
void ReplaceURL(AString &iHayStack, const AString &iNeedle, const AString &iReplaceWith)
Replaces each occurence of iNeedle in iHayStack with iReplaceWith, after URL-encoding iReplaceWith.
AString StringJoin(const AStringVector &a_Strings, const AString &a_Delimiter)
Join a list of strings with the given delimiter between entries.
AString TrimString(const AString &str)
Trims whitespace at both ends of the string.
AString & vPrintf(AString &a_Dst, const char *a_Format, fmt::printf_args a_ArgList)
Output the formatted text into the string.
unsigned short GetBEUShort(const char *a_Mem)
Reads two bytes from the specified memory location and interprets them as BigEndian unsigned short.
AString & RawBEToUTF8(const char *a_RawData, size_t a_NumShorts, AString &a_UTF8)
Converts a stream of BE shorts into UTF-8 string; returns a_UTF8.
AString Base64Encode(const AString &a_Input)
Encodes a string into Base64.
AString & Printf(AString &a_Dst, const char *a_Format, const Args &... a_Args)
AStringVector StringSplitAndTrim(const AString &str, const AString &delim)
Split the string at any of the listed delimiters and trim each value.
AString UnicodeCharToUtf8(unsigned a_UnicodeChar)
Converts a unicode character to its UTF8 representation.
AString StripColorCodes(const AString &a_Message)
Removes all control codes used by MC for colors and styles.
AString StringsConcat(const AStringVector &a_Strings, char a_Separator)
Concatenates the specified strings into a single string, separated by the specified separator charact...
AString Base64Decode(const AString &a_Base64String)
Decodes a Base64-encoded string into the raw data.
AString EscapeString(const AString &a_Message)
Returns a copy of a_Message with all quotes and backslashes escaped by a backslash.
AString StrToUpper(const AString &s)
Returns an upper-cased copy of the string.
T GetStringMapInteger(const AStringMap &a_Map, const AString &a_Key, T a_Default)
Returns a number (of any integer type T) from a key-value string map.
std::vector< AString > AStringVector