Cuberite
A lightweight, fast and extensible game server for Minecraft
|
Go to the source code of this file.
Typedefs | |
typedef std::string | AString |
typedef std::list< AString > | AStringList |
typedef std::map< AString, AString > | AStringMap |
A string dictionary, used for key-value pairs. More... | |
typedef std::vector< AString > | AStringVector |
Functions | |
template<typename... Args> | |
AString & | AppendPrintf (AString &a_Dst, const char *a_Format, const Args &... a_Args) |
AString | Base64Decode (const AString &a_Base64String) |
Decodes a Base64-encoded string into the raw data. More... | |
AString | Base64Encode (const AString &a_Input) |
Encodes a string into Base64. More... | |
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. More... | |
AString | EscapeString (const AString &a_Message) |
Returns a copy of a_Message with all quotes and backslashes escaped by a backslash. More... | |
int | GetBEInt (const std::byte *a_Mem) |
Reads four bytes from the specified memory location and interprets them as BigEndian int. More... | |
short | GetBEShort (const std::byte *a_Mem) |
Reads two bytes from the specified memory location and interprets them as BigEndian short. More... | |
unsigned short | GetBEUShort (const char *a_Mem) |
Reads two bytes from the specified memory location and interprets them as BigEndian unsigned short. More... | |
template<typename T > | |
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. More... | |
AString & | InPlaceLowercase (AString &s) |
In-place string conversion to lowercase. More... | |
AString & | InPlaceUppercase (AString &s) |
In-place string conversion to uppercase. More... | |
bool | IsOnlyWhitespace (const AString &a_String) |
Returns true if only whitespace characters are present in the string. More... | |
AStringVector | MergeStringVectors (const AStringVector &a_Strings1, const AStringVector &a_Strings2) |
Merges the two vectors of strings, removing duplicate entries from the second vector. More... | |
int | NoCaseCompare (const AString &s1, const AString &s2) |
Case-insensitive string comparison. More... | |
template<typename... Args> | |
AString & | Printf (AString &a_Dst, const char *a_Format, const Args &... a_Args) |
template<typename... Args> | |
AString | Printf (const char *a_Format, const Args &... a_Args) |
size_t | RateCompareString (const AString &s1, const AString &s2) |
Case-insensitive string comparison that returns a rating of equal-ness between [0 - s1.length()]. More... | |
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. More... | |
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. More... | |
void | ReplaceString (AString &iHayStack, const AString &iNeedle, const AString &iReplaceWith) |
Replaces each occurence of iNeedle in iHayStack with iReplaceWith. More... | |
void | ReplaceURL (AString &iHayStack, const AString &iNeedle, const AString &iReplaceWith) |
Replaces each occurence of iNeedle in iHayStack with iReplaceWith, after URL-encoding iReplaceWith. More... | |
void | SetBEInt (std::byte *a_Mem, Int32 a_Value) |
Writes four bytes to the specified memory location so that they interpret as BigEndian int. More... | |
bool | SplitZeroTerminatedStrings (const AString &a_Strings, AStringVector &a_Output) |
Splits a string that has embedded \0 characters, on those characters. More... | |
AString | StringJoin (const AStringVector &a_Strings, const AString &a_Delimiter) |
Join a list of strings with the given delimiter between entries. More... | |
AString | StringsConcat (const AStringVector &a_Strings, char a_Separator) |
Concatenates the specified strings into a single string, separated by the specified separator character. More... | |
AStringVector | StringSplit (const AString &str, const AString &delim) |
Split the string at any of the listed delimiters. More... | |
AStringVector | StringSplitAndTrim (const AString &str, const AString &delim) |
Split the string at any of the listed delimiters and trim each value. More... | |
AStringVector | StringSplitWithQuotes (const AString &str, const AString &delim) |
Split the string at any of the listed delimiters. More... | |
bool | StringToFloat (const AString &a_String, float &a_Num) |
Converts a string into a float. More... | |
template<class T > | |
bool | StringToInteger (const AString &a_str, T &a_Num) |
Parses any integer type. More... | |
AString | StripColorCodes (const AString &a_Message) |
Removes all control codes used by MC for colors and styles. More... | |
AString | StrToLower (const AString &s) |
Returns a lower-cased copy of the string. More... | |
AString | StrToUpper (const AString &s) |
Returns an upper-cased copy of the string. More... | |
AString | TrimString (const AString &str) |
Trims whitespace at both ends of the string. More... | |
AString | UnicodeCharToUtf8 (unsigned a_UnicodeChar) |
Converts a unicode character to its UTF8 representation. More... | |
std::pair< bool, AString > | URLDecode (const AString &a_String) |
URL-Decodes the given string. More... | |
AString | URLEncode (const AString &a_Text) |
URL-encodes the given string. More... | |
std::u16string | UTF8ToRawBEUTF16 (const AString &a_String) |
Converts a UTF-8 string into a UTF-16 BE string. More... | |
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. More... | |
AString & | vPrintf (AString &a_Dst, const char *a_Format, fmt::printf_args a_ArgList) |
Output the formatted text into the string. More... | |
AString | vPrintf (const char *a_Format, fmt::printf_args a_ArgList) |
Output the formatted text into string Returns the formatted string by value. More... | |
typedef std::string AString |
Definition at line 11 of file StringUtils.h.
typedef std::list<AString> AStringList |
Definition at line 13 of file StringUtils.h.
typedef std::map<AString, AString> AStringMap |
A string dictionary, used for key-value pairs.
Definition at line 16 of file StringUtils.h.
typedef std::vector<AString> AStringVector |
Definition at line 12 of file StringUtils.h.
AString& AppendPrintf | ( | AString & | a_Dst, |
const char * | a_Format, | ||
const Args &... | a_Args | ||
) |
Definition at line 44 of file StringUtils.h.
Decodes a Base64-encoded string into the raw data.
Definition at line 900 of file StringUtils.cpp.
Encodes a string into Base64.
Definition at line 936 of file StringUtils.cpp.
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.
Creates a nicely formatted HEX dump of the given memory block.
Definition at line 652 of file StringUtils.cpp.
Returns a copy of a_Message with all quotes and backslashes escaped by a backslash.
Definition at line 699 of file StringUtils.cpp.
int GetBEInt | ( | const std::byte * | a_Mem | ) |
Reads four bytes from the specified memory location and interprets them as BigEndian int.
Definition at line 1007 of file StringUtils.cpp.
short GetBEShort | ( | const std::byte * | a_Mem | ) |
Reads two bytes from the specified memory location and interprets them as BigEndian short.
Definition at line 985 of file StringUtils.cpp.
unsigned short GetBEUShort | ( | const char * | a_Mem | ) |
Reads two bytes from the specified memory location and interprets them as BigEndian unsigned short.
Definition at line 997 of file StringUtils.cpp.
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.
Returns a_Default if the key is not present or the value is not a number representable in type T.
Definition at line 243 of file StringUtils.h.
In-place string conversion to lowercase.
Returns the same string object.
Definition at line 260 of file StringUtils.cpp.
In-place string conversion to uppercase.
Returns the same string object.
Definition at line 270 of file StringUtils.cpp.
bool IsOnlyWhitespace | ( | const AString & | a_String | ) |
Returns true if only whitespace characters are present in the string.
Definition at line 1116 of file StringUtils.cpp.
AStringVector MergeStringVectors | ( | const AStringVector & | a_Strings1, |
const AStringVector & | a_Strings2 | ||
) |
Merges the two vectors of strings, removing duplicate entries from the second vector.
The resulting vector contains items from a_Strings1 first, then from a_Strings2. The order of items doesn't change, only the duplicates are removed. If a_Strings1 contains duplicates, the result will still contain those duplicates.
Definition at line 1061 of file StringUtils.cpp.
Case-insensitive string comparison.
Returns 0 if the strings are the same, <0 if s1 < s2 and >0 if s1 > s2.
Definition at line 304 of file StringUtils.cpp.
AString& Printf | ( | AString & | a_Dst, |
const char * | a_Format, | ||
const Args &... | a_Args | ||
) |
Definition at line 26 of file StringUtils.h.
AString Printf | ( | const char * | a_Format, |
const Args &... | a_Args | ||
) |
Definition at line 35 of file StringUtils.h.
Case-insensitive string comparison that returns a rating of equal-ness between [0 - s1.length()].
Definition at line 317 of file StringUtils.cpp.
Converts a stream of BE shorts into UTF-8 string; returns a_UTF8.
Definition at line 378 of file StringUtils.cpp.
Replaces all occurrences of char a_From inside a_String with char a_To.
Definition at line 855 of file StringUtils.cpp.
Replaces each occurence of iNeedle in iHayStack with iReplaceWith.
Definition at line 348 of file StringUtils.cpp.
Replaces each occurence of iNeedle in iHayStack with iReplaceWith, after URL-encoding iReplaceWith.
Definition at line 368 of file StringUtils.cpp.
void SetBEInt | ( | std::byte * | a_Mem, |
Int32 | a_Value | ||
) |
Writes four bytes to the specified memory location so that they interpret as BigEndian int.
Definition at line 1021 of file StringUtils.cpp.
bool SplitZeroTerminatedStrings | ( | const AString & | a_Strings, |
AStringVector & | a_Output | ||
) |
Splits a string that has embedded \0 characters, on those characters.
a_Output is first cleared and then each separate string is pushed back into a_Output. Returns true if there are at least two strings in a_Output (there was at least one \0 separator).
Definition at line 1033 of file StringUtils.cpp.
AString StringJoin | ( | const AStringVector & | a_Strings, |
const AString & | a_Delimiter | ||
) |
Join a list of strings with the given delimiter between entries.
Definition at line 169 of file StringUtils.cpp.
AString StringsConcat | ( | const AStringVector & | a_Strings, |
char | a_Separator | ||
) |
Concatenates the specified strings into a single string, separated by the specified separator character.
Use StringJoin() if you need multiple separator characters.
Definition at line 1082 of file StringUtils.cpp.
AStringVector StringSplit | ( | const AString & | str, |
const AString & | delim | ||
) |
Split the string at any of the listed delimiters.
Return the splitted strings as a stringvector.
Definition at line 91 of file StringUtils.cpp.
AStringVector StringSplitAndTrim | ( | const AString & | str, |
const AString & | delim | ||
) |
Split the string at any of the listed delimiters and trim each value.
Returns the splitted strings as a stringvector.
Definition at line 205 of file StringUtils.cpp.
AStringVector StringSplitWithQuotes | ( | const AString & | str, |
const AString & | delim | ||
) |
Split the string at any of the listed delimiters.
Keeps quoted content together Resolves issue #490 Return the splitted strings as a stringvector.
Definition at line 112 of file StringUtils.cpp.
bool StringToFloat | ( | const AString & | a_String, |
float & | a_Num | ||
) |
Converts a string into a float.
Returns false if the conversion fails.
Definition at line 1105 of file StringUtils.cpp.
bool StringToInteger | ( | const AString & | a_str, |
T & | a_Num | ||
) |
Parses any integer type.
Checks bounds and returns errors out of band.
Definition at line 170 of file StringUtils.h.
Removes all control codes used by MC for colors and styles.
Definition at line 736 of file StringUtils.cpp.
Returns a lower-cased copy of the string.
Definition at line 280 of file StringUtils.cpp.
Returns an upper-cased copy of the string.
Definition at line 292 of file StringUtils.cpp.
Trims whitespace at both ends of the string.
Returns a trimmed copy of the original string.
Definition at line 226 of file StringUtils.cpp.
AString UnicodeCharToUtf8 | ( | unsigned | a_UnicodeChar | ) |
Converts a unicode character to its UTF8 representation.
Definition at line 393 of file StringUtils.cpp.
URL-Decodes the given string.
The first value specifies whether the decoding was successful. The second value is the decoded string, if successful.
Definition at line 755 of file StringUtils.cpp.
URL-encodes the given string.
Definition at line 825 of file StringUtils.cpp.
std::u16string UTF8ToRawBEUTF16 | ( | const AString & | a_String | ) |
Converts a UTF-8 string into a UTF-16 BE string.
Definition at line 547 of file StringUtils.cpp.
Add the formated string to the existing data in the string.
Returns a_Dst.
Definition at line 78 of file StringUtils.cpp.
Output the formatted text into the string.
Returns a_Dst.
Definition at line 55 of file StringUtils.cpp.
AString vPrintf | ( | const char * | a_Format, |
fmt::printf_args | a_ArgList | ||
) |
Output the formatted text into string Returns the formatted string by value.
Definition at line 68 of file StringUtils.cpp.