#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 <optional>Go to the source code of this file.
Classes | |
| struct | FlagDesc |
Macros | |
| #define | STRINGIFY(x) |
| #define | TOSTRING(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) |
| #define | IS_UTF8_MULTB_INNER(x) |
| #define | IS_UTF8_MULTB_START(x) |
| #define | UTF8_MULTB_START_LEN(x) |
| #define | UTF8_MULTB_MAX 4 |
| #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) |
| size_t | utf8_truncate_count (std::string_view input) |
| Takes a string that may end with a truncated UTF-8 sequence and gets rid of the incomplete sequence. | |
| 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 |
| u64 | read_seed (const char *str) |
| turn string into a map seed. either directly if it's a number or by hashing it. | |
| 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 (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> | |
| 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. | |
| std::string | my_double_to_string (double number) |
| Converts double to string. Handles high precision and inf/nan. | |
| std::optional< double > | my_string_to_double (const std::string &s) |
| Converts string to double. Handles high precision and inf/nan. | |
| void | str_replace (std::string &str, char from, char to) |
Replace all occurrences of the character from in str with to. | |
| 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_texture_modifiers_escape (std::string &str) |
| Escapes characters to nest texture modifiers. | |
| 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 (std::basic_string_view< T > str, const T esc=T('\\')) |
| Unescapes a string. | |
| std::string | unescape_string (std::string_view s, const char esc='\\') |
| std::wstring | unescape_string (std::wstring_view s, const wchar_t esc=L'\\') |
| template<typename T> | |
| std::basic_string< T > | unescape_enriched (std::basic_string_view< T > s) |
Remove all escape sequences in s. | |
| std::string | unescape_enriched (std::string_view s) |
| std::wstring | unescape_enriched (std::wstring_view s) |
| template<typename T> | |
| std::vector< std::basic_string< T > > | split (std::basic_string_view< T > s, T delim, T escape=static_cast< T >('\\')) |
Splits a string into its component parts separated by the character delimiter. | |
| template<typename T> | |
| std::vector< std::basic_string< T > > | split (const std::basic_string< T > &s, T delim, T escape=static_cast< T >('\\')) |
| 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 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. | |
| std::optional< v3f > | str_to_v3f (std::string_view str) |
| Parses a string of form (1, 2, 3) or 1, 2, 4 to a v3f. | |
| #define IS_ASCII_PRINTABLE_CHAR | ( | x | ) |
Referenced by safe_print_string(), and TestUtilities::testAsciiPrintableHelper().
| #define IS_PRIVATE_USE_CHAR | ( | x | ) |
Referenced by GUIChatConsole::OnEvent().
| #define IS_PRIVATE_USE_CHAR32 | ( | x | ) |
| #define IS_UTF8_MULTB_INNER | ( | x | ) |
Referenced by safe_print_string(), utf8_truncate_count(), and wrap_rows().
| #define IS_UTF8_MULTB_START | ( | x | ) |
Referenced by safe_print_string(), and utf8_truncate_count().
| #define MAKE_VARIANT | ( | _name, | |
| _t0, | |||
| _t1 ) |
| #define stof mystof |
Referenced by WearBarParams::deserializeJson(), GUIFormSpecMenu::getElementBasePos(), Settings::getFloat(), Settings::getFloat(), StyleSpec::getFont(), Settings::getNoiseParamsFromValue(), GUIFormSpecMenu::getRealCoordinateBasePos(), GUIFormSpecMenu::getRealCoordinateGeometry(), getToolRange(), Settings::getV2F(), GUIFormSpecMenu::parseAnchor(), GUIFormSpecMenu::parseAnimatedImage(), GUIFormSpecMenu::parseBackground(), GUIFormSpecMenu::parseBox(), GUIFormSpecMenu::parseButton(), GUIFormSpecMenu::parseContainer(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseHyperText(), GUIFormSpecMenu::parseHyperTip(), GUIFormSpecMenu::parseImage(), GUIFormSpecMenu::parseImageButton(), GUIFormSpecMenu::parseItemImage(), GUIFormSpecMenu::parseItemImageButton(), GUIFormSpecMenu::parseLabel(), GUIFormSpecMenu::parseModel(), GUIFormSpecMenu::parsePadding(), GUIFormSpecMenu::parsePosition(), GUIFormSpecMenu::parsePwdField(), GUIFormSpecMenu::parseScrollBar(), GUIFormSpecMenu::parseScrollContainer(), GUIFormSpecMenu::parseSize(), GUIFormSpecMenu::parseTabHeader(), GUIFormSpecMenu::parseTable(), GUIFormSpecMenu::parseTextArea(), GUIFormSpecMenu::parseTextList(), GUIFormSpecMenu::parseTooltip(), StyleSpec::parseVector2f(), and GUITable::setTable().
| #define stoi mystoi |
Referenced by ICraftAction::ICraftAction(), IDropAction::IDropAction(), IMoveAction::IMoveAction(), TextureOverrideSource::TextureOverrideSource(), InventoryLocation::deSerialize(), ItemStack::deSerialize(), drawItemStack(), ImageSource::generateImagePart(), Settings::getFlagStr(), StyleSpec::getFont(), StyleSpec::getIntArray(), Settings::getNoiseParamsFromValue(), Settings::getS16(), Settings::getS32(), Settings::getU16(), Settings::getU32(), ParsedText::globalTag(), MetaDataRef::l_get_int(), ModApiMapgen::l_get_mapgen_params(), ClientLauncher::launch_game(), GUIFormSpecMenu::parseAnimatedImage(), GUIFormSpecMenu::parseBackground(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseList(), GUIFormSpecMenu::parseMiddleRect(), StyleSpec::parseRect(), GUIFormSpecMenu::parseScrollBar(), GUIFormSpecMenu::parseScrollBarOptions(), GUIFormSpecMenu::parseTabHeader(), GUIFormSpecMenu::parseTable(), ParsedText::parseTag(), GUIFormSpecMenu::parseTextList(), MapgenParams::readParams(), and GUITable::setTable().
| #define STRINGIFY | ( | x | ) |
| #define UTF8_MULTB_MAX 4 |
Referenced by utf8_truncate_count().
| #define UTF8_MULTB_START_LEN | ( | x | ) |
Referenced by utf8_truncate_count().
| typedef std::unordered_map<std::string, std::string> StringMap |
|
inline |
Returns a C-string, either "true" or "false", corresponding to val.
val is true, then "true" is returned, otherwise "false". References bool_to_cstr().
Referenced by bool_to_cstr(), set_default_settings(), Game::toggleAutoforward(), Game::toggleCinematic(), Game::toggleFast(), Game::toggleFreeMove(), Game::toggleNoClip(), and Game::togglePitchMove().
|
inline |
Converts a duration in seconds to a pretty-printed duration in days, hours, minutes and seconds.
| sec | duration in seconds |
References duration_to_string().
Referenced by duration_to_string(), Server::ShutdownState::getShutdownTimerMessage(), Server::getStatusString(), and Server::requestShutdown().
| std::string encodeHexColorString | ( | video::SColor | color | ) |
References encodeHexColorString().
Referenced by ParsedText::ParsedText(), encodeHexColorString(), and WearBarParams::serializeJson().
|
inline |
Returns a value represented by the string val.
References from_string().
Referenced by from_string(), Settings::getU64(), ModApiMapgen::l_get_mapgen_params(), LBMManager::parseIntroductionTimesString(), and stoi64().
|
inline |
Returns a string representing the exact decimal value of the float value f.
References ftos().
Referenced by content_nodemeta_deserialize_legacy_body(), ftos(), QuicktuneValue::getString(), WearBarParams::serializeJson(), and Settings::setFloat().
|
inline |
Returns a string representing the decimal value of the 64-bit value i.
References i64tos().
Referenced by Database_LevelDB::deleteBlock(), Database_Redis::deleteBlock(), i64tos(), Database_LevelDB::loadBlock(), Database_Redis::loadBlock(), Database_LevelDB::saveBlock(), and Database_Redis::saveBlock().
|
inline |
Checks that all characters in to_check are decimal digits.
| to_check |
References is_number().
Referenced by ImageSource::generateImagePart(), is_number(), GUIFormSpecMenu::parseVersionDirect(), MapgenParams::readParams(), and TestUtilities::testIsNumber().
|
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.
| str |
References is_yes(), lowercase(), and trim().
Referenced by ModConfiguration::addModsFromConfig(), Settings::getBool(), StyleSpec::getBool(), ModApiUtil::Initialize(), ModApiUtil::InitializeAsync(), ModApiUtil::InitializeClient(), ModApiUtil::InitializeSSCSM(), is_yes(), ModApiUtil::l_is_yes(), GUIFormSpecMenu::parseAllowClose(), GUIFormSpecMenu::parseBackground(), GUIFormSpecMenu::parseBackgroundColor(), GUIFormSpecMenu::parseCheckbox(), 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().
|
inline |
Returns a string representing the decimal value of the 32-bit value i.
References itos().
Referenced by EmergeThread::EmergeThread(), GUIFormSpecMenu::acceptInput(), RollbackManager::actionRowsFromSelect(), AsyncEngine::addWorkerThread(), analyze_block(), MapBlock::correctBlockNodeIds(), Game::decreaseViewRange(), NodeMetadataList::deSerialize(), deSerializeString32(), drawItemStack(), fs::get_unique(), con::Connection::getDesc(), GenerateNotifier::getEvents(), Server::getPlayerName(), QuicktuneValue::getString(), Game::increaseViewRange(), con::UDPPeer::isTimedOut(), itos(), ModApiItem::l_register_item_raw(), MetaDataRef::l_set_int(), ClientLauncher::launch_game(), PlayerDatabaseFiles::loadPlayer(), SettingsHierarchy::onLayerCreated(), Database_SQLite3::openDatabase(), Settings::parseCommandLine(), PlayerDatabaseFiles::removePlayer(), PlayerDatabaseFiles::savePlayer(), Settings::setS16(), Settings::setS32(), Settings::setU16(), takeScreenshot(), TestFileSys::testSafeWriteToFile(), RollbackAction::toString(), GameUI::update(), and ShadowRenderer::updateSMTextures().
|
inlinenodiscard |
| str |
str converted to all lowercase characters. References lowercase(), and my_tolower().
Referenced by ScriptApiSecurity::checkPathWithGamedef(), gen_srp_v(), init_gettext(), is_yes(), lowercase(), main(), parseNamedColorString(), Client::startAuth(), and TestUtilities::testLowercase().
| std::string my_double_to_string | ( | double | number | ) |
Converts double to string. Handles high precision and inf/nan.
References my_double_to_string().
Referenced by MetaDataRef::l_set_float(), my_double_to_string(), and TestUtilities::testMyDoubleStringConversions().
|
inline |
References my_isspace().
Referenced by my_isspace(), my_isspace(), and trim().
|
inline |
| std::optional< double > my_string_to_double | ( | const std::string & | s | ) |
Converts string to double. Handles high precision and inf/nan.
References my_string_to_double().
Referenced by MetaDataRef::l_get_float(), my_string_to_double(), and TestUtilities::testMyDoubleStringConversions().
|
inline |
Converts a letter to lowercase, with safe handling of the char type and non-ASCII.
| c | input letter |
References my_tolower().
Referenced by lowercase(), fs::match_paths(), my_tolower(), ChatPrompt::nickCompletion(), str_ends_with(), str_equal(), str_starts_with(), and TestFileSys::testIsDirDelimiter().
|
inline |
|
inline |
Returns a 32-bit value reprensented by the string str (decimal).
References mystoi().
|
inline |
Converts the string str to a signed 32-bit integer.
The converted value is constrained so that min <= value <= max.
| str | |
| min | Range minimum |
| max | Range maximum |
References mystoi().
Referenced by ImageSource::generateImagePart(), ItemVisualsManager::getItemstackColor(), mystoi(), mystoi(), Game::nodePlacement(), GUIFormSpecMenu::parseVersionDirect(), and TestUtilities::testStrToIntConversion().
|
noexcept |
References MYMIN, and mystrlcpy().
Referenced by mystrlcpy().
|
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.
References padStringRight().
Referenced by padStringRight(), print_allowed_options(), print_help(), and TestUtilities::testPadString().
| bool parseColorString | ( | const std::string & | value, |
| video::SColor & | color, | ||
| bool | quiet, | ||
| unsigned char | default_alpha = 0xff ) |
References errorstream, parseColorString(), parseHexColorString(), and parseNamedColorString().
Referenced by ChatBuffer::ChatBuffer(), EnrichedString::addAtEnd(), check_color(), WearBarParams::deserializeJson(), ImageSource::generateImagePart(), StyleSpec::getColor(), StyleSpec::getColor(), StyleSpec::getColorArray(), ItemVisualsManager::getItemstackColor(), ParsedText::globalTag(), ModApiMainMenu::l_set_clouds_color(), ModApiMainMenu::l_set_sky_color(), GUIFormSpecMenu::parseBackgroundColor(), GUIFormSpecMenu::parseBox(), parseColorString(), GUIFormSpecMenu::parseListColors(), GUIFormSpecMenu::parseTooltip(), read_color(), ParsedText::Element::setStyle(), GUITable::setTable(), and GUITable::setTextList().
| u64 read_seed | ( | const char * | str | ) |
turn string into a map seed. either directly if it's a number or by hashing it.
References murmur_hash_64_ua(), and read_seed().
Referenced by read_seed(), MapgenParams::readParams(), and TestUtilities::testReadSeed().
| u32 readFlagString | ( | std::string | str, |
| const FlagDesc * | flagdesc, | ||
| u32 * | flagmask ) |
References FlagDesc::flag, FlagDesc::name, and readFlagString().
Referenced by Settings::getFlagStr(), read_flags(), readFlagString(), and TestSettings::testFlagDesc().
|
inline |
Returns a version of str with the first occurrence of a string contained within ends[] removed from the end of the string.
| str | |
| ends | A 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. |
References removeStringEnd().
Referenced by Server::addMediaFile(), porting::detectMSVCBuildDir(), Translations::getFileBaseName(), getImagePath(), Client::loadMedia(), Translations::loadTranslation(), removeStringEnd(), and TestUtilities::testRemoveStringEnd().
| 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, IS_UTF8_MULTB_START, and safe_print_string().
Referenced by HTTPFetchOngoing::complete(), IMetadata::resolveString(), safe_print_string(), and string_safe_for_curl().
|
nodiscard |
Sanitize an untrusted string (e.g.
from the network). This will strip control characters and (optionally) any Luanti-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 are permitted.
References remove_indexed(), and sanitize_untrusted().
Referenced by pkt_read_formspec_fields(), sanitize_untrusted(), and TestUtilities::testSanitizeUntrusted().
|
nodiscard |
Sanitize the name of a new directory.
This consists of two stages:
References disallowed_dir_names, disallowed_path_chars, sanitizeDirName(), str_equal(), utf8_to_wide(), and wide_to_utf8().
Referenced by ModApiMainMenu::l_create_world(), sanitizeDirName(), and TestUtilities::testSanitizeDirName().
|
nodiscard |
|
nodiscard |
Splits a string into its component parts separated by the character delimiter.
escape is interpreted as an escape character, but not removed.
References split().
Referenced by EnrichedString::addAtEnd(), StyleSpec::getFont(), k_d_tree::KdTree< Dim, Component, Id >::init(), GUIFormSpecMenu::parseAnchor(), GUIFormSpecMenu::parseAnchorDirect(), GUIFormSpecMenu::parseAnimatedImage(), StyleSpec::parseArray(), GUIFormSpecMenu::parseBackground(), GUIFormSpecMenu::parseBox(), GUIFormSpecMenu::parseButton(), GUIFormSpecMenu::parseCheckbox(), GUIFormSpecMenu::parseContainer(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseHyperText(), GUIFormSpecMenu::parseHyperTip(), 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(), k_d_tree::KdTree< Dim, Component, Id >::rangeQuery(), GUIFormSpecMenu::regenerateGui(), split(), split(), TestUtilities::testStrSplit(), translate_all(), and translate_string().
|
inline |
Returns a 64-bit signed value represented by the string str (decimal).
References from_string(), and stoi64().
Referenced by Database_LevelDB::listAllLoadableBlocks(), Database_Redis::listAllLoadableBlocks(), and stoi64().
|
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).
| str | |
| suffix | |
| case_insensitive |
References my_tolower(), and str_ends_with().
Referenced by GettextPluralForm::GettextPluralForm(), str_ends_with(), and TestUtilities::testSanitizeUntrusted().
|
inline |
Check two strings for equivalence.
If case_insensitive is true then the case of the strings is ignored (default is false).
| s1 | |
| s2 | |
| case_insensitive |
References my_tolower(), and str_equal().
Referenced by parseImageTransform(), sanitizeDirName(), str_equal(), and TestUtilities::testStrEqual().
|
inline |
Escapes characters that cannot be used in formspecs.
References str_formspec_escape(), and str_replace().
Referenced by GameFormSpec::showPauseMenu(), and str_formspec_escape().
|
inlinenodiscard |
Joins a vector of strings by the string delimiter.
References str_join().
Referenced by print_help(), str_join(), TestAuthDatabase::testListNames(), TestAuthDatabase::testRecall(), TestAuthDatabase::testRecallChanged(), TestAuthDatabase::testRecallChangedPrivileges(), TestUtilities::testStringJoin(), and AuthDatabaseFiles::writeAuthFile().
| void str_replace | ( | std::string & | str, |
| char | from, | ||
| char | to ) |
Replace all occurrences of the character from in str with to.
| str | The string to (potentially) modify. |
| from | The character in str to replace. |
| to | The replacement character. |
References str_replace().
Referenced by ScriptApiSecurity::checkPathWithGamedef(), ImageSource::generateImagePart(), Client::initLocalMapSaving(), p(), ScriptApiSecurity::safeLoadFile(), ModVFS::scanModSubfolder(), str_formspec_escape(), str_replace(), str_replace(), str_texture_modifiers_escape(), and TestUtilities::testStringReplace().
|
inline |
Replace all occurrences of pattern in str with replacement.
| str | String to replace pattern with replacement within. |
| pattern | The pattern to replace. |
| replacement | What to replace the pattern with. |
References str_replace().
|
inlinenodiscard |
Splits a string into its component parts separated by the character delimiter.
References str_split().
Referenced by sound::ALExtensions::ALExtensions(), TextureOverrideSource::TextureOverrideSource(), checkModNameWhitelisted(), decode_srp_verifier_and_salt(), getKeySetting(), getTextureDirs(), getTexturePathsReversed(), Server::handleCommand_Init(), Translations::loadMoEntry(), Translations::loadMoTranslation(), Translations::loadPoTranslation(), Translations::loadTranslation(), Translations::loadTrTranslation(), LBMManager::parseIntroductionTimesString(), parseModContents(), AuthDatabaseFiles::readAuthFile(), str_split(), and TestUtilities::testStrSplit().
|
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).
| str | |
| prefix | |
| case_insensitive |
References my_tolower(), and str_starts_with().
Referenced by GettextPluralForm::GettextPluralForm(), InputHandler::InputHandler(), LBMManager::addLBMDef(), checkModNameWhitelisted(), Settings::checkValueValid(), GameGlobalShaderUniformSetterFactory::create(), ShadowUniformSetterFactory::create(), ImageSource::generateImagePart(), NodeDefManager::getIds(), NodeResolver::getIdsFromNrBacklog(), isGroupRecipeStr(), Translations::loadMoTranslation(), Translations::loadPoTranslation(), Translations::loadTrTranslation(), KeyPress::loadUnsignedFromPrefix(), main(), ChatPrompt::nickCompletion(), porting::open_url(), read_pointabilities(), reduce_ltr_single(), IMetadata::resolveString(), TileDef::serialize(), RemoteClient::setEncryptedPassword(), str_starts_with(), TestUtilities::testSanitizeUntrusted(), and TestUtilities::testStartsWith().
|
inline |
Escapes characters to nest texture modifiers.
References str_replace(), and str_texture_modifiers_escape().
Referenced by TileAnimationParams::extractFirstFrame(), and str_texture_modifiers_escape().
| std::optional< v3f > str_to_v3f | ( | std::string_view | str | ) |
Parses a string of form (1, 2, 3) or 1, 2, 4 to a v3f.
| str | string |
References str_to_v3f(), and trim().
Referenced by Settings::getV3F(), ItemStack::getWieldScale(), MapgenParams::readParams(), and str_to_v3f().
|
inline |
Check that a string only contains whitelisted characters.
This is the opposite of string_allowed_blacklist().
| str | The string to be checked. |
| allowed_chars | A string containing permitted characters. |
References string_allowed().
Referenced by ClientMediaDownloader::addFile(), LBMManager::addLBMDef(), Server::addMediaFile(), ModSpec::checkAndLog(), Server::handleCommand_Init(), Client::handleCommand_MediaPush(), is_valid_player_name(), parseDependsString(), GUITable::setTable(), string_allowed(), and TestUtilities::testStringAllowed().
|
inline |
Check that a string contains no blacklisted characters.
This is the opposite of string_allowed().
| str | The string to be checked. |
| blacklisted_chars | A string containing prohibited characters. |
References string_allowed_blacklist().
Referenced by string_allowed_blacklist(), and TestUtilities::testStringAllowed().
|
nodiscard |
|
nodiscard |
References translate_all(), and translate_string().
Referenced by GUIFormSpecMenu::FieldSpec::FieldSpec(), GUIFormSpecMenu::TooltipSpec::TooltipSpec(), GUIFormSpecMenu::drawMenu(), Camera::drawNametags(), ModApiMainMenu::l_get_content_translation(), ModApiEnv::l_get_translated_string(), EnrichedString::operator=(), GUIFormSpecMenu::parseButton(), GUIFormSpecMenu::parseCheckbox(), GUIFormSpecMenu::parseHyperText(), GUIFormSpecMenu::parseHyperTip(), GUIFormSpecMenu::parsePwdField(), GUIFormSpecMenu::parseSimpleField(), GUIFormSpecMenu::parseTextArea(), and GUIEngine::setTopleftText().
|
inlinenodiscard |
|
inlinenodiscard |
|
inlinenodiscard |
| str |
str with leading and trailing whitespace removed. References trim().
|
inlinenodiscard |
| str |
str with leading and trailing whitespace removed. References my_isspace(), and trim().
Referenced by sound::ALExtensions::ALExtensions(), TextureOverrideSource::TextureOverrideSource(), ItemStack::deSerialize(), ShaderSource::generateShader(), Server::handleChat(), Client::handleCommand_AnnounceMedia(), is_yes(), ModApiMainMenu::l_start(), BanManager::load(), Translations::loadMoTranslation(), Translations::loadPoTranslation(), Translations::loadTrTranslation(), parse_atomic(), parse_expr(), parse_ltr(), parse_negation(), parse_parenthesized(), parse_ternary(), GUIFormSpecMenu::parseAnchorDirect(), Settings::parseConfigObject(), parseDependsString(), GUIFormSpecMenu::parseElement(), GUIFormSpecMenu::parsePaddingDirect(), Translations::parsePoLine(), GUIFormSpecMenu::parsePositionDirect(), GUIFormSpecMenu::parseScrollBarOptions(), GUIFormSpecMenu::parseSizeDirect(), GUIFormSpecMenu::parseStyle(), GUIFormSpecMenu::parseVersionDirect(), reduce_ltr_single(), GUIFormSpecMenu::regenerateGui(), str_to_v3f(), TestUtilities::testTrim(), trim(), trim(), trim(), and trim().
|
nodiscard |
Remove all escape sequences in s.
| s | The string in which to remove escape sequences. |
s, with escape sequences removed. References unescape_enriched().
Referenced by GUIFormSpecMenu::FieldSpec::FieldSpec(), drawItemStack(), Server::handleChat(), Client::handleCommand_ChatMessage(), ModApiUtil::l_strip_escapes(), TestUtilities::testRemoveEscapes(), unescape_enriched(), unescape_enriched(), unescape_enriched(), and unescape_translate().
|
inlinenodiscard |
|
inlinenodiscard |
|
nodiscard |
Unescapes a string.
References unescape_string().
Referenced by Hud::drawLuaElements(), GUIFormSpecMenu::drawMenu(), ImageSource::generateImagePart(), GUIFormSpecMenu::parseAnimatedImage(), GUIFormSpecMenu::parseBackground(), GUIFormSpecMenu::parseButton(), GUIFormSpecMenu::parseCheckbox(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseHyperText(), GUIFormSpecMenu::parseHyperTip(), GUIFormSpecMenu::parseImage(), GUIFormSpecMenu::parseImageButton(), GUIFormSpecMenu::parseItemImageButton(), GUIFormSpecMenu::parseLabel(), GUIFormSpecMenu::parseListImages(), GUIFormSpecMenu::parseModel(), GUIFormSpecMenu::parsePwdField(), GUIFormSpecMenu::parseSimpleField(), GUIFormSpecMenu::parseStyle(), GUIFormSpecMenu::parseTabHeader(), GUIFormSpecMenu::parseTable(), GUIFormSpecMenu::parseTableColumns(), GUIFormSpecMenu::parseTableOptions(), GUIFormSpecMenu::parseTextArea(), GUIFormSpecMenu::parseTextList(), GUIFormSpecMenu::parseTooltip(), GUIFormSpecMenu::parseVertLabel(), TestUtilities::testRemoveEscapes(), unescape_string(), unescape_string(), and unescape_string().
|
inlinenodiscard |
|
inlinenodiscard |
|
inlinenodiscard |
References translate_string(), unescape_enriched(), and unescape_translate().
Referenced by Game::checkConnection(), Hud::drawLuaElements(), Camera::drawNametags(), Game::handlePointingAtNode(), Game::handlePointingAtObject(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseTabHeader(), GUIFormSpecMenu::parseTable(), GUIFormSpecMenu::parseTextList(), and unescape_translate().
| std::string urldecode | ( | std::string_view | str | ) |
References hex_digit_decode(), and urldecode().
Referenced by TestUtilities::testUrlDecode(), and urldecode().
| std::string urlencode | ( | std::string_view | str | ) |
References urlencode().
Referenced by HTTPFetchOngoing::HTTPFetchOngoing(), ModApiUtil::Initialize(), ModApiUtil::InitializeAsync(), ModApiUtil::InitializeClient(), ModApiUtil::InitializeSSCSM(), ModApiUtil::l_urlencode(), TestUtilities::testUrlEncode(), and urlencode().
|
nodiscard |
References convert(), DEFAULT_ENCODING, infostream, and utf8_to_wide().
Referenced by GUIFileSelectMenu::GUIFileSelectMenu(), GUITable::allocString(), GUIButtonKey::cancelCapture(), Game::checkConnection(), Game::createClient(), ProfilerGraph::draw(), drawItemStack(), Hud::drawLuaElements(), GUIFormSpecMenu::drawMenu(), Camera::drawNametags(), Client::getCraftDefManager(), 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(), lookup_keyname(), ChatPrompt::nickCompletion(), GUIChatConsole::OnEvent(), GUIFormSpecMenu::parseButton(), GUIFormSpecMenu::parseCheckbox(), GUIFormSpecMenu::parseDropDown(), GUIFormSpecMenu::parseHyperText(), GUIFormSpecMenu::parseHyperTip(), 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(), GUIEngine::run(), sanitizeDirName(), GUIButtonKey::setKey(), GUIEngine::setTopleftText(), TestUtilities::testStrEqual(), TestUtilities::testUTF8(), TestUtilities::testWrapRows(), Game::toggleMinimap(), GameUI::update(), Game::updateChat(), GameUI::updateProfiler(), utf8_to_wide(), GUIChatConsole::weblinkClick(), and wstrgettext().
| size_t utf8_truncate_count | ( | std::string_view | input | ) |
Takes a string that may end with a truncated UTF-8 sequence and gets rid of the incomplete sequence.
| void wide_add_codepoint | ( | std::wstring & | result, |
| char32_t | codepoint ) |
References wide_add_codepoint().
Referenced by Translations::unescapeC(), and wide_add_codepoint().
|
nodiscard |
References convert(), DEFAULT_ENCODING, infostream, and wide_to_utf8().
Referenced by GUIFileSelectMenu::acceptInput(), GUIFormSpecMenu::acceptInput(), EnrichedString::addAtEnd(), Game::checkConnection(), ChatBuffer::formatChatLine(), Server::handleChat(), Client::handleCommand_AccessDenied(), Client::handleCommand_ChatMessage(), ModApiMainMenu::l_get_content_translation(), ModApiEnv::l_get_translated_string(), Translations::loadPoEntry(), Translations::loadPoTranslation(), lookup_keychar(), ChatPrompt::nickCompletion(), GUIChatConsole::OnEvent(), GUIFormSpecMenu::parseTable(), ParsedText::parseTag(), GUIFormSpecMenu::parseTextList(), GUIModalMenu::preprocessEvent(), GUIPasswordChange::processInput(), sanitizeDirName(), GUIButtonKey::setText(), TestUtilities::testUTF8(), Server::ShutdownState::tick(), translate_string(), Client::typeChatMessage(), Translations::unescapeC(), GUIChatConsole::updatePrimarySelection(), and wide_to_utf8().
| 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.
row_len characters whether it breaks a word or not. It is intended to be used for, for example, showing paths in the GUI.| from | The (utf-8) string to be wrapped into rows. |
| row_len | The row length (in characters). |
| has_color_codes | Whether the source string has colorize codes. |
References IS_UTF8_MULTB_INNER, and wrap_rows().
Referenced by GUIOpenURLMenu::regenerateGui(), TestUtilities::testWrapRows(), and wrap_rows().
| std::string writeFlagString | ( | u32 | flags, |
| const FlagDesc * | flagdesc, | ||
| u32 | flagmask ) |
References FlagDesc::name, and writeFlagString().
Referenced by push_flags_string(), Settings::setDefault(), Settings::setFlagStr(), and writeFlagString().