Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
string.h File Reference
#include "irrlichttypes_bloated.h"
#include "config.h"
#include <cstdlib>
#include <string>
#include <string_view>
#include <cstring>
#include <vector>
#include <limits>
#include <sstream>
#include <iomanip>
#include <cctype>
#include <cwctype>
#include <unordered_map>
+ Include dependency graph for string.h:

Go to the source code of this file.

Classes

struct  FlagDesc
 

Macros

#define STRINGIFY(x)   #x
 
#define TOSTRING(x)   STRINGIFY(x)
 
#define IS_ASCII_PRINTABLE_CHAR(x)
 
#define IS_PRIVATE_USE_CHAR16(x)
 
#define IS_PRIVATE_USE_CHAR32(x)
 
#define IS_PRIVATE_USE_CHAR(x)   IS_PRIVATE_USE_CHAR16(x)
 
#define IS_UTF8_MULTB_INNER(x)
 
#define IS_UTF8_MULTB_START(x)
 
#define UTF8_MULTB_START_LEN(x)
 
#define MAKE_VARIANT(_name, _t0, _t1)
 
#define stoi   mystoi
 
#define stof   mystof
 

Typedefs

typedef std::unordered_map< std::string, std::string > StringMap
 

Functions

std::wstring utf8_to_wide (std::string_view input)
 
std::string wide_to_utf8 (std::wstring_view input)
 
void wide_add_codepoint (std::wstring &result, char32_t codepoint)
 
std::string urlencode (std::string_view str)
 
std::string urldecode (std::string_view str)
 
u32 readFlagString (std::string str, const FlagDesc *flagdesc, u32 *flagmask)
 
std::string writeFlagString (u32 flags, const FlagDesc *flagdesc, u32 flagmask)
 
size_t mystrlcpy (char *dst, const char *src, size_t size) noexcept
 
char * mystrtok_r (char *s, const char *sep, char **lasts) noexcept
 
u64 read_seed (const char *str)
 
bool parseColorString (const std::string &value, video::SColor &color, bool quiet, unsigned char default_alpha=0xff)
 
std::string encodeHexColorString (video::SColor color)
 
char my_tolower (char c)
 Converts a letter to lowercase, with safe handling of the char type and non-ASCII.
 
std::string padStringRight (std::string str, size_t len)
 Returns a copy of str with spaces inserted at the right hand side to ensure that the string is len characters in length.
 
std::string_view removeStringEnd (std::string_view str, const char *ends[])
 Returns a version of str with the first occurrence of a string contained within ends[] removed from the end of the string.
 
template<typename T >
bool str_equal (std::basic_string_view< T > s1, std::basic_string_view< T > s2, bool case_insensitive=false)
 Check two strings for equivalence.
 
template<typename T >
bool str_starts_with (std::basic_string_view< T > str, std::basic_string_view< T > prefix, bool case_insensitive=false)
 Check whether str begins with the string prefix.
 
template<typename T >
bool str_ends_with (std::basic_string_view< T > str, std::basic_string_view< T > suffix, bool case_insensitive=false)
 Check whether str ends with the string suffix.
 
template<typename T >
std::vector< std::basic_string< T > > str_split (const std::basic_string< T > &str, T delimiter)
 Splits a string into its component parts separated by the character delimiter.
 
std::string lowercase (std::string_view str)
 
bool my_isspace (const char c)
 
bool my_isspace (const wchar_t c)
 
template<typename T >
std::basic_string_view< T > trim (const std::basic_string_view< T > &str)
 
template<typename T >
std::basic_string< T > trim (std::basic_string< T > &&str)
 
template<typename T >
std::basic_string_view< T > trim (const std::basic_string< T > &str)
 
template<typename T >
std::basic_string_view< T > trim (const T *str)
 
bool is_yes (std::string_view str)
 Returns whether str should be regarded as (bool) true.
 
s32 mystoi (const std::string &str, s32 min, s32 max)
 Converts the string str to a signed 32-bit integer.
 
s32 mystoi (const std::string &str)
 Returns a 32-bit value reprensented by the string str (decimal).
 
float mystof (const std::string &str)
 Returns a float reprensented by the string str (decimal).
 
template<typename T >
from_string (const std::string &str)
 Returns a value represented by the string val.
 
s64 stoi64 (const std::string &str)
 Returns a 64-bit signed value represented by the string str (decimal).
 
std::string itos (s32 i)
 Returns a string representing the decimal value of the 32-bit value i.
 
std::string i64tos (s64 i)
 Returns a string representing the decimal value of the 64-bit value i.
 
std::string ftos (float f)
 Returns a string representing the exact decimal value of the float value f.
 
void str_replace (std::string &str, std::string_view pattern, std::string_view replacement)
 Replace all occurrences of pattern in str with replacement.
 
void str_formspec_escape (std::string &str)
 Escapes characters that cannot be used in formspecs.
 
void str_replace (std::string &str, char from, char to)
 Replace all occurrences of the character from in str with to.
 
bool string_allowed (std::string_view str, std::string_view allowed_chars)
 Check that a string only contains whitelisted characters.
 
bool string_allowed_blacklist (std::string_view str, std::string_view blacklisted_chars)
 Check that a string contains no blacklisted characters.
 
std::string wrap_rows (std::string_view from, unsigned row_len, bool has_color_codes=false)
 Create a string based on from where a newline is forcefully inserted every row_len characters.
 
template<typename T >
std::basic_string< T > unescape_string (const std::basic_string< T > &s)
 Removes backslashes from an escaped string (FormSpec strings)
 
template<typename T >
std::basic_string< T > unescape_enriched (const std::basic_string< T > &s)
 Remove all escape sequences in s.
 
template<typename T >
std::vector< std::basic_string< T > > split (const std::basic_string< T > &s, T delim)
 
std::wstring translate_string (std::wstring_view s, Translations *translations)
 
std::wstring translate_string (std::wstring_view s)
 
std::wstring unescape_translate (std::wstring_view s)
 
bool is_number (std::string_view to_check)
 Checks that all characters in to_check are a decimal digits.
 
const char * bool_to_cstr (bool val)
 Returns a C-string, either "true" or "false", corresponding to val.
 
const std::string duration_to_string (int sec)
 Converts a duration in seconds to a pretty-printed duration in days, hours, minutes and seconds.
 
std::string str_join (const std::vector< std::string > &list, std::string_view delimiter)
 Joins a vector of strings by the string delimiter.
 
std::string sanitizeDirName (std::string_view str, std::string_view optional_prefix)
 Sanitize the name of a new directory.
 
std::string sanitize_untrusted (std::string_view str, bool keep_escapes=true)
 Sanitize an untrusted string (e.g.
 
void safe_print_string (std::ostream &os, std::string_view str)
 Prints a sanitized version of a string without control characters.
 
v3f str_to_v3f (std::string_view str)
 Parses a string of form (1, 2, 3) to a v3f.
 

Macro Definition Documentation

◆ IS_ASCII_PRINTABLE_CHAR

#define IS_ASCII_PRINTABLE_CHAR ( x)
Value:
(((unsigned int)(x) >= 0x20) && \
( (unsigned int)(x) <= 0x7e))

Referenced by safe_print_string(), and TestUtilities::testAsciiPrintableHelper().

◆ IS_PRIVATE_USE_CHAR

#define IS_PRIVATE_USE_CHAR ( x)    IS_PRIVATE_USE_CHAR16(x)

Referenced by GUIChatConsole::OnEvent().

◆ IS_PRIVATE_USE_CHAR16

#define IS_PRIVATE_USE_CHAR16 ( x)
Value:
((wchar_t)(x) >= 0xE000 && \
(wchar_t)(x) <= 0xF8FF)

◆ IS_PRIVATE_USE_CHAR32

#define IS_PRIVATE_USE_CHAR32 ( x)
Value:
(((wchar_t)(x) >= 0xF0000 && \
(wchar_t)(x) <= 0xFFFFD) || \
((wchar_t)(x) >= 0x100000 && \
(wchar_t)(x) <= 0x10FFFD))

◆ IS_UTF8_MULTB_INNER

#define IS_UTF8_MULTB_INNER ( x)
Value:
(((unsigned char)(x) >= 0x80) && \
( (unsigned char)(x) <= 0xbf))

Referenced by safe_print_string(), and wrap_rows().

◆ IS_UTF8_MULTB_START

#define IS_UTF8_MULTB_START ( x)
Value:
(((unsigned char)(x) >= 0xc2) && \
( (unsigned char)(x) <= 0xf4))

Referenced by safe_print_string().

◆ MAKE_VARIANT

#define MAKE_VARIANT ( _name,
_t0,
_t1 )
Value:
template <typename T, typename... Args> \
inline auto _name(_t0 arg1, _t1 arg2, Args&&... args) \
{ \
return (_name)(std::basic_string_view<T>(arg1), std::basic_string_view<T>(arg2), \
std::forward<Args>(args)...); \
}

◆ stof

◆ stoi

◆ STRINGIFY

#define STRINGIFY ( x)    #x

◆ TOSTRING

◆ UTF8_MULTB_START_LEN

#define UTF8_MULTB_START_LEN ( x)
Value:
(((unsigned char)(x) < 0xe0) ? 2 : \
(((unsigned char)(x) < 0xf0) ? 3 : 4))

Typedef Documentation

◆ StringMap

typedef std::unordered_map<std::string, std::string> StringMap

Function Documentation

◆ bool_to_cstr()

const char * bool_to_cstr ( bool val)
inline

Returns a C-string, either "true" or "false", corresponding to val.

Returns
If val is true, then "true" is returned, otherwise "false".

Referenced by set_default_settings(), Game::toggleAutoforward(), Game::toggleCinematic(), Game::toggleFast(), Game::toggleFreeMove(), Game::toggleNoClip(), and Game::togglePitchMove().

+ Here is the caller graph for this function:

◆ duration_to_string()

const std::string duration_to_string ( int sec)
inline

Converts a duration in seconds to a pretty-printed duration in days, hours, minutes and seconds.

Parameters
secduration in seconds
Returns
pretty-printed duration

Referenced by Server::ShutdownState::getShutdownTimerMessage(), Server::getStatusString(), and Server::requestShutdown().

+ Here is the caller graph for this function:

◆ encodeHexColorString()

std::string encodeHexColorString ( video::SColor color)

References hex_encode().

Referenced by WearBarParams::serializeJson().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ from_string()

template<typename T >
T from_string ( const std::string & str)
inline

Returns a value represented by the string val.

Referenced by Settings::getU64(), ModApiMapgen::l_get_mapgen_params(), LBMManager::loadIntroductionTimes(), and stoi64().

+ Here is the caller graph for this function:

◆ ftos()

std::string ftos ( float f)
inline

Returns a string representing the exact decimal value of the float value f.

Referenced by content_nodemeta_deserialize_legacy_body(), QuicktuneValue::getString(), WearBarParams::serializeJson(), and Settings::setFloat().

+ Here is the caller graph for this function:

◆ i64tos()

std::string i64tos ( s64 i)
inline

Returns a string representing the decimal value of the 64-bit value i.

Referenced by Database_LevelDB::deleteBlock(), Database_Redis::deleteBlock(), Database_LevelDB::loadBlock(), Database_Redis::loadBlock(), Database_LevelDB::saveBlock(), and Database_Redis::saveBlock().

+ Here is the caller graph for this function:

◆ is_number()

bool is_number ( std::string_view to_check)
inline

Checks that all characters in to_check are a decimal digits.

Parameters
to_check
Returns
true if to_check is not empty and all characters in to_check are decimal digits, otherwise false

Referenced by ImageSource::generateImagePart(), GUIFormSpecMenu::parseVersionDirect(), and TestUtilities::testIsNumber().

+ Here is the caller graph for this function:

◆ is_yes()

bool is_yes ( std::string_view str)
inline

Returns whether str should be regarded as (bool) true.

Case and leading and trailing whitespace are ignored. Values that will return true are "y", "yes", "true" and any number that is not 0.

Parameters
str

References lowercase(), and trim().

Referenced by ModConfiguration::addModsFromConfig(), Settings::getBool(), StyleSpec::getBool(), ModApiUtil::Initialize(), ModApiUtil::InitializeAsync(), ModApiUtil::InitializeClient(), ModApiUtil::l_is_yes(), GUIFormSpecMenu::parseBackground(), GUIFormSpecMenu::parseBackgroundColor(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseFieldCloseOnEnter(), GUIFormSpecMenu::parseFieldEnterAfterEdit(), ParsedText::parseGenericStyleAttr(), GUIFormSpecMenu::parseModel(), GUIFormSpecMenu::parseRealCoordinates(), GUIFormSpecMenu::parseSetFocus(), ParsedText::parseTag(), GUIFormSpecMenu::parseTextList(), GUIFormSpecMenu::regenerateGui(), ParsedText::Element::setStyle(), GUITable::setTable(), Game::shouldShowTouchControls(), and TestUtilities::testIsYes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ itos()

◆ lowercase()

std::string lowercase ( std::string_view str)
inline
Parameters
str
Returns
A copy of str converted to all lowercase characters.

References my_tolower().

Referenced by ScriptApiSecurity::checkPathWithGamedef(), gen_srp_v(), init_gettext(), is_yes(), main(), parseImageTransform(), parseNamedColorString(), JoystickController::setLayoutFromControllerName(), Client::startAuth(), and TestUtilities::testLowercase().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ my_isspace() [1/2]

bool my_isspace ( const char c)
inline

Referenced by trim().

+ Here is the caller graph for this function:

◆ my_isspace() [2/2]

bool my_isspace ( const wchar_t c)
inline

◆ my_tolower()

char my_tolower ( char c)
inline

Converts a letter to lowercase, with safe handling of the char type and non-ASCII.

Parameters
cinput letter
Returns
same letter but lowercase

Referenced by lowercase(), fs::PathStartsWith(), str_ends_with(), str_equal(), and str_starts_with().

+ Here is the caller graph for this function:

◆ mystof()

float mystof ( const std::string & str)
inline

Returns a float reprensented by the string str (decimal).

See also
atof(3)

◆ mystoi() [1/2]

s32 mystoi ( const std::string & str)
inline

Returns a 32-bit value reprensented by the string str (decimal).

See also
atoi(3) for further limitations

◆ mystoi() [2/2]

s32 mystoi ( const std::string & str,
s32 min,
s32 max )
inline

Converts the string str to a signed 32-bit integer.

The converted value is constrained so that min <= value <= max.

See also
atoi(3) for limitations
Parameters
str
minRange minimum
maxRange maximum
Returns
The value converted to a signed 32-bit integer and constrained within the range defined by min and max (inclusive)

Referenced by ImageSource::generateImagePart(), Game::nodePlacement(), GUIFormSpecMenu::parseVersionDirect(), and TestUtilities::testStrToIntConversion().

+ Here is the caller graph for this function:

◆ mystrlcpy()

size_t mystrlcpy ( char * dst,
const char * src,
size_t size )
noexcept

References MYMIN.

◆ mystrtok_r()

char * mystrtok_r ( char * s,
const char * sep,
char ** lasts )
noexcept

◆ padStringRight()

std::string padStringRight ( std::string str,
size_t len )
inline

Returns a copy of str with spaces inserted at the right hand side to ensure that the string is len characters in length.

If str is <= len then the returned string will be identical to str.

Referenced by print_allowed_options(), and TestUtilities::testPadString().

+ Here is the caller graph for this function:

◆ parseColorString()

bool parseColorString ( const std::string & value,
video::SColor & color,
bool quiet,
unsigned char default_alpha = 0xff )

References errorstream, parseHexColorString(), and parseNamedColorString().

Referenced by ChatBuffer::ChatBuffer(), EnrichedString::addAtEnd(), check_color(), WearBarParams::deserializeJson(), ImageSource::generateImagePart(), StyleSpec::getColor(), StyleSpec::getColor(), StyleSpec::getColorArray(), ParsedText::globalTag(), GUIFormSpecMenu::parseBackgroundColor(), GUIFormSpecMenu::parseBox(), GUIFormSpecMenu::parseListColors(), GUIFormSpecMenu::parseTooltip(), read_color(), ParsedText::Element::setStyle(), GUITable::setTable(), and GUITable::setTextList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_seed()

u64 read_seed ( const char * str)

References murmur_hash_64_ua().

Referenced by MapgenParams::readParams().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readFlagString()

u32 readFlagString ( std::string str,
const FlagDesc * flagdesc,
u32 * flagmask )

References FlagDesc::flag, and FlagDesc::name.

Referenced by Settings::getFlagStr(), read_flags(), and TestSettings::testFlagDesc().

+ Here is the caller graph for this function:

◆ removeStringEnd()

std::string_view removeStringEnd ( std::string_view str,
const char * ends[] )
inline

Returns a version of str with the first occurrence of a string contained within ends[] removed from the end of the string.

Parameters
str
endsA NULL- or ""- terminated array of strings to remove from s in the copy produced. Note that once one of these strings is removed that no further postfixes contained within this array are removed.
Returns
If no end could be removed then "" is returned.

References p().

Referenced by Server::addMediaFile(), porting::detectMSVCBuildDir(), getAvailableGameIds(), Translations::getFileLanguage(), getImagePath(), Client::loadMedia(), Translations::loadTranslation(), and TestUtilities::testRemoveStringEnd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ safe_print_string()

void safe_print_string ( std::ostream & os,
std::string_view str )

Prints a sanitized version of a string without control characters.

'\t' and '
' are allowed, as are UTF-8 control characters (e.g. RTL). ASCII control characters are replaced with their hex encoding in angle brackets (e.g. "a\x1eb" -> "a<1e>b").

References IS_ASCII_PRINTABLE_CHAR, IS_UTF8_MULTB_INNER, and IS_UTF8_MULTB_START.

Referenced by HTTPFetchOngoing::complete(), and IMetadata::resolveString().

+ Here is the caller graph for this function:

◆ sanitize_untrusted()

std::string sanitize_untrusted ( std::string_view str,
bool keep_escapes = true )
nodiscard

Sanitize an untrusted string (e.g.

from the network). This will get strip control characters and (optionally) any MT-style escape sequences too. Note that they won't be removed cleanly but rather just broken, unlike with unescape_enriched. Line breaks and UTF-8 is permitted.

References remove_indexed().

Referenced by pkt_read_formspec_fields(), and TestUtilities::testSanitizeUntrusted().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sanitizeDirName()

std::string sanitizeDirName ( std::string_view str,
std::string_view optional_prefix )

Sanitize the name of a new directory.

This consists of two stages:

  1. Check for 'reserved filenames' that can't be used on some filesystems and add a prefix to them
  2. Remove 'unsafe' characters from the name by replacing them with '_'

References disallowed_dir_names, disallowed_path_chars, str_equal(), utf8_to_wide(), and wide_to_utf8().

Referenced by ModApiMainMenu::l_create_world(), and TestUtilities::testSanitizeDirName().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ split()

template<typename T >
std::vector< std::basic_string< T > > split ( const std::basic_string< T > & s,
T delim )

Referenced by EnrichedString::addAtEnd(), StyleSpec::getFont(), GUIFormSpecMenu::parseAnchor(), GUIFormSpecMenu::parseAnchorDirect(), GUIFormSpecMenu::parseAnimatedImage(), StyleSpec::parseArray(), GUIFormSpecMenu::parseBackground(), GUIFormSpecMenu::parseBox(), GUIFormSpecMenu::parseButton(), GUIFormSpecMenu::parseCheckbox(), GUIFormSpecMenu::parseContainer(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseHyperText(), GUIFormSpecMenu::parseImage(), GUIFormSpecMenu::parseImageButton(), GUIFormSpecMenu::parseItemImage(), GUIFormSpecMenu::parseItemImageButton(), GUIFormSpecMenu::parseLabel(), GUIFormSpecMenu::parseList(), GUIFormSpecMenu::parseListRing(), GUIFormSpecMenu::parseMiddleRect(), GUIFormSpecMenu::parseModel(), GUIFormSpecMenu::parsePadding(), GUIFormSpecMenu::parsePaddingDirect(), GUIFormSpecMenu::parsePosition(), GUIFormSpecMenu::parsePositionDirect(), GUIFormSpecMenu::parsePwdField(), StyleSpec::parseRect(), GUIFormSpecMenu::parseScrollBar(), GUIFormSpecMenu::parseScrollBarOptions(), GUIFormSpecMenu::parseScrollContainer(), GUIFormSpecMenu::parseSize(), GUIFormSpecMenu::parseSizeDirect(), GUIFormSpecMenu::parseStyle(), GUIFormSpecMenu::parseTabHeader(), GUIFormSpecMenu::parseTable(), GUIFormSpecMenu::parseTableColumns(), GUIFormSpecMenu::parseTableOptions(), ParsedText::parseTag(), GUIFormSpecMenu::parseTextArea(), GUIFormSpecMenu::parseTextList(), GUIFormSpecMenu::parseTooltip(), StyleSpec::parseVector2f(), GUIFormSpecMenu::parseVersionDirect(), GUIFormSpecMenu::parseVertLabel(), GUIFormSpecMenu::precheckElement(), GUIFormSpecMenu::regenerateGui(), translate_all(), and translate_string().

+ Here is the caller graph for this function:

◆ stoi64()

s64 stoi64 ( const std::string & str)
inline

Returns a 64-bit signed value represented by the string str (decimal).

References from_string().

Referenced by Database_LevelDB::listAllLoadableBlocks(), and Database_Redis::listAllLoadableBlocks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ str_ends_with()

template<typename T >
bool str_ends_with ( std::basic_string_view< T > str,
std::basic_string_view< T > suffix,
bool case_insensitive = false )
inline

Check whether str ends with the string suffix.

If case_insensitive is true then the check is case insensitve (default is false; i.e. case is significant).

Parameters
str
suffix
case_insensitive
Returns
true if the str begins with suffix

References my_tolower().

Referenced by ImageSource::generateImagePart(), GettextPluralForm::parseHeaderLine(), Server::sendMediaAnnouncement(), and TestUtilities::testSanitizeUntrusted().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ str_equal()

template<typename T >
bool str_equal ( std::basic_string_view< T > s1,
std::basic_string_view< T > s2,
bool case_insensitive = false )
inline

Check two strings for equivalence.

If case_insensitive is true then the case of the strings is ignored (default is false).

Parameters
s1
s2
case_insensitive
Returns
true if the strings match

References my_tolower().

Referenced by ChatPrompt::nickCompletion(), sanitizeDirName(), and TestUtilities::testStrEqual().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ str_formspec_escape()

void str_formspec_escape ( std::string & str)
inline

Escapes characters that cannot be used in formspecs.

References str_replace().

Referenced by Game::showPauseMenu().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ str_join()

std::string str_join ( const std::vector< std::string > & list,
std::string_view delimiter )
inline

Joins a vector of strings by the string delimiter.

Returns
A std::string

Referenced by TestAuthDatabase::testListNames(), TestAuthDatabase::testRecall(), TestAuthDatabase::testRecallChanged(), TestAuthDatabase::testRecallChangedPrivileges(), TestUtilities::testStringJoin(), and AuthDatabaseFiles::writeAuthFile().

+ Here is the caller graph for this function:

◆ str_replace() [1/2]

void str_replace ( std::string & str,
char from,
char to )

Replace all occurrences of the character from in str with to.

Parameters
strThe string to (potentially) modify.
fromThe character in str to replace.
toThe replacement character.

Referenced by ImageSource::generateImagePart(), Client::initLocalMapSaving(), and TestUtilities::testStringReplace().

+ Here is the caller graph for this function:

◆ str_replace() [2/2]

void str_replace ( std::string & str,
std::string_view pattern,
std::string_view replacement )
inline

Replace all occurrences of pattern in str with replacement.

Parameters
strString to replace pattern with replacement within.
patternThe pattern to replace.
replacementWhat to replace the pattern with.

Referenced by str_formspec_escape().

+ Here is the caller graph for this function:

◆ str_split()

template<typename T >
std::vector< std::basic_string< T > > str_split ( const std::basic_string< T > & str,
T delimiter )
inline

Splits a string into its component parts separated by the character delimiter.

Returns
An std::vector<std::basic_string<T> > of the component parts

Referenced by sound::ALExtensions::ALExtensions(), TextureOverrideSource::TextureOverrideSource(), checkModNameWhitelisted(), decode_srp_verifier_and_salt(), Server::handleCommand_Init(), LBMManager::loadIntroductionTimes(), Translations::loadMoEntry(), Translations::loadMoTranslation(), Translations::loadPoTranslation(), Translations::loadTranslation(), Translations::loadTrTranslation(), parseModContents(), and AuthDatabaseFiles::readAuthFile().

+ Here is the caller graph for this function:

◆ str_starts_with()

template<typename T >
bool str_starts_with ( std::basic_string_view< T > str,
std::basic_string_view< T > prefix,
bool case_insensitive = false )
inline

Check whether str begins with the string prefix.

If case_insensitive is true then the check is case insensitve (default is false; i.e. case is significant).

Parameters
str
prefix
case_insensitive
Returns
true if the str begins with prefix

References my_tolower().

Referenced by checkModNameWhitelisted(), ImageSource::generateImagePart(), NodeDefManager::getIds(), NodeResolver::getIdsFromNrBacklog(), isGroupRecipeStr(), Translations::loadMoTranslation(), Translations::loadPoTranslation(), Translations::loadTrTranslation(), main(), ChatPrompt::nickCompletion(), porting::open_url(), GettextPluralForm::parseHeaderLine(), read_pointabilities(), reduce_ltr(), IMetadata::resolveString(), TileDef::serialize(), RemoteClient::setEncryptedPassword(), TestUtilities::testSanitizeUntrusted(), and TestUtilities::testStartsWith().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ str_to_v3f()

v3f str_to_v3f ( std::string_view str)

Parses a string of form (1, 2, 3) to a v3f.

Parameters
strstring
Returns
float vector

References BasicStrfnd< T >::next(), and stof.

Referenced by Settings::getV3F(), and ItemStack::getWieldScale().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ string_allowed()

bool string_allowed ( std::string_view str,
std::string_view allowed_chars )
inline

Check that a string only contains whitelisted characters.

This is the opposite of string_allowed_blacklist().

Parameters
strThe string to be checked.
allowed_charsA string containing permitted characters.
Returns
true if the string is allowed, otherwise false.
See also
string_allowed_blacklist()

Referenced by ClientMediaDownloader::addFile(), LBMManager::addLBMDef(), Server::addMediaFile(), ModSpec::checkAndLog(), Server::handleCommand_Init(), Client::handleCommand_MediaPush(), is_valid_player_name(), parseDependsString(), GUITable::setTable(), and TestUtilities::testStringAllowed().

+ Here is the caller graph for this function:

◆ string_allowed_blacklist()

bool string_allowed_blacklist ( std::string_view str,
std::string_view blacklisted_chars )
inline

Check that a string contains no blacklisted characters.

This is the opposite of string_allowed().

Parameters
strThe string to be checked.
blacklisted_charsA string containing prohibited characters.
Returns
true if the string is allowed, otherwise false.
See also
string_allowed()

Referenced by TestUtilities::testStringAllowed().

+ Here is the caller graph for this function:

◆ translate_string() [1/2]

std::wstring translate_string ( std::wstring_view s)

References g_client_translations, and translate_string().

+ Here is the call graph for this function:

◆ translate_string() [2/2]

std::wstring translate_string ( std::wstring_view s,
Translations * translations )

References translate_all().

Referenced by unescape_translate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ trim() [1/4]

template<typename T >
std::basic_string_view< T > trim ( const std::basic_string< T > & str)
inline

References trim().

+ Here is the call graph for this function:

◆ trim() [2/4]

template<typename T >
std::basic_string_view< T > trim ( const std::basic_string_view< T > & str)
inline

◆ trim() [3/4]

template<typename T >
std::basic_string_view< T > trim ( const T * str)
inline

References trim().

+ Here is the call graph for this function:

◆ trim() [4/4]

template<typename T >
std::basic_string< T > trim ( std::basic_string< T > && str)
inline
Parameters
str
Returns
A copy of str with leading and trailing whitespace removed.

References trim().

+ Here is the call graph for this function:

◆ unescape_enriched()

template<typename T >
std::basic_string< T > unescape_enriched ( const std::basic_string< T > & s)

Remove all escape sequences in s.

Parameters
sThe string in which to remove escape sequences.
Returns
s, with escape sequences removed.

Referenced by drawItemStack(), Server::handleChat(), TestUtilities::testRemoveEscapes(), and unescape_translate().

+ Here is the caller graph for this function:

◆ unescape_string()

template<typename T >
std::basic_string< T > unescape_string ( const std::basic_string< T > & s)
inline

Removes backslashes from an escaped string (FormSpec strings)

◆ unescape_translate()

std::wstring unescape_translate ( std::wstring_view s)
inline

References translate_string(), and unescape_enriched().

Referenced by Hud::drawLuaElements(), Camera::drawNametags(), Game::handlePointingAtNode(), Game::handlePointingAtObject(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseTabHeader(), GUIFormSpecMenu::parseTable(), GUIFormSpecMenu::parseTextList(), and GUIFormSpecMenu::parseVertLabel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ urldecode()

std::string urldecode ( std::string_view str)

References hex_digit_decode().

Referenced by TestUtilities::testUrlDecode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ urlencode()

std::string urlencode ( std::string_view str)

Referenced by HTTPFetchOngoing::HTTPFetchOngoing(), ModApiUtil::Initialize(), ModApiUtil::InitializeAsync(), ModApiUtil::InitializeClient(), ModApiUtil::l_urlencode(), and TestUtilities::testUrlEncode().

+ Here is the caller graph for this function:

◆ utf8_to_wide()

std::wstring utf8_to_wide ( std::string_view input)

References convert(), DEFAULT_ENCODING, hex_encode(), and infostream.

Referenced by GUITable::allocString(), Game::createClient(), ProfilerGraph::draw(), drawItemStack(), Hud::drawLuaElements(), GUIFormSpecMenu::drawMenu(), Camera::drawNametags(), Game::getServerContent(), FontEngine::getTextWidth(), FontEngine::getTextWidth(), Server::handleChat(), Game::handlePointingAtNode(), Game::handlePointingAtObject(), GameUI::init(), ModApiServer::l_chat_send_all(), ModApiServer::l_chat_send_player(), ModApiClient::l_display_chat_message(), ModApiMainMenu::l_get_content_translation(), ModApiEnv::l_get_translated_string(), ModApiClient::l_send_chat_message(), Translations::loadMoEntry(), Translations::loadMoTranslation(), Translations::loadPoTranslation(), Translations::loadTrTranslation(), Client::makeScreenshot(), ChatPrompt::nickCompletion(), GUIChatConsole::OnEvent(), GUIFormSpecMenu::parseButton(), GUIFormSpecMenu::parseCheckbox(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseHyperText(), GUIFormSpecMenu::parseImageButton(), GUIFormSpecMenu::parseItemImageButton(), GUIFormSpecMenu::parseLabel(), Translations::parsePoLine(), GUIFormSpecMenu::parsePwdField(), GUIFormSpecMenu::parseSimpleField(), GUIFormSpecMenu::parseTabHeader(), GUIFormSpecMenu::parseTable(), GUIFormSpecMenu::parseTextArea(), GUIFormSpecMenu::parseTextList(), GUIFormSpecMenu::parseTooltip(), GUIFormSpecMenu::parseVertLabel(), Server::printToConsoleOnly(), Game::processKeyInput(), GUIOpenURLMenu::regenerateGui(), Server::requestShutdown(), ClientLauncher::run(), sanitizeDirName(), GUIEngine::setTopleftText(), TestUtilities::testStrEqual(), TestUtilities::testUTF8(), TestUtilities::testWrapRows(), Game::toggleMinimap(), GameUI::update(), Game::updateChat(), GameUI::updateProfiler(), GUIChatConsole::weblinkClick(), and wstrgettext().

+ Here is the call graph for this function:

◆ wide_add_codepoint()

void wide_add_codepoint ( std::wstring & result,
char32_t codepoint )

Referenced by Translations::unescapeC().

+ Here is the caller graph for this function:

◆ wide_to_utf8()

◆ wrap_rows()

std::string wrap_rows ( std::string_view from,
unsigned row_len,
bool has_color_codes = false )

Create a string based on from where a newline is forcefully inserted every row_len characters.

Note
This function does not honour word wraps and blindly inserts a newline every row_len characters whether it breaks a word or not. It is intended to be used for, for example, showing paths in the GUI.
This function doesn't wrap inside utf-8 multibyte sequences and also counts multibyte sequences correcly as single characters.
Parameters
fromThe (utf-8) string to be wrapped into rows.
row_lenThe row length (in characters).
has_color_codesWhether the source string has colorize codes.
Returns
A new string with the wrapping applied.

References IS_UTF8_MULTB_INNER.

Referenced by GUIOpenURLMenu::regenerateGui(), and TestUtilities::testWrapRows().

+ Here is the caller graph for this function:

◆ writeFlagString()

std::string writeFlagString ( u32 flags,
const FlagDesc * flagdesc,
u32 flagmask )

References FlagDesc::name.

Referenced by push_flags_string(), Settings::setDefault(), and Settings::setFlagStr().

+ Here is the caller graph for this function: